mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-07-04 09:47:33 +08:00
优化函数命名风格
FindField改名为findSubString
This commit is contained in:
@@ -180,11 +180,11 @@ void SdpParser::load(const string &sdp) {
|
||||
break;
|
||||
}
|
||||
case 'a': {
|
||||
string attr = FindField(opt_val.data(), nullptr, ":");
|
||||
string attr = findSubString(opt_val.data(), nullptr, ":");
|
||||
if (attr.empty()) {
|
||||
track->_attr.emplace(opt_val, "");
|
||||
} else {
|
||||
track->_attr.emplace(attr, FindField(opt_val.data(), ":", nullptr));
|
||||
track->_attr.emplace(attr, findSubString(opt_val.data(), ":", nullptr));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -245,7 +245,7 @@ void SdpParser::load(const string &sdp) {
|
||||
it = track._attr.erase(it);
|
||||
continue;
|
||||
}
|
||||
track._fmtp = FindField(fmtp.data(), " ", nullptr);
|
||||
track._fmtp = findSubString(fmtp.data(), " ", nullptr);
|
||||
++it;
|
||||
}
|
||||
|
||||
|
||||
@@ -273,7 +273,7 @@ void RtspPlayer::handleResSETUP(const Parser &parser, unsigned int track_idx) {
|
||||
if (track_idx == 0) {
|
||||
_session_id = parser["Session"];
|
||||
_session_id.append(";");
|
||||
_session_id = FindField(_session_id.data(), nullptr, ";");
|
||||
_session_id = findSubString(_session_id.data(), nullptr, ";");
|
||||
}
|
||||
|
||||
auto strTransport = parser["Transport"];
|
||||
@@ -469,7 +469,7 @@ void RtspPlayer::handleResPAUSE(const Parser &parser, int type) {
|
||||
// 修正时间轴
|
||||
auto strRange = parser["Range"];
|
||||
if (strRange.size()) {
|
||||
auto strStart = FindField(strRange.data(), "npt=", "-");
|
||||
auto strStart = findSubString(strRange.data(), "npt=", "-");
|
||||
if (strStart == "now") {
|
||||
strStart = "0";
|
||||
}
|
||||
|
||||
@@ -291,13 +291,13 @@ void RtspPusher::handleResSetup(const Parser &parser, unsigned int track_idx) {
|
||||
if (track_idx == 0) {
|
||||
_session_id = parser["Session"];
|
||||
_session_id.append(";");
|
||||
_session_id = FindField(_session_id.data(), nullptr, ";");
|
||||
_session_id = findSubString(_session_id.data(), nullptr, ";");
|
||||
}
|
||||
|
||||
auto transport = parser["Transport"];
|
||||
if (transport.find("TCP") != string::npos || transport.find("interleaved") != string::npos) {
|
||||
_rtp_type = Rtsp::RTP_TCP;
|
||||
string interleaved = FindField(FindField((transport + ";").data(), "interleaved=", ";").data(), NULL, "-");
|
||||
string interleaved = findSubString(findSubString((transport + ";").data(), "interleaved=", ";").data(), NULL, "-");
|
||||
_track_vec[track_idx]->_interleaved = atoi(interleaved.data());
|
||||
} else if (transport.find("multicast") != string::npos) {
|
||||
throw std::runtime_error("SETUP rtsp pusher can not support multicast!");
|
||||
@@ -305,9 +305,9 @@ void RtspPusher::handleResSetup(const Parser &parser, unsigned int track_idx) {
|
||||
_rtp_type = Rtsp::RTP_UDP;
|
||||
createUdpSockIfNecessary(track_idx);
|
||||
const char *strPos = "server_port=";
|
||||
auto port_str = FindField((transport + ";").data(), strPos, ";");
|
||||
uint16_t rtp_port = atoi(FindField(port_str.data(), NULL, "-").data());
|
||||
uint16_t rtcp_port = atoi(FindField(port_str.data(), "-", NULL).data());
|
||||
auto port_str = findSubString((transport + ";").data(), strPos, ";");
|
||||
uint16_t rtp_port = atoi(findSubString(port_str.data(), NULL, "-").data());
|
||||
uint16_t rtcp_port = atoi(findSubString(port_str.data(), "-", NULL).data());
|
||||
auto &rtp_sock = _rtp_sock[track_idx];
|
||||
auto &rtcp_sock = _rtcp_sock[track_idx];
|
||||
|
||||
|
||||
@@ -595,8 +595,8 @@ void RtspSession::onAuthUser(const string &realm,const string &authorization){
|
||||
return;
|
||||
}
|
||||
//请求中包含认证信息
|
||||
auto authType = FindField(authorization.data(),NULL," ");
|
||||
auto authStr = FindField(authorization.data()," ",NULL);
|
||||
auto authType = findSubString(authorization.data(), NULL, " ");
|
||||
auto authStr = findSubString(authorization.data(), " ", NULL);
|
||||
if(authType.empty() || authStr.empty()){
|
||||
//认证信息格式不合法,回复401 Unauthorized
|
||||
onAuthFailed(realm,"can not find auth type or auth string");
|
||||
@@ -690,9 +690,9 @@ void RtspSession::handleReq_Setup(const Parser &parser) {
|
||||
_rtcp_socks[trackIdx] = pr.second;
|
||||
|
||||
//设置客户端内网端口信息
|
||||
string strClientPort = FindField(parser["Transport"].data(), "client_port=", NULL);
|
||||
uint16_t ui16RtpPort = atoi(FindField(strClientPort.data(), NULL, "-").data());
|
||||
uint16_t ui16RtcpPort = atoi(FindField(strClientPort.data(), "-", NULL).data());
|
||||
string strClientPort = findSubString(parser["Transport"].data(), "client_port=", NULL);
|
||||
uint16_t ui16RtpPort = atoi(findSubString(strClientPort.data(), NULL, "-").data());
|
||||
uint16_t ui16RtcpPort = atoi(findSubString(strClientPort.data(), "-", NULL).data());
|
||||
|
||||
auto peerAddr = SockUtil::make_sockaddr(get_peer_ip().data(), ui16RtpPort);
|
||||
//设置rtp发送目标地址
|
||||
@@ -785,7 +785,7 @@ void RtspSession::handleReq_Play(const Parser &parser) {
|
||||
if (!strRange.empty()) {
|
||||
//这是seek操作
|
||||
res_header.emplace("Range", strRange);
|
||||
auto strStart = FindField(strRange.data(), "npt=", "-");
|
||||
auto strStart = findSubString(strRange.data(), "npt=", "-");
|
||||
if (strStart == "now") {
|
||||
strStart = "0";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user