[Red5commits] [1546] send NetStream? events when recording (Trac #127)
jbauch
luke at codegent.com
Wed Jan 24 10:52:19 EST 2007
send NetStream? events when recording (Trac #127)
Timestamp: 11/15/06 18:55:13 EST (2 months ago)
Change: 1546
Author: jbauch
Files (see diff or trac for details):
doc/trunk/changelog.txt
java/server/trunk/src/org/red5/server/stream/ClientBroadcastStream.java
java/server/trunk/src/org/red5/server/stream/StreamService.java
Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1546
Index: /java/server/trunk/src/org/red5/server/stream/StreamService.java
===================================================================
--- /java/server/trunk/src/org/red5/server/stream/StreamService.java (revision 1538)
+++ /java/server/trunk/src/org/red5/server/stream/StreamService.java (revision 1546)
@@ -246,4 +246,5 @@
IClientBroadcastStream bs = (IClientBroadcastStream) stream;
try {
+ bs.setPublishedName(name);
if (IClientStream.MODE_RECORD.equals(mode)) {
bs.start();
@@ -256,5 +257,4 @@
IProviderService providerService = (IProviderService) context
.getBean(IProviderService.BEAN_NAME);
- bs.setPublishedName(name);
// TODO handle registration failure
if (providerService.registerBroadcastStream(conn.getScope(),
Index: /java/server/trunk/src/org/red5/server/stream/ClientBroadcastStream.java
===================================================================
--- /java/server/trunk/src/org/red5/server/stream/ClientBroadcastStream.java (revision 1541)
+++ /java/server/trunk/src/org/red5/server/stream/ClientBroadcastStream.java (revision 1546)
@@ -83,4 +83,6 @@
private IPipe recordPipe;
+
+ private boolean recording = false;
private boolean sendStartNotification = true;
@@ -116,7 +118,6 @@
recordParamMap.put("record", null);
recordPipe.subscribe((IProvider) this, recordParamMap);
+ recording = false;
setCodecInfo(new StreamCodecInfo());
- sendStartNotify();
- notifyBroadcastStart();
}
@@ -126,5 +127,8 @@
}
recordPipe.unsubscribe((IProvider) this);
- sendStopNotify();
+ if (recording)
+ sendRecordStopNotify();
+ else
+ sendPublishStopNotify();
notifyBroadcastClose();
}
@@ -185,4 +189,5 @@
}
recordPipe.subscribe(fc, paramMap);
+ recording = true;
} catch (IOException e) {
}
@@ -280,19 +285,4 @@
streamCodec.setHasVideo(true);
}
- IEventListener source = event.getSource();
- if (sendStartNotification) {
- // Notify handler that stream starts publishing
- sendStartNotification = false;
- if (source instanceof IConnection) {
- IScope scope = ((IConnection) source).getScope();
- if (scope.hasHandler()) {
- Object handler = scope.getHandler();
- if (handler instanceof IStreamAwareScopeHandler) {
- ((IStreamAwareScopeHandler) handler)
- .streamPublishStart(this);
- }
- }
- }
- }
if (rtmpEvent.getHeader().isTimerRelative()) {
videoTime += rtmpEvent.getTimestamp();
@@ -316,4 +306,5 @@
thisTime = dataTime;
}
+ checkSendNotifications(event);
RTMPMessage msg = new RTMPMessage();
@@ -324,4 +315,28 @@
}
recordPipe.pushMessage(msg);
+ }
+
+ private void checkSendNotifications(IEvent event) {
+ IEventListener source = event.getSource();
+ if (sendStartNotification) {
+ // Notify handler that stream starts recording/publishing
+ sendStartNotification = false;
+ if (source instanceof IConnection) {
+ IScope scope = ((IConnection) source).getScope();
+ if (scope.hasHandler()) {
+ Object handler = scope.getHandler();
+ if (handler instanceof IStreamAwareScopeHandler) {
+ ((IStreamAwareScopeHandler) handler)
+ .streamPublishStart(this);
+ }
+ }
+ }
+
+ if (recording) {
+ sendRecordStartNotify();
+ } else
+ sendPublishStartNotify();
+ notifyBroadcastStart();
+ }
}
@@ -350,5 +365,5 @@
}
- private void sendStartNotify() {
+ private void sendPublishStartNotify() {
Status start = new Status(StatusCodes.NS_PUBLISH_START);
start.setClientid(getStreamId());
@@ -360,5 +375,5 @@
}
- private void sendStopNotify() {
+ private void sendPublishStopNotify() {
Status stop = new Status(StatusCodes.NS_UNPUBLISHED_SUCCESS);
stop.setClientid(getStreamId());
@@ -368,4 +383,24 @@
stopMsg.setBody(stop);
connMsgOut.pushMessage(stopMsg);
+ }
+
+ private void sendRecordStartNotify() {
+ Status start = new Status(StatusCodes.NS_RECORD_START);
+ start.setClientid(getStreamId());
+ start.setDetails(getPublishedName());
+
+ StatusMessage startMsg = new StatusMessage();
+ startMsg.setBody(start);
+ connMsgOut.pushMessage(startMsg);
+ }
+
+ private void sendRecordStopNotify() {
+ Status start = new Status(StatusCodes.NS_RECORD_STOP);
+ start.setClientid(getStreamId());
+ start.setDetails(getPublishedName());
+
+ StatusMessage startMsg = new StatusMessage();
+ startMsg.setBody(start);
+ connMsgOut.pushMessage(startMsg);
}
Index: /doc/trunk/changelog.txt
===================================================================
--- /doc/trunk/changelog.txt (revision 1545)
+++ /doc/trunk/changelog.txt (revision 1546)
@@ -23,4 +23,5 @@
- fixed NPE in FlowControlService thread (Trac #175)
- deserializing of mixed arrays now works in all cases (Trac #109, #195)
+- "NetStream.Record.Start" and "NetStream.Record.Stop" are sent (Trac #127)
Note:
Diffs are chopped if more than 25k.
This is to get past the limit on the mailing list.
More information about the Red5commits
mailing list