MediaSession Class Reference

#include <MediaSession.hh>

Inheritance diagram for MediaSession:

Inheritance graph
[legend]
Collaboration diagram for MediaSession:

Collaboration graph
[legend]

Public Member Functions

Boolean hasSubsessions () const
double & playStartTime ()
double & playEndTime ()
char * connectionEndpointName () const
char const * CNAME () const
in_addr const & sourceFilterAddr () const
float & scale ()
char * mediaSessionType () const
char * sessionName () const
char * sessionDescription () const
char const * controlPath () const
Boolean initiateByMediaType (char const *mimeType, MediaSubsession *&resultSubsession, int useSpecialRTPoffset=-1)
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 isServerMediaSession () const
virtual Boolean isDarwinInjector () const

Static Public Member Functions

static MediaSessioncreateNew (UsageEnvironment &env, char const *sdpDescription)
static Boolean lookupByName (UsageEnvironment &env, char const *sourceName, MediaSession *&resultSession)
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 Boolean isMediaSession () const
 MediaSession (UsageEnvironment &env)
virtual ~MediaSession ()
Boolean initializeWithSDP (char const *sdpDescription)
Boolean parseSDPLine (char const *input, char const *&nextLine)
Boolean parseSDPLine_s (char const *sdpLine)
Boolean parseSDPLine_i (char const *sdpLine)
Boolean parseSDPLine_c (char const *sdpLine)
Boolean parseSDPAttribute_type (char const *sdpLine)
Boolean parseSDPAttribute_control (char const *sdpLine)
Boolean parseSDPAttribute_range (char const *sdpLine)
Boolean parseSDPAttribute_source_filter (char const *sdpLine)
TaskTokennextTask ()

Static Protected Member Functions

static char * lookupPayloadFormat (unsigned char rtpPayloadType, unsigned &rtpTimestampFrequency, unsigned &numChannels)
static unsigned guessRTPTimestampFrequency (char const *mediumName, char const *codecName)

Protected Attributes

char * fCNAME
MediaSubsessionfSubsessionsHead
MediaSubsessionfSubsessionsTail
char * fConnectionEndpointName
double fMaxPlayStartTime
double fMaxPlayEndTime
in_addr fSourceFilterAddr
float fScale
char * fMediaSessionType
char * fSessionName
char * fSessionDescription
char * fControlPath

Friends

class MediaSubsessionIterator

Detailed Description

Definition at line 33 of file MediaSession.hh.


Constructor & Destructor Documentation

MediaSession::MediaSession ( UsageEnvironment env  )  [protected]

Definition at line 59 of file MediaSession.cpp.

References CNAME(), fCNAME, fSourceFilterAddr, our_random(), and strDup().

Referenced by createNew().

00060   : Medium(env),
00061     fSubsessionsHead(NULL), fSubsessionsTail(NULL),
00062     fConnectionEndpointName(NULL), fMaxPlayStartTime(0.0f), fMaxPlayEndTime(0.0f),
00063     fScale(1.0f), fMediaSessionType(NULL), fSessionName(NULL), fSessionDescription(NULL),
00064     fControlPath(NULL) {
00065   fSourceFilterAddr.s_addr = 0;
00066 
00067   // Get our host name, and use this for the RTCP CNAME:
00068   const unsigned maxCNAMElen = 100;
00069   char CNAME[maxCNAMElen+1];
00070 #ifndef CRIS
00071   gethostname((char*)CNAME, maxCNAMElen);
00072 #else
00073   // "gethostname()" isn't defined for this platform
00074   sprintf(CNAME, "unknown host %d", (unsigned)(our_random()*0x7FFFFFFF));
00075 #endif
00076   CNAME[maxCNAMElen] = '\0'; // just in case
00077   fCNAME = strDup(CNAME);
00078 }

MediaSession::~MediaSession (  )  [protected, virtual]

Definition at line 80 of file MediaSession.cpp.

References fCNAME, fConnectionEndpointName, fControlPath, fMediaSessionType, fSessionDescription, fSessionName, and fSubsessionsHead.

00080                             {
00081   delete fSubsessionsHead;
00082   delete[] fCNAME;
00083   delete[] fConnectionEndpointName;
00084   delete[] fMediaSessionType;
00085   delete[] fSessionName;
00086   delete[] fSessionDescription;
00087   delete[] fControlPath;
00088 }


Member Function Documentation

MediaSession * MediaSession::createNew ( UsageEnvironment env,
char const *  sdpDescription 
) [static]

Definition at line 29 of file MediaSession.cpp.

References env, initializeWithSDP(), MediaSession(), and NULL.

Referenced by continueAfterDESCRIBE(), and DarwinInjector::setDestination().

00030                                                                   {
00031   MediaSession* newSession = new MediaSession(env);
00032   if (newSession != NULL) {
00033     if (!newSession->initializeWithSDP(sdpDescription)) {
00034       delete newSession;
00035       return NULL;
00036     }
00037   }
00038 
00039   return newSession;
00040 }

Boolean MediaSession::lookupByName ( UsageEnvironment env,
char const *  sourceName,
MediaSession *&  resultSession 
) [static]

Definition at line 42 of file MediaSession.cpp.

References env, False, Medium::isMediaSession(), Medium::lookupByName(), NULL, and True.

