Commit a991bcfd authored by Hirokazu Honda's avatar Hirokazu Honda Committed by Commit Bot

RtcVideoEncoder: Fallback SW encoder when unexpected buffer is given

This adds if statement to cause a software encoder fallback if non GBM based
VideoFrame is given in native input mode. This CL also changes DCHECK_EQs to
if-statements in MojoVideoEncodeAccelerator. It is because, if the conditions
are false, it causes a renderer process crash.

Bug: 1014209
Test: webrtc.DecodeAccelUsedVP8
Change-Id: I7aefe0c8e37dae5f086c6f0ce49651a3816194d1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1862355Reviewed-by: default avatarDan Sanders <sandersd@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706277}
parent 605ad6d6
...@@ -144,9 +144,12 @@ void MojoVideoEncodeAccelerator::Encode(scoped_refptr<VideoFrame> frame, ...@@ -144,9 +144,12 @@ void MojoVideoEncodeAccelerator::Encode(scoped_refptr<VideoFrame> frame,
return; return;
} }
DCHECK_EQ(PIXEL_FORMAT_I420, frame->format()); if (frame->format() != PIXEL_FORMAT_I420 ||
DCHECK_EQ(VideoFrame::STORAGE_SHMEM, frame->storage_type()); VideoFrame::STORAGE_SHMEM != frame->storage_type() ||
DCHECK(frame->shm_region()->IsValid()); !frame->shm_region()->IsValid()) {
DLOG(ERROR) << "Unexpected video frame buffer";
return;
}
// Oftentimes |frame|'s underlying planes will be aligned and not tightly // Oftentimes |frame|'s underlying planes will be aligned and not tightly
// packed, so don't use VideoFrame::AllocationSize(). // packed, so don't use VideoFrame::AllocationSize().
......
...@@ -827,8 +827,12 @@ void RTCVideoEncoder::Impl::EncodeOneFrameWithNativeInput() { ...@@ -827,8 +827,12 @@ void RTCVideoEncoder::Impl::EncodeOneFrameWithNativeInput() {
next_frame->video_frame_buffer().get()) next_frame->video_frame_buffer().get())
->getMediaVideoFrame(); ->getMediaVideoFrame();
} }
DCHECK_EQ(frame->storage_type(),
media::VideoFrame::STORAGE_GPU_MEMORY_BUFFER); if (frame->storage_type() != media::VideoFrame::STORAGE_GPU_MEMORY_BUFFER) {
LogAndNotifyError(FROM_HERE, "frame isn't GpuMemoryBuffer based VideoFrame",
media::VideoEncodeAccelerator::kPlatformFailureError);
return;
}
constexpr int kDummyIndex = -1; constexpr int kDummyIndex = -1;
frame->AddDestructionObserver(media::BindToCurrentLoop(base::BindOnce( frame->AddDestructionObserver(media::BindToCurrentLoop(base::BindOnce(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment