Search in sources :

Example 6 with IBroadcastStream

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

the class VideoApplication method streamBroadcastClose.

@Override
public void streamBroadcastClose(IBroadcastStream stream) {
    super.streamBroadcastClose(stream);
    IConnection conn = Red5.getConnectionLocal();
    String scopeName;
    if (conn != null) {
        scopeName = conn.getScope().getName();
    } else {
        log.info("Connection local was null, using scope name from the stream: {}", stream);
        scopeName = stream.getScope().getName();
    }
    log.info("Stream broadcast closed for stream=[{}] meeting=[{}]", stream.getPublishedName(), scopeName);
    String userId = getUserId();
    String meetingId = conn.getScope().getName();
    String streamId = stream.getPublishedName();
    Matcher matcher = RECORD_STREAM_ID_PATTERN.matcher(stream.getPublishedName());
    if (matcher.matches()) {
        IStreamListener listener = streamListeners.remove(scopeName + "-" + stream.getPublishedName());
        if (listener != null) {
            ((VideoStreamListener) listener).streamStopped();
            stream.removeStreamListener(listener);
        }
        long publishDuration = (System.currentTimeMillis() - stream.getCreationTime()) / 1000;
        log.info("Stop recording event for stream=[{}] meeting=[{}]", stream.getPublishedName(), scopeName);
        Map<String, String> event = new HashMap<String, String>();
        event.put("module", "WEBCAM");
        event.put("timestamp", genTimestamp().toString());
        event.put("meetingId", scopeName);
        event.put("stream", stream.getPublishedName());
        event.put("duration", new Long(publishDuration).toString());
        event.put("eventName", "StopWebcamShareEvent");
        recordingService.record(scopeName, event);
    }
}
Also used : IStreamListener(org.red5.server.api.stream.IStreamListener) Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) IConnection(org.red5.server.api.IConnection)

Example 7 with IBroadcastStream

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

the class VideoApplication method streamPublishStart.

@Override
public void streamPublishStart(IBroadcastStream stream) {
    super.streamPublishStart(stream);
    IConnection conn = Red5.getConnectionLocal();
    log.info("streamPublishStart " + stream.getPublishedName() + " " + System.currentTimeMillis() + " " + conn.getScope().getName());
}
Also used : IConnection(org.red5.server.api.IConnection)

Example 8 with IBroadcastStream

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

the class Red5AppAdapter method streamBroadcastClose.

@Override
public void streamBroadcastClose(IBroadcastStream stream) {
    super.streamBroadcastClose(stream);
    log.info("streamBroadcastStop " + stream.getPublishedName() + "]");
    String streamId = stream.getPublishedName();
    Matcher matcher = STREAM_ID_PATTERN.matcher(stream.getPublishedName());
    if (matcher.matches()) {
        String meetingId = matcher.group(1).trim();
        app.streamStopped(meetingId, streamId);
        boolean recordVideoStream = app.recordStream(meetingId, streamId);
        if (recordVideoStream) {
            IConnection conn = Red5.getConnectionLocal();
            String scopeName;
            if (conn != null) {
                scopeName = conn.getScope().getName();
            } else {
                log.info("Connection local was null, using scope name from the stream: {}", stream);
                scopeName = stream.getScope().getName();
            }
            IStreamListener listener = streamListeners.remove(scopeName + "-" + stream.getPublishedName());
            if (listener != null) {
                stream.removeStreamListener(listener);
            }
            String filename = recordingDirectory;
            if (!filename.endsWith("/")) {
                filename.concat("/");
            }
            filename = filename.concat(meetingId).concat("/").concat(stream.getPublishedName()).concat(".flv");
            long publishDuration = (System.currentTimeMillis() - stream.getCreationTime()) / 1000;
            Map<String, String> event = new HashMap<String, String>();
            event.put("module", "Deskshare");
            event.put("timestamp", genTimestamp().toString());
            event.put("meetingId", scopeName);
            event.put("stream", stream.getPublishedName());
            event.put("file", filename);
            event.put("duration", new Long(publishDuration).toString());
            event.put("eventName", "DeskshareStoppedEvent");
            recordingService.record(scopeName, event);
        }
        Map<String, Object> logData = new HashMap<String, Object>();
        logData.put("meetingId", meetingId);
        logData.put("streamId", streamId);
        logData.put("recorded", recordVideoStream);
        Gson gson = new Gson();
        String logStr = gson.toJson(logData);
        log.info("ScreenShare broadcast stopped: data={}", logStr);
    } else {
        log.error("Invalid streamid format [{}]", streamId);
    }
}
Also used : IStreamListener(org.red5.server.api.stream.IStreamListener) Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) IConnection(org.red5.server.api.IConnection)

Example 9 with IBroadcastStream

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

the class Red5AppAdapter 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)

Example 10 with IBroadcastStream

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

the class Red5AppAdapter method streamBroadcastStart.

@Override
public void streamBroadcastStart(IBroadcastStream stream) {
    IConnection conn = Red5.getConnectionLocal();
    super.streamBroadcastStart(stream);
    log.info("streamBroadcastStart " + stream.getPublishedName() + "]");
    String streamId = stream.getPublishedName();
    Matcher matcher = STREAM_ID_PATTERN.matcher(stream.getPublishedName());
    if (matcher.matches()) {
        String meetingId = matcher.group(1).trim();
        String url = streamBaseUrl + "/" + meetingId + "/" + streamId;
        app.streamStarted(meetingId, streamId, url);
        boolean recordVideoStream = app.recordStream(meetingId, streamId);
        if (recordVideoStream) {
            recordStream(stream);
            ScreenshareStreamListener listener = new ScreenshareStreamListener(recordingService, recordingDirectory);
            stream.addStreamListener(listener);
            streamListeners.put(conn.getScope().getName() + "-" + stream.getPublishedName(), listener);
        }
        Map<String, Object> logData = new HashMap<String, Object>();
        logData.put("meetingId", meetingId);
        logData.put("streamId", streamId);
        logData.put("url", url);
        logData.put("recorded", recordVideoStream);
        Gson gson = new Gson();
        String logStr = gson.toJson(logData);
        log.info("ScreenShare broadcast started: data={}", logStr);
    } else {
        log.error("Invalid streamid format [{}]", streamId);
    }
}
Also used : Matcher(java.util.regex.Matcher) HashMap(java.util.HashMap) Gson(com.google.gson.Gson) IConnection(org.red5.server.api.IConnection) ScreenshareStreamListener(org.bigbluebutton.app.screenshare.ScreenshareStreamListener)

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