StreamState Class Reference

Collaboration diagram for StreamState:

Collaboration graph
[legend]

Public Member Functions

 StreamState (OnDemandServerMediaSubsession &master, Port const &serverRTPPort, Port const &serverRTCPPort, RTPSink *rtpSink, BasicUDPSink *udpSink, unsigned totalBW, FramedSource *mediaSource, Groupsock *rtpGS, Groupsock *rtcpGS)
virtual ~StreamState ()
void startPlaying (Destinations *destinations, TaskFunc *rtcpRRHandler, void *rtcpRRHandlerClientData)
void pause ()
void endPlaying (Destinations *destinations)
void reclaim ()
unsigned & referenceCount ()
Port const & serverRTPPort () const
Port const & serverRTCPPort () const
RTPSinkrtpSink () const
float streamDuration () const
FramedSourcemediaSource () const

Private Attributes

OnDemandServerMediaSubsessionfMaster
Boolean fAreCurrentlyPlaying
unsigned fReferenceCount
Port fServerRTPPort
Port fServerRTCPPort
RTPSinkfRTPSink
BasicUDPSinkfUDPSink
float fStreamDuration
unsigned fTotalBW
RTCPInstancefRTCPInstance
FramedSourcefMediaSource
GroupsockfRTPgs
GroupsockfRTCPgs

Detailed Description

Definition at line 100 of file OnDemandServerMediaSubsession.cpp.


Constructor & Destructor Documentation

StreamState::StreamState ( OnDemandServerMediaSubsession master,
Port const &  serverRTPPort,
Port const &  serverRTCPPort,
RTPSink rtpSink,
BasicUDPSink udpSink,
unsigned  totalBW,
FramedSource mediaSource,
Groupsock rtpGS,
Groupsock rtcpGS 
)

Definition at line 409 of file OnDemandServerMediaSubsession.cpp.

00414   : fMaster(master), fAreCurrentlyPlaying(False), fReferenceCount(1),
00415     fServerRTPPort(serverRTPPort), fServerRTCPPort(serverRTCPPort),
00416     fRTPSink(rtpSink), fUDPSink(udpSink), fStreamDuration(master.duration()),
00417     fTotalBW(totalBW), fRTCPInstance(NULL) /* created later */,
00418     fMediaSource(mediaSource), fRTPgs(rtpGS), fRTCPgs(rtcpGS) {
00419 }

StreamState::~StreamState (  )  [virtual]

Definition at line 421 of file OnDemandServerMediaSubsession.cpp.

References reclaim().

00421                           {
00422   reclaim();
00423 }


Member Function Documentation

void StreamState::startPlaying ( Destinations destinations,
TaskFunc rtcpRRHandler,
void *  rtcpRRHandlerClientData 
)

Definition at line 426 of file OnDemandServerMediaSubsession.cpp.

References Groupsock::addDestination(), Destinations::addr, RTCPInstance::addStreamSocket(), RTPSink::addStreamSocket(), afterPlayingStreamState(), RTCPInstance::createNew(), Medium::envir(), fAreCurrentlyPlaying, OnDemandServerMediaSubsession::fCNAME, fMaster, fMediaSource, fRTCPgs, fRTCPInstance, fRTPgs, fRTPSink, fTotalBW, fUDPSink, Destinations::isTCP, NULL, Destinations::rtcpChannelId, Destinations::rtcpPort, Destinations::rtpChannelId, Destinations::rtpPort, RTCPInstance::setSpecificRRHandler(), MediaSink::startPlaying(), Destinations::tcpSocketNum, and True.

Referenced by OnDemandServerMediaSubsession::startStream().

