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