RTSP Announce命令是数据源向Darwin服务端主动发起的上报本地媒体sdp信息的命令,在Darwin中处理该命令的函数为QTSSReflectorModule模块的DoAnnounce()函数,下面对该函数的进行剖析:
【转载请注明出处】:http://blog.csdn.net/longlong530
1. 判断sAnnounceEnabled是否开启,由以下配置项确定,默认为true
<PREF NAME="enable_broadcast_announce" TYPE="Bool16" >true</PREF>
2. 通过键值qtssRTSPReqLocalPath获取完整的转发路径,比如D:\MSU\Movies\34020000001320000008.sdp
3. 验证上面路径的结尾是否为.kill,如果是设置killBroadcast为true,那么下面就会进入KillSession流程if (killBroadcast) { theFullPath.Len -= sSDPKillSuffix.Len; if (KillSession(&theFullPath, killBroadcast)) return QTSSModuleUtils::SendErrorResponse(inParams->inRTSPRequest, qtssServerInternal,0); else return QTSSModuleUtils::SendErrorResponseWithMessage(inParams->inRTSPRequest, qtssClientNotFound, &sKILLNotValidMessage); }
//theBufferOffset直接被设置为0,这里好像没有用到该偏移值; //这里通过该方法将RTSP请求消息中的sdp字符串解析出来了。 theErr = QTSS_Read(inParams->inRTSPRequest, theRequestBody + theBufferOffset, *theContentLenP - theBufferOffset, &theLen);
SDPLineSorter sortedSDP(&checkedSDPContainer ); // ------------ Write the SDP //SDP字符串中的会话相关字段 /* v=0 o=- 0 0 IN IP4 192.168.10.177 s=PLAY c=IN IP4 192.168.10.177 t=0 0 a=x-qt-text-nam:PLAY a=x-qt-text-inf:LIVE555 Streaming Media a=x-qt-text-cmt:source application:PLAY a=x-qt-text-aut: a=x-qt-text-cpy: */ char* sessionHeaders = sortedSDP.GetSessionHeaders()->GetAsCString(); OSCharArrayDeleter sessionHeadersDeleter(sessionHeaders); //SDP字符串中的媒体相关字段 /* m=video 20020 RTP/AVP 96 a=rtpmap:96 PS/90000 a=fmtp:96 packetization-mode=1;profile-level-id=4D4033;sprop-parameter-sets=Z01AM5p0FCNCAAEEugA9CQEeMGVA,aO48gA== a=control:trackID=1 */ char* mediaHeaders = sortedSDP.GetMediaHeaders()->GetAsCString(); OSCharArrayDeleter mediaHeadersDeleter(mediaHeaders);