Fixed ffmpeg compatibility with urlencoding library in SDP lib
This commit is contained in:
parent
a634f4a738
commit
66d64317c9
1 changed files with 81 additions and 62 deletions
53
lib/sdp.cpp
53
lib/sdp.cpp
|
@ -51,21 +51,24 @@ namespace SDP{
|
||||||
mediaDesc << "m=video 0 RTP/AVP 97\r\n"
|
mediaDesc << "m=video 0 RTP/AVP 97\r\n"
|
||||||
"a=rtpmap:97 H264/90000\r\n"
|
"a=rtpmap:97 H264/90000\r\n"
|
||||||
"a=cliprect:0,0,"
|
"a=cliprect:0,0,"
|
||||||
<< trk.height << "," << trk.width << "\r\n"
|
<< trk.height << "," << trk.width
|
||||||
|
<< "\r\n"
|
||||||
"a=framesize:97 "
|
"a=framesize:97 "
|
||||||
<< trk.width << '-' << trk.height
|
<< trk.width << '-' << trk.height
|
||||||
<< "\r\n"
|
<< "\r\n"
|
||||||
"a=fmtp:97 packetization-mode=1;profile-level-id="
|
"a=fmtp:97 packetization-mode=1;profile-level-id="
|
||||||
<< std::hex << std::setw(2) << std::setfill('0') << (int)trk.init.data()[1]
|
<< std::hex << std::setw(2) << std::setfill('0') << (int)trk.init.data()[1]
|
||||||
<< std::dec << "E0" << std::hex << std::setw(2) << std::setfill('0')
|
<< std::dec << "E0" << std::hex << std::setw(2) << std::setfill('0')
|
||||||
<< (int)trk.init.data()[3] << std::dec << ";"
|
<< (int)trk.init.data()[3] << std::dec
|
||||||
|
<< ";"
|
||||||
"sprop-parameter-sets="
|
"sprop-parameter-sets="
|
||||||
<< Encodings::Base64::encode(std::string(avccbox.getSPS(), avccbox.getSPSLen()))
|
<< Encodings::Base64::encode(std::string(avccbox.getSPS(), avccbox.getSPSLen()))
|
||||||
<< ","
|
<< ","
|
||||||
<< Encodings::Base64::encode(std::string(avccbox.getPPS(), avccbox.getPPSLen()))
|
<< Encodings::Base64::encode(std::string(avccbox.getPPS(), avccbox.getPPSLen()))
|
||||||
<< "\r\n"
|
<< "\r\n"
|
||||||
"a=framerate:"
|
"a=framerate:"
|
||||||
<< ((double)trk.fpks) / 1000.0 << "\r\n"
|
<< ((double)trk.fpks) / 1000.0
|
||||||
|
<< "\r\n"
|
||||||
"a=control:track"
|
"a=control:track"
|
||||||
<< trk.trackID << "\r\n";
|
<< trk.trackID << "\r\n";
|
||||||
}else if (trk.codec == "HEVC"){
|
}else if (trk.codec == "HEVC"){
|
||||||
|
@ -73,7 +76,8 @@ namespace SDP{
|
||||||
mediaDesc << "m=video 0 RTP/AVP 104\r\n"
|
mediaDesc << "m=video 0 RTP/AVP 104\r\n"
|
||||||
"a=rtpmap:104 H265/90000\r\n"
|
"a=rtpmap:104 H265/90000\r\n"
|
||||||
"a=cliprect:0,0,"
|
"a=cliprect:0,0,"
|
||||||
<< trk.height << "," << trk.width << "\r\n"
|
<< trk.height << "," << trk.width
|
||||||
|
<< "\r\n"
|
||||||
"a=framesize:104 "
|
"a=framesize:104 "
|
||||||
<< trk.width << '-' << trk.height << "\r\n"
|
<< trk.width << '-' << trk.height << "\r\n"
|
||||||
<< "a=fmtp:104 sprop-vps=";
|
<< "a=fmtp:104 sprop-vps=";
|
||||||
|
@ -100,13 +104,15 @@ namespace SDP{
|
||||||
mediaDesc << Encodings::Base64::encode(*it);
|
mediaDesc << Encodings::Base64::encode(*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mediaDesc << "\r\na=framerate:" << ((double)trk.fpks) / 1000.0 << "\r\n"
|
mediaDesc << "\r\na=framerate:" << ((double)trk.fpks) / 1000.0
|
||||||
|
<< "\r\n"
|
||||||
"a=control:track"
|
"a=control:track"
|
||||||
<< trk.trackID << "\r\n";
|
<< trk.trackID << "\r\n";
|
||||||
}else if (trk.codec == "MPEG2"){
|
}else if (trk.codec == "MPEG2"){
|
||||||
mediaDesc << "m=video 0 RTP/AVP 32\r\n"
|
mediaDesc << "m=video 0 RTP/AVP 32\r\n"
|
||||||
"a=cliprect:0,0,"
|
"a=cliprect:0,0,"
|
||||||
<< trk.height << "," << trk.width << "\r\n"
|
<< trk.height << "," << trk.width
|
||||||
|
<< "\r\n"
|
||||||
"a=framesize:32 "
|
"a=framesize:32 "
|
||||||
<< trk.width << '-' << trk.height << "\r\n"
|
<< trk.width << '-' << trk.height << "\r\n"
|
||||||
<< "a=framerate:" << ((double)trk.fpks) / 1000.0 << "\r\n"
|
<< "a=framerate:" << ((double)trk.fpks) / 1000.0 << "\r\n"
|
||||||
|
@ -129,14 +135,16 @@ namespace SDP{
|
||||||
mediaDesc << "m=" << trk.type << " 0 RTP/AVP 14"
|
mediaDesc << "m=" << trk.type << " 0 RTP/AVP 14"
|
||||||
<< "\r\n"
|
<< "\r\n"
|
||||||
"a=rtpmap:14 MPA/90000/"
|
"a=rtpmap:14 MPA/90000/"
|
||||||
<< trk.channels << "\r\n"
|
<< trk.channels
|
||||||
|
<< "\r\n"
|
||||||
"a=control:track"
|
"a=control:track"
|
||||||
<< trk.trackID << "\r\n";
|
<< trk.trackID << "\r\n";
|
||||||
}else if (trk.codec == "AC3"){
|
}else if (trk.codec == "AC3"){
|
||||||
mediaDesc << "m=audio 0 RTP/AVP 100"
|
mediaDesc << "m=audio 0 RTP/AVP 100"
|
||||||
<< "\r\n"
|
<< "\r\n"
|
||||||
"a=rtpmap:100 AC3/"
|
"a=rtpmap:100 AC3/"
|
||||||
<< trk.rate << "/" << trk.channels << "\r\n"
|
<< trk.rate << "/" << trk.channels
|
||||||
|
<< "\r\n"
|
||||||
"a=control:track"
|
"a=control:track"
|
||||||
<< trk.trackID << "\r\n";
|
<< trk.trackID << "\r\n";
|
||||||
}else if (trk.codec == "ALAW"){
|
}else if (trk.codec == "ALAW"){
|
||||||
|
@ -177,7 +185,8 @@ namespace SDP{
|
||||||
mediaDesc << "m=audio 0 RTP/AVP 102"
|
mediaDesc << "m=audio 0 RTP/AVP 102"
|
||||||
<< "\r\n"
|
<< "\r\n"
|
||||||
"a=rtpmap:102 opus/"
|
"a=rtpmap:102 opus/"
|
||||||
<< trk.rate << "/" << trk.channels << "\r\n"
|
<< trk.rate << "/" << trk.channels
|
||||||
|
<< "\r\n"
|
||||||
"a=control:track"
|
"a=control:track"
|
||||||
<< trk.trackID << "\r\n";
|
<< trk.trackID << "\r\n";
|
||||||
}
|
}
|
||||||
|
@ -192,7 +201,8 @@ namespace SDP{
|
||||||
// We simply request interleaved delivery over a trackNo-based identifier.
|
// We simply request interleaved delivery over a trackNo-based identifier.
|
||||||
// No need to set any internal state, parseTransport will handle it all.
|
// No need to set any internal state, parseTransport will handle it all.
|
||||||
std::stringstream tStr;
|
std::stringstream tStr;
|
||||||
tStr << "RTP/AVP/TCP;unicast;interleaved=" << ((trackNo - 1) * 2) << "-" << ((trackNo - 1) * 2 + 1);
|
tStr << "RTP/AVP/TCP;unicast;interleaved=" << ((trackNo - 1) * 2) << "-"
|
||||||
|
<< ((trackNo - 1) * 2 + 1);
|
||||||
return tStr.str();
|
return tStr.str();
|
||||||
}else{
|
}else{
|
||||||
// A little more tricky: we need to find free ports and remember them.
|
// A little more tricky: we need to find free ports and remember them.
|
||||||
|
@ -264,7 +274,8 @@ namespace SDP{
|
||||||
cPortA = cPortB = 0;
|
cPortA = cPortB = 0;
|
||||||
size_t sPort_loc = transport.rfind("server_port=") + 12;
|
size_t sPort_loc = transport.rfind("server_port=") + 12;
|
||||||
if (sPort_loc != std::string::npos){
|
if (sPort_loc != std::string::npos){
|
||||||
sPortA = atol(transport.substr(sPort_loc, transport.find('-', sPort_loc) - sPort_loc).c_str());
|
sPortA =
|
||||||
|
atol(transport.substr(sPort_loc, transport.find('-', sPort_loc) - sPort_loc).c_str());
|
||||||
sPortB = atol(transport.substr(transport.find('-', sPort_loc) + 1).c_str());
|
sPortB = atol(transport.substr(transport.find('-', sPort_loc) + 1).c_str());
|
||||||
}
|
}
|
||||||
size_t port_loc = transport.rfind("client_port=") + 12;
|
size_t port_loc = transport.rfind("client_port=") + 12;
|
||||||
|
@ -285,7 +296,8 @@ namespace SDP{
|
||||||
std::stringstream tStr;
|
std::stringstream tStr;
|
||||||
tStr << "RTP/AVP/UDP;unicast;client_port=" << cPortA << '-' << cPortB << ";";
|
tStr << "RTP/AVP/UDP;unicast;client_port=" << cPortA << '-' << cPortB << ";";
|
||||||
if (source.size()){tStr << "source=" << source << ";";}
|
if (source.size()){tStr << "source=" << source << ";";}
|
||||||
tStr << "server_port=" << portA << "-" << portB << ";ssrc=" << std::hex << mySSRC << std::dec;
|
tStr << "server_port=" << portA << "-" << portB << ";ssrc=" << std::hex << mySSRC
|
||||||
|
<< std::dec;
|
||||||
transportString = tStr.str();
|
transportString = tStr.str();
|
||||||
}else{
|
}else{
|
||||||
// Client mode - check ports and/or obey given ports if possible
|
// Client mode - check ports and/or obey given ports if possible
|
||||||
|
@ -483,9 +495,7 @@ namespace SDP{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (to.substr(0, 12) == "a=framerate:"){
|
if (to.substr(0, 12) == "a=framerate:"){
|
||||||
if (!thisTrack->rate){
|
if (!thisTrack->rate){thisTrack->rate = atof(to.c_str() + 12) * 1000;}
|
||||||
thisTrack->rate = atof(to.c_str() + 12)*1000;
|
|
||||||
}
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (to.substr(0, 12) == "a=framesize:"){
|
if (to.substr(0, 12) == "a=framesize:"){
|
||||||
|
@ -543,7 +553,8 @@ namespace SDP{
|
||||||
// at this point, the data is definitely for a track
|
// at this point, the data is definitely for a track
|
||||||
INFO_MSG("Unhandled SDP line for track %llu: %s", trackNo, to.c_str());
|
INFO_MSG("Unhandled SDP line for track %llu: %s", trackNo, to.c_str());
|
||||||
}
|
}
|
||||||
for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta->tracks.begin(); it != myMeta->tracks.end(); ++it){
|
for (std::map<unsigned int, DTSC::Track>::iterator it = myMeta->tracks.begin();
|
||||||
|
it != myMeta->tracks.end(); ++it){
|
||||||
INFO_MSG("Detected track %s", it->second.getIdentifier().c_str());
|
INFO_MSG("Detected track %s", it->second.getIdentifier().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -610,7 +621,9 @@ namespace SDP{
|
||||||
HTTP::URL url(H.url);
|
HTTP::URL url(H.url);
|
||||||
std::string urlString = url.getBareUrl();
|
std::string urlString = url.getBareUrl();
|
||||||
std::string pw = H.GetVar("pass");
|
std::string pw = H.GetVar("pass");
|
||||||
|
bool loop = true;
|
||||||
|
|
||||||
|
while (loop){
|
||||||
if (tracks.size()){
|
if (tracks.size()){
|
||||||
for (std::map<uint32_t, Track>::iterator it = tracks.begin(); it != tracks.end(); ++it){
|
for (std::map<uint32_t, Track>::iterator it = tracks.begin(); it != tracks.end(); ++it){
|
||||||
if (!it->second.control.size()){
|
if (!it->second.control.size()){
|
||||||
|
@ -643,6 +656,12 @@ namespace SDP{
|
||||||
return trackNo;
|
return trackNo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (urlString != url.path){
|
||||||
|
urlString = url.path;
|
||||||
|
}else{
|
||||||
|
loop = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,5 +1034,5 @@ namespace SDP{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}// namespace SDP
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue