MP3AudioFileServerMediaSubsession Class Reference

#include <MP3AudioFileServerMediaSubsession.hh>

Inheritance diagram for MP3AudioFileServerMediaSubsession:

Inheritance graph
[legend]
Collaboration diagram for MP3AudioFileServerMediaSubsession:

Collaboration graph
[legend]

Public Member Functions

unsigned trackNumber () const
char const * trackId ()
void setServerAddressAndPortForSDP (netAddressBits addressBits, portNumBits portBits)
UsageEnvironmentenvir () const
char const * name () const
virtual Boolean isSource () const
virtual Boolean isSink () const
virtual Boolean isRTCPInstance () const
virtual Boolean isRTSPClient () const
virtual Boolean isRTSPServer () const
virtual Boolean isMediaSession () const
virtual Boolean isServerMediaSession () const
virtual Boolean isDarwinInjector () const

Static Public Member Functions

static MP3AudioFileServerMediaSubsessioncreateNew (UsageEnvironment &env, char const *fileName, Boolean reuseFirstSource, Boolean generateADUs, Interleaving *interleaving)
static Boolean lookupByName (UsageEnvironment &env, char const *mediumName, Medium *&resultMedium)
static void close (UsageEnvironment &env, char const *mediumName)
static void close (Medium *medium)

Protected Member Functions

virtual char const * sdpLines ()
virtual void getStreamParameters (unsigned clientSessionId, netAddressBits clientAddress, Port const &clientRTPPort, Port const &clientRTCPPort, int tcpSocketNum, unsigned char rtpChannelId, unsigned char rtcpChannelId, netAddressBits &destinationAddress, u_int8_t &destinationTTL, Boolean &isMulticast, Port &serverRTPPort, Port &serverRTCPPort, void *&streamToken)
virtual void startStream (unsigned clientSessionId, void *streamToken, TaskFunc *rtcpRRHandler, void *rtcpRRHandlerClientData, unsigned short &rtpSeqNum, unsigned &rtpTimestamp)
virtual void pauseStream (unsigned clientSessionId, void *streamToken)
virtual void seekStream (unsigned clientSessionId, void *streamToken, float seekNPT)
virtual void setStreamScale (unsigned clientSessionId, void *streamToken, float scale)
virtual void deleteStream (unsigned clientSessionId, void *&streamToken)
virtual char const * getAuxSDPLine (RTPSink *rtpSink, FramedSource *inputSource)
virtual void closeStreamSource (FramedSource *inputSource)
char const * rangeSDPLine () const
TaskTokennextTask ()

Protected Attributes

char const * fFileName
u_int64_t fFileSize
ServerMediaSessionfParentSession
netAddressBits fServerAddressForSDP
portNumBits fPortNumForSDP

Private Member Functions

 MP3AudioFileServerMediaSubsession (UsageEnvironment &env, char const *fileName, Boolean reuseFirstSource, Boolean generateADUs, Interleaving *interleaving)
virtual ~MP3AudioFileServerMediaSubsession ()
virtual void seekStreamSource (FramedSource *inputSource, float seekNPT)
virtual void setStreamSourceScale (FramedSource *inputSource, float scale)
virtual FramedSourcecreateNewStreamSource (unsigned clientSessionId, unsigned &estBitrate)
virtual RTPSinkcreateNewRTPSink (Groupsock *rtpGroupsock, unsigned char rtpPayloadTypeIfDynamic, FramedSource *inputSource)
virtual void testScaleFactor (float &scale)
virtual float duration () const

Private Attributes

Boolean fGenerateADUs
InterleavingfInterleaving
float fFileDuration

Detailed Description

Definition at line 33 of file MP3AudioFileServerMediaSubsession.hh.


Constructor & Destructor Documentation

MP3AudioFileServerMediaSubsession::MP3AudioFileServerMediaSubsession ( UsageEnvironment env,
char const *  fileName,
Boolean  reuseFirstSource,
Boolean  generateADUs,
Interleaving interleaving 
) [private]

Definition at line 37 of file MP3AudioFileServerMediaSubsession.cpp.

00041   : FileServerMediaSubsession(env, fileName, reuseFirstSource),
00042     fGenerateADUs(generateADUs), fInterleaving(interleaving), fFileDuration(0.0) {
00043 }

MP3AudioFileServerMediaSubsession::~MP3AudioFileServerMediaSubsession (  )  [private, virtual]

