- make recording process work

This commit is contained in:
Richard Alam 2014-06-12 12:31:24 -07:00
parent 702c57ebab
commit 97262dfba5
8 changed files with 50 additions and 22 deletions

View File

@ -20,6 +20,8 @@ package org.bigbluebutton.app.video;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
@ -85,6 +87,10 @@ public class VideoApplication extends MultiThreadedApplicationAdapter {
}
}
private Long genTimestamp() {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
}
@Override
public void streamBroadcastClose(IBroadcastStream stream) {
IConnection conn = Red5.getConnectionLocal();
@ -96,11 +102,11 @@ public class VideoApplication extends MultiThreadedApplicationAdapter {
stream.removeStreamListener(listener);
}
long publishDuration = (System.currentTimeMillis() - stream.getCreationTime()) / 1000;
log.info("streamBroadcastClose " + stream.getPublishedName() + " " + System.currentTimeMillis() + " " + conn.getScope().getName());
long publishDuration = (System.currentTimeMillis() - stream.getCreationTime()) / 1000;
log.info("streamBroadcastClose " + stream.getPublishedName() + " " + System.currentTimeMillis() + " " + conn.getScope().getName());
Map<String, String> event = new HashMap<String, String>();
event.put("module", "WEBCAM");
event.put("timestamp", new Long(System.currentTimeMillis()).toString());
event.put("timestamp", genTimestamp().toString());
event.put("meetingId", conn.getScope().getName());
event.put("stream", stream.getPublishedName());
event.put("duration", new Long(publishDuration).toString());

View File

@ -20,6 +20,8 @@ package org.bigbluebutton.app.video;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.apache.mina.core.buffer.IoBuffer;
import org.red5.server.api.IConnection;
import org.red5.server.api.Red5;
@ -47,6 +49,10 @@ public class VideoStreamListener implements IStreamListener {
private EventRecordingService recordingService;
private volatile boolean firstPacketReceived = false;
private Long genTimestamp() {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
}
@Override
public void packetReceived(IBroadcastStream stream, IStreamPacket packet) {
IoBuffer buf = packet.getData();
@ -63,7 +69,7 @@ public class VideoStreamListener implements IStreamListener {
IConnection conn = Red5.getConnectionLocal();
Map<String, String> event = new HashMap<String, String>();
event.put("module", "WEBCAM");
event.put("timestamp", new Long(System.currentTimeMillis()).toString());
event.put("timestamp", genTimestamp().toString());
event.put("meetingId", conn.getScope().getName());
event.put("stream", stream.getPublishedName());
event.put("eventName", "StartWebcamShareEvent");

View File

@ -87,10 +87,14 @@ public class FreeswitchApplication implements ConferenceServiceProvider {
queueMessage(mpc);
}
private Long genTimestamp() {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
}
@Override
public void record(String room, String meetingid){
String RECORD_DIR = "/var/freeswitch/meetings";
String voicePath = RECORD_DIR + File.separatorChar + meetingid + "-" + System.currentTimeMillis() + ".wav";
String voicePath = RECORD_DIR + File.separatorChar + meetingid + "-" + genTimestamp() + ".wav";
RecordConferenceCommand rcc = new RecordConferenceCommand(room, USER, true, voicePath);
queueMessage(rcc);

View File

@ -41,7 +41,7 @@ class PollEventRedisRecorder(recorder: RecorderApplication) extends OutMessageLi
}
}
ev.setTimestamp(System.currentTimeMillis())
ev.setTimestamp(TimestampGenerator.generateTimestamp)
ev.setMeetingId(msg.meetingID)
recorder.record(msg.meetingID, ev)
}
@ -65,7 +65,7 @@ class PollEventRedisRecorder(recorder: RecorderApplication) extends OutMessageLi
}
}
ev.setTimestamp(System.currentTimeMillis())
ev.setTimestamp(TimestampGenerator.generateTimestamp)
ev.setMeetingId(msg.meetingID)
recorder.record(msg.meetingID, ev)
}
@ -75,7 +75,7 @@ class PollEventRedisRecorder(recorder: RecorderApplication) extends OutMessageLi
if(msg.recorded){
val ev = new PollRemovedRecordEvent()
ev.setPollID(msg.pollID)
ev.setTimestamp(System.currentTimeMillis())
ev.setTimestamp(TimestampGenerator.generateTimestamp)
ev.setMeetingId(msg.meetingID)
recorder.record(msg.meetingID, ev)
}
@ -85,7 +85,7 @@ class PollEventRedisRecorder(recorder: RecorderApplication) extends OutMessageLi
if(msg.recorded){
val ev = new PollStoppedRecordEvent()
ev.setPollID(msg.pollID)
ev.setTimestamp(System.currentTimeMillis())
ev.setTimestamp(TimestampGenerator.generateTimestamp)
ev.setMeetingId(msg.meetingID)
recorder.record(msg.meetingID, ev)
}
@ -105,7 +105,7 @@ class PollEventRedisRecorder(recorder: RecorderApplication) extends OutMessageLi
if(msg.recorded){
val ev = new PollClearedRecordEvent()
ev.setPollID(msg.pollID)
ev.setTimestamp(System.currentTimeMillis())
ev.setTimestamp(TimestampGenerator.generateTimestamp)
ev.setMeetingId(msg.meetingID)
recorder.record(msg.meetingID, ev)
}

