【Darwin学习笔记】之QTSSReflectorModule的Setup消息处理

来源:互联网 发布:java set和get意义 编辑:程序博客网 时间:2024/05/17 09:43

Setup消息进入到DoSetup函数单独处理,处理流程如下:

【转载请注明出处】:http://blog.csdn.net/longlong530

1. 根据关键字qtssRTSPReqTransportMode判断是否为推模式,具体isPush值由Setup请求中的mode值有关,mode="receive" || mode="record"表示isPush为true。对应的解析函数为:void RTSPRequest::ParseModeSubHeader(StrPtrLen* inModeSubHeader)

[cpp] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. StrPtrLen theMode;  
  2. theSubHeaderParser.ConsumeWord(&theMode);  
  3. //mode="receive" || mode="record"表示isPush为true,即为推模式。  
  4. if ( theMode.EqualIgnoreCase(sReceiveMode) || theMode.EqualIgnoreCase(sRecordMode) )  
  5. {     
  6.     fTransportMode = qtssRTPTransportModeRecord;  
  7.     break;  
  8. }  

2. 查询是否已经建立RTPSessionOutput。

1.1)    如果没有,且是从UI发来的标准RTSP客户端请求,那么

[cpp] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. //增加客户端输出管道(多路转发);  
  2.  RTPSessionOutput* theNewOutput = NEW RTPSessionOutput(inParams->inClientSession, theSession, sServerPrefs, sStreamCookieAttr );  
  3.  theSession->AddOutput(theNewOutput,true);  
  4.  //将新建的RTPSessionOutput存储起来,key = sOutputAttr;  
  5.  (void)QTSS_SetValue(inParams->inClientSession, sOutputAttr, 0, &theNewOutput, sizeof(theNewOutput));  
1.2)   如果isPush = true,代表为Announce推流中的SETUP消息,那么

[cpp] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. /* 
  2. 根据前面Announce中存储于qtssRTSPReqLocalPath的路径读取sdp信息,调用DoSessionSetup创建或引用已存在的ReflectorSession<span style="font-family: Arial, Helvetica, sans-serif;">转发会话</span><span style="font-family: Arial, Helvetica, sans-serif;"> </span> 
  3. */  
  4.  theSession = DoSessionSetup(inParams, qtssRTSPReqFilePathTrunc,isPush,&foundSession);  

2) 如果已经存在输出会话,即直接调用。


3. 解析track ID,后面会根据这个track id来获取流信息

[cpp] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. char* theDigitStr = NULL;  
  2. void)QTSS_GetValueAsString(inParams->inRTSPRequest, qtssRTSPReqFileDigit, 0, &theDigitStr);  
  3. QTSSCharArrayDeleter theDigitStrDeleter(theDigitStr);  

4. 如果是推流模式:

[cpp] view plain copy
 print?在CODE上查看代码片派生到我的代码片
  1. //标识流转发的建立  
  2.         theStreamInfo->fSetupToReceive = true;  
  3.         // This is an incoming data session. Set the Reflector Session in the ClientSession  
  4.         //设置转发会话的RTPSession字典的sClientBroadcastSessionAttr字段  
  5.         theErr = QTSS_SetValue(inParams->inClientSession, sClientBroadcastSessionAttr, 0, &theSession, sizeof(theSession));  
  6.         Assert(theErr == QTSS_NoErr);  
  7.         //设置ReflectorSession的fBroadcasterSession属性为inParams->inClientSession  
  8.         if (theSession != NULL)  
  9.             theSession->AddBroadcasterClientSession(inParams);  

0 0