Definition at line 46 of file MP3AudioFileServerMediaSubsession.cpp.

00046                                      {
00047   delete fInterleaving;
00048 }


Member Function Documentation

MP3AudioFileServerMediaSubsession * MP3AudioFileServerMediaSubsession::createNew ( UsageEnvironment env,
char const *  fileName,
Boolean  reuseFirstSource,
Boolean  generateADUs,
Interleaving interleaving 
) [static]

Definition at line 30 of file MP3AudioFileServerMediaSubsession.cpp.

References env.

Referenced by createNewSMS().

00031                                                               {
00032   return new MP3AudioFileServerMediaSubsession(env, fileName, reuseFirstSource,
00033                                                generateADUs, interleaving);
00034 }

void MP3AudioFileServerMediaSubsession::seekStreamSource ( FramedSource inputSource,
float  seekNPT 
) [private, virtual]

Reimplemented from OnDemandServerMediaSubsession.

Definition at line 51 of file MP3AudioFileServerMediaSubsession.cpp.

References FramedFilter::inputSource(), NULL, ADUFromMP3Source::resetInput(), and MP3FileSource::seekWithinFile().

00051                                                            {
00052   MP3FileSource* mp3Source;
00053   if (fGenerateADUs) {
00054     // "inputSource" is a filter; use its input source instead.
00055     ADUFromMP3Source* filter;
00056     if (fInterleaving != NULL) {
00057       // There's another filter as well.
00058       filter = (ADUFromMP3Source*)(((FramedFilter*)inputSource)->inputSource());
00059     } else {
00060       filter = (ADUFromMP3Source*)inputSource;
00061     }
00062     filter->resetInput(); // because we're about to seek within its source
00063     mp3Source = (MP3FileSource*)(filter->inputSource());
00064   } else if (fFileDuration > 0.0) {
00065     // There are a pair of filters - MP3->ADU and ADU->MP3 - in front of the
00066     // original MP3 source:
00067     MP3FromADUSource* filter2 = (MP3FromADUSource*)inputSource;
00068     ADUFromMP3Source* filter1 = (ADUFromMP3Source*)(filter2->inputSource());
00069     filter1->resetInput(); // because we're about to seek within its source
00070     mp3Source = (MP3FileSource*)(filter1->inputSource());
00071   } else {
00072     // "inputSource" is the original MP3 source:
00073     mp3Source = (MP3FileSource*)inputSource;
00074   }
00075 
00076   mp3Source->seekWithinFile(seekNPT);
00077 }

void MP3AudioFileServerMediaSubsession::setStreamSourceScale ( FramedSource inputSource,
float  scale 
) [private, virtual]

Reimplemented from OnDemandServerMediaSubsession.

Definition at line 80 of file MP3AudioFileServerMediaSubsession.cpp.

References FramedFilter::inputSource(), NULL, MP3FileSource::setPresentationTimeScale(), and ADUFromMP3Source::setScaleFactor().

00080                                                              {
00081   int iScale = (int)scale;
00082   MP3FileSource* mp3Source;
00083   ADUFromMP3Source* aduSource = NULL;
00084   if (fGenerateADUs) {
00085     if (fInterleaving != NULL) {
00086       // There's an interleaving filter in front.
00087       aduSource = (ADUFromMP3Source*)(((FramedFilter*)inputSource)->inputSource());
00088     } else {
00089       aduSource = (ADUFromMP3Source*)inputSource;
00090     }
00091     mp3Source = (MP3FileSource*)(aduSource->inputSource());
00092   } else if (fFileDuration > 0.0) {
00093     // There are a pair of filters - MP3->ADU and ADU->MP3 - in front of the
00094     // original MP3 source.  So, go back one, to reach the ADU source:
00095     aduSource = (ADUFromMP3Source*)(((FramedFilter*)inputSource)->inputSource());
00096 
00097     // Then, go back one more, to reach the MP3 source:
00098     mp3Source = (MP3FileSource*)(aduSource->inputSource());
00099   } else return; // the stream is not scalable
00100 
00101   aduSource->setScaleFactor(iScale);
00102   mp3Source->setPresentationTimeScale(iScale);
00103 }

FramedSource * MP3AudioFileServerMediaSubsession::createNewStreamSource ( unsigned  clientSessionId,
unsigned &  estBitrate 
) [private, virtual]

