OggFileServerDemux.hh 3.3 KB

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