View File

@ -17,6 +17,7 @@ import org.bigbluebutton.core.api.SendCursorUpdateOutMsg
import org.bigbluebutton.conference.service.recorder.presentation.CursorUpdateRecordEvent
import org.bigbluebutton.core.api.ClearPresentationOutMsg
import org.bigbluebutton.core.api.PresentationConversionDone
import org.bigbluebutton.core.api.TimestampGenerator
class PresentationEventRedisRecorder(recorder: RecorderApplication) extends OutMessageListener2 {
private val GENERATED_SLIDE_KEY = "GENERATED_SLIDE";
@ -43,7 +44,7 @@ class PresentationEventRedisRecorder(recorder: RecorderApplication) extends OutM
if (msg.recorded) {
val event = new ConversionCompletedPresentationRecordEvent();
event.setMeetingId(msg.meetingID);
event.setTimestamp(System.currentTimeMillis());
event.setTimestamp(TimestampGenerator.generateTimestamp);
event.setPresentationName(msg.presentation.id);
event.setOriginalFilename(msg.presentation.name);
recorder.record(msg.meetingID, event);
@ -55,7 +56,7 @@ class PresentationEventRedisRecorder(recorder: RecorderApplication) extends OutM
if (msg.recorded) {
val event = new GotoSlidePresentationRecordEvent();
event.setMeetingId(msg.meetingID);
event.setTimestamp(System.currentTimeMillis());
event.setTimestamp(TimestampGenerator.generateTimestamp);
event.setSlide(msg.page.num);
event.setId(msg.page.id);
event.setNum(msg.page.num);
@ -75,7 +76,7 @@ class PresentationEventRedisRecorder(recorder: RecorderApplication) extends OutM
if (msg.recorded) {
val event = new ResizeAndMoveSlidePresentationRecordEvent();
event.setMeetingId(msg.meetingID);
event.setTimestamp(System.currentTimeMillis());
event.setTimestamp(TimestampGenerator.generateTimestamp);
event.setId(msg.page.id);
event.setNum(msg.page.num);
event.setThumbUri(msg.page.thumbUri);
@ -95,7 +96,7 @@ class PresentationEventRedisRecorder(recorder: RecorderApplication) extends OutM
if (msg.recorded) {
val event = new RemovePresentationPresentationRecordEvent();
event.setMeetingId(msg.meetingID);
event.setTimestamp(System.currentTimeMillis());
event.setTimestamp(TimestampGenerator.generateTimestamp);
event.setPresentationName(msg.presentationID);
recorder.record(msg.meetingID, event);
}
@ -105,7 +106,7 @@ class PresentationEventRedisRecorder(recorder: RecorderApplication) extends OutM
if (msg.recorded) {
val event = new SharePresentationPresentationRecordEvent();
event.setMeetingId(msg.meetingID);
event.setTimestamp(System.currentTimeMillis());
event.setTimestamp(TimestampGenerator.generateTimestamp);
event.setPresentationName(msg.presentation.id);
event.setOriginalFilename(msg.presentation.name);
event.setShare(true);
@ -117,7 +118,7 @@ class PresentationEventRedisRecorder(recorder: RecorderApplication) extends OutM
if (msg.recorded) {
val event = new CursorUpdateRecordEvent();
event.setMeetingId(msg.meetingID);
event.setTimestamp(System.currentTimeMillis());
event.setTimestamp(TimestampGenerator.generateTimestamp);
event.setXPercent(msg.xPercent);
event.setYPercent(msg.yPercent);

View File

@ -51,7 +51,7 @@ class WhiteboardEventRedisRecorder(recorder: RecorderApplication) extends OutMes
val event = new ModifyTextWhiteboardRecordEvent()
event.setMeetingId(msg.meetingID)
event.setTimestamp(System.currentTimeMillis())
event.setTimestamp(TimestampGenerator.generateTimestamp)
event.setPresentation(getPresentationId(msg.whiteboardId))
event.setPageNumber(getPageNum(msg.whiteboardId))
event.setWhiteboardId(msg.whiteboardId)
@ -60,7 +60,7 @@ class WhiteboardEventRedisRecorder(recorder: RecorderApplication) extends OutMes
} else {
val event = new AddShapeWhiteboardRecordEvent()
event.setMeetingId(msg.meetingID)
event.setTimestamp(System.currentTimeMillis())
event.setTimestamp(TimestampGenerator.generateTimestamp)
event.setPresentation(getPresentationId(msg.whiteboardId))
event.setPageNumber(getPageNum(msg.whiteboardId))
event.setWhiteboardId(msg.whiteboardId);
@ -72,7 +72,7 @@ class WhiteboardEventRedisRecorder(recorder: RecorderApplication) extends OutMes
private def handleClearWhiteboardEvent(msg: ClearWhiteboardEvent) {
val event = new ClearPageWhiteboardRecordEvent()
event.setMeetingId(msg.meetingID)
event.setTimestamp(System.currentTimeMillis())
event.setTimestamp(TimestampGenerator.generateTimestamp)
event.setPresentation(getPresentationId(msg.whiteboardId))
event.setPageNumber(getPageNum(msg.whiteboardId))
event.setWhiteboardId(msg.whiteboardId)
@ -82,7 +82,7 @@ class WhiteboardEventRedisRecorder(recorder: RecorderApplication) extends OutMes
private def handleUndoWhiteboardEvent(msg: UndoWhiteboardEvent) {
val event = new UndoShapeWhiteboardRecordEvent()
event.setMeetingId(msg.meetingID)
event.setTimestamp(System.currentTimeMillis())
event.setTimestamp(TimestampGenerator.generateTimestamp)
event.setPresentation(getPresentationId(msg.whiteboardId))
event.setPageNumber(getPageNum(msg.whiteboardId))
event.setWhiteboardId(msg.whiteboardId)

View File

@ -18,6 +18,8 @@
*/
package org.bigbluebutton.deskshare.server.recorder;
import java.util.concurrent.TimeUnit;
import org.bigbluebutton.deskshare.server.recorder.event.AbstractDeskshareRecordEvent;
import org.bigbluebutton.deskshare.server.recorder.event.RecordEvent;
import org.bigbluebutton.deskshare.server.recorder.event.RecordStartedEvent;
@ -35,6 +37,10 @@ public class EventRecorder implements RecordStatusListener {
this.port = port;
}
private Long genTimestamp() {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
}
private void record(String session, RecordEvent message) {
Jedis jedis = new Jedis(host, port);
Long msgid = jedis.incr("global:nextRecordedMsgId");
@ -45,7 +51,7 @@ public class EventRecorder implements RecordStatusListener {
@Override
public void notify(RecordEvent event) {
if ((event instanceof RecordStoppedEvent) || (event instanceof RecordStartedEvent)) {
event.setTimestamp(System.currentTimeMillis());
event.setTimestamp(genTimestamp());
event.setMeetingId(((AbstractDeskshareRecordEvent)event).getSession());
record(((AbstractDeskshareRecordEvent)event).getSession(), event);
}

View File

@ -25,6 +25,7 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
import org.apache.mina.core.buffer.IoBuffer;
import org.bigbluebutton.deskshare.server.recorder.event.RecordErrorEvent;
@ -54,9 +55,13 @@ public class FileRecorder implements Recorder {
public FileRecorder(String name, String recordingPath) {
session = name;
flvFilename = recordingPath + "/" + name + "-" + System.currentTimeMillis() + ".flv";
flvFilename = recordingPath + "/" + name + "-" + genTimestamp() + ".flv";
}
private Long genTimestamp() {
return TimeUnit.NANOSECONDS.toMillis(System.nanoTime());
}
public void addListener(RecordStatusListener l) {
listeners.addListener(l);
}