Implements OnDemandServerMediaSubsession.

Definition at line 106 of file MP3AudioFileServerMediaSubsession.cpp.

References MP3FromADUSource::createNew(), MP3ADUinterleaver::createNew(), ADUFromMP3Source::createNew(), MP3FileSource::createNew(), MP3FileSource::filePlayTime(), and NULL.

00106                                                                           {
00107   estBitrate = 128; // kbps, estimate
00108 
00109   FramedSource* streamSource;
00110   do {
00111     MP3FileSource* mp3Source;
00112     streamSource = mp3Source = MP3FileSource::createNew(envir(), fFileName);
00113     if (streamSource == NULL) break;
00114     fFileDuration = mp3Source->filePlayTime();
00115 
00116     if (fGenerateADUs) {
00117       // Add a filter that converts the source MP3s to ADUs:
00118       streamSource = ADUFromMP3Source::createNew(envir(), streamSource);
00119       if (streamSource == NULL) break;
00120 
00121       if (fInterleaving != NULL) {
00122         // Add another filter that interleaves the ADUs before packetizing:
00123         streamSource = MP3ADUinterleaver::createNew(envir(), *fInterleaving,
00124                                                     streamSource);
00125         if (streamSource == NULL) break;
00126       }
00127     } else if (fFileDuration > 0.0) {
00128       // Because this is a seekable file, insert a pair of filters: one that
00129       // converts the input MP3 stream to ADUs; another that converts these
00130       // ADUs back to MP3.  This allows us to seek within the input stream without
00131       // tripping over the MP3 'bit reservoir':
00132       streamSource = ADUFromMP3Source::createNew(envir(), streamSource);
00133       if (streamSource == NULL) break;
00134 
00135       streamSource = MP3FromADUSource::createNew(envir(), streamSource);
00136       if (streamSource == NULL) break;
00137     }
00138   } while (0);
00139 
00140   return streamSource;
00141 }

RTPSink * MP3AudioFileServerMediaSubsession::createNewRTPSink ( Groupsock rtpGroupsock,
unsigned char  rtpPayloadTypeIfDynamic,
FramedSource inputSource 
) [private, virtual]

Implements OnDemandServerMediaSubsession.

Definition at line 144 of file MP3AudioFileServerMediaSubsession.cpp.

References MPEG1or2AudioRTPSink::createNew(), and MP3ADURTPSink::createNew().

00146                                                   {
00147   if (fGenerateADUs) {
00148     return MP3ADURTPSink::createNew(envir(), rtpGroupsock,
00149                                     rtpPayloadTypeIfDynamic);
00150   } else {
00151     return MPEG1or2AudioRTPSink::createNew(envir(), rtpGroupsock);
00152   }
00153 }

void MP3AudioFileServerMediaSubsession::testScaleFactor ( float &  scale  )  [private, virtual]

Reimplemented from ServerMediaSubsession.

Definition at line 155 of file MP3AudioFileServerMediaSubsession.cpp.

References fFileDuration.

00155                                                                     {
00156   if (fFileDuration <= 0.0) {
00157     // The file is non-seekable, so is probably a live input source.
00158     // We don't support scale factors other than 1
00159     scale = 1;
00160   } else {
00161     // We support any integral scale >= 1
00162     int iScale = (int)(scale + 0.5); // round
00163     if (iScale < 1) iScale = 1;
00164     scale = (float)iScale;
00165   }
00166 }

float MP3AudioFileServerMediaSubsession::duration (  )  const [private, virtual]

Reimplemented from ServerMediaSubsession.

Definition at line 168 of file MP3AudioFileServerMediaSubsession.cpp.

References fFileDuration.

00168                                                         {
00169   return fFileDuration;
00170 }

char const * OnDemandServerMediaSubsession::sdpLines (  )  [protected, virtual, inherited]

Implements ServerMediaSubsession.

Definition at line 74 of file OnDemandServerMediaSubsession.cpp.

References Medium::close(), OnDemandServerMediaSubsession::closeStreamSource(), OnDemandServerMediaSubsession::createNewRTPSink(), OnDemandServerMediaSubsession::createNewStreamSource(), Medium::envir(), OnDemandServerMediaSubsession::fSDPLines, NULL, OnDemandServerMediaSubsession::setSDPLinesFromRTPSink(), and ServerMediaSubsession::trackNumber().

Referenced by OnDemandServerMediaSubsession::setSDPLinesFromRTPSink().

00074                                         {
00075   if (fSDPLines == NULL) {
00076     // We need to construct a set of SDP lines that describe this
00077     // subsession (as a unicast stream).  To do so, we first create
00078     // dummy (unused) source and "RTPSink" objects,
00079     // whose parameters we use for the SDP lines:
00080     unsigned estBitrate; // unused
00081     FramedSource* inputSource = createNewStreamSource(0, estBitrate);
00082     if (inputSource == NULL) return NULL; // file not found
00083 
00084     struct in_addr dummyAddr;
00085     dummyAddr.s_addr = 0;
00086     Groupsock dummyGroupsock(envir(), dummyAddr, 0, 0);
00087     unsigned char rtpPayloadType = 96 + trackNumber()-1; // if dynamic
00088     RTPSink* dummyRTPSink
00089       = createNewRTPSink(&dummyGroupsock, rtpPayloadType, inputSource);
00090 
00091     setSDPLinesFromRTPSink(dummyRTPSink, inputSource);
00092     Medium::close(dummyRTPSink);
00093     closeStreamSource(inputSource);
00094   }
00095 
00096   return fSDPLines;
00097 }

void OnDemandServerMediaSubsession::getStreamParameters ( unsigned  clientSessionId,
netAddressBits  clientAddress,
Port const &  clientRTPPort,
Port const &  clientRTCPPort,
int  tcpSocketNum,
unsigned char  rtpChannelId,
unsigned char  rtcpChannelId,
netAddressBits destinationAddress,
u_int8_t &  destinationTTL,
Boolean isMulticast,
Port serverRTPPort,
Port serverRTCPPort,
void *&  streamToken 
) [protected, virtual, inherited]

Implements ServerMediaSubsession.

Definition at line 145 of file OnDemandServerMediaSubsession.cpp.

References HashTable::Add(), BasicUDPSink::createNew(), OnDemandServerMediaSubsession::createNewRTPSink(), OnDemandServerMediaSubsession::createNewStreamSource(), Medium::envir(), False, OnDemandServerMediaSubsession::fDestinationsHashTable, OnDemandServerMediaSubsession::fInitialPortNum, OnDemandServerMediaSubsession::fLastStreamToken, OnDemandServerMediaSubsession::fReuseFirstSource, NULL, Port::num(), Groupsock::removeAllDestinations(), Socket::socketNum(), OnDemandServerMediaSubsession::StreamState, and ServerMediaSubsession::trackNumber().

