| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/filters/gpu_video_decoder.h" | 5 #include "media/filters/gpu_video_decoder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( | 123 static void ReportGpuVideoDecoderInitializeStatusToUMAAndRunCB( |
| 124 const VideoDecoder::InitCB& cb, | 124 const VideoDecoder::InitCB& cb, |
| 125 bool success) { | 125 bool success) { |
| 126 // TODO(xhwang): Report |success| directly. | 126 // TODO(xhwang): Report |success| directly. |
| 127 PipelineStatus status = success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED; | 127 PipelineStatus status = success ? PIPELINE_OK : DECODER_ERROR_NOT_SUPPORTED; |
| 128 UMA_HISTOGRAM_ENUMERATION( | 128 UMA_HISTOGRAM_ENUMERATION( |
| 129 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); | 129 "Media.GpuVideoDecoderInitializeStatus", status, PIPELINE_STATUS_MAX + 1); |
| 130 cb.Run(success); | 130 cb.Run(success); |
| 131 } | 131 } |
| 132 | 132 |
| 133 // static |
| 134 void ReleaseMailboxTrampoline( |
| 135 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
| 136 const VideoFrame::ReleaseMailboxCB& release_mailbox_cb, |
| 137 const gpu::SyncToken& release_sync_token) { |
| 138 if (task_runner->BelongsToCurrentThread()) { |
| 139 release_mailbox_cb.Run(release_sync_token); |
| 140 return; |
| 141 } |
| 142 |
| 143 task_runner->PostTask(FROM_HERE, |
| 144 base::Bind(release_mailbox_cb, release_sync_token)); |
| 145 } |
| 146 |
| 133 std::string GpuVideoDecoder::GetDisplayName() const { | 147 std::string GpuVideoDecoder::GetDisplayName() const { |
| 134 return kDecoderName; | 148 return kDecoderName; |
| 135 } | 149 } |
| 136 | 150 |
| 137 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, | 151 void GpuVideoDecoder::Initialize(const VideoDecoderConfig& config, |
| 138 bool /* low_delay */, | 152 bool /* low_delay */, |
| 139 CdmContext* cdm_context, | 153 CdmContext* cdm_context, |
| 140 const InitCB& init_cb, | 154 const InitCB& init_cb, |
| 141 const OutputCB& output_cb) { | 155 const OutputCB& output_cb) { |
| 142 DVLOG(3) << "Initialize()"; | 156 DVLOG(3) << "Initialize()"; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 194 } |
| 181 | 195 |
| 182 config_ = config; | 196 config_ = config; |
| 183 needs_all_picture_buffers_to_decode_ = | 197 needs_all_picture_buffers_to_decode_ = |
| 184 capabilities.flags & | 198 capabilities.flags & |
| 185 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; | 199 VideoDecodeAccelerator::Capabilities::NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE; |
| 186 needs_bitstream_conversion_ = (config.codec() == kCodecH264); | 200 needs_bitstream_conversion_ = (config.codec() == kCodecH264); |
| 187 supports_deferred_initialization_ = !!( | 201 supports_deferred_initialization_ = !!( |
| 188 capabilities.flags & | 202 capabilities.flags & |
| 189 VideoDecodeAccelerator::Capabilities::SUPPORTS_DEFERRED_INITIALIZATION); | 203 VideoDecodeAccelerator::Capabilities::SUPPORTS_DEFERRED_INITIALIZATION); |
| 190 output_cb_ = BindToCurrentLoop(output_cb); | 204 output_cb_ = output_cb; |
| 191 | 205 |
| 192 if (config.is_encrypted() && !supports_deferred_initialization_) { | 206 if (config.is_encrypted() && !supports_deferred_initialization_) { |
| 193 DVLOG(1) << __FUNCTION__ | 207 DVLOG(1) << __FUNCTION__ |
| 194 << " Encrypted stream requires deferred initialialization."; | 208 << " Encrypted stream requires deferred initialialization."; |
| 195 bound_init_cb.Run(false); | 209 bound_init_cb.Run(false); |
| 196 return; | 210 return; |
| 197 } | 211 } |
| 198 | 212 |
| 199 if (previously_initialized) { | 213 if (previously_initialized) { |
| 200 DVLOG(3) << __FUNCTION__ | 214 DVLOG(3) << __FUNCTION__ |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 } | 554 } |
| 541 | 555 |
| 542 DCHECK(decoder_texture_target_); | 556 DCHECK(decoder_texture_target_); |
| 543 | 557 |
| 544 bool opaque = IsOpaque(config_.format()); | 558 bool opaque = IsOpaque(config_.format()); |
| 545 | 559 |
| 546 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture( | 560 scoped_refptr<VideoFrame> frame(VideoFrame::WrapNativeTexture( |
| 547 opaque ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB, | 561 opaque ? PIXEL_FORMAT_XRGB : PIXEL_FORMAT_ARGB, |
| 548 gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(), | 562 gpu::MailboxHolder(pb.texture_mailbox(0), gpu::SyncToken(), |
| 549 decoder_texture_target_), | 563 decoder_texture_target_), |
| 550 BindToCurrentLoop(base::Bind( | 564 base::Bind(&ReleaseMailboxTrampoline, factories_->GetTaskRunner(), |
| 551 &GpuVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), | 565 base::Bind(&GpuVideoDecoder::ReleaseMailbox, |
| 552 factories_, picture.picture_buffer_id(), pb.texture_ids())), | 566 weak_factory_.GetWeakPtr(), factories_, |
| 567 picture.picture_buffer_id(), pb.texture_ids())), |
| 553 pb.size(), visible_rect, natural_size, timestamp)); | 568 pb.size(), visible_rect, natural_size, timestamp)); |
| 554 if (!frame) { | 569 if (!frame) { |
| 555 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); | 570 DLOG(ERROR) << "Create frame failed for: " << picture.picture_buffer_id(); |
| 556 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); | 571 NotifyError(VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 557 return; | 572 return; |
| 558 } | 573 } |
| 559 if (picture.allow_overlay()) | 574 if (picture.allow_overlay()) |
| 560 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); | 575 frame->metadata()->SetBoolean(VideoFrameMetadata::ALLOW_OVERLAY, true); |
| 561 #if defined(OS_MACOSX) || defined(OS_WIN) | 576 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 562 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true); | 577 frame->metadata()->SetBoolean(VideoFrameMetadata::DECODER_OWNS_FRAME, true); |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 } | 779 } |
| 765 return false; | 780 return false; |
| 766 } | 781 } |
| 767 | 782 |
| 768 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() | 783 void GpuVideoDecoder::DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() |
| 769 const { | 784 const { |
| 770 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); | 785 DCHECK(factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 771 } | 786 } |
| 772 | 787 |
| 773 } // namespace media | 788 } // namespace media |
| OLD | NEW |