Fixed trailing zeroes in WebRTC RTP packets

This commit is contained in:
Thulinma 2020-10-13 16:05:39 +02:00
parent ffcc2b3473
commit e6f4f1f8aa

View file

@ -1610,13 +1610,13 @@ namespace Mist{
buffer.push_back((rtcTrack.SSRC >> 8) & 0xFF); // ssrc of receiver buffer.push_back((rtcTrack.SSRC >> 8) & 0xFF); // ssrc of receiver
buffer.push_back((rtcTrack.SSRC) & 0xFF); // ssrc of receiver buffer.push_back((rtcTrack.SSRC) & 0xFF); // ssrc of receiver
// protect.
int buffer_size_in_bytes = (int)buffer.size();
// space for protection // space for protection
size_t trailer_space = SRTP_MAX_TRAILER_LEN + 4; size_t trailer_space = SRTP_MAX_TRAILER_LEN + 4;
for (size_t i = 0; i < trailer_space; ++i){buffer.push_back(0x00);} for (size_t i = 0; i < trailer_space; ++i){buffer.push_back(0x00);}
// protect.
int buffer_size_in_bytes = (int)buffer.size();
if (doDTLS){ if (doDTLS){
if (srtpWriter.protectRtcp(&buffer[0], &buffer_size_in_bytes) != 0){ if (srtpWriter.protectRtcp(&buffer[0], &buffer_size_in_bytes) != 0){
ERROR_MSG("Failed to protect the RTCP message."); ERROR_MSG("Failed to protect the RTCP message.");
@ -1661,13 +1661,13 @@ namespace Mist{
buffer.push_back(0x00); // BLP: Bitmask of following losses. (not implemented atm). buffer.push_back(0x00); // BLP: Bitmask of following losses. (not implemented atm).
buffer.push_back(0x00); // BLP: Bitmask of following losses. (not implemented atm). buffer.push_back(0x00); // BLP: Bitmask of following losses. (not implemented atm).
// protect.
int buffer_size_in_bytes = (int)buffer.size();
// space for protection // space for protection
size_t trailer_space = SRTP_MAX_TRAILER_LEN + 4; size_t trailer_space = SRTP_MAX_TRAILER_LEN + 4;
for (size_t i = 0; i < trailer_space; ++i){buffer.push_back(0x00);} for (size_t i = 0; i < trailer_space; ++i){buffer.push_back(0x00);}
// protect.
int buffer_size_in_bytes = (int)buffer.size();
if (doDTLS){ if (doDTLS){
if (srtpWriter.protectRtcp(&buffer[0], &buffer_size_in_bytes) != 0){ if (srtpWriter.protectRtcp(&buffer[0], &buffer_size_in_bytes) != 0){
ERROR_MSG("Failed to protect the RTCP message."); ERROR_MSG("Failed to protect the RTCP message.");