diff --git a/dom/media/webcodecs/VideoFrame.cpp b/dom/media/webcodecs/VideoFrame.cpp index d1189c7b39d8..5b18ece19161 100644 --- a/dom/media/webcodecs/VideoFrame.cpp +++ b/dom/media/webcodecs/VideoFrame.cpp @@ -608,6 +608,19 @@ static Result ParseVideoFrameCopyToOptions( const Sequence* optLayout = OptionalToPointer(aOptions.mLayout); + VideoFrame::Format format(aFormat); + if (aOptions.mFormat.WasPassed()) { + if (aOptions.mFormat.Value() != VideoPixelFormat::RGBA && + aOptions.mFormat.Value() != VideoPixelFormat::RGBX && + aOptions.mFormat.Value() != VideoPixelFormat::BGRA && + aOptions.mFormat.Value() != VideoPixelFormat::BGRX) { + nsAutoCString error(dom::GetEnumString(aOptions.mFormat.Value()).get()); + error.Append(" is unsupported in ParseVideoFrameCopyToOptions"); + return Err(MediaResult(NS_ERROR_DOM_NOT_SUPPORTED_ERR, error)); + } + format = VideoFrame::Format(aOptions.mFormat.Value()); + } + return ComputeLayoutAndAllocationSize(parsedRect, aFormat, optLayout); } @@ -1744,7 +1757,12 @@ uint32_t VideoFrame::AllocationSize(const VideoFrameCopyToOptions& aOptions, auto r = ParseVideoFrameCopyToOptions(aOptions, mVisibleRect, mCodedSize, mResource->mFormat.ref()); if (r.isErr()) { - aRv.ThrowTypeError(r.unwrapErr().Message()); + MediaResult error = r.unwrapErr(); + if (error.Code() == NS_ERROR_DOM_NOT_SUPPORTED_ERR) { + aRv.ThrowNotSupportedError(error.Message()); + } else { + aRv.ThrowTypeError(error.Message()); + } return 0; } CombinedBufferLayout layout = r.unwrap(); @@ -1776,7 +1794,12 @@ already_AddRefed VideoFrame::CopyTo( auto r = ParseVideoFrameCopyToOptions(aOptions, mVisibleRect, mCodedSize, mResource->mFormat.ref()); if (r.isErr()) { - p->MaybeRejectWithTypeError(r.unwrapErr().Message()); + MediaResult error = r.unwrapErr(); + if (error.Code() == NS_ERROR_DOM_NOT_SUPPORTED_ERR) { + p->MaybeRejectWithNotSupportedError(error.Message()); + } else { + p->MaybeRejectWithTypeError(error.Message()); + } return p.forget(); } CombinedBufferLayout layout = r.unwrap(); diff --git a/testing/web-platform/meta/webcodecs/videoFrame-copyTo-rgb.any.js.ini b/testing/web-platform/meta/webcodecs/videoFrame-copyTo-rgb.any.js.ini index 3390f6a282f5..c5a5376fe7d2 100644 --- a/testing/web-platform/meta/webcodecs/videoFrame-copyTo-rgb.any.js.ini +++ b/testing/web-platform/meta/webcodecs/videoFrame-copyTo-rgb.any.js.ini @@ -119,33 +119,6 @@ [Convert 4-color canvas frame to RGBX / display-p3] expected: FAIL - [Unsupported format I420] - expected: FAIL - - [Unsupported format I420P10] - expected: FAIL - - [Unsupported format I420P12] - expected: FAIL - - [Unsupported format I420A] - expected: FAIL - - [Unsupported format I422] - expected: FAIL - - [Unsupported format I422A] - expected: FAIL - - [Unsupported format I444] - expected: FAIL - - [Unsupported format I444A] - expected: FAIL - - [Unsupported format NV12] - expected: FAIL - [videoFrame-copyTo-rgb.any.worker.html] [Convert 4x4 null I420 frames to RGBA / srgb] @@ -267,30 +240,3 @@ [Convert 4-color canvas frame to RGBX / display-p3] expected: FAIL - - [Unsupported format I420] - expected: FAIL - - [Unsupported format I420P10] - expected: FAIL - - [Unsupported format I420P12] - expected: FAIL - - [Unsupported format I420A] - expected: FAIL - - [Unsupported format I422] - expected: FAIL - - [Unsupported format I422A] - expected: FAIL - - [Unsupported format I444] - expected: FAIL - - [Unsupported format I444A] - expected: FAIL - - [Unsupported format NV12] - expected: FAIL