00427                                                                        {
00428   if (dests == NULL) return;
00429   if (!fAreCurrentlyPlaying && fMediaSource != NULL) {
00430     if (fRTPSink != NULL) {
00431       fRTPSink->startPlaying(*fMediaSource, afterPlayingStreamState, this);
00432       fAreCurrentlyPlaying = True;
00433     } else if (fUDPSink != NULL) {
00434       fUDPSink->startPlaying(*fMediaSource, afterPlayingStreamState, this);
00435       fAreCurrentlyPlaying = True;
00436     }
00437   }
00438 
00439   if (fRTCPInstance == NULL && fRTPSink != NULL) {
00440     // Create (and start) a 'RTCP instance' for this RTP sink:
00441     fRTCPInstance
00442       = RTCPInstance::createNew(fRTPSink->envir(), fRTCPgs,
00443                                 fTotalBW, (unsigned char*)fMaster.fCNAME,
00444                                 fRTPSink, NULL /* we're a server */);
00445         // Note: This starts RTCP running automatically
00446   }
00447 
00448   if (dests->isTCP) {
00449     // Change RTP and RTCP to use the TCP socket instead of UDP:
00450     if (fRTPSink != NULL) {
00451       fRTPSink->addStreamSocket(dests->tcpSocketNum, dests->rtpChannelId);
00452     }
00453     if (fRTCPInstance != NULL) {
00454       fRTCPInstance->addStreamSocket(dests->tcpSocketNum, dests->rtcpChannelId);
00455       fRTCPInstance->setSpecificRRHandler(dests->tcpSocketNum, dests->rtcpChannelId,
00456                                           rtcpRRHandler, rtcpRRHandlerClientData);
00457     }
00458   } else {
00459     // Tell the RTP and RTCP 'groupsocks' about this destination
00460     // (in case they don't already have it):
00461     if (fRTPgs != NULL) fRTPgs->addDestination(dests->addr, dests->rtpPort);
00462     if (fRTCPgs != NULL) fRTCPgs->addDestination(dests->addr, dests->rtcpPort);
00463     if (fRTCPInstance != NULL) {
00464       fRTCPInstance->setSpecificRRHandler(dests->addr.s_addr, dests->rtcpPort,
00465                                           rtcpRRHandler, rtcpRRHandlerClientData);
00466     }
00467   }
00468 }

void StreamState::pause (  ) 

Definition at line 470 of file OnDemandServerMediaSubsession.cpp.

References False, fAreCurrentlyPlaying, fRTPSink, fUDPSink, NULL, and MediaSink::stopPlaying().

Referenced by OnDemandServerMediaSubsession::pauseStream().

00470                         {
00471   if (fRTPSink != NULL) fRTPSink->stopPlaying();
00472   if (fUDPSink != NULL) fUDPSink->stopPlaying();
00473   fAreCurrentlyPlaying = False;
00474 }

void StreamState::endPlaying ( Destinations destinations  ) 

Definition at line 476 of file OnDemandServerMediaSubsession.cpp.

References Destinations::addr, fRTCPgs, fRTCPInstance, fRTPgs, fRTPSink, Destinations::isTCP, NULL, Groupsock::removeDestination(), RTCPInstance::removeStreamSocket(), RTPSink::removeStreamSocket(), Destinations::rtcpChannelId, Destinations::rtcpPort, Destinations::rtpChannelId, Destinations::rtpPort, RTCPInstance::setSpecificRRHandler(), and Destinations::tcpSocketNum.

Referenced by OnDemandServerMediaSubsession::deleteStream().

00476                                                 {
00477   if (dests->isTCP) {
00478     if (fRTPSink != NULL) {
00479       fRTPSink->removeStreamSocket(dests->tcpSocketNum, dests->rtpChannelId);
00480     }
00481     if (fRTCPInstance != NULL) {
00482       fRTCPInstance->removeStreamSocket(dests->tcpSocketNum, dests->rtcpChannelId);
00483       fRTCPInstance->setSpecificRRHandler(dests->tcpSocketNum, dests->rtcpChannelId,
00484                                           NULL, NULL);
00485     }
00486   } else {
00487     // Tell the RTP and RTCP 'groupsocks' to stop using these destinations:
00488     if (fRTPgs != NULL) fRTPgs->removeDestination(dests->addr, dests->rtpPort);
00489     if (fRTCPgs != NULL) fRTCPgs->removeDestination(dests->addr, dests->rtcpPort);
00490     if (fRTCPInstance != NULL) {
00491       fRTCPInstance->setSpecificRRHandler(dests->addr.s_addr, dests->rtcpPort,
00492                                           NULL, NULL);
00493     }
00494   }
00495 }

void StreamState::reclaim (  ) 

Definition at line 497 of file OnDemandServerMediaSubsession.cpp.

References Medium::close(), OnDemandServerMediaSubsession::closeStreamSource(), fMaster, fMediaSource, fRTCPgs, fRTCPInstance, fRTPgs, fRTPSink, fUDPSink, and NULL.

