liveMedia/RTSPClient.cpp File Reference

#include "RTSPClient.hh"
#include "RTSPCommon.hh"
#include "Base64.hh"
#include "Locale.hh"
#include <GroupsockHelper.hh>
#include "ourMD5.hh"

Include dependency graph for RTSPClient.cpp:

Go to the source code of this file.

Functions

static char * createSessionString (char const *sessionId)
static char * createScaleString (float scale, float currentScale)
static char * createRangeString (double start, double end, char const *absStartTime, char const *absEndTime)
static Boolean isAbsoluteURL (char const *url)
static char * getLine (char *startOfLine)


Function Documentation

static char* createRangeString ( double  start,
double  end,
char const *  absStartTime,
char const *  absEndTime 
) [static]

Definition at line 555 of file RTSPClient.cpp.

References NULL, Numeric, and strDup().

Referenced by RTSPClient::setRequestFields().

00555                                                                                                            {
00556   char buf[100];
00557 
00558   if (absStartTime != NULL) {
00559     // Create a "Range:" header that specifies 'absolute' time values:
00560 
00561     if (absEndTime == NULL) {
00562       // There's no end time:
00563       snprintf(buf, sizeof buf, "Range: clock=%s-\r\n", absStartTime);
00564     } else {
00565       // There's both a start and an end time; include them both in the "Range:" hdr
00566       snprintf(buf, sizeof buf, "Range: clock=%s-%s\r\n", absStartTime, absEndTime);
00567     }
00568   } else {
00569     // Create a "Range:" header that specifies relative (i.e., NPT) time values:
00570 
00571     if (start < 0) {
00572       // We're resuming from a PAUSE; there's no "Range:" header at all
00573       buf[0] = '\0';
00574     } else if (end < 0) {
00575       // There's no end time:
00576       Locale l("C", Numeric);
00577       sprintf(buf, "Range: npt=%.3f-\r\n", start);
00578     } else {
00579       // There's both a start and an end time; include them both in the "Range:" hdr
00580       Locale l("C", Numeric);
00581       sprintf(buf, "Range: npt=%.3f-%.3f\r\n", start, end);
00582     }
00583   }
00584 
00585   return strDup(buf);
00586 }

static char* createScaleString ( float  scale,
float  currentScale 
) [static]

Definition at line 542 of file RTSPClient.cpp.

References Numeric, and strDup().

Referenced by RTSPClient::setRequestFields().

00542                                                                 {
00543   char buf[100];
00544   if (scale == 1.0f && currentScale == 1.0f) {
00545     // This is the default value; we don't need a "Scale:" header:
00546     buf[0] = '\0';
00547   } else {
00548     Locale l("C", Numeric);
00549     sprintf(buf, "Scale: %f\r\n", scale);
00550   }
00551 
00552   return strDup(buf);
00553 }

static char* createSessionString ( char const *  sessionId  )  [static]

Definition at line 531 of file RTSPClient.cpp.

References NULL, and strDup().

Referenced by RTSPClient::setRequestFields().

00531                                                         {
00532   char* sessionStr;
00533   if (sessionId != NULL) {
00534     sessionStr = new char[20+strlen(sessionId)];
00535     sprintf(sessionStr, "Session: %s\r\n", sessionId);
00536   } else {
00537     sessionStr = strDup("");
00538   }
00539   return sessionStr;
00540 }

static char* getLine ( char *  startOfLine  )  [static]

Definition at line 1448 of file RTSPClient.cpp.

References NULL.

Referenced by SIPClient::getResponseCode(), RTSPClient::handleResponseBytes(), and setupSubsession().

01448                                         {
01449   // returns the start of the next line, or NULL if none.  Note that this modifies the input string to add '\0' characters.
01450   for (char* ptr = startOfLine; *ptr != '\0'; ++ptr) {
01451     // Check for the end of line: \r\n (but also accept \r or \n by itself):
01452     if (*ptr == '\r' || *ptr == '\n') {
01453       // We found the end of the line
01454       if (*ptr == '\r') {
01455         *ptr++ = '\0';
01456         if (*ptr == '\n') ++ptr;
01457       } else {
01458         *ptr++ = '\0';
01459       }
01460       return ptr;
01461     }
01462   }
01463 
01464   return NULL;
01465 }

static Boolean isAbsoluteURL ( char const *  url  )  [static]

Definition at line 1285 of file RTSPClient.cpp.

References False, and True.

Referenced by RTSPClient::constructSubsessionURL().

01285                                               {
01286   // Assumption: "url" is absolute if it contains a ':', before any
01287   // occurrence of '/'
01288   while (*url != '\0' && *url != '/') {
01289     if (*url == ':') return True;
01290     ++url;
01291   }
01292 
01293   return False;
01294 }


Generated on Tue Mar 25 14:38:27 2014 for live by  doxygen 1.5.2