Search in sources :

Example 16 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);
    // TODO Anton publish a message to a redis channel so that all [Flash client] users are
    // notified that there is no longer rtmp stream being broadcasted.
    String userId = getUserId();
    String meetingId = conn.getScope().getName();
    String streamId = stream.getPublishedName();
    if (recordVideoStream) {
        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", "WEBRTC-DESKSHARE");
        event.put("timestamp", genTimestamp().toString());
        event.put("meetingId", scopeName);
        event.put("stream", stream.getPublishedName());
        event.put("duration", new Long(publishDuration).toString());
        event.put("eventName", "StopWebRTCDesktopShareEvent");
        recordingService.record(scopeName, event);
    }
}
Also used : HashMap(java.util.HashMap) IConnection(org.red5.server.api.IConnection)

Example 17 with IBroadcastStream

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

the class VideoStreamListener 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) {
        // keep track of last time video was received
        lastVideoTime = System.currentTimeMillis();
        packetCount++;
        if (!firstPacketReceived) {
            firstPacketReceived = true;
            publishing = true;
            firstPacketTime = lastVideoTime;
            // start the worker to monitor if we are still receiving video packets
            timeoutJobName = scheduler.addScheduledJob(videoTimeout, new TimeoutJob());
            if (record) {
                Map<String, String> event = new HashMap<String, String>();
                event.put("module", "WEBCAM");
                event.put("timestamp", genTimestamp().toString());
                event.put("meetingId", scope.getName());
                event.put("stream", stream.getPublishedName());
                event.put("eventName", "StartWebRTCDeskShareEvent");
                recordingService.record(scope.getName(), event);
            }
        }
        if (streamPaused) {
            streamPaused = false;
            long now = System.currentTimeMillis();
            long numSeconds = (now - lastVideoTime) / 1000;
            Map<String, Object> logData = new HashMap<String, Object>();
            logData.put("meetingId", scope.getName());
            logData.put("userId", userId);
            logData.put("stream", stream.getPublishedName());
            logData.put("packetCount", packetCount);
            logData.put("publishing", publishing);
            logData.put("pausedFor (sec)", numSeconds);
            Gson gson = new Gson();
            String logStr = gson.toJson(logData);
            log.warn("Video stream restarted. data={}", logStr);
        }
    }
}
Also used : HashMap(java.util.HashMap) VideoData(org.red5.server.net.rtmp.event.VideoData) Gson(com.google.gson.Gson) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Example 18 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 19 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());
    if (recordVideoStream) {
        recordStream(stream);
    }
}
Also used : IConnection(org.red5.server.api.IConnection)

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