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(media::VideoCodecProfile profile) { |
28 // TODO(vrk): Support multiple decoders. | 28 // TODO(vrk): Support multiple decoders. |
29 if (decoder_) | 29 if (decoder_.get()) |
30 return true; | 30 return true; |
31 | 31 |
32 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | 32 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
33 | 33 |
34 // This is not synchronous, but subsequent IPC messages will be buffered, so | 34 // 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. | 35 // it is okay to immediately send IPC messages through the returned channel. |
36 GpuChannelHost* channel = | 36 GpuChannelHost* channel = |
37 render_thread->EstablishGpuChannelSync( | 37 render_thread->EstablishGpuChannelSync( |
38 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 38 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
39 | 39 |
40 if (!channel) | 40 if (!channel) |
41 return false; | 41 return false; |
42 | 42 |
43 DCHECK_EQ(channel->state(), GpuChannelHost::kConnected); | 43 DCHECK_EQ(channel->state(), GpuChannelHost::kConnected); |
44 | 44 |
45 // Send IPC message to initialize decoder in GPU process. | 45 // Send IPC message to initialize decoder in GPU process. |
46 decoder_ = channel->CreateVideoDecoder( | 46 decoder_.reset(channel->CreateVideoDecoder( |
47 command_buffer_route_id_, profile, this); | 47 command_buffer_route_id_, profile, this)); |
48 return decoder_.get() != NULL; | 48 return decoder_.get() != NULL; |
49 } | 49 } |
50 | 50 |
51 void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) { | 51 void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) { |
52 DCHECK(decoder_); | 52 DCHECK(decoder_.get()); |
53 decoder_->Decode(bitstream_buffer); | 53 decoder_->Decode(bitstream_buffer); |
54 } | 54 } |
55 | 55 |
56 void PlatformVideoDecoderImpl::AssignPictureBuffers( | 56 void PlatformVideoDecoderImpl::AssignPictureBuffers( |
57 const std::vector<media::PictureBuffer>& buffers) { | 57 const std::vector<media::PictureBuffer>& buffers) { |
58 DCHECK(decoder_); | 58 DCHECK(decoder_.get()); |
59 decoder_->AssignPictureBuffers(buffers); | 59 decoder_->AssignPictureBuffers(buffers); |
60 } | 60 } |
61 | 61 |
62 void PlatformVideoDecoderImpl::ReusePictureBuffer( | 62 void PlatformVideoDecoderImpl::ReusePictureBuffer( |
63 int32 picture_buffer_id) { | 63 int32 picture_buffer_id) { |
64 DCHECK(decoder_); | 64 DCHECK(decoder_.get()); |
65 decoder_->ReusePictureBuffer(picture_buffer_id); | 65 decoder_->ReusePictureBuffer(picture_buffer_id); |
66 } | 66 } |
67 | 67 |
68 void PlatformVideoDecoderImpl::Flush() { | 68 void PlatformVideoDecoderImpl::Flush() { |
69 DCHECK(decoder_); | 69 DCHECK(decoder_.get()); |
70 decoder_->Flush(); | 70 decoder_->Flush(); |
71 } | 71 } |
72 | 72 |
73 void PlatformVideoDecoderImpl::Reset() { | 73 void PlatformVideoDecoderImpl::Reset() { |
74 DCHECK(decoder_); | 74 DCHECK(decoder_.get()); |
75 decoder_->Reset(); | 75 decoder_->Reset(); |
76 } | 76 } |
77 | 77 |
78 void PlatformVideoDecoderImpl::Destroy() { | 78 void PlatformVideoDecoderImpl::Destroy( |
79 DCHECK(decoder_); | 79 scoped_ptr<VideoDecodeAccelerator> self) { |
80 decoder_->Destroy(); | 80 DCHECK(decoder_.get()); |
| 81 decoder_->Destroy(decoder_.Pass()); |
81 client_ = NULL; | 82 client_ = NULL; |
82 decoder_ = NULL; | |
83 } | 83 } |
84 | 84 |
85 void PlatformVideoDecoderImpl::NotifyError( | 85 void PlatformVideoDecoderImpl::NotifyError( |
86 VideoDecodeAccelerator::Error error) { | 86 VideoDecodeAccelerator::Error error) { |
87 DCHECK(RenderThreadImpl::current()); | 87 DCHECK(RenderThreadImpl::current()); |
88 client_->NotifyError(error); | 88 client_->NotifyError(error); |
89 } | 89 } |
90 | 90 |
91 void PlatformVideoDecoderImpl::ProvidePictureBuffers( | 91 void PlatformVideoDecoderImpl::ProvidePictureBuffers( |
92 uint32 requested_num_of_buffers, | 92 uint32 requested_num_of_buffers, |
(...skipping 26 matching lines...) Expand all Loading... |
119 | 119 |
120 void PlatformVideoDecoderImpl::NotifyFlushDone() { | 120 void PlatformVideoDecoderImpl::NotifyFlushDone() { |
121 DCHECK(RenderThreadImpl::current()); | 121 DCHECK(RenderThreadImpl::current()); |
122 client_->NotifyFlushDone(); | 122 client_->NotifyFlushDone(); |
123 } | 123 } |
124 | 124 |
125 void PlatformVideoDecoderImpl::NotifyResetDone() { | 125 void PlatformVideoDecoderImpl::NotifyResetDone() { |
126 DCHECK(RenderThreadImpl::current()); | 126 DCHECK(RenderThreadImpl::current()); |
127 client_->NotifyResetDone(); | 127 client_->NotifyResetDone(); |
128 } | 128 } |
OLD | NEW |