Bug 1340129: P1. Allow empty raw frames. r?gerald
MozReview-Commit-ID: AU0QrahHtYe
--- a/dom/media/gmp/widevine-adapter/WidevineVideoDecoder.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineVideoDecoder.cpp
@@ -107,17 +107,17 @@ WidevineVideoDecoder::Decode(GMPVideoEnc
// and retrieve them on output.
mFrameDurations[aInputFrame->TimeStamp()] = aInputFrame->Duration();
mSentInput = true;
InputBuffer sample;
RefPtr<MediaRawData> raw(
new MediaRawData(aInputFrame->Buffer(), aInputFrame->Size()));
- if (!raw->Data()) {
+ if (aInputFrame->Size() && !raw->Data()) {
// OOM.
mCallback->Error(GMPAllocErr);
return;
}
raw->mExtraData = mExtraData;
raw->mKeyframe = (aInputFrame->FrameType() == kGMPKeyFrame);
if (mCodecType == kGMPVideoCodecH264) {
// Convert input from AVCC, which GMPAPI passes in, to AnnexB, which
--- a/dom/media/ipc/VideoDecoderParent.cpp
+++ b/dom/media/ipc/VideoDecoderParent.cpp
@@ -123,17 +123,17 @@ VideoDecoderParent::RecvInit()
mozilla::ipc::IPCResult
VideoDecoderParent::RecvInput(const MediaRawDataIPDL& aData)
{
MOZ_ASSERT(OnManagerThread());
// XXX: This copies the data into a buffer owned by the MediaRawData. Ideally
// we'd just take ownership of the shmem.
RefPtr<MediaRawData> data = new MediaRawData(aData.buffer().get<uint8_t>(),
aData.buffer().Size<uint8_t>());
- if (!data->Data()) {
+ if (aData.buffer().Size<uint8_t>() && !data->Data()) {
// OOM
Error(NS_ERROR_OUT_OF_MEMORY);
return IPC_OK();
}
data->mOffset = aData.base().offset();
data->mTime = aData.base().time();
data->mTimecode = aData.base().timecode();
data->mDuration = aData.base().duration();
--- a/dom/media/ogg/OggCodecState.cpp
+++ b/dom/media/ogg/OggCodecState.cpp
@@ -243,17 +243,17 @@ OggCodecState::PacketOutAsMediaRawData()
if (!packet) {
return nullptr;
}
NS_ASSERTION(
!IsHeader(packet.get()),
"PacketOutAsMediaRawData can only be called on non-header packets");
RefPtr<MediaRawData> sample = new MediaRawData(packet->packet, packet->bytes);
- if (!sample->Data()) {
+ if (packet->bytes && !sample->Data()) {
// OOM.
return nullptr;
}
int64_t end_tstamp = Time(packet->granulepos);
NS_ASSERTION(end_tstamp >= 0, "timestamp invalid");
int64_t duration = PacketDuration(packet.get());
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -697,23 +697,23 @@ WebMDemuxer::GetNextPacket(TrackInfo::Tr
}
}
WEBM_DEBUG("push sample tstamp: %ld next_tstamp: %ld length: %ld kf: %d",
tstamp, next_tstamp, length, isKeyframe);
RefPtr<MediaRawData> sample;
if (mInfo.mVideo.HasAlpha() && alphaLength != 0) {
sample = new MediaRawData(data, length, alphaData, alphaLength);
- if (!sample->Data() || !sample->AlphaData()) {
+ if ((length && !sample->Data()) || (alphaLength && !sample->AlphaData())) {
// OOM.
return false;
}
} else {
sample = new MediaRawData(data, length);
- if (!sample->Data()) {
+ if (length && !sample->Data()) {
// OOM.
return false;
}
}
sample->mTimecode = tstamp;
sample->mTime = tstamp;
sample->mDuration = next_tstamp - tstamp;
sample->mOffset = holder->Offset();