Advertisement
mschuck

MyRTSPClient::sendSetParametersCommand

Sep 24th, 2012
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.31 KB | None | 0 0
  1. unsigned MyRTSPClient::sendSetParametersCommand(
  2.   MediaSession& session
  3.   ,responseHandler* responseHandler
  4.   ,unsigned int parameterCount
  5.   ,char const** parameterNames
  6.   ,char const** parameterValues
  7.   ,Authenticator* authenticator)
  8. {
  9.   if (authenticator != NULL)
  10.     fCurrentAuthenticator = *authenticator;
  11.  
  12.   //Construct the parameters section.
  13.   //First figure out how long of a string we will need to store
  14.   //each name value \r\n pair.
  15.   int parameterSectionLen = 0;
  16.   for( int i = 0; i != parameterCount; ++i )
  17.   {
  18.     parameterSectionLen += strlen(parameterNames[i]);
  19.     parameterSectionLen += strlen(parameterValues[i]);
  20.     parameterSectionLen += 4; //+4 is for the ": " between the value and the parameter and the \r\n after the parameter "name: value"
  21.   }
  22.   //Now new a string big enough to hold the formated parameter list.
  23.   char* paramString = new char[parameterSectionLen+1];
  24.   char* pos = paramString;
  25.  
  26.   //Now format all the parameter "name: value\r\n" lines.
  27.   for( int i = 0; i != parameterCount; ++i )
  28.   {
  29.     pos += sprintf( pos, "%s: %s\r\n", parameterNames[i], parameterValues[i] );
  30.   }
  31.  
  32.   unsigned result = sendRequest(new RequestRecord(++fCSeq, "SET_PARAMETER", responseHandler, &session, NULL, False, 0.0, 0.0, 0.0, paramString));
  33.   delete[] paramString;
  34.   return result;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement