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