Changeset 715


Ignore:
Timestamp:
01/13/12 09:32:27 (4 months ago)
Author:
josh
Message:

-- RTMP: Allow application-selectable outfile streams.

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • branches/1.0/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h

    r658 r715  
    2727#include "protocols/rtmp/rtmpprotocolserializer.h" 
    2828#include "protocols/rtmp/sharedobjects/somanager.h" 
    29 #include "basertmpprotocol.h" 
     29#include "streaming/baseoutstream.h" 
     30#include "streaming/baseoutfilestream.h" 
    3031 
    3132class OutboundRTMPProtocol; 
    3233class BaseRTMPProtocol; 
     34class BaseOutFileStream; 
    3335 
    3436class DLLEXP BaseRTMPAppProtocolHandler 
     
    234236        bool SendRTMPMessage(BaseRTMPProtocol *pTo, Variant message, 
    235237                        bool trackResponse = false); 
     238 
     239        /* 
     240         * Create a file stream for writing to disk. 
     241         * pFrom - The connection which wants to stream to disk 
     242         * meta - Stream metadata 
     243         * append - Whether to append this stream to an exiting file 
     244         * */ 
     245        virtual BaseOutFileStream *CreateOutFileStream(BaseRTMPProtocol *pFrom, Variant &meta, bool append); 
    236246private: 
    237247        /* 
  • branches/1.0/sources/thelib/include/protocols/rtmp/streaming/innetrtmpstream.h

    r637 r715  
    2828class BaseRTMPProtocol; 
    2929class BaseOutStream; 
     30class BaseOutFileStream; 
    3031 
    3132class DLLEXP InNetRTMPStream 
     
    7172                        bool persistent = true); 
    7273        bool SendOnStatusStreamPublished(); 
    73         bool RecordFLV(Variant &meta, bool append); 
    74         bool RecordMP4(Variant &meta); 
     74        bool Record(BaseOutFileStream* pOutFileStream); 
    7575 
    7676        virtual void SignalOutStreamAttached(BaseOutStream *pOutStream); 
  • branches/1.0/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp

    r688 r715  
    2929#include "protocols/rtmp/streaming/infilertmpstream.h" 
    3030#include "protocols/rtmp/streaming/innetrtmpstream.h" 
     31#include "protocols/rtmp/streaming/outfilertmpflvstream.h" 
    3132#include "streaming/streamstypes.h" 
    3233#include "streaming/baseinstream.h" 
     
    812813                Variant meta = GetMetaData(streamName, false); 
    813814 
    814                 if ((meta[META_MEDIA_TYPE] == MEDIA_TYPE_LIVE_OR_FLV) || 
    815                                 (meta[META_MEDIA_TYPE] == MEDIA_TYPE_FLV)) { 
    816                         if (!pInNetRTMPStream->RecordFLV(meta, appending)) { 
    817                                 FATAL("Unable to bind the recording stream"); 
    818                                 return false; 
    819                         } 
    820                 } else if (meta[META_MEDIA_TYPE] == MEDIA_TYPE_MP4) { 
    821                         if (!pInNetRTMPStream->RecordMP4(meta)) { 
    822                                 FATAL("Unable to bind the recording stream"); 
    823                                 return false; 
    824                         } 
     815                BaseOutFileStream *pOutFileStream = CreateOutFileStream(pFrom, meta, appending); 
     816                if (!pOutFileStream || !pInNetRTMPStream->Record(pOutFileStream)) { 
     817                        FATAL("Unable to bind the recording stream"); 
     818                        return false; 
    825819                } 
    826820        } 
     
    18661860} 
    18671861 
     1862BaseOutFileStream* BaseRTMPAppProtocolHandler::CreateOutFileStream( 
     1863        BaseRTMPProtocol *pFrom, Variant &meta, bool append) 
     1864{ 
     1865        //1. Compute the file name 
     1866        string fileName = meta[META_SERVER_MEDIA_DIR]; 
     1867        fileName += (string) meta[META_SERVER_FILE_NAME]; 
     1868        FINEST("fileName: %s", STR(fileName)); 
     1869 
     1870        //2. Delete the old file 
     1871        if (append) { 
     1872                WARN("append not supported yet. File will be overwritten"); 
     1873        } 
     1874        deleteFile(fileName); 
     1875 
     1876        if ((meta[META_MEDIA_TYPE] == MEDIA_TYPE_LIVE_OR_FLV) || 
     1877                        (meta[META_MEDIA_TYPE] == MEDIA_TYPE_FLV)) { 
     1878                return new OutFileRTMPFLVStream(pFrom, 
     1879                        GetApplication()->GetStreamsManager(), fileName); 
     1880        } 
     1881        if (meta[META_MEDIA_TYPE] == MEDIA_TYPE_MP4) { 
     1882                FATAL("Streaming to MP4 file not supported"); 
     1883                return NULL; 
     1884        } 
     1885        FATAL("Media type not supported"); 
     1886        return NULL; 
     1887} 
     1888 
    18681889string NormalizeStreamName(string streamName) { 
    18691890        replace(streamName, "-", "_"); 
  • branches/1.0/sources/thelib/src/protocols/rtmp/streaming/innetrtmpstream.cpp

    r701 r715  
    188188} 
    189189 
    190 bool InNetRTMPStream::RecordFLV(Variant &meta, bool append) { 
    191         //1. Compute the file name 
    192         string fileName = meta[META_SERVER_MEDIA_DIR]; 
    193         fileName += (string) meta[META_SERVER_FILE_NAME]; 
    194         FINEST("fileName: %s", STR(fileName)); 
    195  
    196         //2. Delete the old file 
    197         if (append) { 
    198                 WARN("append not supported yet. File will be overwritten"); 
    199         } 
    200         deleteFile(fileName); 
    201  
    202         //3. Create the out file 
    203         _pOutFileRTMPFLVStream = new OutFileRTMPFLVStream(_pProtocol, 
    204                         _pStreamsManager, fileName); 
    205  
    206         //4. Link it 
     190bool InNetRTMPStream::Record(BaseOutFileStream *pOutStream) { 
     191 
     192        _pOutFileRTMPFLVStream = pOutStream; 
    207193        return _pOutFileRTMPFLVStream->Link(this); 
    208 } 
    209  
    210 bool InNetRTMPStream::RecordMP4(Variant &meta) { 
    211         NYIR; 
    212194} 
    213195 
  • trunk/sources/thelib/include/protocols/rtmp/basertmpappprotocolhandler.h

    r658 r715  
    2727#include "protocols/rtmp/rtmpprotocolserializer.h" 
    2828#include "protocols/rtmp/sharedobjects/somanager.h" 
    29 #include "basertmpprotocol.h" 
     29#include "streaming/baseoutstream.h" 
     30#include "streaming/baseoutfilestream.h" 
    3031 
    3132class OutboundRTMPProtocol; 
    3233class BaseRTMPProtocol; 
     34class BaseOutFileStream; 
    3335 
    3436class DLLEXP BaseRTMPAppProtocolHandler 
     
    234236        bool SendRTMPMessage(BaseRTMPProtocol *pTo, Variant message, 
    235237                        bool trackResponse = false); 
     238 
     239        /* 
     240         * Create a file stream for writing to disk. 
     241         * pFrom - The connection which wants to stream to disk 
     242         * meta - Stream metadata 
     243         * append - Whether to append this stream to an exiting file 
     244         * */ 
     245        virtual BaseOutFileStream *CreateOutFileStream(BaseRTMPProtocol *pFrom, Variant &meta, bool append); 
    236246private: 
    237247        /* 
  • trunk/sources/thelib/include/protocols/rtmp/streaming/innetrtmpstream.h

    r637 r715  
    2828class BaseRTMPProtocol; 
    2929class BaseOutStream; 
     30class BaseOutFileStream; 
    3031 
    3132class DLLEXP InNetRTMPStream 
     
    7172                        bool persistent = true); 
    7273        bool SendOnStatusStreamPublished(); 
    73         bool RecordFLV(Variant &meta, bool append); 
    74         bool RecordMP4(Variant &meta); 
     74        bool Record(BaseOutFileStream* pOutFileStream); 
    7575 
    7676        virtual void SignalOutStreamAttached(BaseOutStream *pOutStream); 
  • trunk/sources/thelib/src/protocols/rtmp/basertmpappprotocolhandler.cpp

    r688 r715  
    2929#include "protocols/rtmp/streaming/infilertmpstream.h" 
    3030#include "protocols/rtmp/streaming/innetrtmpstream.h" 
     31#include "protocols/rtmp/streaming/outfilertmpflvstream.h" 
    3132#include "streaming/streamstypes.h" 
    3233#include "streaming/baseinstream.h" 
     
    812813                Variant meta = GetMetaData(streamName, false); 
    813814 
    814                 if ((meta[META_MEDIA_TYPE] == MEDIA_TYPE_LIVE_OR_FLV) || 
    815                                 (meta[META_MEDIA_TYPE] == MEDIA_TYPE_FLV)) { 
    816                         if (!pInNetRTMPStream->RecordFLV(meta, appending)) { 
    817                                 FATAL("Unable to bind the recording stream"); 
    818                                 return false; 
    819                         } 
    820                 } else if (meta[META_MEDIA_TYPE] == MEDIA_TYPE_MP4) { 
    821                         if (!pInNetRTMPStream->RecordMP4(meta)) { 
    822                                 FATAL("Unable to bind the recording stream"); 
    823                                 return false; 
    824                         } 
     815                BaseOutFileStream *pOutFileStream = CreateOutFileStream(pFrom, meta, appending); 
     816                if (!pOutFileStream || !pInNetRTMPStream->Record(pOutFileStream)) { 
     817                        FATAL("Unable to bind the recording stream"); 
     818                        return false; 
    825819                } 
    826820        } 
     
    18661860} 
    18671861 
     1862BaseOutFileStream* BaseRTMPAppProtocolHandler::CreateOutFileStream( 
     1863        BaseRTMPProtocol *pFrom, Variant &meta, bool append) 
     1864{ 
     1865        //1. Compute the file name 
     1866        string fileName = meta[META_SERVER_MEDIA_DIR]; 
     1867        fileName += (string) meta[META_SERVER_FILE_NAME]; 
     1868        FINEST("fileName: %s", STR(fileName)); 
     1869 
     1870        //2. Delete the old file 
     1871        if (append) { 
     1872                WARN("append not supported yet. File will be overwritten"); 
     1873        } 
     1874        deleteFile(fileName); 
     1875 
     1876        if ((meta[META_MEDIA_TYPE] == MEDIA_TYPE_LIVE_OR_FLV) || 
     1877                        (meta[META_MEDIA_TYPE] == MEDIA_TYPE_FLV)) { 
     1878                return new OutFileRTMPFLVStream(pFrom, 
     1879                        GetApplication()->GetStreamsManager(), fileName); 
     1880        } 
     1881        if (meta[META_MEDIA_TYPE] == MEDIA_TYPE_MP4) { 
     1882                FATAL("Streaming to MP4 file not supported"); 
     1883                return NULL; 
     1884        } 
     1885        FATAL("Media type not supported"); 
     1886        return NULL; 
     1887} 
     1888 
    18681889string NormalizeStreamName(string streamName) { 
    18691890        replace(streamName, "-", "_"); 
  • trunk/sources/thelib/src/protocols/rtmp/streaming/innetrtmpstream.cpp

    r701 r715  
    188188} 
    189189 
    190 bool InNetRTMPStream::RecordFLV(Variant &meta, bool append) { 
    191         //1. Compute the file name 
    192         string fileName = meta[META_SERVER_MEDIA_DIR]; 
    193         fileName += (string) meta[META_SERVER_FILE_NAME]; 
    194         FINEST("fileName: %s", STR(fileName)); 
    195  
    196         //2. Delete the old file 
    197         if (append) { 
    198                 WARN("append not supported yet. File will be overwritten"); 
    199         } 
    200         deleteFile(fileName); 
    201  
    202         //3. Create the out file 
    203         _pOutFileRTMPFLVStream = new OutFileRTMPFLVStream(_pProtocol, 
    204                         _pStreamsManager, fileName); 
    205  
    206         //4. Link it 
     190bool InNetRTMPStream::Record(BaseOutFileStream *pOutStream) { 
     191 
     192        _pOutFileRTMPFLVStream = pOutStream; 
    207193        return _pOutFileRTMPFLVStream->Link(this); 
    208 } 
    209  
    210 bool InNetRTMPStream::RecordMP4(Variant &meta) { 
    211         NYIR; 
    212194} 
    213195 
Note: See TracChangeset for help on using the changeset viewer.