Skip to content

Commit

Permalink
Parse multiple streams in RTP-Info
Browse files Browse the repository at this point in the history
  • Loading branch information
knight-of-ni committed Dec 3, 2014
1 parent a6a7799 commit 97ee989
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/zm_rtsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ int RtspThread::run()

uint32_t rtpClock = 0;
std::string trackUrl = mUrl;
std::string controlUrl;

_AVCODECID codecId;

Expand All @@ -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;
Expand Down Expand Up @@ -569,26 +570,37 @@ 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.");
}
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;
}
}
}
Expand Down

0 comments on commit 97ee989

Please sign in to comment.