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
00064 void testScaleFactor(float& scale);
00065 float duration() const;
00066
00067
00068
00069
00070 unsigned referenceCount() const { return fReferenceCount; }
00071 void incrementReferenceCount() { ++fReferenceCount; }
00072 void decrementReferenceCount() { if (fReferenceCount > 0) --fReferenceCount; }
00073 Boolean& deleteWhenUnreferenced() { return fDeleteWhenUnreferenced; }
00074
00075 protected:
00076 ServerMediaSession(UsageEnvironment& env, char const* streamName,
00077 char const* info, char const* description,
00078 Boolean isSSM, char const* miscSDPLines);
00079
00080
00081 private:
00082 virtual Boolean isServerMediaSession() const;
00083
00084 private:
00085 Boolean fIsSSM;
00086
00087
00088 friend class ServerMediaSubsessionIterator;
00089 ServerMediaSubsession* fSubsessionsHead;
00090 ServerMediaSubsession* fSubsessionsTail;
00091 unsigned fSubsessionCounter;
00092
00093 char* fStreamName;
00094 char* fInfoSDPString;
00095 char* fDescriptionSDPString;
00096 char* fMiscSDPLines;
00097 struct timeval fCreationTime;
00098 unsigned fReferenceCount;
00099 Boolean fDeleteWhenUnreferenced;
00100 };
00101
00102
00103 class ServerMediaSubsessionIterator {
00104 public:
00105 ServerMediaSubsessionIterator(ServerMediaSession& session);
00106 virtual ~ServerMediaSubsessionIterator();
00107
00108 ServerMediaSubsession* next();
00109 void reset();
00110
00111 private:
00112 ServerMediaSession& fOurSession;
00113 ServerMediaSubsession* fNextPtr;
00114 };
00115
00116
00117 class ServerMediaSubsession: public Medium {
00118 public:
00119 virtual ~ServerMediaSubsession();
00120
00121 unsigned trackNumber() const { return fTrackNumber; }
00122 char const* trackId();
00123 virtual char const* sdpLines() = 0;
00124 virtual void getStreamParameters(unsigned clientSessionId,
00125 netAddressBits clientAddress,
00126 Port const& clientRTPPort,
00127 Port const& clientRTCPPort,
00128 int tcpSocketNum,
00129 unsigned char rtpChannelId,
00130 unsigned char rtcpChannelId,
00131 netAddressBits& destinationAddress,
00132 u_int8_t& destinationTTL,
00133 Boolean& isMulticast,
00134 Port& serverRTPPort,
00135 Port& serverRTCPPort,
00136 void*& streamToken
00137 ) = 0;
00138 virtual void startStream(unsigned clientSessionId, void* streamToken,
00139 TaskFunc* rtcpRRHandler,
00140 void* rtcpRRHandlerClientData,
00141 unsigned short& rtpSeqNum,
00142 unsigned& rtpTimestamp,
00143 ServerRequestAlternativeByteHandler* serverRequestAlternativeByteHandler,
00144 void* serverRequestAlternativeByteHandlerClientData) = 0;
00145 virtual void pauseStream(unsigned clientSessionId, void* streamToken);
00146 virtual void seekStream(unsigned clientSessionId, void* streamToken, double& seekNPT, double streamDuration, u_int64_t& numBytes);
00147
00148
00149 virtual void setStreamScale(unsigned clientSessionId, void* streamToken, float scale);
00150 virtual FramedSource* getStreamSource(void* streamToken);
00151 virtual void deleteStream(unsigned clientSessionId, void*& streamToken);
00152
00153 virtual void testScaleFactor(float& scale);
00154 virtual float duration() const;
00155
00156
00157
00158
00159
00160 void setServerAddressAndPortForSDP(netAddressBits addressBits,
00161 portNumBits portBits);
00162
00163 protected:
00164 ServerMediaSubsession(UsageEnvironment& env);
00165
00166 char const* rangeSDPLine() const;
00167
00168
00169 ServerMediaSession* fParentSession;
00170 netAddressBits fServerAddressForSDP;
00171 portNumBits fPortNumForSDP;
00172
00173 private:
00174 friend class ServerMediaSession;
00175 friend class ServerMediaSubsessionIterator;
00176 ServerMediaSubsession* fNext;
00177
00178 unsigned fTrackNumber;
00179 char const* fTrackId;
00180 };
00181
00182 #endif