| 1 | /********** |
| 2 | This library is free software; you can redistribute it and/or modify it under |
| 3 | the terms of the GNU Lesser General Public License as published by the |
| 4 | Free Software Foundation; either version 3 of the License, or (at your |
| 5 | option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.) |
| 6 | |
| 7 | This library is distributed in the hope that it will be useful, but WITHOUT |
| 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for |
| 10 | more details. |
| 11 | |
| 12 | You should have received a copy of the GNU Lesser General Public License |
| 13 | along with this library; if not, write to the Free Software Foundation, Inc., |
| 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 15 | **********/ |
| 16 | // "liveMedia" |
| 17 | // Copyright (c) 1996-2020 Live Networks, Inc. All rights reserved. |
| 18 | // A server demultiplexor for an Ogg file |
| 19 | // C++ header |
| 20 | |
| 21 | #ifndef _OGG_FILE_SERVER_DEMUX_HH |
| 22 | #define _OGG_FILE_SERVER_DEMUX_HH |
| 23 | |
| 24 | #ifndef _SERVER_MEDIA_SESSION_HH |
| 25 | #include "ServerMediaSession.hh" |
| 26 | #endif |
| 27 | |
| 28 | #ifndef _OGG_FILE_HH |
| 29 | #include "OggFile.hh" |
| 30 | #endif |
| 31 | |
| 32 | class OggFileServerDemux: public Medium { |
| 33 | public: |
| 34 | typedef void (onCreationFunc)(OggFileServerDemux* newDemux, void* clientData); |
| 35 | static void createNew(UsageEnvironment& env, char const* fileName, |
| 36 | onCreationFunc* onCreation, void* onCreationClientData); |
| 37 | // Note: Unlike most "createNew()" functions, this one doesn't return a new object immediately. Instead, because this class |
| 38 | // requires file reading (to parse the Ogg 'Track' headers) before a new object can be initialized, the creation of a new |
| 39 | // object is signalled by calling - from the event loop - an 'onCreationFunc' that is passed as a parameter to "createNew()". |
| 40 | |
| 41 | ServerMediaSubsession* newServerMediaSubsession(); |
| 42 | ServerMediaSubsession* newServerMediaSubsession(u_int32_t& resultTrackNumber); |
| 43 | // Returns a new "ServerMediaSubsession" object that represents the next media track |
| 44 | // from the file. This function returns NULL when no more media tracks exist. |
| 45 | |
| 46 | ServerMediaSubsession* newServerMediaSubsessionByTrackNumber(u_int32_t trackNumber); |
| 47 | // As above, but creates a new "ServerMediaSubsession" object for a specific track number |
| 48 | // within the Ogg file. |
| 49 | // (You should not call this function more than once with the same track number.) |
| 50 | |
| 51 | // The following public: member functions are called only by the "ServerMediaSubsession" objects: |
| 52 | |
| 53 | OggFile* ourOggFile() { return fOurOggFile; } |
| 54 | char const* fileName() const { return fFileName; } |
| 55 | |
| 56 | FramedSource* newDemuxedTrack(unsigned clientSessionId, u_int32_t trackNumber); |
| 57 | // Used by the "ServerMediaSubsession" objects to implement their "createNewStreamSource()" virtual function. |
| 58 | |
| 59 | private: |
| 60 | OggFileServerDemux(UsageEnvironment& env, char const* fileName, |
| 61 | onCreationFunc* onCreation, void* onCreationClientData); |
| 62 | // called only by createNew() |
| 63 | virtual ~OggFileServerDemux(); |
| 64 | |
| 65 | static void onOggFileCreation(OggFile* newFile, void* clientData); |
| 66 | void onOggFileCreation(OggFile* newFile); |
| 67 | private: |
| 68 | char const* fFileName; |
| 69 | onCreationFunc* fOnCreation; |
| 70 | void* fOnCreationClientData; |
| 71 | OggFile* fOurOggFile; |
| 72 | |
| 73 | // Used to implement "newServerMediaSubsession()": |
| 74 | OggTrackTableIterator* fIter; |
| 75 | |
| 76 | // Used to set up demuxing, to implement "newDemuxedTrack()": |
| 77 | unsigned fLastClientSessionId; |
| 78 | OggDemux* fLastCreatedDemux; |
| 79 | }; |
| 80 | |
| 81 | #endif |
| 82 | |