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
3 // found in the LICENSE file.
5 #include "content/renderer/media/pepper_platform_video_decoder.h"
8 #include "base/logging.h"
9 #include "content/child/child_process.h"
10 #include "content/common/gpu/client/gpu_channel_host.h"
11 #include "content/renderer/render_thread_impl.h"
13 using media::BitstreamBuffer
;
17 PlatformVideoDecoder::PlatformVideoDecoder(
18 VideoDecodeAccelerator::Client
* client
,
19 int32 command_buffer_route_id
)
21 command_buffer_route_id_(command_buffer_route_id
) {
25 PlatformVideoDecoder::~PlatformVideoDecoder() {}
27 bool PlatformVideoDecoder::Initialize(media::VideoCodecProfile profile
) {
28 // TODO(vrk): Support multiple decoders.
32 RenderThreadImpl
* render_thread
= RenderThreadImpl::current();
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.
36 GpuChannelHost
* channel
=
37 render_thread
->EstablishGpuChannelSync(
38 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE
);
43 // Send IPC message to initialize decoder in GPU process.
45 channel
->CreateVideoDecoder(command_buffer_route_id_
, profile
, this);
46 return decoder_
.get() != NULL
;
49 void PlatformVideoDecoder::Decode(const BitstreamBuffer
& bitstream_buffer
) {
50 DCHECK(decoder_
.get());
51 decoder_
->Decode(bitstream_buffer
);
54 void PlatformVideoDecoder::AssignPictureBuffers(
55 const std::vector
<media::PictureBuffer
>& buffers
) {
56 DCHECK(decoder_
.get());
57 decoder_
->AssignPictureBuffers(buffers
);
60 void PlatformVideoDecoder::ReusePictureBuffer(int32 picture_buffer_id
) {
61 DCHECK(decoder_
.get());
62 decoder_
->ReusePictureBuffer(picture_buffer_id
);
65 void PlatformVideoDecoder::Flush() {
66 DCHECK(decoder_
.get());
70 void PlatformVideoDecoder::Reset() {
71 DCHECK(decoder_
.get());
75 void PlatformVideoDecoder::Destroy() {
77 decoder_
.release()->Destroy();
82 void PlatformVideoDecoder::NotifyError(
83 VideoDecodeAccelerator::Error error
) {
84 DCHECK(RenderThreadImpl::current());
85 client_
->NotifyError(error
);
88 void PlatformVideoDecoder::ProvidePictureBuffers(
89 uint32 requested_num_of_buffers
,
90 const gfx::Size
& dimensions
,
91 uint32 texture_target
) {
92 DCHECK(RenderThreadImpl::current());
93 client_
->ProvidePictureBuffers(requested_num_of_buffers
, dimensions
,
97 void PlatformVideoDecoder::DismissPictureBuffer(int32 picture_buffer_id
) {
98 DCHECK(RenderThreadImpl::current());
99 client_
->DismissPictureBuffer(picture_buffer_id
);
102 void PlatformVideoDecoder::PictureReady(const media::Picture
& picture
) {
103 DCHECK(RenderThreadImpl::current());
104 client_
->PictureReady(picture
);
107 void PlatformVideoDecoder::NotifyInitializeDone() {
108 NOTREACHED() << "GpuVideoDecodeAcceleratorHost::Initialize is synchronous!";
111 void PlatformVideoDecoder::NotifyEndOfBitstreamBuffer(
112 int32 bitstream_buffer_id
) {
113 DCHECK(RenderThreadImpl::current());
114 client_
->NotifyEndOfBitstreamBuffer(bitstream_buffer_id
);
117 void PlatformVideoDecoder::NotifyFlushDone() {
118 DCHECK(RenderThreadImpl::current());
119 client_
->NotifyFlushDone();
122 void PlatformVideoDecoder::NotifyResetDone() {
123 DCHECK(RenderThreadImpl::current());
124 client_
->NotifyResetDone();
127 } // namespace content