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

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

【转载请注明出处】:

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

StrPtrLen theMode;theSubHeaderParser.ConsumeWord(&theMode);//mode="receive" || mode="record"表示isPush为true,即为推模式。if ( theMode.EqualIgnoreCase(sReceiveMode) || theMode.EqualIgnoreCase(sRecordMode) ){<span style="white-space:pre"></span>fTransportMode = qtssRTPTransportModeRecord;<span style="white-space:pre"></span>break;}

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

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

//增加客户端输出管道(多路转发); RTPSessionOutput* theNewOutput = NEW RTPSessionOutput(inParams->inClientSession, theSession, sServerPrefs, sStreamCookieAttr ); theSession->AddOutput(theNewOutput,true); //将新建的RTPSessionOutput存储起来,key = sOutputAttr; (void)QTSS_SetValue(inParams->inClientSession, sOutputAttr, 0, &theNewOutput, sizeof(theNewOutput));1.2) 如果isPush = true,代表为Announce推流中的SETUP消息,那么/*根据前面Announce中存储于qtssRTSPReqLocalPath的路径读取sdp信息,调用DoSessionSetup创建或引用已存在的ReflectorSession<span style="font-family: Arial, Helvetica, sans-serif;">转发会话</span><span style="font-family: Arial, Helvetica, sans-serif;"> </span>*/ theSession = DoSessionSetup(inParams, qtssRTSPReqFilePathTrunc,isPush,&foundSession);

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

3. 解析track ID,,后面会根据这个track id来获取流信息 char* theDigitStr = NULL;(void)QTSS_GetValueAsString(inParams->inRTSPRequest, qtssRTSPReqFileDigit, 0, &theDigitStr); QTSSCharArrayDeleter theDigitStrDeleter(theDigitStr);4. 如果是推流模式://标识流转发的建立theStreamInfo->fSetupToReceive = true;// This is an incoming data session. Set the Reflector Session in the ClientSession//设置转发会话的RTPSession字典的sClientBroadcastSessionAttr字段theErr = QTSS_SetValue(inParams->inClientSession, sClientBroadcastSessionAttr, 0, &theSession, sizeof(theSession));Assert(theErr == QTSS_NoErr);//设置ReflectorSession的fBroadcasterSession属性为inParams->inClientSessionif (theSession != NULL)theSession->AddBroadcasterClientSession(inParams);【转载请注明出处】:

有理想在的地方,地狱就是天堂

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

相关文章:

你感兴趣的文章:

标签云: