| 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 "content/renderer/media/pepper_platform_video_decoder_impl.h" | 5 #include "content/renderer/media/pepper_platform_video_decoder_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "content/common/child_process.h" | 11 #include "content/common/child_process.h" |
| 12 #include "content/common/gpu/client/gpu_channel_host.h" | 12 #include "content/common/gpu/client/gpu_channel_host.h" |
| 13 #include "content/renderer/render_thread_impl.h" | 13 #include "content/renderer/render_thread_impl.h" |
| 14 | 14 |
| 15 using media::BitstreamBuffer; | 15 using media::BitstreamBuffer; |
| 16 | 16 |
| 17 PlatformVideoDecoderImpl::PlatformVideoDecoderImpl( | 17 PlatformVideoDecoderImpl::PlatformVideoDecoderImpl( |
| 18 VideoDecodeAccelerator::Client* client, | 18 VideoDecodeAccelerator::Client* client, |
| 19 int32 command_buffer_route_id) | 19 int32 command_buffer_route_id) |
| 20 : client_(client), | 20 : client_(client), |
| 21 command_buffer_route_id_(command_buffer_route_id) { | 21 command_buffer_route_id_(command_buffer_route_id) { |
| 22 DCHECK(client); | 22 DCHECK(client); |
| 23 } | 23 } |
| 24 | 24 |
| 25 PlatformVideoDecoderImpl::~PlatformVideoDecoderImpl() {} | 25 PlatformVideoDecoderImpl::~PlatformVideoDecoderImpl() {} |
| 26 | 26 |
| 27 bool PlatformVideoDecoderImpl::Initialize(media::VideoCodecProfile profile) { | 27 bool PlatformVideoDecoderImpl::Initialize( |
| 28 media::VideoCodecProfile profile, |
| 29 const gfx::Size& frame_size, |
| 30 const std::vector<uint8_t>& extra_data) { |
| 28 // TODO(vrk): Support multiple decoders. | 31 // TODO(vrk): Support multiple decoders. |
| 29 if (decoder_) | 32 if (decoder_) |
| 30 return true; | 33 return true; |
| 31 | 34 |
| 32 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 35 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 33 | 36 |
| 34 // This is not synchronous, but subsequent IPC messages will be buffered, so | 37 // This is not synchronous, but subsequent IPC messages will be buffered, so |
| 35 // it is okay to immediately send IPC messages through the returned channel. | 38 // it is okay to immediately send IPC messages through the returned channel. |
| 36 GpuChannelHost* channel = | 39 GpuChannelHost* channel = |
| 37 render_thread->EstablishGpuChannelSync( | 40 render_thread->EstablishGpuChannelSync( |
| 38 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 41 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| 39 | 42 |
| 40 if (!channel) | 43 if (!channel) |
| 41 return false; | 44 return false; |
| 42 | 45 |
| 43 DCHECK_EQ(channel->state(), GpuChannelHost::kConnected); | 46 DCHECK_EQ(channel->state(), GpuChannelHost::kConnected); |
| 44 | 47 |
| 45 // Send IPC message to initialize decoder in GPU process. | 48 // Send IPC message to initialize decoder in GPU process. |
| 46 decoder_ = channel->CreateVideoDecoder( | 49 decoder_ = channel->CreateVideoDecoder( |
| 47 command_buffer_route_id_, profile, this); | 50 command_buffer_route_id_, profile, frame_size, extra_data, this); |
| 48 return decoder_.get() != NULL; | 51 return decoder_.get() != NULL; |
| 49 } | 52 } |
| 50 | 53 |
| 51 void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) { | 54 void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) { |
| 52 DCHECK(decoder_); | 55 DCHECK(decoder_); |
| 53 decoder_->Decode(bitstream_buffer); | 56 decoder_->Decode(bitstream_buffer); |
| 54 } | 57 } |
| 55 | 58 |
| 56 void PlatformVideoDecoderImpl::AssignPictureBuffers( | 59 void PlatformVideoDecoderImpl::AssignPictureBuffers( |
| 57 const std::vector<media::PictureBuffer>& buffers) { | 60 const std::vector<media::PictureBuffer>& buffers) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 | 120 |
| 118 void PlatformVideoDecoderImpl::NotifyFlushDone() { | 121 void PlatformVideoDecoderImpl::NotifyFlushDone() { |
| 119 DCHECK(RenderThreadImpl::current()); | 122 DCHECK(RenderThreadImpl::current()); |
| 120 client_->NotifyFlushDone(); | 123 client_->NotifyFlushDone(); |
| 121 } | 124 } |
| 122 | 125 |
| 123 void PlatformVideoDecoderImpl::NotifyResetDone() { | 126 void PlatformVideoDecoderImpl::NotifyResetDone() { |
| 124 DCHECK(RenderThreadImpl::current()); | 127 DCHECK(RenderThreadImpl::current()); |
| 125 client_->NotifyResetDone(); | 128 client_->NotifyResetDone(); |
| 126 } | 129 } |
| OLD | NEW |