live
MPEG2TransportFileServerMediaSubsession.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 'ServerMediaSubsession' object that creates new, unicast, "RTPSink"s
19// on demand, from a MPEG-2 Transport Stream file.
20// C++ header
21
22#ifndef _MPEG2_TRANSPORT_FILE_SERVER_MEDIA_SUBSESSION_HH
23#define _MPEG2_TRANSPORT_FILE_SERVER_MEDIA_SUBSESSION_HH
24
25#ifndef _FILE_SERVER_MEDIA_SUBSESSION_HH
27#endif
28#ifndef _MPEG2_TRANSPORT_STREAM_FRAMER_HH
30#endif
31#ifndef _BYTE_STREAM_FILE_SOURCE_HH
33#endif
34#ifndef _MPEG2_TRANSPORT_STREAM_TRICK_MODE_FILTER_HH
36#endif
37#ifndef _MPEG2_TRANSPORT_STREAM_FROM_ES_SOURCE_HH
39#endif
40
41class ClientTrickPlayState; // forward
42
44public:
47 char const* dataFileName, char const* indexFileName,
48 Boolean reuseFirstSource);
49
50protected:
52 char const* fileName,
54 Boolean reuseFirstSource);
55 // called only by createNew();
57
59
60private: // redefined virtual functions
61 // Note that because - to implement 'trick play' operations - we're operating on
62 // more than just the input source, we reimplement some functions that are
63 // already implemented in "OnDemandServerMediaSubsession", rather than
64 // reimplementing "seekStreamSource()" and "setStreamSourceScale()":
65 virtual void startStream(unsigned clientSessionId, void* streamToken,
66 TaskFunc* rtcpRRHandler,
67 void* rtcpRRHandlerClientData,
68 unsigned short& rtpSeqNum,
69 unsigned& rtpTimestamp,
70 ServerRequestAlternativeByteHandler* serverRequestAlternativeByteHandler,
71 void* serverRequestAlternativeByteHandlerClientData);
72 virtual void pauseStream(unsigned clientSessionId, void* streamToken);
73 virtual void seekStream(unsigned clientSessionId, void* streamToken, double& seekNPT, double streamDuration, u_int64_t& numBytes);
74 virtual void setStreamScale(unsigned clientSessionId, void* streamToken, float scale);
75 virtual void deleteStream(unsigned clientSessionId, void*& streamToken);
76
77 // The virtual functions that are usually implemented by "ServerMediaSubsession"s:
78 virtual FramedSource* createNewStreamSource(unsigned clientSessionId,
79 unsigned& estBitrate);
80 virtual RTPSink* createNewRTPSink(Groupsock* rtpGroupsock,
81 unsigned char rtpPayloadTypeIfDynamic,
82 FramedSource* inputSource);
83
84 virtual void testScaleFactor(float& scale);
85 virtual float duration() const;
86
87private:
88 ClientTrickPlayState* lookupClient(unsigned clientSessionId);
89
90private:
92 float fDuration;
93 HashTable* fClientSessionHashTable; // indexed by client session id
94};
95
96
97// This class encapsulates the 'trick play' state for each current client (for
98// a given "MPEG2TransportFileServerMediaSubsession" - i.e., Transport Stream file).
99// It is used only within the implementation of "MPEG2TransportFileServerMediaSubsession", but is included here,
100// in case subclasses of "MPEG2TransportFileServerMediaSubsession" want to use it.
101
103public:
105
106 // Functions to bring "fNPT", "fTSRecordNum" and "fIxRecordNum" in sync:
107 unsigned long updateStateFromNPT(double npt, double seekDuration);
109 void updateStateOnPlayChange(Boolean reverseToPreviousVSH);
110
113
114 void setNextScale(float nextScale) { fNextScale = nextScale; }
116
117protected:
120
121protected:
129};
130
131#endif
unsigned char Boolean
Definition: Boolean.hh:25
void ServerRequestAlternativeByteHandler(void *instance, u_int8_t requestByte)
Definition: RTPInterface.hh:41
void TaskFunc(void *clientData)
void reseekOriginalTransportStreamSource()
void updateStateOnScaleChange()
MPEG2TransportStreamTrickModeFilter * fTrickModeFilter
void setSource(MPEG2TransportStreamFramer *framer)
unsigned long updateStateFromNPT(double npt, double seekDuration)
ClientTrickPlayState(MPEG2TransportStreamIndexFile *indexFile)
void updateStateOnPlayChange(Boolean reverseToPreviousVSH)
MPEG2TransportStreamIndexFile * fIndexFile
MPEG2TransportStreamFromESSource * fTrickPlaySource
ClientTrickPlayState * lookupClient(unsigned clientSessionId)
MPEG2TransportFileServerMediaSubsession(UsageEnvironment &env, char const *fileName, MPEG2TransportStreamIndexFile *indexFile, Boolean reuseFirstSource)
virtual void startStream(unsigned clientSessionId, void *streamToken, TaskFunc *rtcpRRHandler, void *rtcpRRHandlerClientData, unsigned short &rtpSeqNum, unsigned &rtpTimestamp, ServerRequestAlternativeByteHandler *serverRequestAlternativeByteHandler, void *serverRequestAlternativeByteHandlerClientData)
virtual RTPSink * createNewRTPSink(Groupsock *rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource *inputSource)
virtual void testScaleFactor(float &scale)
virtual void setStreamScale(unsigned clientSessionId, void *streamToken, float scale)
virtual FramedSource * createNewStreamSource(unsigned clientSessionId, unsigned &estBitrate)
static MPEG2TransportFileServerMediaSubsession * createNew(UsageEnvironment &env, char const *dataFileName, char const *indexFileName, Boolean reuseFirstSource)
virtual void deleteStream(unsigned clientSessionId, void *&streamToken)
virtual void seekStream(unsigned clientSessionId, void *streamToken, double &seekNPT, double streamDuration, u_int64_t &numBytes)
virtual ClientTrickPlayState * newClientTrickPlayState()
virtual void pauseStream(unsigned clientSessionId, void *streamToken)