00044                                                                  {
00045   resultSession = NULL; // unless we succeed
00046 
00047   Medium* medium;
00048   if (!Medium::lookupByName(env, instanceName, medium)) return False;
00049 
00050   if (!medium->isMediaSession()) {
00051     env.setResultMsg(instanceName, " is not a 'MediaSession' object");
00052     return False;
00053   }
00054 
00055   resultSession = (MediaSession*)medium;
00056   return True;
00057 }

Boolean MediaSession::hasSubsessions (  )  const [inline]

Definition at line 41 of file MediaSession.hh.

References fSubsessionsHead, and NULL.

Referenced by continueAfterDESCRIBE().

00041 { return fSubsessionsHead != NULL; }

double& MediaSession::playStartTime (  )  [inline]

Definition at line 42 of file MediaSession.hh.

References fMaxPlayStartTime.

Referenced by RTSPClient::handlePLAYResponse(), MediaSubsession::parseSDPAttribute_range(), parseSDPAttribute_range(), and MediaSubsession::playStartTime().

00042 { return fMaxPlayStartTime; }

double& MediaSession::playEndTime (  )  [inline]

Definition at line 43 of file MediaSession.hh.

References fMaxPlayEndTime.

Referenced by RTSPClient::handlePLAYResponse(), MediaSubsession::parseSDPAttribute_range(), parseSDPAttribute_range(), MediaSubsession::playEndTime(), and setupStreams().

00043 { return fMaxPlayEndTime; }

char* MediaSession::connectionEndpointName (  )  const [inline]

Definition at line 44 of file MediaSession.hh.

References fConnectionEndpointName.

Referenced by MediaSubsession::connectionEndpointAddress(), and parseSDPLine_c().

00044 { return fConnectionEndpointName; }

char const* MediaSession::CNAME (  )  const [inline]

Definition at line 45 of file MediaSession.hh.

References fCNAME.

Referenced by MediaSubsession::initiate(), and MediaSession().

00045 { return fCNAME; }

struct in_addr const& MediaSession::sourceFilterAddr (  )  const [inline, read]

Definition at line 46 of file MediaSession.hh.

References fSourceFilterAddr.

00046 { return fSourceFilterAddr; }

float& MediaSession::scale (  )  [inline]

Definition at line 47 of file MediaSession.hh.

References fScale.

Referenced by RTSPClient::handlePLAYResponse(), and RTSPClient::sendRequest().

00047 { return fScale; }

char* MediaSession::mediaSessionType (  )  const [inline]

Definition at line 48 of file MediaSession.hh.

References fMediaSessionType.

00048 { return fMediaSessionType; }

char* MediaSession::sessionName (  )  const [inline]

Definition at line 49 of file MediaSession.hh.

References fSessionName.

00049 { return fSessionName; }

char* MediaSession::sessionDescription (  )  const [inline]

Definition at line 50 of file MediaSession.hh.

References fSessionDescription.

00050 { return fSessionDescription; }

char const* MediaSession::controlPath (  )  const [inline]

Definition at line 51 of file MediaSession.hh.

References fControlPath.

Referenced by parseSDPAttribute_control(), and RTSPClient::sessionURL().

00051 { return fControlPath; }

Boolean MediaSession::initiateByMediaType ( char const *  mimeType,
MediaSubsession *&  resultSubsession,
int  useSpecialRTPoffset = -1 
)

Definition at line 467 of file MediaSession.cpp.

References MediaSubsession::deInitiate(), Medium::envir(), False, MediaSubsession::initiate(), iter, MediaSource::MIMEtype(), MediaSubsessionIterator::next(), NULL, MediaSubsession::readSource(), UsageEnvironment::setResultMsg(), subsession, and True.

00469                                                {
00470   // Look through this session's subsessions for media that match "mimeType"
00471   resultSubsession = NULL;
00472   MediaSubsessionIterator iter(*this);
00473   MediaSubsession* subsession;
00474   while ((subsession = iter.next()) != NULL) {
00475     Boolean wasAlreadyInitiated = subsession->readSource() != NULL;
00476     if (!wasAlreadyInitiated) {
00477       // Try to create a source for this subsession:
00478       if (!subsession->initiate(useSpecialRTPoffset)) return False;
00479     }
00480 
00481     // Make sure the source's MIME type is one that we handle:
00482     if (strcmp(subsession->readSource()->MIMEtype(), mimeType) != 0) {
00483       if (!wasAlreadyInitiated) subsession->deInitiate();
00484       continue;
00485     }
00486 
00487     resultSubsession = subsession;
00488     break; // use this
00489   }
00490 
00491   if (resultSubsession == NULL) {
00492     envir().setResultMsg("Session has no usable media subsession");
00493     return False;
00494   }
00495 
00496   return True;
00497 }

Boolean MediaSession::isMediaSession (  )  const [protected, virtual]

Reimplemented from Medium.

Definition at line 90 of file MediaSession.cpp.

References True.

00090                                            {
00091   return True;
00092 }

Boolean MediaSession::initializeWithSDP ( char const *  sdpDescription  )  [protected]

Definition at line 94 of file MediaSession.cpp.

