From 97ee989a94a8bf584e4ff7ebb3d1ce1f5ecc23a9 Mon Sep 17 00:00:00 2001 From: Andrew Bauer Date: Tue, 2 Dec 2014 19:33:05 -0600 Subject: [PATCH] Parse multiple streams in RTP-Info --- src/zm_rtsp.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/src/zm_rtsp.cpp b/src/zm_rtsp.cpp index fd3be18be0..cdba32a530 100644 --- a/src/zm_rtsp.cpp +++ b/src/zm_rtsp.cpp @@ -397,6 +397,7 @@ int RtspThread::run() uint32_t rtpClock = 0; std::string trackUrl = mUrl; + std::string controlUrl; _AVCODECID codecId; @@ -412,7 +413,7 @@ int RtspThread::run() #endif { // Check if control Url is absolute or relative - std::string controlUrl = mediaDesc->getControlUrl(); + controlUrl = mediaDesc->getControlUrl(); if (std::equal(trackUrl.begin(), trackUrl.end(), controlUrl.begin())) { trackUrl = controlUrl; @@ -569,6 +570,7 @@ int RtspThread::run() int seq = 0; unsigned long rtpTime = 0; + StringVector streams; if ( rtpInfo.empty() ) { Debug( 1, "RTP Info Empty. Starting values for Sequence and Rtptime shall be zero."); @@ -576,19 +578,29 @@ int RtspThread::run() else { Debug( 2, "Got RTP Info %s", rtpInfo.c_str() ); - - parts = split( rtpInfo.c_str(), ";" ); - for ( size_t i = 0; i < parts.size(); i++ ) + // More than one stream can be included in the RTP Info + streams = split( rtpInfo.c_str(), "," ); + for ( size_t i = 0; i < streams.size(); i++ ) { - if ( startsWith( parts[i], "seq=" ) ) - { - StringVector subparts = split( parts[i], "=" ); - seq = strtol( subparts[1].c_str(), NULL, 10 ); - } - else if ( startsWith( parts[i], "rtptime=" ) ) + // We want the stream that matches the trackUrl we are using + if ( streams[i].find(controlUrl.c_str()) != std::string::npos ) { - StringVector subparts = split( parts[i], "=" ); - rtpTime = strtol( subparts[1].c_str(), NULL, 10 ); + // Parse the sequence and rtptime values + parts = split( streams[i].c_str(), ";" ); + for ( size_t j = 0; j < parts.size(); j++ ) + { + if ( startsWith( parts[j], "seq=" ) ) + { + StringVector subparts = split( parts[j], "=" ); + seq = strtol( subparts[1].c_str(), NULL, 10 ); + } + else if ( startsWith( parts[j], "rtptime=" ) ) + { + StringVector subparts = split( parts[j], "=" ); + rtpTime = strtol( subparts[1].c_str(), NULL, 10 ); + } + } + break; } } }