00157                                           {
00158   if (destinationAddress == 0) destinationAddress = clientAddress;
00159   struct in_addr destinationAddr; destinationAddr.s_addr = destinationAddress;
00160   isMulticast = False;
00161 
00162   if (fLastStreamToken != NULL && fReuseFirstSource) {
00163     // Special case: Rather than creating a new 'StreamState',
00164     // we reuse the one that we've already created:
00165     serverRTPPort = ((StreamState*)fLastStreamToken)->serverRTPPort();
00166     serverRTCPPort = ((StreamState*)fLastStreamToken)->serverRTCPPort();
00167     ++((StreamState*)fLastStreamToken)->referenceCount();
00168     streamToken = fLastStreamToken;
00169   } else {
00170     // Normal case: Create a new media source:
00171     unsigned streamBitrate;
00172     FramedSource* mediaSource
00173       = createNewStreamSource(clientSessionId, streamBitrate);
00174 
00175     // Create 'groupsock' and 'sink' objects for the destination,
00176     // using previously unused server port numbers:
00177     RTPSink* rtpSink;
00178     BasicUDPSink* udpSink;
00179     Groupsock* rtpGroupsock;
00180     Groupsock* rtcpGroupsock;
00181     portNumBits serverPortNum;
00182     if (clientRTCPPort.num() == 0) {
00183       // We're streaming raw UDP (not RTP). Create a single groupsock:
00184       NoReuse dummy; // ensures that we skip over ports that are already in use
00185       for (serverPortNum = fInitialPortNum; ; ++serverPortNum) {
00186         struct in_addr dummyAddr; dummyAddr.s_addr = 0;
00187 
00188         serverRTPPort = serverPortNum;
00189         rtpGroupsock = new Groupsock(envir(), dummyAddr, serverRTPPort, 255);
00190         if (rtpGroupsock->socketNum() >= 0) break; // success
00191       }
00192 
00193       rtcpGroupsock = NULL;
00194       rtpSink = NULL;
00195       udpSink = BasicUDPSink::createNew(envir(), rtpGroupsock);
00196     } else {
00197       // Normal case: We're streaming RTP (over UDP or TCP).  Create a pair of
00198       // groupsocks (RTP and RTCP), with adjacent port numbers (RTP port number even):
00199       NoReuse dummy; // ensures that we skip over ports that are already in use
00200       for (portNumBits serverPortNum = fInitialPortNum; ; serverPortNum += 2) {
00201         struct in_addr dummyAddr; dummyAddr.s_addr = 0;
00202 
00203         serverRTPPort = serverPortNum;
00204         rtpGroupsock = new Groupsock(envir(), dummyAddr, serverRTPPort, 255);
00205         if (rtpGroupsock->socketNum() < 0) {
00206           delete rtpGroupsock;
00207           continue; // try again
00208         }
00209 
00210         serverRTCPPort = serverPortNum+1;
00211         rtcpGroupsock = new Groupsock(envir(), dummyAddr, serverRTCPPort, 255);
00212         if (rtcpGroupsock->socketNum() < 0) {
00213           delete rtpGroupsock;
00214           delete rtcpGroupsock;
00215           continue; // try again
00216         }
00217 
00218         break; // success
00219       }
00220 
00221       unsigned char rtpPayloadType = 96 + trackNumber()-1; // if dynamic
00222       rtpSink = createNewRTPSink(rtpGroupsock, rtpPayloadType, mediaSource);
00223       udpSink = NULL;
00224     }
00225 
00226     // Turn off the destinations for each groupsock.  They'll get set later
00227     // (unless TCP is used instead):
00228     if (rtpGroupsock != NULL) rtpGroupsock->removeAllDestinations();
00229     if (rtcpGroupsock != NULL) rtcpGroupsock->removeAllDestinations();
00230 
00231     // Set up the state of the stream.  The stream will get started later:
00232     streamToken = fLastStreamToken
00233       = new StreamState(*this, serverRTPPort, serverRTCPPort, rtpSink, udpSink,
00234                         streamBitrate, mediaSource,
00235                         rtpGroupsock, rtcpGroupsock);
00236   }
00237 
00238   // Record these destinations as being for this client session id:
00239   Destinations* destinations;
00240   if (tcpSocketNum < 0) { // UDP
00241     destinations = new Destinations(destinationAddr, clientRTPPort, clientRTCPPort);
00242   } else { // TCP
00243     destinations = new Destinations(tcpSocketNum, rtpChannelId, rtcpChannelId);
00244   }
00245   fDestinationsHashTable->Add((char const*)clientSessionId, destinations);
00246 }

void OnDemandServerMediaSubsession::startStream ( unsigned  clientSessionId,
void *  streamToken,
TaskFunc rtcpRRHandler,
void *  rtcpRRHandlerClientData,
unsigned short &  rtpSeqNum,
unsigned &  rtpTimestamp 
) [protected, virtual, inherited]

Implements ServerMediaSubsession.

Reimplemented in MPEG2TransportFileServerMediaSubsession.

Definition at line 248 of file OnDemandServerMediaSubsession.cpp.

References RTPSink::currentSeqNo(), OnDemandServerMediaSubsession::fDestinationsHashTable, HashTable::Lookup(), NULL, RTPSink::presetNextTimestamp(), StreamState::rtpSink(), and StreamState::startPlaying().

Referenced by MPEG2TransportFileServerMediaSubsession::startStream().

00253                                                                         {
00254   StreamState* streamState = (StreamState*)streamToken;
00255   Destinations* destinations
00256     = (Destinations*)(fDestinationsHashTable->Lookup((char const*)clientSessionId));
00257   if (streamState != NULL) {
00258     streamState->startPlaying(destinations,
00259                               rtcpRRHandler, rtcpRRHandlerClientData);
00260     if (streamState->rtpSink() != NULL) {
00261       rtpSeqNum = streamState->rtpSink()->currentSeqNo();
00262       rtpTimestamp = streamState->rtpSink()->presetNextTimestamp();
00263     }
00264   }
00265 }

void OnDemandServerMediaSubsession::pauseStream ( unsigned  clientSessionId,
void *  streamToken 
) [protected, virtual, inherited]

Reimplemented from ServerMediaSubsession.

Reimplemented in MPEG2TransportFileServerMediaSubsession.

Definition at line 267 of file OnDemandServerMediaSubsession.cpp.

References OnDemandServerMediaSubsession::fReuseFirstSource, NULL, and StreamState::pause().

Referenced by MPEG2TransportFileServerMediaSubsession::pauseStream(), and MPEG2TransportFileServerMediaSubsession::startStream().

00268                                                                    {
00269   // Pausing isn't allowed if multiple clients are receiving data from
00270   // the same source:
00271   if (fReuseFirstSource) return;
00272 
00273   StreamState* streamState = (StreamState*)streamToken;
00274   if (streamState != NULL) streamState->pause();
00275 }

void OnDemandServerMediaSubsession::seekStream ( unsigned  clientSessionId,
void *  streamToken,
float  seekNPT 
) [protected, virtual, inherited]

Reimplemented from ServerMediaSubsession.

Reimplemented in MPEG2TransportFileServerMediaSubsession.

Definition at line 277 of file OnDemandServerMediaSubsession.cpp.

References OnDemandServerMediaSubsession::fReuseFirstSource, StreamState::mediaSource(), NULL, and OnDemandServerMediaSubsession::seekStreamSource().

Referenced by MPEG2TransportFileServerMediaSubsession::seekStream().

00278                                                                                  {
00279   // Seeking isn't allowed if multiple clients are receiving data from
00280   // the same source:
00281   if (fReuseFirstSource) return;
00282 
00283   StreamState* streamState = (StreamState*)streamToken;
00284   if (streamState != NULL && streamState->mediaSource() != NULL) {
00285     seekStreamSource(streamState->mediaSource(), seekNPT);
00286   }
00287 }

void OnDemandServerMediaSubsession::setStreamScale ( unsigned  clientSessionId,
void *  streamToken,
float  scale 
) [protected, virtual, inherited]

Reimplemented from ServerMediaSubsession.

Reimplemented in MPEG2TransportFileServerMediaSubsession.

Definition at line 289 of file OnDemandServerMediaSubsession.cpp.

References OnDemandServerMediaSubsession::fReuseFirstSource, StreamState::mediaSource(), NULL, and OnDemandServerMediaSubsession::setStreamSourceScale().

Referenced by MPEG2TransportFileServerMediaSubsession::setStreamScale().

00290                                                                                    {
00291   // Changing the scale factor isn't allowed if multiple clients are receiving data
00292   // from the same source:
00293   if (fReuseFirstSource) return;
00294 
00295   StreamState* streamState = (StreamState*)streamToken;
00296   if (streamState != NULL && streamState->mediaSource() != NULL) {
00297     setStreamSourceScale(streamState->mediaSource(), scale);
00298   }
00299 }

void OnDemandServerMediaSubsession::deleteStream ( unsigned  clientSessionId,
void *&  streamToken 
) [protected, virtual, inherited]

Reimplemented from ServerMediaSubsession.

Reimplemented in MPEG2TransportFileServerMediaSubsession.

Definition at line 301 of file OnDemandServerMediaSubsession.cpp.

References StreamState::endPlaying(), OnDemandServerMediaSubsession::fDestinationsHashTable, OnDemandServerMediaSubsession::fLastStreamToken, HashTable::Lookup(), NULL, StreamState::referenceCount(), and HashTable::Remove().

Referenced by MPEG2TransportFileServerMediaSubsession::deleteStream().

00302                                                                      {
00303   StreamState* streamState = (StreamState*)streamToken;
00304 
00305   // Look up (and remove) the destinations for this client session:
00306   Destinations* destinations
00307     = (Destinations*)(fDestinationsHashTable->Lookup((char const*)clientSessionId));
00308   if (destinations != NULL) {
00309     fDestinationsHashTable->Remove((char const*)clientSessionId);
00310 
00311     // Stop streaming to these destinations:
00312     if (streamState != NULL) streamState->endPlaying(destinations);
00313   }
00314 
00315   // Delete the "StreamState" structure if it's no longer being used:
00316   if (streamState != NULL) {
00317     if (streamState->referenceCount() > 0) --streamState->referenceCount();
00318     if (streamState->referenceCount() == 0) {
00319       delete streamState;
00320       if (fLastStreamToken == streamToken) fLastStreamToken = NULL;
00321       streamToken = NULL;
00322     }
00323   }
00324 
00325   // Finally, delete the destinations themselves:
00326   delete destinations;
00327 }

