提交 1528cfe9 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo

Mitigate #159 (the fact that the VP8 payload has field i does not mean that it has PictureId)

上级 95b4b1d7
...@@ -65,7 +65,8 @@ namespace RTC ...@@ -65,7 +65,8 @@ namespace RTC
uint8_t keyIndex : 5; uint8_t keyIndex : 5;
bool isKeyFrame = { false }; bool isKeyFrame = { false };
bool hasTwoBytePictureId = { false }; bool hasOneBytePictureId = { false };
bool hasTwoBytesPictureId = { false };
}; };
public: public:
......
...@@ -50,13 +50,15 @@ namespace RTC ...@@ -50,13 +50,15 @@ namespace RTC
if (len < ++offset + 1) if (len < ++offset + 1)
return nullptr; return nullptr;
payloadDescriptor->hasTwoBytePictureId = true; payloadDescriptor->hasTwoBytesPictureId = true;
payloadDescriptor->pictureId = (byte & 0x7F) << 8; payloadDescriptor->pictureId = (byte & 0x7F) << 8;
payloadDescriptor->pictureId += data[offset]; payloadDescriptor->pictureId += data[offset];
} }
else else
{ {
payloadDescriptor->hasOneBytePictureId = true;
payloadDescriptor->pictureId = byte & 0x7F; payloadDescriptor->pictureId = byte & 0x7F;
} }
} }
...@@ -99,7 +101,7 @@ namespace RTC ...@@ -99,7 +101,7 @@ namespace RTC
if (this->i) if (this->i)
{ {
if (this->hasTwoBytePictureId) if (this->hasTwoBytesPictureId)
{ {
uint16_t netPictureId = htons(pictureId); uint16_t netPictureId = htons(pictureId);
...@@ -107,7 +109,7 @@ namespace RTC ...@@ -107,7 +109,7 @@ namespace RTC
data[0] |= 0x80; data[0] |= 0x80;
data += 2; data += 2;
} }
else else if (this->hasOneBytePictureId)
{ {
*data = pictureId; *data = pictureId;
data++; data++;
...@@ -149,7 +151,8 @@ namespace RTC ...@@ -149,7 +151,8 @@ namespace RTC
MS_DUMP(" y : %" PRIu8, this->y); MS_DUMP(" y : %" PRIu8, this->y);
MS_DUMP(" keyIndex : %" PRIu8, this->keyIndex); MS_DUMP(" keyIndex : %" PRIu8, this->keyIndex);
MS_DUMP(" isKeyFrame : %s", this->isKeyFrame ? "true" : "false"); MS_DUMP(" isKeyFrame : %s", this->isKeyFrame ? "true" : "false");
MS_DUMP(" hasTwoBytePictureId : %s", this->hasTwoBytePictureId ? "true" : "false"); MS_DUMP(" hasOneBytePictureId : %s", this->hasOneBytePictureId ? "true" : "false");
MS_DUMP(" hasTwoBytesPictureId : %s", this->hasTwoBytesPictureId ? "true" : "false");
MS_DUMP("</PayloadDescriptor>"); MS_DUMP("</PayloadDescriptor>");
} }
...@@ -226,14 +229,15 @@ namespace RTC ...@@ -226,14 +229,15 @@ namespace RTC
packet->SetPayloadDescriptorHandler(payloadDescriptorHandler); packet->SetPayloadDescriptorHandler(payloadDescriptorHandler);
// Modify the RtpPacket payload in order to always have two byte pictureId. // Modify the RtpPacket payload in order to always have two byte pictureId.
if (payloadDescriptor->i && !payloadDescriptor->hasTwoBytePictureId) if (payloadDescriptor->hasOneBytePictureId)
{ {
// Shift the RTP payload one byte from the begining of the pictureId field. // Shift the RTP payload one byte from the begining of the pictureId field.
packet->ShiftPayload(2, 1, true /*expand*/); packet->ShiftPayload(2, 1, true /*expand*/);
// Set the two byte pictureId marker bit. // Set the two byte pictureId marker bit.
data[2] = 0x80; data[2] = 0x80;
// Update the payloadDescriptor. // Update the payloadDescriptor.
payloadDescriptor->hasTwoBytePictureId = true; payloadDescriptor->hasOneBytePictureId = false;
payloadDescriptor->hasTwoBytesPictureId = true;
} }
} }
} // namespace Codecs } // namespace Codecs
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论