Search in sources :

Example 1 with IBroadcastStream

use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.

the class ScreenshareStreamListener method packetReceived.

@Override
public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {
    IoBuffer buf = packet.getData();
    if (buf != null)
        buf.rewind();
    if (buf == null || buf.remaining() == 0) {
        return;
    }
    if (packet instanceof VideoData) {
        if (!firstPacketReceived) {
            firstPacketReceived = true;
            IConnection conn = Red5.getConnectionLocal();
            String meetingId = conn.getScope().getName();
            String filename = recordingDir;
            if (!filename.endsWith("/")) {
                filename.concat("/");
            }
            filename = filename.concat(meetingId).concat("/").concat(stream.getPublishedName()).concat(".flv");
            Map<String, String> event = new HashMap<String, String>();
            event.put("module", "Deskshare");
            event.put("timestamp", genTimestamp().toString());
            event.put("meetingId", meetingId);
            event.put("file", filename);
            event.put("stream", stream.getPublishedName());
            event.put("eventName", "DeskshareStartedEvent");
            recordingService.record(conn.getScope().getName(), event);
        }
    }
}
Also used : HashMap(java.util.HashMap) VideoData(org.red5.server.net.rtmp.event.VideoData) IConnection(org.red5.server.api.IConnection) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 2 with IBroadcastStream

use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.

the class VideoApplication method streamBroadcastStart.

@Override
public void streamBroadcastStart(IBroadcastStream stream) {
    IConnection conn = Red5.getConnectionLocal();
    super.streamBroadcastStart(stream);
    log.info("streamBroadcastStart " + stream.getPublishedName() + " " + System.currentTimeMillis() + " " + conn.getScope().getName());
    String userId = getUserId();
    String meetingId = conn.getScope().getName();
    String streamId = stream.getPublishedName();
    Matcher matcher = RECORD_STREAM_ID_PATTERN.matcher(stream.getPublishedName());
    if (matcher.matches()) {
        log.info("Start recording of stream=[" + stream.getPublishedName() + "] for meeting=[" + conn.getScope().getName() + "]");
        Boolean recordVideoStream = true;
        VideoStreamListener listener = new VideoStreamListener(conn.getScope(), stream, recordVideoStream, userId, packetTimeout);
        listener.setEventRecordingService(recordingService);
        stream.addStreamListener(listener);
        streamListeners.put(conn.getScope().getName() + "-" + stream.getPublishedName(), listener);
        recordStream(stream);
    }
}
Also used : Matcher(java.util.regex.Matcher) IConnection(org.red5.server.api.IConnection)

Example 3 with IBroadcastStream

use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.

the class Application method recordStream.

/**
     * 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();
    }
}
Also used : IConnection(org.red5.server.api.IConnection) ClientBroadcastStream(org.red5.server.stream.ClientBroadcastStream) PeerNotFoundException(org.bigbluebutton.voiceconf.sip.PeerNotFoundException)

Example 4 with IBroadcastStream

use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.

the class VideoApplication method recordStream.

/**
	 * A hook to record a stream. A file is written in webapps/video-broadcast/streams/
	 * @param stream
	 */
private void recordStream(IBroadcastStream stream) {
    IConnection conn = Red5.getConnectionLocal();
    long now = System.currentTimeMillis();
    // + "-" + now; /** Comment out for now...forgot why I added this - ralam */
    String recordingStreamName = stream.getPublishedName();
    try {
        log.info("Recording stream " + recordingStreamName);
        ClientBroadcastStream cstream = (ClientBroadcastStream) this.getBroadcastStream(conn.getScope(), stream.getPublishedName());
        cstream.saveAs(recordingStreamName, false);
    } catch (Exception e) {
        log.error("ERROR while recording stream " + e.getMessage());
        e.printStackTrace();
    }
}
Also used : IConnection(org.red5.server.api.IConnection) ClientBroadcastStream(org.red5.server.stream.ClientBroadcastStream)

Example 5 with IBroadcastStream

use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.

the class VideoApplication method recordStream.

/**
     * A hook to record a stream. A file is written in webapps/video/streams/
     * @param stream
     */
private void recordStream(IBroadcastStream stream) {
    IConnection conn = Red5.getConnectionLocal();
    long now = System.currentTimeMillis();
    // + "-" + now; /** Comment out for now...forgot why I added this - ralam */
    String recordingStreamName = stream.getPublishedName();
    try {
        log.info("Recording stream " + recordingStreamName);
        ClientBroadcastStream cstream = (ClientBroadcastStream) this.getBroadcastStream(conn.getScope(), stream.getPublishedName());
        cstream.saveAs(recordingStreamName, false);
    } catch (Exception e) {
        log.error("ERROR while recording stream " + e.getMessage());
        e.printStackTrace();
    }
}
Also used : IConnection(org.red5.server.api.IConnection) ClientBroadcastStream(org.red5.server.stream.ClientBroadcastStream)

Aggregations

IConnection (org.red5.server.api.IConnection)16 HashMap (java.util.HashMap)7 Gson (com.google.gson.Gson)4 Matcher (java.util.regex.Matcher)4 IoBuffer (org.apache.mina.core.buffer.IoBuffer)4 ClientBroadcastStream (org.red5.server.stream.ClientBroadcastStream)4 IStreamListener (org.red5.server.api.stream.IStreamListener)3 VideoData (org.red5.server.net.rtmp.event.VideoData)3 ScreenshareStreamListener (org.bigbluebutton.app.screenshare.ScreenshareStreamListener)1 PeerNotFoundException (org.bigbluebutton.voiceconf.sip.PeerNotFoundException)1 IBroadcastStream (org.red5.server.api.stream.IBroadcastStream)1 IStreamPacket (org.red5.server.api.stream.IStreamPacket)1 AudioData (org.red5.server.net.rtmp.event.AudioData)1