References Medium::envir(), False, MediaSubsession::fClientPortNum, MediaSubsession::fCodecName, MediaSubsession::fMediumName, MediaSubsession::fNumChannels, MediaSubsession::fProtocolName, MediaSubsession::fRTPPayloadFormat, MediaSubsession::fRTPTimestampFrequency, MediaSubsession::fSavedSDPLines, fSubsessionsHead, fSubsessionsTail, guessRTPTimestampFrequency(), lookupPayloadFormat(), NULL, MediaSubsession::parseSDPAttribute_control(), parseSDPAttribute_control(), MediaSubsession::parseSDPAttribute_fmtp(), MediaSubsession::parseSDPAttribute_framerate(), MediaSubsession::parseSDPAttribute_range(), parseSDPAttribute_range(), MediaSubsession::parseSDPAttribute_rtpmap(), MediaSubsession::parseSDPAttribute_source_filter(), parseSDPAttribute_source_filter(), parseSDPAttribute_type(), MediaSubsession::parseSDPAttribute_x_dimensions(), parseSDPLine(), MediaSubsession::parseSDPLine_b(), MediaSubsession::parseSDPLine_c(), parseSDPLine_c(), parseSDPLine_i(), parseSDPLine_s(), MediaSubsession::serverPortNum, MediaSubsession::setNext(), UsageEnvironment::setResultMsg(), strDup(), strDupSize(), subsession, and True.

Referenced by createNew().

00094                                                                   {
00095   if (sdpDescription == NULL) return False;
00096 
00097   // Begin by processing all SDP lines until we see the first "m="
00098   char const* sdpLine = sdpDescription;
00099   char const* nextSDPLine;
00100   while (1) {
00101     if (!parseSDPLine(sdpLine, nextSDPLine)) return False;
00102     //##### We should really check for:
00103     // - "a=control:" attributes (to set the URL for aggregate control)
00104     // - the correct SDP version (v=0)
00105     if (sdpLine[0] == 'm') break;
00106     sdpLine = nextSDPLine;
00107     if (sdpLine == NULL) break; // there are no m= lines at all
00108 
00109     // Check for various special SDP lines that we understand:
00110     if (parseSDPLine_s(sdpLine)) continue;
00111     if (parseSDPLine_i(sdpLine)) continue;
00112     if (parseSDPLine_c(sdpLine)) continue;
00113     if (parseSDPAttribute_control(sdpLine)) continue;
00114     if (parseSDPAttribute_range(sdpLine)) continue;
00115     if (parseSDPAttribute_type(sdpLine)) continue;
00116     if (parseSDPAttribute_source_filter(sdpLine)) continue;
00117   }
00118 
00119   while (sdpLine != NULL) {
00120     // We have a "m=" line, representing a new sub-session:
00121     MediaSubsession* subsession = new MediaSubsession(*this);
00122     if (subsession == NULL) {
00123       envir().setResultMsg("Unable to create new MediaSubsession");
00124       return False;
00125     }
00126 
00127     // Parse the line as "m=<medium_name> <client_portNum> RTP/AVP <fmt>"
00128     // or "m=<medium_name> <client_portNum>/<num_ports> RTP/AVP <fmt>"
00129     // (Should we be checking for >1 payload format number here?)#####
00130     char* mediumName = strDupSize(sdpLine); // ensures we have enough space
00131     char const* protocolName = NULL;
00132     unsigned payloadFormat;
00133     if ((sscanf(sdpLine, "m=%s %hu RTP/AVP %u",
00134                 mediumName, &subsession->fClientPortNum, &payloadFormat) == 3 ||
00135          sscanf(sdpLine, "m=%s %hu/%*u RTP/AVP %u",
00136                 mediumName, &subsession->fClientPortNum, &payloadFormat) == 3)
00137         && payloadFormat <= 127) {
00138       protocolName = "RTP";
00139     } else if ((sscanf(sdpLine, "m=%s %hu UDP %u",
00140                        mediumName, &subsession->fClientPortNum, &payloadFormat) == 3 ||
00141                 sscanf(sdpLine, "m=%s %hu udp %u",
00142                        mediumName, &subsession->fClientPortNum, &payloadFormat) == 3 ||
00143                 sscanf(sdpLine, "m=%s %hu RAW/RAW/UDP %u",
00144                        mediumName, &subsession->fClientPortNum, &payloadFormat) == 3)
00145                && payloadFormat <= 127) {
00146       // This is a RAW UDP source
00147       protocolName = "UDP";
00148     } else {
00149       // This "m=" line is bad; output an error message saying so:
00150       char* sdpLineStr;
00151       if (nextSDPLine == NULL) {
00152         sdpLineStr = (char*)sdpLine;
00153       } else {
00154         sdpLineStr = strDup(sdpLine);
00155         sdpLineStr[nextSDPLine-sdpLine] = '\0';
00156       }
00157       envir() << "Bad SDP \"m=\" line: " <<  sdpLineStr << "\n";
00158       if (sdpLineStr != (char*)sdpLine) delete[] sdpLineStr;
00159 
00160       delete[] mediumName;
00161       delete subsession;
00162 
00163       // Skip the following SDP lines, up until the next "m=":
00164       while (1) {
00165         sdpLine = nextSDPLine;
00166         if (sdpLine == NULL) break; // we've reached the end
00167         if (!parseSDPLine(sdpLine, nextSDPLine)) return False;
00168 
00169         if (sdpLine[0] == 'm') break; // we've reached the next subsession
00170       }
00171       continue;
00172     }
00173 
00174     // Insert this subsession at the end of the list:
00175     if (fSubsessionsTail == NULL) {
00176       fSubsessionsHead = fSubsessionsTail = subsession;
00177     } else {
00178       fSubsessionsTail->setNext(subsession);
00179       fSubsessionsTail = subsession;
00180     }
00181 
00182     subsession->serverPortNum = subsession->fClientPortNum; // by default
00183 
00184     char const* mStart = sdpLine;
00185     subsession->fSavedSDPLines = strDup(mStart);
00186 
00187     subsession->fMediumName = strDup(mediumName);
00188     delete[] mediumName;
00189     subsession->fProtocolName = strDup(protocolName);
00190     subsession->fRTPPayloadFormat = payloadFormat;
00191 
00192     // Process the following SDP lines, up until the next "m=":
00193     while (1) {
00194       sdpLine = nextSDPLine;
00195       if (sdpLine == NULL) break; // we've reached the end
00196       if (!parseSDPLine(sdpLine, nextSDPLine)) return False;
00197 
00198       if (sdpLine[0] == 'm') break; // we've reached the next subsession
00199 
00200       // Check for various special SDP lines that we understand:
00201       if (subsession->parseSDPLine_c(sdpLine)) continue;
00202       if (subsession->parseSDPLine_b(sdpLine)) continue;
00203       if (subsession->parseSDPAttribute_rtpmap(sdpLine)) continue;
00204       if (subsession->parseSDPAttribute_control(sdpLine)) continue;
00205       if (subsession->parseSDPAttribute_range(sdpLine)) continue;
00206       if (subsession->parseSDPAttribute_fmtp(sdpLine)) continue;
00207       if (subsession->parseSDPAttribute_source_filter(sdpLine)) continue;
00208       if (subsession->parseSDPAttribute_x_dimensions(sdpLine)) continue;
00209       if (subsession->parseSDPAttribute_framerate(sdpLine)) continue;
00210 
00211       // (Later, check for malformed lines, and other valid SDP lines#####)
00212     }
00213     if (sdpLine != NULL) subsession->fSavedSDPLines[sdpLine-mStart] = '\0';
00214 
00215     // If we don't yet know the codec name, try looking it up from the
00216     // list of static payload types:
00217     if (subsession->fCodecName == NULL) {
00218       subsession->fCodecName
00219         = lookupPayloadFormat(subsession->fRTPPayloadFormat,
00220                               subsession->fRTPTimestampFrequency,
00221                               subsession->fNumChannels);
00222       if (subsession->fCodecName == NULL) {
00223         char typeStr[20];
00224         sprintf(typeStr, "%d", subsession->fRTPPayloadFormat);
00225         envir().setResultMsg("Unknown codec name for RTP payload type ",
00226                              typeStr);
00227         return False;
00228       }
00229     }
00230 
00231     // If we don't yet know this subsession's RTP timestamp frequency
00232     // (because it uses a dynamic payload type and the corresponding
00233     // SDP "rtpmap" attribute erroneously didn't specify it),
00234     // then guess it now:
00235     if (subsession->fRTPTimestampFrequency == 0) {
00236       subsession->fRTPTimestampFrequency
00237         = guessRTPTimestampFrequency(subsession->fMediumName,
00238                                      subsession->fCodecName);
00239     }
00240   }
00241 
00242   return True;
00243 }

