Example #1
0
inline int RtspPlayer::onProcess(const char* pcBuf) {
    auto strRtsp = FindField(pcBuf, "RTSP", "\r\n\r\n");
    if(strRtsp.empty()){
        return 4;
    }
    strRtsp = string("RTSP") + strRtsp + "\r\n\r\n";
	Parser parser;
	parser.Parse(strRtsp.data());
    int iLen = 0;
	if (parser.Url() == "200") {
		iLen = atoi(parser["Content-Length"].data());
		if (iLen) {
			string strContent(pcBuf + strRtsp.size(), iLen);
			parser.setContent(strContent);
		}
	}
	auto fun = m_onHandshake;
	m_onHandshake = nullptr;
    if(fun){
        fun(parser);
    }
	parser.Clear();
    return strRtsp.size() + iLen;
}