Fix build break
[chromium-blink-merge.git] / content / renderer / media / pepper_platform_video_decoder_impl.cc
blobab444e82f50db7932fabc0970466cbe5756d2a69
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_impl.h"
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "content/common/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;
15 namespace content {
17 PlatformVideoDecoderImpl::PlatformVideoDecoderImpl(
18 VideoDecodeAccelerator::Client* client,
19 int32 command_buffer_route_id)
20 : client_(client),
21 command_buffer_route_id_(command_buffer_route_id) {
22 DCHECK(client);
25 PlatformVideoDecoderImpl::~PlatformVideoDecoderImpl() {}
27 bool PlatformVideoDecoderImpl::Initialize(media::VideoCodecProfile profile) {
28 // TODO(vrk): Support multiple decoders.
29 if (decoder_.get())
30 return true;
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);
40 if (!channel)
41 return false;
43 DCHECK_EQ(channel->state(), GpuChannelHost::kConnected);
45 // Send IPC message to initialize decoder in GPU process.
46 decoder_.reset(channel->CreateVideoDecoder(
47 command_buffer_route_id_, profile, this));
48 return decoder_.get() != NULL;
51 void PlatformVideoDecoderImpl::Decode(const BitstreamBuffer& bitstream_buffer) {
52 DCHECK(decoder_.get());
53 decoder_->Decode(bitstream_buffer);
56 void PlatformVideoDecoderImpl::AssignPictureBuffers(
57 const std::vector<media::PictureBuffer>& buffers) {
58 DCHECK(decoder_.get());
59 decoder_->AssignPictureBuffers(buffers);
62 void PlatformVideoDecoderImpl::ReusePictureBuffer(
63 int32 picture_buffer_id) {
64 DCHECK(decoder_.get());
65 decoder_->ReusePictureBuffer(picture_buffer_id);
68 void PlatformVideoDecoderImpl::Flush() {
69 DCHECK(decoder_.get());
70 decoder_->Flush();
73 void PlatformVideoDecoderImpl::Reset() {
74 DCHECK(decoder_.get());
75 decoder_->Reset();
78 void PlatformVideoDecoderImpl::Destroy() {
79 if (decoder_.get())
80 decoder_.release()->Destroy();
81 client_ = NULL;
82 delete this;
85 void PlatformVideoDecoderImpl::NotifyError(
86 VideoDecodeAccelerator::Error error) {
87 DCHECK(RenderThreadImpl::current());
88 client_->NotifyError(error);
91 void PlatformVideoDecoderImpl::ProvidePictureBuffers(
92 uint32 requested_num_of_buffers,
93 const gfx::Size& dimensions,
94 uint32 texture_target) {
95 DCHECK(RenderThreadImpl::current());
96 client_->ProvidePictureBuffers(requested_num_of_buffers, dimensions,
97 texture_target);
100 void PlatformVideoDecoderImpl::DismissPictureBuffer(int32 picture_buffer_id) {
101 DCHECK(RenderThreadImpl::current());
102 client_->DismissPictureBuffer(picture_buffer_id);
105 void PlatformVideoDecoderImpl::PictureReady(const media::Picture& picture) {
106 DCHECK(RenderThreadImpl::current());
107 client_->PictureReady(picture);
110 void PlatformVideoDecoderImpl::NotifyInitializeDone() {
111 NOTREACHED() << "GpuVideoDecodeAcceleratorHost::Initialize is synchronous!";
114 void PlatformVideoDecoderImpl::NotifyEndOfBitstreamBuffer(
115 int32 bitstream_buffer_id) {
116 DCHECK(RenderThreadImpl::current());
117 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id);
120 void PlatformVideoDecoderImpl::NotifyFlushDone() {
121 DCHECK(RenderThreadImpl::current());
122 client_->NotifyFlushDone();
125 void PlatformVideoDecoderImpl::NotifyResetDone() {
126 DCHECK(RenderThreadImpl::current());
127 client_->NotifyResetDone();
130 } // namespace content