Boolean MediaSession::parseSDPLine ( char const *  input,
char const *&  nextLine 
) [protected]

Definition at line 245 of file MediaSession.cpp.

References Medium::envir(), False, NULL, and True.

Referenced by initializeWithSDP().

00246                                                          {
00247   // Begin by finding the start of the next line (if any):
00248   nextLine = NULL;
00249   for (char const* ptr = inputLine; *ptr != '\0'; ++ptr) {
00250     if (*ptr == '\r' || *ptr == '\n') {
00251       // We found the end of the line
00252       ++ptr;
00253       while (*ptr == '\r' || *ptr == '\n') ++ptr;
00254       nextLine = ptr;
00255       if (nextLine[0] == '\0') nextLine = NULL; // special case for end
00256       break;
00257     }
00258   }
00259 
00260   // Then, check that this line is a SDP line of the form <char>=<etc>
00261   // (However, we also accept blank lines in the input.)
00262   if (inputLine[0] == '\r' || inputLine[0] == '\n') return True;
00263   if (strlen(inputLine) < 2 || inputLine[1] != '='
00264       || inputLine[0] < 'a' || inputLine[0] > 'z') {
00265     envir().setResultMsg("Invalid SDP line: ", inputLine);
00266     return False;
00267   }
00268 
00269   return True;
00270 }

Boolean MediaSession::parseSDPLine_s ( char const *  sdpLine  )  [protected]

Definition at line 284 of file MediaSession.cpp.

References False, fSessionName, strDup(), strDupSize(), and True.

Referenced by initializeWithSDP().

00284                                                         {
00285   // Check for "s=<session name>" line
00286   char* buffer = strDupSize(sdpLine);
00287   Boolean parseSuccess = False;
00288 
00289   if (sscanf(sdpLine, "s=%[^\r\n]", buffer) == 1) {
00290     delete[] fSessionName; fSessionName = strDup(buffer);
00291     parseSuccess = True;
00292   }
00293   delete[] buffer;
00294 
00295   return parseSuccess;
00296 }

Boolean MediaSession::parseSDPLine_i ( char const *  sdpLine  )  [protected]

Definition at line 298 of file MediaSession.cpp.

References False, fSessionDescription, strDup(), strDupSize(), and True.

Referenced by initializeWithSDP().

