Timing out a Broadcast

QUESTION:

Is there a way to stop a particular broadcast after a certain timeframe from the server side?

 

ANSWER:

1.  Please compile and integrate a BroadCaster.java file (content at end of FAQ) into your project to stop a broadcast from the server. If you edit the

red5/webapps/live/WEB-INF/red5-web.xml

web handler to be that class instead of the Red5ProLive class, then you can recycle the live app files and put the BroadcastCloser class in the proper place:

red5/webapps/live/WEB-INF/classes/com/infrared5/red5pro/live/BroadcastCloser.class

after compiling.  Here is our git project for Red5ProLive.

 

 

BroadcastCloser.java: 

package com.infrared5.red5pro.live;


import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.Red5;
import org.red5.server.api.scheduling.IScheduledJob;
import org.red5.server.api.scheduling.ISchedulingService;
import org.red5.server.api.scope.IScope;
import org.red5.server.api.stream.IStreamPublishSecurity;

/**
* This app adapter will close the publisher after 60 seconds.
*
*/

public class BroadcastCloser extends MultiThreadedApplicationAdapter implements IStreamPublishSecurity {
public boolean appStart(IScope scope){
super.appStart(scope);
this.registerStreamPublishSecurity(this);
return true;
}

/**
* called when publish begins
*/

@Override
public boolean isPublishAllowed(IScope arg0, String arg1, String arg2) {
//get the publisher connection
final IConnection connection = Red5.getConnectionLocal();
//how many miliseconds to allow.
long miliseconds = 60000;
//schedule the thread and thread task
this.schedulingService.addScheduledOnceJob(milliseconds, new IScheduledJob(){
//this is the future task
@Override
public void execute(ISchedulingService arg0)throws CloneNotSupportedException {
//close it. Server will clean up live stream.
connection.close();
}});

//return yes, publish is allowed.
return true;
}

}
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.