[Red5commits] [1539] added tutorial about how to stream to/from custom directories

jbauch luke at codegent.com
Wed Jan 24 10:51:25 EST 2007


added tutorial about how to stream to/from custom directories


Timestamp: 11/14/06 17:52:58 EST (2 months ago) 
Change: 1539 
Author: jbauch

Files (see diff or trac for details): 
doc/trunk/HOWTO-StreamCustomDirectories.txt


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

Index: /doc/trunk/HOWTO-StreamCustomDirectories.txt
===================================================================
--- /doc/trunk/HOWTO-StreamCustomDirectories.txt (revision 1539)
+++ /doc/trunk/HOWTO-StreamCustomDirectories.txt (revision 1539)
@@ -0,0 +1,120 @@
+-------------------------------------------------
+ HOWTO stream content to/from custom directories
+-------------------------------------------------
+
+:Author: Joachim Bauch
+:Contact: jojo at struktur.de
+:Date: $Date$
+:Revision: $Revision$
+:Id: $Id$
+
+.. contents::
+
+Preface
+==========================
+This document describes how applications can stream ondemand videos from or
+record to custom directories other than the default `streams` folder inside
+the webapp.
+
+Filename generator service
+==========================
+Red5 uses a concept called `scope services` for functionality that is provided
+for a certain scope. One of these scope services is IStreamFilenameGenerator_
+that generates filenames for VOD streams that should be played or recorded.
+
+Custom generator
+==========================
+To generate filename in different folders, a new filename generator must be
+implemented::
+
+    import org.red5.server.api.IScope;
+    import org.red5.server.api.stream.IStreamFilenameGenerator;
+
+    public class CustomFilenameGenerator implements IStreamFilenameGenerator {
+
+        /** Path that will store recorded videos. */
+        public String recordPath = "recordedStreams/";
+        /** Path that contains VOD streams. */
+        public String playbackPath = "videoStreams/";
+        
+        public String generateFilename(IScope scope, String name) {
+            // Generate filename without an extension.
+            return generateFilename(scope, name, null);
+        }
+
+        public String generateFilename(IScope scope, String name,
+                String extension) {
+            String filename;
+            if (name.startsWith("red5RecordDemo"))
+                filename = recordPath + name;
+            else
+                filename = playbackPath + name;
+            
+            if (extension != null)
+                // Add extension
+                filename += extension;
+            
+            return filename;
+        }
+    }
+
+The above class will generate filenames for recorded streams like
+`recordedStreams/red5RecordDemo1234.flv` and use the directory `videoStreams`
+as source for all VOD streams.
+
+Activate custom generator
+==========================
+In the next step, the custom generator must be activate in the configuration
+files for the desired application.
+
+Add the following definition to `yourApp/WEB-INF/red5-web.xml`::
+
+    <bean id="streamFilenameGenerator" 
+          class="path.to.your.CustomFilenameGenerator" />
+
+This will use the class defined above to generate stream filenames.
+
+Change paths through configuration
+==================================
+While the class described here works as expected, it's a bit unhandy to
+change the paths inside the code as every change requires recompilation
+of the class.
+
+Therefore you can pass parameters to the bean defined in the previous step
+to specify the paths to use inside the configuration file.
+
+Add two methods to your class that will be executed while the configuration
+file is parsed::
+
+    public void setRecordPath(String path) {
+        recordPath = path;
+    }
+
+    public void setPlaybackPath(String path) {
+        playbackPath = path;
+    }
+    
+Now you can set the paths inside the bean definition::
+
+    <bean id="streamFilenameGenerator" 
+          class="path.to.your.CustomFilenameGenerator">
+        <property name="recordPath" value="recordedStreams/" />
+        <property name="playbackPath" value="videoStreams/" />
+    </bean>
+
+You can also move the paths to the `yourApp/WEB-INF/red5-web.properties`
+file and use parameters to access them::
+
+    <bean id="streamFilenameGenerator" 
+          class="path.to.your.CustomFilenameGenerator">
+        <property name="recordPath" value="${recordPath}" />
+        <property name="playbackPath" value="${playbackPath}" />
+    </bean>
+
+In that case you will have to add the following lines to your properties
+file::
+
+    recordPath=recordedStreams/
+    playbackPath=videoStreams/
+
+.. _IStreamFilenameGenerator: http://dl.fancycode.com/red5/api/org/red5/server/api/stream/IStreamFilenameGenerator.html


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