00298                                                         {
00299   // Check for "i=<session description>" line
00300   char* buffer = strDupSize(sdpLine);
00301   Boolean parseSuccess = False;
00302 
00303   if (sscanf(sdpLine, "i=%[^\r\n]", buffer) == 1) {
00304     delete[] fSessionDescription; fSessionDescription = strDup(buffer);
00305     parseSuccess = True;
00306   }
00307   delete[] buffer;
00308 
00309   return parseSuccess;
00310 }

Boolean MediaSession::parseSDPLine_c ( char const *  sdpLine  )  [protected]

Definition at line 312 of file MediaSession.cpp.

References connectionEndpointName(), False, fConnectionEndpointName, NULL, parseCLine(), and True.

Referenced by initializeWithSDP().

00312                                                         {
00313   // Check for "c=IN IP4 <connection-endpoint>"
00314   // or "c=IN IP4 <connection-endpoint>/<ttl+numAddresses>"
00315   // (Later, do something with <ttl+numAddresses> also #####)
00316   char* connectionEndpointName = parseCLine(sdpLine);
00317   if (connectionEndpointName != NULL) {
00318     delete[] fConnectionEndpointName;
00319     fConnectionEndpointName = connectionEndpointName;
00320     return True;
00321   }
00322 
00323   return False;
00324 }

Boolean MediaSession::parseSDPAttribute_type ( char const *  sdpLine  )  [protected]

Definition at line 326 of file MediaSession.cpp.

References False, fMediaSessionType, strDup(), strDupSize(), and True.

Referenced by initializeWithSDP().

00326                                                                 {
00327   // Check for a "a=type:broadcast|meeting|moderated|test|H.332|recvonly" line:
00328   Boolean parseSuccess = False;
00329 
00330   char* buffer = strDupSize(sdpLine);
00331   if (sscanf(sdpLine, "a=type: %[^ ]", buffer) == 1) {
00332     delete[] fMediaSessionType;
00333     fMediaSessionType = strDup(buffer);
00334     parseSuccess = True;
00335   }
00336   delete[] buffer;
00337 
00338   return parseSuccess;
00339 }

Boolean MediaSession::parseSDPAttribute_control ( char const *  sdpLine  )  [protected]

Definition at line 345 of file MediaSession.cpp.

References controlPath(), False, fControlPath, strDup(), strDupSize(), and True.

Referenced by initializeWithSDP().

00345                                                                    {
00346   // Check for a "a=control:<control-path>" line:
00347   Boolean parseSuccess = False;
00348 
00349   char* controlPath = strDupSize(sdpLine); // ensures we have enough space
00350   if (sscanf(sdpLine, "a=control: %s", controlPath) == 1) {
00351     parseSuccess = True;
00352     delete[] fControlPath; fControlPath = strDup(controlPath);
00353   }
00354   delete[] controlPath;
00355 
00356   return parseSuccess;
00357 }

Boolean MediaSession::parseSDPAttribute_range ( char const *  sdpLine  )  [protected]

Definition at line 359 of file MediaSession.cpp.

References False, fMaxPlayEndTime, fMaxPlayStartTime, parseRangeAttribute(), playEndTime(), playStartTime(), and True.

Referenced by initializeWithSDP().

00359                                                                  {
00360   // Check for a "a=range:npt=<startTime>-<endTime>" line:
00361   // (Later handle other kinds of "a=range" attributes also???#####)
00362   Boolean parseSuccess = False;
00363 
00364   double playStartTime;
00365   double playEndTime;
00366   if (parseRangeAttribute(sdpLine, playStartTime, playEndTime)) {
00367     parseSuccess = True;
00368     if (playStartTime > fMaxPlayStartTime) {
00369       fMaxPlayStartTime = playStartTime;
00370     }
00371     if (playEndTime > fMaxPlayEndTime) {
00372       fMaxPlayEndTime = playEndTime;
00373     }
00374   }
00375 
00376   return parseSuccess;
00377 }

Boolean MediaSession::parseSDPAttribute_source_filter ( char const *  sdpLine  )  [protected]

Definition at line 408 of file MediaSession.cpp.

References fSourceFilterAddr, and parseSourceFilterAttribute().

Referenced by initializeWithSDP().

00408                                                      {
00409   return parseSourceFilterAttribute(sdpLine, fSourceFilterAddr);
00410 }

char * MediaSession::lookupPayloadFormat ( unsigned char  rtpPayloadType,
unsigned &  rtpTimestampFrequency,
unsigned &  numChannels 
) [static, protected]

Definition at line 412 of file MediaSession.cpp.

References NULL, and strDup().

Referenced by initializeWithSDP().

00413                                                                        {
00414   // Look up the codec name and timestamp frequency for known (static)
00415   // RTP payload formats.
00416   char const* temp = NULL;
00417   switch (rtpPayloadType) {
00418   case 0: {temp = "PCMU"; freq = 8000; nCh = 1; break;}
00419   case 2: {temp = "G726-32"; freq = 8000; nCh = 1; break;}
00420   case 3: {temp = "GSM"; freq = 8000; nCh = 1; break;}
00421   case 4: {temp = "G723"; freq = 8000; nCh = 1; break;}
00422   case 5: {temp = "DVI4"; freq = 8000; nCh = 1; break;}
00423   case 6: {temp = "DVI4"; freq = 16000; nCh = 1; break;}
00424   case 7: {temp = "LPC"; freq = 8000; nCh = 1; break;}
00425   case 8: {temp = "PCMA"; freq = 8000; nCh = 1; break;}
00426   case 9: {temp = "G722"; freq = 8000; nCh = 1; break;}
00427   case 10: {temp = "L16"; freq = 44100; nCh = 2; break;}
00428   case 11: {temp = "L16"; freq = 44100; nCh = 1; break;}
00429   case 12: {temp = "QCELP"; freq = 8000; nCh = 1; break;}
00430   case 14: {temp = "MPA"; freq = 90000; nCh = 1; break;}
00431     // 'number of channels' is actually encoded in the media stream
00432   case 15: {temp = "G728"; freq = 8000; nCh = 1; break;}
00433   case 16: {temp = "DVI4"; freq = 11025; nCh = 1; break;}
00434   case 17: {temp = "DVI4"; freq = 22050; nCh = 1; break;}
00435   case 18: {temp = "G729"; freq = 8000; nCh = 1; break;}
00436   case 25: {temp = "CELB"; freq = 90000; nCh = 1; break;}
00437   case 26: {temp = "JPEG"; freq = 90000; nCh = 1; break;}
00438   case 28: {temp = "NV"; freq = 90000; nCh = 1; break;}
00439   case 31: {temp = "H261"; freq = 90000; nCh = 1; break;}
00440   case 32: {temp = "MPV"; freq = 90000; nCh = 1; break;}
00441   case 33: {temp = "MP2T"; freq = 90000; nCh = 1; break;}
00442   case 34: {temp = "H263"; freq = 90000; nCh = 1; break;}
00443   };
00444 
00445   return strDup(temp);
00446 }

unsigned MediaSession::guessRTPTimestampFrequency ( char const *  mediumName,
char const *  codecName 
) [static, protected]

Definition at line 448 of file MediaSession.cpp.

Referenced by initializeWithSDP().

