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 _GROUPEID_HH
00031 #include "GroupEId.hh"
00032 #endif
00033
00034 class ServerMediaSubsession;
00035
00036 class ServerMediaSession: public Medium {
00037 public:
00038 static ServerMediaSession* createNew(UsageEnvironment& env,
00039 char const* streamName = NULL,
00040 char const* info = NULL,
00041 char const* description = NULL,
00042 Boolean isSSM = False,
00043 char const* miscSDPLines = NULL);
00044
00045 virtual ~ServerMediaSession();
00046
00047 static Boolean lookupByName(UsageEnvironment& env,
00048 char const* mediumName,
00049 ServerMediaSession*& resultSession);
00050
00051 char* generateSDPDescription();
00052
00053
00054 char const* streamName() const { return fStreamName; }
00055
00056 Boolean addSubsession(ServerMediaSubsession* subsession);
00057
00058 void testScaleFactor(float& scale);
00059 float duration() const;
00060
00061
00062
00063
00064 unsigned referenceCount() const { return fReferenceCount; }
00065 void incrementReferenceCount() { ++fReferenceCount; }
00066 void decrementReferenceCount() { if (fReferenceCount > 0) --fReferenceCount; }
00067 Boolean& deleteWhenUnreferenced() { return fDeleteWhenUnreferenced; }
00068
00069 protected:
00070 ServerMediaSession(UsageEnvironment& env, char const* streamName,
00071 char const* info, char const* description,
00072 Boolean isSSM, char const* miscSDPLines);
00073
00074
00075 private:
00076 virtual Boolean isServerMediaSession() const;
00077
00078 private:
00079 Boolean fIsSSM;
00080
00081
00082 friend class ServerMediaSubsessionIterator;
00083 ServerMediaSubsession* fSubsessionsHead;
00084 ServerMediaSubsession* fSubsessionsTail;
00085 unsigned fSubsessionCounter;
00086
00087 char* fStreamName;
00088 char* fInfoSDPString;
00089 char* fDescriptionSDPString;
00090 char* fMiscSDPLines;
00091 struct timeval fCreationTime;
00092 unsigned fReferenceCount;
00093 Boolean fDeleteWhenUnreferenced;
00094 };
00095
00096
00097 class ServerMediaSubsessionIterator {
00098 public:
00099 ServerMediaSubsessionIterator(ServerMediaSession& session);
00100 virtual ~ServerMediaSubsessionIterator();
00101
00102 ServerMediaSubsession* next();
00103 void reset();
00104
00105 private:
00106 ServerMediaSession& fOurSession;
00107 ServerMediaSubsession* fNextPtr;
00108 };
00109
00110
00111 class ServerMediaSubsession: public Medium {
00112 public:
00113 virtual ~ServerMediaSubsession();
00114
00115 unsigned trackNumber() const { return fTrackNumber; }
00116 char const* trackId();
00117 virtual char const* sdpLines() = 0;
00118 virtual void getStreamParameters(unsigned clientSessionId,
00119 netAddressBits clientAddress,
00120 Port const& clientRTPPort,
00121 Port const& clientRTCPPort,
00122 int tcpSocketNum,
00123 unsigned char rtpChannelId,
00124 unsigned char rtcpChannelId,
00125 netAddressBits& destinationAddress,
00126 u_int8_t& destinationTTL,
00127 Boolean& isMulticast,
00128 Port& serverRTPPort,
00129 Port& serverRTCPPort,
00130 void*& streamToken
00131 ) = 0;
00132 virtual void startStream(unsigned clientSessionId, void* streamToken,
00133 TaskFunc* rtcpRRHandler,
00134 void* rtcpRRHandlerClientData,
00135 unsigned short& rtpSeqNum,
00136 unsigned& rtpTimestamp) = 0;
00137 virtual void pauseStream(unsigned clientSessionId, void* streamToken);
00138 virtual void seekStream(unsigned clientSessionId, void* streamToken, float seekNPT);
00139 virtual void setStreamScale(unsigned clientSessionId, void* streamToken, float scale);
00140 virtual void deleteStream(unsigned clientSessionId, void*& streamToken);
00141
00142 virtual void testScaleFactor(float& scale);
00143 virtual float duration() const;
00144
00145
00146
00147
00148
00149 void setServerAddressAndPortForSDP(netAddressBits addressBits,
00150 portNumBits portBits);
00151
00152 protected:
00153 ServerMediaSubsession(UsageEnvironment& env);
00154
00155 char const* rangeSDPLine() const;
00156
00157
00158 ServerMediaSession* fParentSession;
00159 netAddressBits fServerAddressForSDP;
00160 portNumBits fPortNumForSDP;
00161
00162 private:
00163 friend class ServerMediaSession;
00164 friend class ServerMediaSubsessionIterator;
00165 ServerMediaSubsession* fNext;
00166
00167 unsigned fTrackNumber;
00168 char const* fTrackId;
00169 };
00170
00171 #endif