Referenced by afterPlayingStreamState(), and ~StreamState().

00497                           {
00498   // Delete allocated media objects
00499   Medium::close(fRTCPInstance) /* will send a RTCP BYE */; fRTCPInstance = NULL;
00500   Medium::close(fRTPSink); fRTPSink = NULL;
00501   Medium::close(fUDPSink); fUDPSink = NULL;
00502 
00503   fMaster.closeStreamSource(fMediaSource); fMediaSource = NULL;
00504 
00505   delete fRTPgs; fRTPgs = NULL;
00506   delete fRTCPgs; fRTCPgs = NULL;
00507 }

unsigned& StreamState::referenceCount (  )  [inline]

Definition at line 115 of file OnDemandServerMediaSubsession.cpp.

Referenced by OnDemandServerMediaSubsession::deleteStream().

00115 { return fReferenceCount; }

Port const& StreamState::serverRTPPort (  )  const [inline]

Definition at line 117 of file OnDemandServerMediaSubsession.cpp.

00117 { return fServerRTPPort; }

Port const& StreamState::serverRTCPPort (  )  const [inline]

Definition at line 118 of file OnDemandServerMediaSubsession.cpp.

00118 { return fServerRTCPPort; }

RTPSink* StreamState::rtpSink (  )  const [inline]

Definition at line 120 of file OnDemandServerMediaSubsession.cpp.

Referenced by OnDemandServerMediaSubsession::startStream().

00120 { return fRTPSink; }

float StreamState::streamDuration (  )  const [inline]

Definition at line 122 of file OnDemandServerMediaSubsession.cpp.

Referenced by afterPlayingStreamState().

00122 { return fStreamDuration; }

FramedSource* StreamState::mediaSource (  )  const [inline]

Definition at line 124 of file OnDemandServerMediaSubsession.cpp.

Referenced by OnDemandServerMediaSubsession::seekStream(), and OnDemandServerMediaSubsession::setStreamScale().

00124 { return fMediaSource; }


Field Documentation

OnDemandServerMediaSubsession& StreamState::fMaster [private]

Definition at line 127 of file OnDemandServerMediaSubsession.cpp.

Referenced by reclaim(), and startPlaying().

Boolean StreamState::fAreCurrentlyPlaying [private]

Definition at line 128 of file OnDemandServerMediaSubsession.cpp.

Referenced by pause(), and startPlaying().

unsigned StreamState::fReferenceCount [private]

Definition at line 129 of file OnDemandServerMediaSubsession.cpp.

Port StreamState::fServerRTPPort [private]

Definition at line 131 of file OnDemandServerMediaSubsession.cpp.

Port StreamState::fServerRTCPPort [private]

Definition at line 131 of file OnDemandServerMediaSubsession.cpp.

RTPSink* StreamState::fRTPSink [private]

Definition at line 133 of file OnDemandServerMediaSubsession.cpp.

Referenced by endPlaying(), pause(), reclaim(), and startPlaying().

BasicUDPSink* StreamState::fUDPSink [private]

Definition at line 134 of file OnDemandServerMediaSubsession.cpp.

Referenced by pause(), reclaim(), and startPlaying().

float StreamState::fStreamDuration [private]

Definition at line 136 of file OnDemandServerMediaSubsession.cpp.

unsigned StreamState::fTotalBW [private]

Definition at line 137 of file OnDemandServerMediaSubsession.cpp.

Referenced by startPlaying().

RTCPInstance* StreamState::fRTCPInstance [private]

Definition at line 137 of file OnDemandServerMediaSubsession.cpp.

Referenced by endPlaying(), reclaim(), and startPlaying().

FramedSource* StreamState::fMediaSource [private]

Definition at line 139 of file OnDemandServerMediaSubsession.cpp.

Referenced by reclaim(), and startPlaying().

Groupsock* StreamState::fRTPgs [private]

Definition at line 141 of file OnDemandServerMediaSubsession.cpp.

Referenced by endPlaying(), reclaim(), and startPlaying().

Groupsock* StreamState::fRTCPgs [private]

Definition at line 141 of file OnDemandServerMediaSubsession.cpp.

Referenced by endPlaying(), reclaim(), and startPlaying().


The documentation for this class was generated from the following file:
Generated on Tue Oct 7 15:40:12 2008 for live by  doxygen 1.5.2