| 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 "media/gpu/android_video_decode_accelerator.h" | 5 #include "media/gpu/android_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 did_work = true; | 577 did_work = true; |
| 578 } while (did_input || did_output); | 578 } while (did_input || did_output); |
| 579 | 579 |
| 580 ManageTimer(did_work || start_timer); | 580 ManageTimer(did_work || start_timer); |
| 581 } | 581 } |
| 582 | 582 |
| 583 bool AndroidVideoDecodeAccelerator::QueueInput() { | 583 bool AndroidVideoDecodeAccelerator::QueueInput() { |
| 584 DCHECK(thread_checker_.CalledOnValidThread()); | 584 DCHECK(thread_checker_.CalledOnValidThread()); |
| 585 TRACE_EVENT0("media", "AVDA::QueueInput"); | 585 TRACE_EVENT0("media", "AVDA::QueueInput"); |
| 586 base::AutoReset<bool> auto_reset(&defer_errors_, true); | 586 base::AutoReset<bool> auto_reset(&defer_errors_, true); |
| 587 if (state_ == ERROR || state_ == WAITING_FOR_CODEC || |
| 588 state_ == WAITING_FOR_KEY) { |
| 589 return false; |
| 590 } |
| 587 if (bitstreams_notified_in_advance_.size() > kMaxBitstreamsNotifiedInAdvance) | 591 if (bitstreams_notified_in_advance_.size() > kMaxBitstreamsNotifiedInAdvance) |
| 588 return false; | 592 return false; |
| 589 if (pending_bitstream_records_.empty()) | 593 if (pending_bitstream_records_.empty()) |
| 590 return false; | 594 return false; |
| 591 if (state_ == WAITING_FOR_KEY) | |
| 592 return false; | |
| 593 | 595 |
| 594 int input_buf_index = pending_input_buf_index_; | 596 int input_buf_index = pending_input_buf_index_; |
| 595 | 597 |
| 596 // Do not dequeue a new input buffer if we failed with MEDIA_CODEC_NO_KEY. | 598 // Do not dequeue a new input buffer if we failed with MEDIA_CODEC_NO_KEY. |
| 597 // That status does not return this buffer back to the pool of | 599 // That status does not return this buffer back to the pool of |
| 598 // available input buffers. We have to reuse it in QueueSecureInputBuffer(). | 600 // available input buffers. We have to reuse it in QueueSecureInputBuffer(). |
| 599 if (input_buf_index == -1) { | 601 if (input_buf_index == -1) { |
| 600 media::MediaCodecStatus status = | 602 media::MediaCodecStatus status = |
| 601 media_codec_->DequeueInputBuffer(NoWaitTimeOut(), &input_buf_index); | 603 media_codec_->DequeueInputBuffer(NoWaitTimeOut(), &input_buf_index); |
| 602 switch (status) { | 604 switch (status) { |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 709 return false; | 711 return false; |
| 710 } | 712 } |
| 711 | 713 |
| 712 return true; | 714 return true; |
| 713 } | 715 } |
| 714 | 716 |
| 715 bool AndroidVideoDecodeAccelerator::DequeueOutput() { | 717 bool AndroidVideoDecodeAccelerator::DequeueOutput() { |
| 716 DCHECK(thread_checker_.CalledOnValidThread()); | 718 DCHECK(thread_checker_.CalledOnValidThread()); |
| 717 TRACE_EVENT0("media", "AVDA::DequeueOutput"); | 719 TRACE_EVENT0("media", "AVDA::DequeueOutput"); |
| 718 base::AutoReset<bool> auto_reset(&defer_errors_, true); | 720 base::AutoReset<bool> auto_reset(&defer_errors_, true); |
| 721 if (state_ == ERROR || state_ == WAITING_FOR_CODEC) |
| 722 return false; |
| 719 if (picturebuffers_requested_ && output_picture_buffers_.empty()) | 723 if (picturebuffers_requested_ && output_picture_buffers_.empty()) |
| 720 return false; | 724 return false; |
| 721 | |
| 722 if (!output_picture_buffers_.empty() && free_picture_ids_.empty()) { | 725 if (!output_picture_buffers_.empty() && free_picture_ids_.empty()) { |
| 723 // Don't have any picture buffer to send. Need to wait more. | 726 // Don't have any picture buffer to send. Need to wait. |
| 724 return false; | 727 return false; |
| 725 } | 728 } |
| 726 | 729 |
| 727 bool eos = false; | 730 bool eos = false; |
| 728 base::TimeDelta presentation_timestamp; | 731 base::TimeDelta presentation_timestamp; |
| 729 int32_t buf_index = 0; | 732 int32_t buf_index = 0; |
| 730 do { | 733 do { |
| 731 size_t offset = 0; | 734 size_t offset = 0; |
| 732 size_t size = 0; | 735 size_t size = 0; |
| 733 | 736 |
| (...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1622 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { | 1625 if (media::MediaCodecUtil::IsSurfaceViewOutputSupported()) { |
| 1623 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: | 1626 capabilities.flags |= media::VideoDecodeAccelerator::Capabilities:: |
| 1624 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1627 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
| 1625 } | 1628 } |
| 1626 } | 1629 } |
| 1627 | 1630 |
| 1628 return capabilities; | 1631 return capabilities; |
| 1629 } | 1632 } |
| 1630 | 1633 |
| 1631 } // namespace media | 1634 } // namespace media |
| OLD | NEW |