char const * OnDemandServerMediaSubsession::getAuxSDPLine ( RTPSink rtpSink,
FramedSource inputSource 
) [protected, virtual, inherited]

Reimplemented in MPEG4VideoFileServerMediaSubsession.

Definition at line 330 of file OnDemandServerMediaSubsession.cpp.

References RTPSink::auxSDPLine(), and NULL.

Referenced by OnDemandServerMediaSubsession::setSDPLinesFromRTPSink().

00330                                                                {
00331   // Default implementation:
00332   return rtpSink == NULL ? NULL : rtpSink->auxSDPLine();
00333 }

void OnDemandServerMediaSubsession::closeStreamSource ( FramedSource inputSource  )  [protected, virtual, inherited]

Definition at line 345 of file OnDemandServerMediaSubsession.cpp.

References Medium::close().

Referenced by StreamState::reclaim(), and OnDemandServerMediaSubsession::sdpLines().

00345                                                                                {
00346   Medium::close(inputSource);
00347 }

unsigned ServerMediaSubsession::trackNumber (  )  const [inline, inherited]

Definition at line 115 of file ServerMediaSession.hh.

References ServerMediaSubsession::fTrackNumber.

Referenced by OnDemandServerMediaSubsession::getStreamParameters(), and OnDemandServerMediaSubsession::sdpLines().

00115 { return fTrackNumber; }

char const * ServerMediaSubsession::trackId (  )  [inherited]

Definition at line 326 of file ServerMediaSession.cpp.

References ServerMediaSubsession::fTrackId, ServerMediaSubsession::fTrackNumber, NULL, and strDup().

Referenced by PassiveServerMediaSubsession::sdpLines(), and OnDemandServerMediaSubsession::setSDPLinesFromRTPSink().

00326                                            {
00327   if (fTrackNumber == 0) return NULL; // not yet in a ServerMediaSession
00328 
00329   if (fTrackId == NULL) {
00330     char buf[100];
00331     sprintf(buf, "track%d", fTrackNumber);
00332     fTrackId = strDup(buf);
00333   }
00334   return fTrackId;
00335 }

void ServerMediaSubsession::setServerAddressAndPortForSDP ( netAddressBits  addressBits,
portNumBits  portBits 
) [inherited]

Definition at line 364 of file ServerMediaSession.cpp.

References ServerMediaSubsession::fPortNumForSDP, and ServerMediaSubsession::fServerAddressForSDP.

00365                                                                                 {
00366   fServerAddressForSDP = addressBits;
00367   fPortNumForSDP = portBits;
00368 }

char const * ServerMediaSubsession::rangeSDPLine (  )  const [protected, inherited]

Definition at line 371 of file ServerMediaSession.cpp.

References ServerMediaSubsession::duration(), ServerMediaSession::duration(), ServerMediaSubsession::fParentSession, NULL, and strDup().

Referenced by PassiveServerMediaSubsession::sdpLines(), and OnDemandServerMediaSubsession::setSDPLinesFromRTPSink().

00371                                           {
00372   if (fParentSession == NULL) return NULL;
00373 
00374   // If all of our parent's subsessions have the same duration
00375   // (as indicated by "fParentSession->duration() >= 0"), there's no "a=range:" line:
00376   if (fParentSession->duration() >= 0.0) return strDup("");
00377 
00378   // Use our own duration for a "a=range:" line:
00379   float ourDuration = duration();
00380   if (ourDuration == 0.0) {
00381     return strDup("a=range:npt=0-\r\n");
00382   } else {
00383     char buf[100];
00384     sprintf(buf, "a=range:npt=0-%.3f\r\n", ourDuration);
00385     return strDup(buf);
00386   }
00387 }

Boolean Medium::lookupByName ( UsageEnvironment env,
char const *  mediumName,
Medium *&  resultMedium 
) [static, inherited]

Definition at line 65 of file Media.cpp.

References env, False, MediaLookupTable::lookup(), NULL, MediaLookupTable::ourMedia(), UsageEnvironment::setResultMsg(), and True.

