提交 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
......@@ -64,8 +64,9 @@ namespace RTC
uint8_t y : 1;
uint8_t keyIndex : 5;
bool isKeyFrame = { false };
bool hasTwoBytePictureId = { false };
bool isKeyFrame = { false };
bool hasOneBytePictureId = { false };
bool hasTwoBytesPictureId = { false };
};
public:
......
......@@ -50,13 +50,15 @@ namespace RTC
if (len < ++offset + 1)
return nullptr;
payloadDescriptor->hasTwoBytePictureId = true;
payloadDescriptor->hasTwoBytesPictureId = true;
payloadDescriptor->pictureId = (byte & 0x7F) << 8;
payloadDescriptor->pictureId += data[offset];
}
else
{
payloadDescriptor->hasOneBytePictureId = true;
payloadDescriptor->pictureId = byte & 0x7F;
}
}
......@@ -99,7 +101,7 @@ namespace RTC
if (this->i)
{
if (this->hasTwoBytePictureId)
if (this->hasTwoBytesPictureId)
{
uint16_t netPictureId = htons(pictureId);
......@@ -107,7 +109,7 @@ namespace RTC
data[0] |= 0x80;
data += 2;
}
else
else if (this->hasOneBytePictureId)
{
*data = pictureId;
data++;
......@@ -133,23 +135,24 @@ namespace RTC
MS_TRACE();
MS_DUMP("<PayloadDescriptor>");
MS_DUMP(" extended : %" PRIu8, this->extended);
MS_DUMP(" nonReference : %" PRIu8, this->nonReference);
MS_DUMP(" start : %" PRIu8, this->start);
MS_DUMP(" partitionIndex : %" PRIu8, this->partitionIndex);
MS_DUMP(" extended : %" PRIu8, this->extended);
MS_DUMP(" nonReference : %" PRIu8, this->nonReference);
MS_DUMP(" start : %" PRIu8, this->start);
MS_DUMP(" partitionIndex : %" PRIu8, this->partitionIndex);
MS_DUMP(
" i|l|t|k : %" PRIu8 "|%" PRIu8 "|%" PRIu8 "|%" PRIu8,
" i|l|t|k : %" PRIu8 "|%" PRIu8 "|%" PRIu8 "|%" PRIu8,
this->i,
this->l,
this->t,
this->k);
MS_DUMP(" pictureId : %" PRIu16, this->pictureId);
MS_DUMP(" tl0PictureIndex : %" PRIu8, this->tl0PictureIndex);
MS_DUMP(" tlIndex : %" PRIu8, this->tlIndex);
MS_DUMP(" y : %" PRIu8, this->y);
MS_DUMP(" keyIndex : %" PRIu8, this->keyIndex);
MS_DUMP(" isKeyFrame : %s", this->isKeyFrame ? "true" : "false");
MS_DUMP(" hasTwoBytePictureId : %s", this->hasTwoBytePictureId ? "true" : "false");
MS_DUMP(" pictureId : %" PRIu16, this->pictureId);
MS_DUMP(" tl0PictureIndex : %" PRIu8, this->tl0PictureIndex);
MS_DUMP(" tlIndex : %" PRIu8, this->tlIndex);
MS_DUMP(" y : %" PRIu8, this->y);
MS_DUMP(" keyIndex : %" PRIu8, this->keyIndex);
MS_DUMP(" isKeyFrame : %s", this->isKeyFrame ? "true" : "false");
MS_DUMP(" hasOneBytePictureId : %s", this->hasOneBytePictureId ? "true" : "false");
MS_DUMP(" hasTwoBytesPictureId : %s", this->hasTwoBytesPictureId ? "true" : "false");
MS_DUMP("</PayloadDescriptor>");
}
......@@ -226,14 +229,15 @@ namespace RTC
packet->SetPayloadDescriptorHandler(payloadDescriptorHandler);
// 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.
packet->ShiftPayload(2, 1, true /*expand*/);
// Set the two byte pictureId marker bit.
data[2] = 0x80;
// Update the payloadDescriptor.
payloadDescriptor->hasTwoBytePictureId = true;
payloadDescriptor->hasOneBytePictureId = false;
payloadDescriptor->hasTwoBytesPictureId = true;
}
}
} // namespace Codecs
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论