Refine: 优化rtsp相关代码

This commit is contained in:
ziyue
2022-01-12 15:21:33 +08:00
parent 5b6ff0af27
commit d52fc4c31f
4 changed files with 22 additions and 17 deletions

View File

@@ -1098,36 +1098,36 @@ bool RtspSession::sendRtspResponse(const string &res_code, const std::initialize
}
int RtspSession::getTrackIndexByTrackType(TrackType type) {
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
for (size_t i = 0; i < _sdp_track.size(); ++i) {
if (type == _sdp_track[i]->_type) {
return i;
}
}
if(_sdp_track.size() == 1){
if (_sdp_track.size() == 1) {
return 0;
}
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << (int) type);
throw SockException(Err_shutdown, StrPrinter << "no such track with type:" << getTrackString(type));
}
int RtspSession::getTrackIndexByControlUrl(const string &control_url) {
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
for (size_t i = 0; i < _sdp_track.size(); ++i) {
if (control_url == _sdp_track[i]->getControlUrl(_content_base)) {
return i;
}
}
if(_sdp_track.size() == 1){
if (_sdp_track.size() == 1) {
return 0;
}
throw SockException(Err_shutdown, StrPrinter << "no such track with control url:" << control_url);
}
int RtspSession::getTrackIndexByInterleaved(int interleaved){
for (unsigned int i = 0; i < _sdp_track.size(); i++) {
int RtspSession::getTrackIndexByInterleaved(int interleaved) {
for (size_t i = 0; i < _sdp_track.size(); ++i) {
if (_sdp_track[i]->_interleaved == interleaved) {
return i;
}
}
if(_sdp_track.size() == 1){
if (_sdp_track.size() == 1) {
return 0;
}
throw SockException(Err_shutdown, StrPrinter << "no such track with interleaved:" << interleaved);