ZLMedia中RTSP协议的处理简要分析(4)--record
推流数据开始前用record命令。回复的代码如下
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
void RtspSession::handleReq_RECORD(const Parser &parser){ if (_sdp_track.empty() || parser["Session"] != _sessionid) { send_SessionNotFound(); throw SockException(Err_shutdown, _sdp_track.empty() ? "can not find any availabe track when record" : "session not found when record"); } _StrPrinter rtp_info; for (auto &track : _sdp_track) { if (track->_inited == false) { //还有track没有setup shutdown(SockException(Err_shutdown, "track not setuped")); return; } rtp_info << "url=" << track->getControlUrl(_content_base) << ","; } rtp_info.pop_back(); sendRtspResponse("200 OK", {"RTP-Info", rtp_info}); if (_rtp_type == Rtsp::RTP_TCP) { //如果是rtsp推流服务器,并且是TCP推流,设置socket flags,,这样能提升接收性能 setSocketFlags(); } }
1.其关键代码
for (auto &track : _sdp_track) {
...............
rtp_info << "url=" << track->getControlUrl(_content_base) << ",";
}
产生RTP-Info部分
![](https://img2022.cnblogs.com/blog/2525040/202207/2525040-20220722172432256-1632249999.png)
2.对网络进行了设置。
对 CP_NODELAY设置为0,关闭了延时。