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", "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);
}
}
}
use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.
the class Application method streamPublishStart.
@Override
public void streamPublishStart(IBroadcastStream stream) {
String clientId = Red5.getConnectionLocal().getClient().getId();
String userid = getUserId();
String username = getUsername();
log.debug("{} has started publishing stream [{}]", username + "[uid=" + userid + "][clientid=" + clientId + "]", stream.getPublishedName());
System.out.println("streamPublishStart: " + stream.getPublishedName());
IConnection conn = Red5.getConnectionLocal();
String peerId = (String) conn.getAttribute("VOICE_CONF_PEER");
if (peerId != null) {
super.streamPublishStart(stream);
sipPeerManager.startTalkStream(peerId, clientId, stream, conn.getScope());
// recordStream(stream);
}
}
use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.
the class Application method streamBroadcastClose.
@Override
public void streamBroadcastClose(IBroadcastStream stream) {
String clientId = Red5.getConnectionLocal().getClient().getId();
String userid = getUserId();
String username = getUsername();
log.debug("{} has stopped publishing stream [{}]", username + "[uid=" + userid + "][clientid=" + clientId + "]", stream.getPublishedName());
IConnection conn = Red5.getConnectionLocal();
String peerId = (String) conn.getAttribute("VOICE_CONF_PEER");
if (peerId != null) {
sipPeerManager.stopTalkStream(peerId, clientId, stream, conn.getScope());
super.streamBroadcastClose(stream);
}
}
use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.
the class FlashToSipAudioStream method start.
public void start(IBroadcastStream broadcastStream, IScope scope) throws StreamException {
if (log.isDebugEnabled())
log.debug("startTranscodingStream({},{})", broadcastStream.getPublishedName(), scope.getName());
mInputListener = new IStreamListener() {
public void packetReceived(IBroadcastStream broadcastStream, IStreamPacket packet) {
IoBuffer buf = packet.getData();
if (buf != null)
buf.rewind();
if (buf == null || buf.remaining() == 0) {
log.debug("skipping empty packet with no data");
return;
}
if (packet instanceof AudioData) {
byte[] data = SerializeUtils.ByteBufferToByteArray(buf);
// Remove the first byte as it is the codec id.
transcoder.handlePacket(data, 1, data.length - 1);
}
}
};
broadcastStream.addStreamListener(mInputListener);
rtpSender = new RtpStreamSender(srcSocket, connInfo);
rtpSender.connect();
transcoder.start();
}
use of org.red5.server.api.stream.IBroadcastStream in project bigbluebutton by bigbluebutton.
the class SipPhoneApplication method streamPublishStart.
public void streamPublishStart(IBroadcastStream stream) {
loginfo("Red5SIP Stream publish start: " + stream.getPublishedName());
IConnection current = Red5.getConnectionLocal();
}
Aggregations