use of org.red5.server.api.stream.IStreamListener in project bigbluebutton by bigbluebutton.
the class ScreenVideoBroadcastStream method dispatchEvent.
public void dispatchEvent(IEvent event) {
try {
// System.out.println("dispatchEvent(event:screenVideo)");
if (event instanceof IRTMPEvent) {
IRTMPEvent rtmpEvent = (IRTMPEvent) event;
if (livePipe != null) {
RTMPMessage msg = RTMPMessage.build(rtmpEvent, Constants.SOURCE_TYPE_LIVE);
if (creationTime == null)
creationTime = (long) rtmpEvent.getTimestamp();
try {
IVideoStreamCodec videoStreamCodec = new ScreenVideo();
streamCodecInfo.setHasVideo(true);
streamCodecInfo.setVideoCodec(videoStreamCodec);
videoStreamCodec.reset();
videoStreamCodec.addData(((VideoData) rtmpEvent).getData());
livePipe.pushMessage(msg);
// Notify listeners about received packet
if (rtmpEvent instanceof IStreamPacket) {
for (IStreamListener listener : getStreamListeners()) {
try {
listener.packetReceived(this, (IStreamPacket) rtmpEvent);
} catch (Exception e) {
log.error("Error while notifying listener " + listener, e);
}
}
}
} catch (IOException ex) {
// ignore
log.error("Got exception: {}", ex);
}
}
}
} finally {
}
}
use of org.red5.server.api.stream.IStreamListener 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);
}
}
use of org.red5.server.api.stream.IStreamListener 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);
}
}
use of org.red5.server.api.stream.IStreamListener 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();
}
Aggregations