OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/pepper_platform_video_decoder_impl.h" | 5 #include "content/renderer/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/renderer/gpu/gpu_channel_host.h" | 12 #include "content/renderer/gpu/gpu_channel_host.h" |
13 #include "content/renderer/render_thread.h" | 13 #include "content/renderer/render_thread.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(const std::vector<int32>& configs) { | 27 bool PlatformVideoDecoderImpl::Initialize(Profile profile) { |
28 // TODO(vrk): Support multiple decoders. | 28 // TODO(vrk): Support multiple decoders. |
29 if (decoder_) | 29 if (decoder_) |
30 return true; | 30 return true; |
31 | 31 |
32 RenderThread* render_thread = RenderThread::current(); | 32 RenderThread* render_thread = RenderThread::current(); |
33 DCHECK(render_thread); | 33 DCHECK(render_thread); |
34 | 34 |
35 // This is not synchronous, but subsequent IPC messages will be buffered, so | 35 // This is not synchronous, but subsequent IPC messages will be buffered, so |
36 // it is okay to immediately send IPC messages through the returned channel. | 36 // it is okay to immediately send IPC messages through the returned channel. |
37 GpuChannelHost* channel = | 37 GpuChannelHost* channel = |
38 render_thread->EstablishGpuChannelSync( | 38 render_thread->EstablishGpuChannelSync( |
39 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 39 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
40 | 40 |
41 if (!channel) | 41 if (!channel) |
42 return false; | 42 return false; |
43 | 43 |
44 DCHECK_EQ(channel->state(), GpuChannelHost::kConnected); | 44 DCHECK_EQ(channel->state(), GpuChannelHost::kConnected); |
45 | 45 |
46 // Send IPC message to initialize decoder in GPU process. | 46 // Send IPC message to initialize decoder in GPU process. |
47 decoder_ = channel->CreateVideoDecoder( | 47 decoder_ = channel->CreateVideoDecoder( |
48 command_buffer_route_id_, configs, this); | 48 command_buffer_route_id_, profile, this); |
49 return decoder_.get() != NULL; | 49 return decoder_.get() != NULL; |
50 } | 50 } |
51 | 51 |
52 void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) { | 52 void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) { |
53 DCHECK(decoder_); | 53 DCHECK(decoder_); |
54 decoder_->Decode(bitstream_buffer); | 54 decoder_->Decode(bitstream_buffer); |
55 } | 55 } |
56 | 56 |
57 void PlatformVideoDecoderImpl::AssignPictureBuffers( | 57 void PlatformVideoDecoderImpl::AssignPictureBuffers( |
58 const std::vector<media::PictureBuffer>& buffers) { | 58 const std::vector<media::PictureBuffer>& buffers) { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 void PlatformVideoDecoderImpl::NotifyFlushDone() { | 124 void PlatformVideoDecoderImpl::NotifyFlushDone() { |
125 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 125 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); |
126 client_->NotifyFlushDone(); | 126 client_->NotifyFlushDone(); |
127 } | 127 } |
128 | 128 |
129 void PlatformVideoDecoderImpl::NotifyResetDone() { | 129 void PlatformVideoDecoderImpl::NotifyResetDone() { |
130 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 130 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); |
131 client_->NotifyResetDone(); | 131 client_->NotifyResetDone(); |
132 } | 132 } |
OLD | NEW |