Search in sources :

Example 6 with VideoData

use of org.red5.server.net.rtmp.event.VideoData 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", "StartWebcamShareEvent");
                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 7 with VideoData

use of org.red5.server.net.rtmp.event.VideoData 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 8 with VideoData

use of org.red5.server.net.rtmp.event.VideoData in project openmeetings by apache.

the class ScreenV1Encoder method getData.

private static VideoData getData(byte[] data) {
    IoBuffer buf = IoBuffer.allocate(data.length);
    buf.clear();
    buf.put(data);
    buf.flip();
    return new VideoData(buf);
}
Also used : VideoData(org.red5.server.net.rtmp.event.VideoData) IoBuffer(org.apache.mina.core.buffer.IoBuffer)

Aggregations

VideoData (org.red5.server.net.rtmp.event.VideoData)6 IoBuffer (org.apache.mina.core.buffer.IoBuffer)4 HashMap (java.util.HashMap)3 Gson (com.google.gson.Gson)2 CaptureScreen (org.apache.openmeetings.screenshare.CaptureScreen)2 JobDataMap (org.quartz.JobDataMap)2 RTMPMessage (org.red5.server.stream.message.RTMPMessage)2 AWTException (java.awt.AWTException)1 Rectangle (java.awt.Rectangle)1 IOException (java.io.IOException)1 JobExecutionException (org.quartz.JobExecutionException)1 IVideoStreamCodec (org.red5.codec.IVideoStreamCodec)1 IConnection (org.red5.server.api.IConnection)1 IStreamListener (org.red5.server.api.stream.IStreamListener)1 IStreamPacket (org.red5.server.api.stream.IStreamPacket)1 ResourceExistException (org.red5.server.api.stream.ResourceExistException)1 ResourceNotFoundException (org.red5.server.api.stream.ResourceNotFoundException)1 IRTMPEvent (org.red5.server.net.rtmp.event.IRTMPEvent)1