[Red5commits] [1712] "NetStream?.Play.Failed" is returned if a VOD stream can not be played due to IO

jbauch luke at codegent.com
Fri Feb 9 18:50:09 EST 2007


"NetStream?.Play.Failed" is returned if a VOD stream can not be played due to IO errors (Jira APPSERVER-52)


Timestamp: 02/09/07 18:43:00 EST (less than one hour ago) 
Change: 1712 
Author: jbauch

Files (see diff or trac for details): 
doc/trunk/changelog.txt
java/server/trunk/src/org/red5/server/api/stream/ISubscriberStream.java
java/server/trunk/src/org/red5/server/messaging/IPullableProvider.java
java/server/trunk/src/org/red5/server/stream/StreamService.java
java/server/trunk/src/org/red5/server/stream/provider/FileProvider.java


Trac: http://mirror1.cvsdude.com/trac/osflash/red5/changeset/1712

Index: /java/server/trunk/src/org/red5/server/stream/provider/FileProvider.java
===================================================================
--- /java/server/trunk/src/org/red5/server/stream/provider/FileProvider.java (revision 1698)
+++ /java/server/trunk/src/org/red5/server/stream/provider/FileProvider.java (revision 1712)
@@ -111,5 +111,5 @@
 
 	/** {@inheritDoc} */
-    public synchronized IMessage pullMessage(IPipe pipe) {
+    public synchronized IMessage pullMessage(IPipe pipe) throws IOException {
 		if (this.pipe != pipe) {
 			return null;
@@ -152,5 +152,5 @@
 
 	/** {@inheritDoc} */
-    public IMessage pullMessage(IPipe pipe, long wait) {
+    public IMessage pullMessage(IPipe pipe, long wait) throws IOException {
 		return pullMessage(pipe);
 	}
@@ -203,5 +203,5 @@
      * Initializes file provider. Creates streamable file factory and service, seeks to start position
      */
-    private void init() {
+    private void init() throws IOException {
 		IStreamableFileFactory factory = (IStreamableFileFactory) ScopeUtils
 				.getScopeService(scope, IStreamableFileFactory.class,
@@ -212,10 +212,6 @@
 			return;
 		}
-		try {
-			IStreamableFile streamFile = service.getStreamableFile(file);
-			reader = streamFile.getReader();
-		} catch (IOException e) {
-			log.error("error read stream file " + file.getAbsolutePath(), e);
-		}
+		IStreamableFile streamFile = service.getStreamableFile(file);
+		reader = streamFile.getReader();
 		if (start > 0) {
 			seek(start);
Index: /java/server/trunk/src/org/red5/server/stream/StreamService.java
===================================================================
--- /java/server/trunk/src/org/red5/server/stream/StreamService.java (revision 1698)
+++ /java/server/trunk/src/org/red5/server/stream/StreamService.java (revision 1712)
@@ -20,4 +20,5 @@
  */
 
+import java.io.IOException;
 import java.util.Set;
 
@@ -184,7 +185,9 @@
 		
 		IClientStream stream = streamConn.getStreamById(streamId);
+		boolean created = false;
 		if (stream == null) {
 			stream = streamConn.newPlaylistSubscriberStream(streamId);
 			stream.start();
+			created = true;
 		}
 		if (!(stream instanceof ISubscriberStream)) {
@@ -209,5 +212,21 @@
 			return;
 		}
-		subscriberStream.play();
+		try {
+			subscriberStream.play();
+		} catch (IOException err) {
+			if (created) {
+				stream.close();
+				streamConn.deleteStreamById(streamId);
+			}
+			Status accessDenied = new Status(StatusCodes.NS_PLAY_FAILED);
+			accessDenied.setClientid(streamId);
+			accessDenied.setDesciption(err.getMessage());
+			accessDenied.setDetails(name);
+			accessDenied.setLevel("error");
+
+			// FIXME: there should be a direct way to send the status
+			Channel channel = ((RTMPConnection) streamConn).getChannel((byte) (4 + ((streamId-1) * 5)));
+			channel.sendStatus(accessDenied);
+		}
 	}
 
Index: /java/server/trunk/src/org/red5/server/messaging/IPullableProvider.java
===================================================================
--- /java/server/trunk/src/org/red5/server/messaging/IPullableProvider.java (revision 1698)
+++ /java/server/trunk/src/org/red5/server/messaging/IPullableProvider.java (revision 1712)
@@ -1,3 +1,5 @@
 package org.red5.server.messaging;
+
+import java.io.IOException;
 
 /*
@@ -29,6 +31,6 @@
 	public static final String KEY = IPullableProvider.class.getName();
 
-	IMessage pullMessage(IPipe pipe);
+	IMessage pullMessage(IPipe pipe) throws IOException;
 
-	IMessage pullMessage(IPipe pipe, long wait);
+	IMessage pullMessage(IPipe pipe, long wait) throws IOException;
 }
Index: /java/server/trunk/src/org/red5/server/api/stream/ISubscriberStream.java
===================================================================
--- /java/server/trunk/src/org/red5/server/api/stream/ISubscriberStream.java (revision 1698)
+++ /java/server/trunk/src/org/red5/server/api/stream/ISubscriberStream.java (revision 1712)
@@ -1,3 +1,5 @@
 package org.red5.server.api.stream;
+
+import java.io.IOException;
 
 /*
@@ -27,6 +29,8 @@
 	/**
 	 * Start playing.
+	 * 
+	 * @throws IOException if an IO error occurred while starting to play the stream
 	 */
-	void play();
+	void play() throws IOException;
 
 	/**
Index: /doc/trunk/changelog.txt
===================================================================
--- /doc/trunk/changelog.txt (revision 1710)
+++ /doc/trunk/changelog.txt (revision 1712)
@@ -57,4 +57,6 @@
 - fixed pausing and seeking audio-only flv files (Jira SN-17)
 - number of streams is no longer limited (Jira SN-14)
+- "NetStream.Play.Failed" is returned if a VOD stream can not be played
+  due to IO errors (Jira APPSERVER-52)
 
 


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