liveMedia/include/MatroskaFileServerDemux.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2012 Live Networks, Inc.  All rights reserved.
00018 // A server demultiplexor for a Matroska file
00019 // C++ header
00020 
00021 #ifndef _MATROSKA_FILE_SERVER_DEMUX_HH
00022 #define _MATROSKA_FILE_SERVER_DEMUX_HH
00023 
00024 #ifndef _SERVER_MEDIA_SESSION_HH
00025 #include "ServerMediaSession.hh"
00026 #endif
00027 
00028 #ifndef _MATROSKA_FILE_HH
00029 #include "MatroskaFile.hh"
00030 #endif
00031 
00032 class MatroskaFileServerDemux: public Medium {
00033 public:
00034   typedef void (onCreationFunc)(MatroskaFileServerDemux* newDemux, void* clientData);
00035   static void createNew(UsageEnvironment& env, char const* fileName, onCreationFunc* onCreation, void* onCreationClientData);
00036     // Note: Unlike most "createNew()" functions, this one doesn't return a new object immediately.  Instead, because this class
00037     // requires file reading (to parse the Matroska 'Track' headers) before a new object can be initialized, the creation of a new
00038     // object is signalled by calling - from the event loop - an 'onCreationFunc' that is passed as a parameter to "createNew()". 
00039 
00040   ServerMediaSubsession* newServerMediaSubsession();
00041     // Returns a new "ServerMediaSubsession" object that represents the next preferred media track
00042     // (video, audio, subtitle - in that order) from the file. (Preferred media tracks are based on the file's language preference.)
00043     // This function returns NULL when no more media tracks exist.
00044 
00045   ServerMediaSubsession* newServerMediaSubsession(unsigned trackNumber);
00046     // As above, but creates a new "ServerMediaSubsession" object for a specific track number within the Matroska file.
00047     // (You should not call this function more than once with the same track number.)
00048 
00049   // The following public: member functions are called only by the "ServerMediaSubsession" objects:
00050 
00051   MatroskaFile* ourMatroskaFile() { return fOurMatroskaFile; }
00052   char const* fileName() const { return fFileName; }
00053   float fileDuration() const { return fOurMatroskaFile->fileDuration(); }
00054   MatroskaTrack* lookup(unsigned trackNumber) { return fOurMatroskaFile->lookup(trackNumber); } // shortcut
00055 
00056   FramedSource* newDemuxedTrack(unsigned clientSessionId, unsigned trackNumber);
00057     // Used by the "ServerMediaSubsession" objects to implement their "createNewStreamSource()" virtual function.
00058 
00059 private:
00060   MatroskaFileServerDemux(UsageEnvironment& env, char const* fileName, onCreationFunc* onCreation, void* onCreationClientData);
00061       // called only by createNew()
00062   virtual ~MatroskaFileServerDemux();
00063 
00064   static void onMatroskaFileCreation(MatroskaFile* newFile, void* clientData);
00065   void onMatroskaFileCreation(MatroskaFile* newFile);
00066 private:
00067   char const* fFileName; 
00068   onCreationFunc* fOnCreation;
00069   void* fOnCreationClientData;
00070   MatroskaFile* fOurMatroskaFile;
00071 
00072   // Used to implement "newServerMediaSubsession()":
00073   u_int8_t fNextTrackTypeToCheck;
00074 
00075   // Used to set up demuxing, to implement "newDemuxedTrack()":
00076   unsigned fLastClientSessionId;
00077   MatroskaDemux* fLastCreatedDemux;
00078 };
00079 
00080 #endif

Generated on Thu May 17 07:11:45 2012 for live by  doxygen 1.5.2