| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/common/gpu/media/android_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/android_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/common/gpu/gpu_channel.h" | 10 #include "content/common/gpu/gpu_channel.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 void AndroidVideoDecodeAccelerator::QueueInput() { | 145 void AndroidVideoDecodeAccelerator::QueueInput() { |
| 146 if (bitstreams_notified_in_advance_.size() > kMaxBitstreamsNotifiedInAdvance) | 146 if (bitstreams_notified_in_advance_.size() > kMaxBitstreamsNotifiedInAdvance) |
| 147 return; | 147 return; |
| 148 if (pending_bitstream_buffers_.empty()) | 148 if (pending_bitstream_buffers_.empty()) |
| 149 return; | 149 return; |
| 150 | 150 |
| 151 int input_buf_index = 0; | 151 int input_buf_index = 0; |
| 152 media::MediaCodecStatus status = media_codec_->DequeueInputBuffer( | 152 media::MediaCodecStatus status = media_codec_->DequeueInputBuffer( |
| 153 NoWaitTimeOut(), &input_buf_index); | 153 NoWaitTimeOut(), &input_buf_index); |
| 154 if (status != media::MEDIA_CODEC_OK) { | 154 if (status != media::MEDIA_CODEC_OK) { |
| 155 DCHECK(status == media::MEDIA_CODEC_ENQUEUE_INPUT_AGAIN_LATER || | 155 DCHECK(status == media::MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER || |
| 156 status == media::MEDIA_CODEC_ERROR); | 156 status == media::MEDIA_CODEC_ERROR); |
| 157 return; | 157 return; |
| 158 } | 158 } |
| 159 | 159 |
| 160 media::BitstreamBuffer& bitstream_buffer = | 160 media::BitstreamBuffer& bitstream_buffer = |
| 161 pending_bitstream_buffers_.front(); | 161 pending_bitstream_buffers_.front(); |
| 162 | 162 |
| 163 if (bitstream_buffer.id() == -1) { | 163 if (bitstream_buffer.id() == -1) { |
| 164 media_codec_->QueueEOS(input_buf_index); | 164 media_codec_->QueueEOS(input_buf_index); |
| 165 pending_bitstream_buffers_.pop(); | 165 pending_bitstream_buffers_.pop(); |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 // TODO(dwkang): find out a way to remove the following hard-coded value. | 410 // TODO(dwkang): find out a way to remove the following hard-coded value. |
| 411 media_codec_->Start( | 411 media_codec_->Start( |
| 412 codec_, gfx::Size(1280, 720), surface.j_surface().obj(), NULL); | 412 codec_, gfx::Size(1280, 720), surface.j_surface().obj(), NULL); |
| 413 media_codec_->GetOutputBuffers(); | 413 media_codec_->GetOutputBuffers(); |
| 414 return true; | 414 return true; |
| 415 } | 415 } |
| 416 | 416 |
| 417 void AndroidVideoDecodeAccelerator::Reset() { | 417 void AndroidVideoDecodeAccelerator::Reset() { |
| 418 DCHECK(thread_checker_.CalledOnValidThread()); | 418 DCHECK(thread_checker_.CalledOnValidThread()); |
| 419 | 419 |
| 420 while(!pending_bitstream_buffers_.empty()) { | 420 while (!pending_bitstream_buffers_.empty()) { |
| 421 media::BitstreamBuffer& bitstream_buffer = | 421 media::BitstreamBuffer& bitstream_buffer = |
| 422 pending_bitstream_buffers_.front(); | 422 pending_bitstream_buffers_.front(); |
| 423 pending_bitstream_buffers_.pop(); | 423 pending_bitstream_buffers_.pop(); |
| 424 | 424 |
| 425 if (bitstream_buffer.id() != -1) { | 425 if (bitstream_buffer.id() != -1) { |
| 426 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( | 426 base::MessageLoop::current()->PostTask(FROM_HERE, base::Bind( |
| 427 &AndroidVideoDecodeAccelerator::NotifyEndOfBitstreamBuffer, | 427 &AndroidVideoDecodeAccelerator::NotifyEndOfBitstreamBuffer, |
| 428 base::AsWeakPtr(this), bitstream_buffer.id())); | 428 base::AsWeakPtr(this), bitstream_buffer.id())); |
| 429 } | 429 } |
| 430 } | 430 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 483 void AndroidVideoDecodeAccelerator::NotifyResetDone() { | 483 void AndroidVideoDecodeAccelerator::NotifyResetDone() { |
| 484 client_->NotifyResetDone(); | 484 client_->NotifyResetDone(); |
| 485 } | 485 } |
| 486 | 486 |
| 487 void AndroidVideoDecodeAccelerator::NotifyError( | 487 void AndroidVideoDecodeAccelerator::NotifyError( |
| 488 media::VideoDecodeAccelerator::Error error) { | 488 media::VideoDecodeAccelerator::Error error) { |
| 489 client_->NotifyError(error); | 489 client_->NotifyError(error); |
| 490 } | 490 } |
| 491 | 491 |
| 492 } // namespace content | 492 } // namespace content |
| OLD | NEW |