RTSP协议的处理--OPTIONS

  一、ABLMediaServer的处理

1、涉及的数据结构

RtspProtect RtspProtectArray[MaxRtspProtectCount];
int RtspProtectArrayOrder;
struct RtspFieldValue
{
  char szKey[64];
  char szValue[384];
};

//rtsp 协议数据
struct RtspProtect
{
  char szRtspCmdString[512];// OPTIONS rtsp://190.15.240.36:554/Camera_00001.sdp RTSP/1.0
  char szRtspCommand[64];// rtsp命令名字 ,OPTIONS ANNOUNCE SETUP RECORD
  char szRtspURL[512];// rtsp://190.15.240.36:554/Camera_00001.sdp

  RtspFieldValue rtspField[MaxRtspValueCount];
  char szRtspContentSDP[1024]; // 媒体描述内容
  int nRtspSDPLength;
};

 2、NetRtspServer.cpp中ProcessNetData函数调用FillHttpHeadToStruct函数。

3、NetRtspServer.cpp中FillHttpHeadToStruct函数

(1)通过for循环,szTemp存的为每行的数据。

(2)第一个循环得到szTemp通过GetHttpModemHttpURL解析。

3、NetRtspServer.cpp中GetHttpModemHttpURL函数

通过“ ”区分

(1)strcpy(RtspProtectArray[RtspProtectArrayOrder].szRtspCmdString, szMedomHttpURL);

OPTIONS rtsp://192.168.169.130:554/live/Camera_00001 RTSP/1.0

(2)memcpy(RtspProtectArray[RtspProtectArrayOrder].szRtspCommand, szMedomHttpURL, nPos1);

OPTIONS

(3)strcpy(RtspProtectArray[RtspProtectArrayOrder].szRtspURL, strTempRtsp.c_str());

rtsp://192.168.169.130:554/live/Camera_00001

4.NetRtspServer.cpp中FillHttpHeadToStruc中

在if ((nFlagLength = FindKeyValueFlag(szTemp)) >= 0)

解析其他的行,由FindKeyValueFlag通过“:”分隔key和value.

CSeq-1  

User-Agent-Lavf58.29.100 

二、ZLMediaKit的处理

1.Parser.cpp文件中Parser类

std::string _strMethod;
std::string _strUrl;
std::string _strTail;
std::string _strContent;
std::string _strNull;
std::string _params;
mutable StrCaseMap _mapHeaders;
mutable StrCaseMap _mapUrlArgs;

2.Parser::Parse函数

(1)line通过FindField得到每一行的函数。

(2)在每一行中,还是通过FindField解析得到每一个属性。

(3)if (start == buf)是解析第一行,else是解析其他的行。

    _strMethod--OPTIONS

   _strUrl--rtsp://192.168.169.130:554/live/Camera_00001

   _strTail--RTSP/1.0

(4)在第二行中,解析key--CSeq,value--1,存入到_mapHeaders。

(5)其他的都为空,没有解析。

(6)_mapUrlArgs为解析url的参数,暂时没用到。

posted @ 2022-11-07 10:52  泽良_小涛  阅读(146)  评论(0编辑  收藏  举报