Referenced by ServerMediaSession::lookupByName(), RTSPServer::lookupByName(), RTSPClient::lookupByName(), RTCPInstance::lookupByName(), MediaSource::lookupByName(), MediaSink::lookupByName(), MediaSession::lookupByName(), and DarwinInjector::lookupByName().

00066                                                          {
00067   resultMedium = MediaLookupTable::ourMedia(env)->lookup(mediumName);
00068   if (resultMedium == NULL) {
00069     env.setResultMsg("Medium ", mediumName, " does not exist");
00070     return False;
00071   }
00072 
00073   return True;
00074 }

void Medium::close ( UsageEnvironment env,
char const *  mediumName 
) [static, inherited]

Definition at line 76 of file Media.cpp.

References env, MediaLookupTable::ourMedia(), and MediaLookupTable::remove().

Referenced by afterPlaying(), Medium::close(), closeMediaSinks(), OnDemandServerMediaSubsession::closeStreamSource(), WAVAudioFileSource::createNew(), QuickTimeFileSink::createNew(), QCELPAudioRTPSource::createNew(), MP3HTTPSource::createNew(), MP3FileSource::createNew(), AVIFileSink::createNew(), AMRAudioRTPSource::createNew(), WAVAudioFileServerMediaSubsession::createNewStreamSource(), MPEG1or2DemuxedServerMediaSubsession::createNewStreamSource(), MediaSubsession::deInitiate(), MediaSubsession::initiate(), MPEG1or2ProgramStreamFileDuration(), MPEG1or2Demux::noteElementaryStreamDeletion(), ByteStreamMultiFileSource::onSourceClosure1(), StreamState::reclaim(), RTSPServer::removeServerMediaSession(), OnDemandServerMediaSubsession::sdpLines(), shutdown(), H264VideoRTPSink::stopPlaying(), subsessionAfterPlaying(), ClientTrickPlayState::updateStateOnScaleChange(), AMRDeinterleaver::~AMRDeinterleaver(), ByteStreamMultiFileSource::~ByteStreamMultiFileSource(), DarwinInjector::~DarwinInjector(), FramedFilter::~FramedFilter(), H264VideoRTPSink::~H264VideoRTPSink(), InputESSourceRecord::~InputESSourceRecord(), MPEG1or2Demux::~MPEG1or2Demux(), MPEG1or2FileServerDemux::~MPEG1or2FileServerDemux(), MPEG2TransportFileServerMediaSubsession::~MPEG2TransportFileServerMediaSubsession(), MPEG2TransportStreamFromPESSource::~MPEG2TransportStreamFromPESSource(), ServerMediaSession::~ServerMediaSession(), and ServerMediaSubsession::~ServerMediaSubsession().

00076                                                           {
00077   MediaLookupTable::ourMedia(env)->remove(name);
00078 }

void Medium::close ( Medium medium  )  [static, inherited]

Definition at line 80 of file Media.cpp.

References Medium::close(), Medium::envir(), Medium::name(), and NULL.

00080                                  {
00081   if (medium == NULL) return;
00082 
00083   close(medium->envir(), medium->name());
00084 }

UsageEnvironment& Medium::envir (  )  const [inline, inherited]

Definition at line 59 of file Media.hh.

References Medium::fEnviron.

Referenced by QuickTimeFileSink::addArbitraryString(), FileSink::addData(), MPEG2IFrameIndexFromTransportStream::addToTail(), StreamParser::afterGettingBytes(), MultiFramedRTPSink::afterGettingFrame1(), InputESSourceRecord::afterGettingFrame1(), MPEG2TransportStreamFramer::afterGettingFrame1(), MPEG2IFrameIndexFromTransportStream::afterGettingFrame1(), HTTPSink::afterGettingFrame1(), BasicUDPSink::afterGettingFrame1(), MPEG4VideoFileServerMediaSubsession::afterPlayingDummy1(), MPEG4VideoStreamParser::analyzeVOLHeader(), RTSPClient::announceSDPDescription(), announceStream(), MPEG4VideoFileServerMediaSubsession::checkForAuxSDPLine1(), Medium::close(), MPEG2IFrameIndexFromTransportStream::compactParseBuffer(), QuickTimeFileSink::continuePlaying(), HTTPSink::continuePlaying(), H264VideoRTPSink::continuePlaying(), AVIFileSink::continuePlaying(),