Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(597)

Unified Diff: content/common/gpu/media/android_video_decode_accelerator.cc

Issue 1706023003: Moving the validation of bitstream_buffer into VDA implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ready for review Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/common/gpu/media/android_video_decode_accelerator.cc
diff --git a/content/common/gpu/media/android_video_decode_accelerator.cc b/content/common/gpu/media/android_video_decode_accelerator.cc
index 37ea2c771c0a6bb73f016a010a540b9a1a6a015a..1960dce32f7a99d6bc257d9fe34e67766a316bf8 100644
--- a/content/common/gpu/media/android_video_decode_accelerator.cc
+++ b/content/common/gpu/media/android_video_decode_accelerator.cc
@@ -618,6 +618,21 @@ void AndroidVideoDecodeAccelerator::SendDecodedFrameToClient(
void AndroidVideoDecodeAccelerator::Decode(
const media::BitstreamBuffer& bitstream_buffer) {
+ // We use id = -1 as a special bitstream_buffer internally, which indicating
Pawel Osciak 2016/02/19 07:48:44 This feels like an opportunity to remove the check
Owen Lin 2016/02/23 09:06:38 Done.
+ // flush the decoder. The client should not passing any id < 0 when call
+ // Decode().
+ if (bitstream_buffer.id() < 0) {
+ POST_ERROR(INVALID_ARGUMENT,
+ "Invalid bistream_buffer, id: " << bitstream_buffer.id());
+ if (base::SharedMemory::IsHandleValid(bitstream_buffer.handle()))
+ base::SharedMemory::CloseHandle(bitstream_buffer.handle());
+ return;
+ }
+ DecodeInternal(bitstream_buffer);
+}
+
+void AndroidVideoDecodeAccelerator::DecodeInternal(
+ const media::BitstreamBuffer& bitstream_buffer) {
DCHECK(thread_checker_.CalledOnValidThread());
if (bitstream_buffer.id() != -1 && bitstream_buffer.size() == 0) {
base::MessageLoop::current()->PostTask(
@@ -704,7 +719,7 @@ void AndroidVideoDecodeAccelerator::ReusePictureBuffer(
void AndroidVideoDecodeAccelerator::Flush() {
DCHECK(thread_checker_.CalledOnValidThread());
- Decode(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0));
+ DecodeInternal(media::BitstreamBuffer(-1, base::SharedMemoryHandle(), 0));
}
bool AndroidVideoDecodeAccelerator::ConfigureMediaCodec() {

Powered by Google App Engine
This is Rietveld 408576698