00449                                                                          {
00450   // By default, we assume that audio sessions use a frequency of 8000,
00451   // video sessions use a frequency of 90000,
00452   // and text sessions use a frequency of 1000.
00453   // Begin by checking for known exceptions to this rule
00454   // (where the frequency is known unambiguously (e.g., not like "DVI4"))
00455   if (strcmp(codecName, "L16") == 0) return 44100;
00456   if (strcmp(codecName, "MPA") == 0
00457       || strcmp(codecName, "MPA-ROBUST") == 0
00458       || strcmp(codecName, "X-MP3-DRAFT-00")) return 90000;
00459 
00460   // Now, guess default values:
00461   if (strcmp(mediumName, "video") == 0) return 90000;
00462   else if (strcmp(mediumName, "text") == 0) return 1000;
00463   return 8000; // for "audio", and any other medium
00464 }

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(), 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(), continueAfterTEARDOWN(), 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(), 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(), RTCPInstance::addStreamSocket(), MPEG2IFrameIndexFromTransportStream::addToTail(), StreamParser::afterGettingBytes(), MultiFramedRTPSink::afterGettingFrame1(), InputESSourceRecord::afterGettingFrame1(), MPEG2TransportStreamFramer::afterGettingFrame1(), MPEG2IFrameIndexFromTransportStream::afterGettingFrame1(), HTTPSink::afterGettingFrame1(), BasicUDPSink::afterGettingFrame1(), MPEG4VideoFileServerMediaSubsession::afterPlayingDummy1(), MPEG4VideoStreamParser::analyzeVOLHeader(), announceStream(), MPEG4VideoFileServerMediaSubsession::checkForAuxSDPLine1(), Medium::close(), MPEG2IFrameIndexFromTransportStream::compactParseBuffer(), RTSPClient::connectionHandler1(), RTSPClient::connectToServer(), QuickTimeFileSink::continuePlaying(), HTTPSink::continuePlaying(), H264VideoRTPSink::continuePlaying(), AVIFileSink::continuePlaying(), MPEG4VideoFileServerMediaSubsession::createNewRTPSink(), MPEG2TransportFileServerMediaSubsession::createNewRTPSink(), MPEG1or2VideoFileServerMediaSubsession::createNewRTPSink(), MPEG1or2DemuxedServerMediaSubsession::createNewRTPSink(), H263plusVideoFileServerMediaSubsession::createNewRTPSink(), DVVideoFileServerMediaSubsession::createNewRTPSink(), AMRAudioFileServerMediaSubsession::createNewRTPSink(), ADTSAudioFileServerMediaSubsession::createNewRTPSink(), MPEG4VideoFileServerMediaSubsession::createNewStreamSource(), MPEG2TransportFileServerMediaSubsession::createNewStreamSource(), MPEG1or2VideoFileServerMediaSubsession::createNewStreamSource(), MPEG1or2DemuxedServerMediaSubsession::createNewStreamSource(), H263plusVideoFileServerMediaSubsession::createNewStreamSource(), DVVideoFileServerMediaSubsession::createNewStreamSource(), AMRAudioFileServerMediaSubsession::createNewStreamSource(), ADTSAudioFileServerMediaSubsession::createNewStreamSource(), MPEG2IFrameIndexFromTransportStream::deliverIndexRecord(), SegmentQueue::dequeue(), WAVAudioFileSource::doGetNextFrame(), MPEG2IFrameIndexFromTransportStream::doGetNextFrame(), MP3FileSource::doGetNextFrame(), H264FUAFragmenter::doGetNextFrame(), ByteStreamMultiFileSource::doGetNextFrame(), ByteStreamFileSource::doGetNextFrame(), BasicUDPSource::doGetNextFrame(), AMRAudioFileSource::doGetNextFrame(), ADTSAudioFileSource::doGetNextFrame(), MultiFramedRTPSource::doGetNextFrame1(), MP3FileSource::doGetNextFrame1(), ADUFromMP3Source::doGetNextFrame1(), SIPClient::doInviteStateMachine(), ByteStreamFileSource::doReadFromFile(), MPEG1or2VideoRTPSink::doSpecialFrameHandling(), MP3ADURTPSink::doSpecialFrameHandling(), H263plusVideoRTPSink::doSpecialFrameHandling(), ByteStreamFileSource::doStopGettingFrames(), BasicUDPSource::doStopGettingFrames(), SegmentQueue::enqueueNewSegment(), StreamParser::ensureValidBytes1(), MediaSubsession::env(), SubsessionIOState::envir(), RTSPServer::RTSPClientSession::envir(), RTSPOverHTTPServer::HTTPClientConnection::envir(), RTPInterface::envir(), AVISubsessionIOState::envir(), ServerMediaSession::generateSDPDescription(), RTPSource::getAttributes(), MP3FileSource::getAttributes(), MP3ADUTranscoder::getAttributes(), MediaSource::getAttributes(), MPEG4VideoFileServerMediaSubsession::getAuxSDPLine(), getMPEG1or2TimeCode(), FramedSource::getNextFrame(), getOptions(), DVVideoStreamFramer::getProfile(), SIPClient::getResponse(), SIPClient::getResponseCode(), getSDPDescription(), OnDemandServerMediaSubsession::getStreamParameters(), RTSPClient::handleGET_PARAMETERResponse(), RTSPClient::handleIncomingRequest(), RTSPClient::handlePLAYResponse(), RTSPClient::handleRequestError(), RTSPClient::handleResponseBytes(), RTSPClient::handleSETUPResponse(), RTSPServer::incomingConnectionHandler1(), RTSPOverHTTPServer::incomingConnectionHandler1(), RTSPClient::incomingDataHandler1(), RTCPInstance::incomingReportHandler1(), MP3FileSource::initializeStream(), initializeWithSDP(), initiateByMediaType(), SIPClient::invite1(), DynamicRTSPServer::lookupServerMediaSession(), MPEG4GenericRTPSource::MPEG4GenericRTPSource(), MPEG1or2FileServerDemux::newElementaryStream(), MPEG1or2Demux::newElementaryStream(), MPEG4GenericBufferedPacket::nextEnclosedFrameSize(), AMRBufferedPacket::nextEnclosedFrameSize(), RTSPClient::openConnection(), MPEG2TransportStreamIndexFile::openFid(), MPEG2IFrameIndexFromTransportStream::parseFrame(), AC3AudioStreamParser::parseFrame(), MPEGProgramStreamParser::parsePackHeader(), MPEGProgramStreamParser::parsePESPacket(), SIPClient::parseResponseCode(), parseSDPLine(), MPEG1or2VideoStreamParser::parseSlice(), MPEGProgramStreamParser::parseSystemHeader(), MPEG4VideoStreamParser::parseVideoObjectLayer(), MPEG4VideoStreamParser::parseVideoObjectPlane(), MPEG4VideoStreamParser::parseVisualObject(), AC3AudioRTPSource::processSpecialHeader(), SIPClient::processURL(), AC3AudioStreamParser::readAndSaveAFrame(), MPEG1or2Demux::registerReadInterest(), RTCPInstance::reschedule(), RTSPClient::resendCommand(), RTSPClient::resetTCPSockets(), RTSPClient::responseHandlerForHTTP_GET1(), RTSPServer::rtspURLPrefix(), RTCPInstance::schedule(), OnDemandServerMediaSubsession::sdpLines(), SIPClient::sendACK(), SIPClient::sendBYE(), SIPClient::sendINVITE(), MultiFramedRTPSink::sendPacketIfNecessary(), SIPClient::sendRequest(), RTSPClient::sendRequest(), DarwinInjector::setDestination(), RTSPClient::setupHTTPTunneling1(), QuickTimeFileSink::setWord(), AVIFileSink::setWord(), QuickTimeFileSink::setWord64(), SIPClient::SIPClient(), AMRAudioRTPSink::sourceIsCompatibleWithUs(), QuickTimeFileSink::startPlaying(), StreamState::startPlaying(), MediaSink::startPlaying(), AVIFileSink::startPlaying(), startPlayingSession(), PassiveServerMediaSubsession::startStream(), MediaSink::stopPlaying(), tearDownSession(), SIPClient::timerAHandler(), SIPClient::timerBHandler(), SIPClient::timerDHandler(), ClientTrickPlayState::updateStateOnScaleChange(), MPEG2TransportStreamFramer::updateTSPacketDurationEstimate(), BasicUDPSource::~BasicUDPSource(), ByteStreamFileSource::~ByteStreamFileSource(), RTSPOverHTTPServer::HTTPClientConnection::~HTTPClientConnection(), and RTSPServer::~RTSPServer().

00059 {return fEnviron;}

char const* Medium::name (  )  const [inline, inherited]

Definition at line 61 of file Media.hh.

References Medium::fMediumName.

Referenced by QuickTimeFileSink::addAtom_hdlr2(), Medium::close(), MP3ADUTranscoder::createNew(), MP3FromADUSource::createNew(), ADUFromMP3Source::createNew(), and MP3FileSource::initializeStream().

00061 {return fMediumName;}

Boolean Medium::isSource (  )  const [virtual, inherited]

Reimplemented in MediaSource.

Definition at line 86 of file Media.cpp.

References False.

Referenced by MediaSource::lookupByName().

00086                                {
00087   return False; // default implementation
00088 }

Boolean Medium::isSink (  )  const [virtual, inherited]

Reimplemented in MediaSink.

Definition at line 90 of file Media.cpp.

References False.

Referenced by MediaSink::lookupByName().

00090                              {
00091   return False; // default implementation
00092 }

Boolean Medium::isRTCPInstance (  )  const [virtual, inherited]

Reimplemented in RTCPInstance.

Definition at line 94 of file Media.cpp.

References False.

Referenced by RTCPInstance::lookupByName().

00094                                      {
00095   return False; // default implementation
00096 }

Boolean Medium::isRTSPClient (  )  const [virtual, inherited]

Reimplemented in RTSPClient.

Definition at line 98 of file Media.cpp.

References False.

Referenced by RTSPClient::lookupByName().

00098                                    {
00099   return False; // default implementation
00100 }

Boolean Medium::isRTSPServer (  )  const [virtual, inherited]

Reimplemented in RTSPServer.

Definition at line 102 of file Media.cpp.

References False.

Referenced by RTSPServer::lookupByName().

00102                                    {
00103   return False; // default implementation
00104 }

Boolean Medium::isServerMediaSession (  )  const [virtual, inherited]

Reimplemented in ServerMediaSession.

Definition at line 110 of file Media.cpp.

References False.

Referenced by ServerMediaSession::lookupByName().

00110                                            {
00111   return False; // default implementation
00112 }

Boolean Medium::isDarwinInjector (  )  const [virtual, inherited]

Reimplemented in DarwinInjector.

Definition at line 114 of file Media.cpp.

References False.

Referenced by DarwinInjector::lookupByName().

00114                                        {
00115   return False; // default implementation
00116 }

TaskToken& Medium::nextTask (  )  [inline, protected, inherited]

Definition at line 77 of file Media.hh.

References Medium::fNextTask.

Referenced by BasicUDPSink::afterGettingFrame1(), MPEG4VideoFileServerMediaSubsession::afterPlayingDummy1(), MPEG4VideoFileServerMediaSubsession::checkForAuxSDPLine1(), WAVAudioFileSource::doGetNextFrame(), MP3FileSource::doGetNextFrame(), AMRAudioFileSource::doGetNextFrame(), ADTSAudioFileSource::doGetNextFrame(), MultiFramedRTPSource::doGetNextFrame1(), ByteStreamFileSource::doReadFromFile(), RTCPInstance::reschedule(), RTCPInstance::schedule(), MultiFramedRTPSink::sendPacketIfNecessary(), and MediaSink::stopPlaying().

00077                         {
00078         return fNextTask;
00079   }


Friends And Related Function Documentation

friend class MediaSubsessionIterator [friend]

Definition at line 84 of file MediaSession.hh.


Field Documentation

char* MediaSession::fCNAME [protected]

Definition at line 85 of file MediaSession.hh.

Referenced by CNAME(), MediaSession(), and ~MediaSession().

MediaSubsession* MediaSession::fSubsessionsHead [protected]

Definition at line 88 of file MediaSession.hh.

Referenced by hasSubsessions(), initializeWithSDP(), MediaSubsessionIterator::reset(), and ~MediaSession().

MediaSubsession* MediaSession::fSubsessionsTail [protected]

Definition at line 89 of file MediaSession.hh.

Referenced by initializeWithSDP().

char* MediaSession::fConnectionEndpointName [protected]

Definition at line 92 of file MediaSession.hh.

Referenced by connectionEndpointName(), parseSDPLine_c(), and ~MediaSession().

double MediaSession::fMaxPlayStartTime [protected]

Definition at line 93 of file MediaSession.hh.

Referenced by parseSDPAttribute_range(), and playStartTime().

double MediaSession::fMaxPlayEndTime [protected]

Definition at line 94 of file MediaSession.hh.

Referenced by parseSDPAttribute_range(), and playEndTime().

struct in_addr MediaSession::fSourceFilterAddr [read, protected]

Definition at line 95 of file MediaSession.hh.

Referenced by MediaSession(), parseSDPAttribute_source_filter(), and sourceFilterAddr().

float MediaSession::fScale [protected]

Definition at line 96 of file MediaSession.hh.

Referenced by scale().

char* MediaSession::fMediaSessionType [protected]

Definition at line 97 of file MediaSession.hh.

Referenced by mediaSessionType(), parseSDPAttribute_type(), and ~MediaSession().

char* MediaSession::fSessionName [protected]

Definition at line 98 of file MediaSession.hh.

Referenced by parseSDPLine_s(), sessionName(), and ~MediaSession().

char* MediaSession::fSessionDescription [protected]

Definition at line 99 of file MediaSession.hh.

Referenced by parseSDPLine_i(), sessionDescription(), and ~MediaSession().

char* MediaSession::fControlPath [protected]

Definition at line 100 of file MediaSession.hh.

Referenced by controlPath(), parseSDPAttribute_control(), and ~MediaSession().


The documentation for this class was generated from the following files:
Generated on Fri Sep 3 02:37:21 2010 for live by  doxygen 1.5.2