- record video camera by setting property

This commit is contained in:
Richard Alam 2011-03-12 19:28:09 -05:00
parent 60d5362627
commit 027e8e8f9b
2 changed files with 39 additions and 4 deletions

View File

@ -22,16 +22,22 @@ import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.api.stream.IServerStream;
import org.red5.server.stream.ClientBroadcastStream;
import org.slf4j.Logger;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.stream.ClientBroadcastStream;
public class VideoApplication extends MultiThreadedApplicationAdapter {
private static Logger log = Red5LoggerFactory.getLogger(VideoApplication.class, "video");
private IScope appScope;
private IServerStream serverStream;
private boolean recordVideoStream = false;
@Override
public boolean appStart(IScope app) {
super.appStart(app);
@ -55,4 +61,32 @@ public class VideoApplication extends MultiThreadedApplicationAdapter {
}
super.appDisconnect(conn);
}
@Override
public void streamPublishStart(IBroadcastStream stream) {
if (recordVideoStream) {
recordStream(stream);
}
}
/**
* A hook to record a sample stream. A file is written in webapps/sip/streams/
* @param stream
*/
private void recordStream(IBroadcastStream stream) {
IConnection conn = Red5.getConnectionLocal();
String streamName = stream.getPublishedName();
try {
ClientBroadcastStream cstream = (ClientBroadcastStream) this.getBroadcastStream(conn.getScope(), stream.getPublishedName() );
cstream.saveAs(streamName, false);
} catch(Exception e) {
System.out.println("ERROR while recording stream " + e.getMessage());
e.printStackTrace();
}
}
public void setRecordVideoStream(boolean recordVideoStream) {
this.recordVideoStream = recordVideoStream;
}
}

7
bbb-video/src/main/webapp/WEB-INF/red5-web.xml Normal file → Executable file
View File

@ -12,8 +12,7 @@
<bean id="web.context" class="org.red5.server.Context"
autowire="byType" />
<bean id="web.scope" class="org.red5.server.WebScope"
init-method="register">
<bean id="web.scope" class="org.red5.server.WebScope" init-method="register">
<property name="server" ref="red5.server" />
<property name="parent" ref="global.scope" />
<property name="context" ref="web.context" />
@ -22,5 +21,7 @@
<property name="virtualHosts" value="${webapp.virtualHosts}" />
</bean>
<bean id="web.handler" class="org.bigbluebutton.app.video.VideoApplication" />
<bean id="web.handler" class="org.bigbluebutton.app.video.VideoApplication">
<property name="recordVideoStream" value="true"/>
</bean>
</beans>