RTP library fixes and improvements.

- Fixes marker bit bug in H264 output over RTP-based protocols
- Fixes RTCP packets going over the wrong channel in TCP-based RTSP
- Fixes RTSP RTCP packets having wrong timestamps
- Fixes payload padding parser bug in H264, H265, VP8 and VP9 RTP-based inputs.
- Cleans up WebRTC's needless use of thisPacket.getTime() to use thisTime instead
This commit is contained in:
Thulinma 2023-06-14 13:46:49 +02:00
parent 132e59db51
commit a1232d56af
5 changed files with 43 additions and 25 deletions

View file

@ -148,19 +148,9 @@ namespace Mist{
if (sdpState.tracks[thisIdx].channel == -1){// UDP connection
socket = &sdpState.tracks[thisIdx].data;
callBack = sendUDP;
if (Util::bootSecs() != sdpState.tracks[thisIdx].rtcpSent){
sdpState.tracks[thisIdx].pack.setTimestamp(timestamp * SDP::getMultiplier(&M, thisIdx));
sdpState.tracks[thisIdx].rtcpSent = Util::bootSecs();
sdpState.tracks[thisIdx].pack.sendRTCP_SR(&sdpState.tracks[thisIdx].rtcp, sendUDP);
}
}else{
socket = &myConn;
callBack = sendTCP;
if (Util::bootSecs() != sdpState.tracks[thisIdx].rtcpSent){
sdpState.tracks[thisIdx].pack.setTimestamp(timestamp * SDP::getMultiplier(&M, thisIdx));
sdpState.tracks[thisIdx].rtcpSent = Util::bootSecs();
sdpState.tracks[thisIdx].pack.sendRTCP_SR(socket, sendTCP);
}
}
uint64_t offset = thisPacket.getInt("offset");
@ -168,6 +158,16 @@ namespace Mist{
sdpState.tracks[thisIdx].pack.sendData(socket, callBack, dataPointer, dataLen,
sdpState.tracks[thisIdx].channel, meta.getCodec(thisIdx));
if (Util::bootSecs() != sdpState.tracks[thisIdx].rtcpSent){
if (sdpState.tracks[thisIdx].channel == -1){// UDP connection
sdpState.tracks[thisIdx].pack.sendRTCP_SR(&sdpState.tracks[thisIdx].rtcp, 0, callBack);
}else{
sdpState.tracks[thisIdx].pack.sendRTCP_SR(socket, sdpState.tracks[thisIdx].channel, callBack);
}
sdpState.tracks[thisIdx].rtcpSent = Util::bootSecs();
}
static uint64_t lastAnnounce = Util::bootSecs();
if (reqUrl.size() && lastAnnounce + 5 < Util::bootSecs()){
INFO_MSG("Sending announce");

View file

@ -170,7 +170,7 @@ namespace Mist{
if (Util::bootSecs() != sdpState.tracks[thisIdx].rtcpSent){
sdpState.tracks[thisIdx].pack.setTimestamp(timestamp * SDP::getMultiplier(&M, thisIdx));
sdpState.tracks[thisIdx].rtcpSent = Util::bootSecs();
sdpState.tracks[thisIdx].pack.sendRTCP_SR(&sdpState.tracks[thisIdx].rtcp, sendUDP);
sdpState.tracks[thisIdx].pack.sendRTCP_SR(&sdpState.tracks[thisIdx].rtcp, sdpState.tracks[thisIdx].channel, sendUDP);
}
}else{
FAIL_MSG("RTP SDP output does not support TCP. No data will be sent to the target address");

View file

@ -1712,8 +1712,8 @@ namespace Mist{
onIdle();
}
if (M.getLive() && stayLive && lastTimeSync + 666 < thisPacket.getTime()){
lastTimeSync = thisPacket.getTime();
if (M.getLive() && stayLive && lastTimeSync + 666 < thisTime){
lastTimeSync = thisTime;
if (liveSeek()){return;}
}
@ -1760,9 +1760,9 @@ namespace Mist{
// This checks if we have a whole integer multiplier, and if so,
// ensures only integer math is used to prevent rounding errors
if (mult == (uint64_t)mult){
rtcTrack.rtpPacketizer.setTimestamp(thisPacket.getTime() * (uint64_t)mult);
rtcTrack.rtpPacketizer.setTimestamp(thisTime * (uint64_t)mult);
}else{
rtcTrack.rtpPacketizer.setTimestamp(thisPacket.getTime() * mult);
rtcTrack.rtpPacketizer.setTimestamp(thisTime * mult);
}
bool isKeyFrame = thisPacket.getFlag("keyframe");
@ -1798,7 +1798,7 @@ namespace Mist{
//If this track hasn't sent yet, actually sent
if (mustSendSR.count(thisIdx)){
mustSendSR.erase(thisIdx);
rtcTrack.rtpPacketizer.sendRTCP_SR((void *)&udp, onRTPPacketizerHasRTCPDataCallback);
rtcTrack.rtpPacketizer.sendRTCP_SR((void *)&udp, 0, onRTPPacketizerHasRTCPDataCallback);
}
}