00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _SERVER_MEDIA_SESSION_HH
00025 #define _SERVER_MEDIA_SESSION_HH
00026
00027 #ifndef _MEDIA_HH
00028 #include "Media.hh"
00029 #endif
00030 #ifndef _FRAMED_SOURCE_HH
00031 #include "FramedSource.hh"
00032 #endif
00033 #ifndef _GROUPEID_HH
00034 #include "GroupEId.hh"
00035 #endif
00036 #ifndef _RTP_INTERFACE_HH
00037 #include "RTPInterface.hh"
00038 #endif
00039
00040 class ServerMediaSubsession;
00041
00042 class ServerMediaSession: public Medium {
00043 public:
00044 static ServerMediaSession* createNew(UsageEnvironment& env,
00045 char const* streamName = NULL,
00046 char const* info = NULL,
00047 char const* description = NULL,
00048 Boolean isSSM = False,
00049 char const* miscSDPLines = NULL);
00050
00051 virtual ~ServerMediaSession();
00052
00053 static Boolean lookupByName(UsageEnvironment& env,
00054 char const* mediumName,
00055 ServerMediaSession*& resultSession);
00056
00057 char* generateSDPDescription();
00058
00059
00060 char const* streamName() const { return fStreamName; }
00061
00062 Boolean addSubsession(ServerMediaSubsession* subsession);
00063 unsigned numSubsessions() const { return fSubsessionCounter; }
00064
00065 void testScaleFactor(float& scale);
00066 float duration() const;
00067
00068
00069
00070
00071 unsigned referenceCount() const { return fReferenceCount; }
00072 void incrementReferenceCount() { ++fReferenceCount; }
00073 void decrementReferenceCount() { if (fReferenceCount > 0) --fReferenceCount; }
00074 Boolean& deleteWhenUnreferenced() { return fDeleteWhenUnreferenced; }
00075
00076 void deleteAllSubsessions();
00077
00078
00079
00080
00081
00082 protected:
00083 ServerMediaSession(UsageEnvironment& env, char const* streamName,
00084 char const* info, char const* description,
00085 Boolean isSSM, char const* miscSDPLines);
00086
00087
00088 private:
00089 virtual Boolean isServerMediaSession() const;
00090
00091 private:
00092 Boolean fIsSSM;
00093
00094
00095 friend class ServerMediaSubsessionIterator;
00096 ServerMediaSubsession* fSubsessionsHead;
00097 ServerMediaSubsession* fSubsessionsTail;
00098 unsigned fSubsessionCounter;
00099
00100 char* fStreamName;
00101 char* fInfoSDPString;
00102 char* fDescriptionSDPString;
00103 char* fMiscSDPLines;
00104 struct timeval fCreationTime;
00105 unsigned fReferenceCount;
00106 Boolean fDeleteWhenUnreferenced;
00107 };
00108
00109
00110 class ServerMediaSubsessionIterator {
00111 public:
00112 ServerMediaSubsessionIterator(ServerMediaSession& session);
00113 virtual ~ServerMediaSubsessionIterator();
00114
00115 ServerMediaSubsession* next();
00116 void reset();
00117
00118 private:
00119 ServerMediaSession& fOurSession;
00120 ServerMediaSubsession* fNextPtr;
00121 };
00122
00123
00124 class ServerMediaSubsession: public Medium {
00125 public:
00126 virtual ~ServerMediaSubsession();
00127
00128 unsigned trackNumber() const { return fTrackNumber; }
00129 char const* trackId();
00130 virtual char const* sdpLines() = 0;
00131 virtual void getStreamParameters(unsigned clientSessionId,
00132 netAddressBits clientAddress,
00133 Port const& clientRTPPort,
00134 Port const& clientRTCPPort,
00135 int tcpSocketNum,
00136 unsigned char rtpChannelId,
00137 unsigned char rtcpChannelId,
00138 netAddressBits& destinationAddress,
00139 u_int8_t& destinationTTL,
00140 Boolean& isMulticast,
00141 Port& serverRTPPort,
00142 Port& serverRTCPPort,
00143 void*& streamToken
00144 ) = 0;
00145 virtual void startStream(unsigned clientSessionId, void* streamToken,
00146 TaskFunc* rtcpRRHandler,
00147 void* rtcpRRHandlerClientData,
00148 unsigned short& rtpSeqNum,
00149 unsigned& rtpTimestamp,
00150 ServerRequestAlternativeByteHandler* serverRequestAlternativeByteHandler,
00151 void* serverRequestAlternativeByteHandlerClientData) = 0;
00152 virtual void pauseStream(unsigned clientSessionId, void* streamToken);
00153 virtual void seekStream(unsigned clientSessionId, void* streamToken, double& seekNPT, double streamDuration, u_int64_t& numBytes);
00154
00155
00156
00157 virtual void seekStream(unsigned clientSessionId, void* streamToken, char*& absStart, char*& absEnd);
00158
00159
00160
00161
00162 virtual void nullSeekStream(unsigned clientSessionId, void* streamToken);
00163
00164 virtual void setStreamScale(unsigned clientSessionId, void* streamToken, float scale);
00165 virtual float getCurrentNPT(void* streamToken);
00166 virtual FramedSource* getStreamSource(void* streamToken);
00167 virtual void deleteStream(unsigned clientSessionId, void*& streamToken);
00168
00169 virtual void testScaleFactor(float& scale);
00170 virtual float duration() const;
00171
00172
00173 virtual void getAbsoluteTimeRange(char*& absStartTime, char*& absEndTime) const;
00174
00175
00176
00177
00178 void setServerAddressAndPortForSDP(netAddressBits addressBits,
00179 portNumBits portBits);
00180
00181 protected:
00182 ServerMediaSubsession(UsageEnvironment& env);
00183
00184 char const* rangeSDPLine() const;
00185
00186
00187 ServerMediaSession* fParentSession;
00188 netAddressBits fServerAddressForSDP;
00189 portNumBits fPortNumForSDP;
00190
00191 private:
00192 friend class ServerMediaSession;
00193 friend class ServerMediaSubsessionIterator;
00194 ServerMediaSubsession* fNext;
00195
00196 unsigned fTrackNumber;
00197 char const* fTrackId;
00198 };
00199
00200 #endif