| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "content/renderer/media/pepper_platform_video_decoder.h" | |
| 6 | |
| 7 #include "base/bind.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" | |
| 12 | |
| 13 using media::BitstreamBuffer; | |
| 14 | |
| 15 namespace content { | |
| 16 | |
| 17 PlatformVideoDecoder::PlatformVideoDecoder(int32 command_buffer_route_id) | |
| 18 : command_buffer_route_id_(command_buffer_route_id) {} | |
| 19 | |
| 20 PlatformVideoDecoder::~PlatformVideoDecoder() {} | |
| 21 | |
| 22 bool PlatformVideoDecoder::Initialize( | |
| 23 media::VideoCodecProfile profile, | |
| 24 media::VideoDecodeAccelerator::Client* client) { | |
| 25 client_ = client; | |
| 26 | |
| 27 // TODO(vrk): Support multiple decoders. | |
| 28 if (decoder_) | |
| 29 return true; | |
| 30 | |
| 31 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | |
| 32 | |
| 33 // This is not synchronous, but subsequent IPC messages will be buffered, so | |
| 34 // it is okay to immediately send IPC messages through the returned channel. | |
| 35 GpuChannelHost* channel = | |
| 36 render_thread->EstablishGpuChannelSync( | |
| 37 CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | |
| 38 | |
| 39 if (!channel) | |
| 40 return false; | |
| 41 | |
| 42 // Send IPC message to initialize decoder in GPU process. | |
| 43 decoder_ = channel->CreateVideoDecoder(command_buffer_route_id_); | |
| 44 return (decoder_ && decoder_->Initialize(profile, this)); | |
| 45 } | |
| 46 | |
| 47 void PlatformVideoDecoder::Decode(const BitstreamBuffer& bitstream_buffer) { | |
| 48 DCHECK(decoder_.get()); | |
| 49 decoder_->Decode(bitstream_buffer); | |
| 50 } | |
| 51 | |
| 52 void PlatformVideoDecoder::AssignPictureBuffers( | |
| 53 const std::vector<media::PictureBuffer>& buffers) { | |
| 54 DCHECK(decoder_.get()); | |
| 55 decoder_->AssignPictureBuffers(buffers); | |
| 56 } | |
| 57 | |
| 58 void PlatformVideoDecoder::ReusePictureBuffer(int32 picture_buffer_id) { | |
| 59 DCHECK(decoder_.get()); | |
| 60 decoder_->ReusePictureBuffer(picture_buffer_id); | |
| 61 } | |
| 62 | |
| 63 void PlatformVideoDecoder::Flush() { | |
| 64 DCHECK(decoder_.get()); | |
| 65 decoder_->Flush(); | |
| 66 } | |
| 67 | |
| 68 void PlatformVideoDecoder::Reset() { | |
| 69 DCHECK(decoder_.get()); | |
| 70 decoder_->Reset(); | |
| 71 } | |
| 72 | |
| 73 void PlatformVideoDecoder::Destroy() { | |
| 74 if (decoder_) | |
| 75 decoder_.release()->Destroy(); | |
| 76 client_ = NULL; | |
| 77 delete this; | |
| 78 } | |
| 79 | |
| 80 void PlatformVideoDecoder::NotifyError( | |
| 81 VideoDecodeAccelerator::Error error) { | |
| 82 DCHECK(RenderThreadImpl::current()); | |
| 83 client_->NotifyError(error); | |
| 84 } | |
| 85 | |
| 86 void PlatformVideoDecoder::ProvidePictureBuffers( | |
| 87 uint32 requested_num_of_buffers, | |
| 88 const gfx::Size& dimensions, | |
| 89 uint32 texture_target) { | |
| 90 DCHECK(RenderThreadImpl::current()); | |
| 91 client_->ProvidePictureBuffers(requested_num_of_buffers, dimensions, | |
| 92 texture_target); | |
| 93 } | |
| 94 | |
| 95 void PlatformVideoDecoder::DismissPictureBuffer(int32 picture_buffer_id) { | |
| 96 DCHECK(RenderThreadImpl::current()); | |
| 97 client_->DismissPictureBuffer(picture_buffer_id); | |
| 98 } | |
| 99 | |
| 100 void PlatformVideoDecoder::PictureReady(const media::Picture& picture) { | |
| 101 DCHECK(RenderThreadImpl::current()); | |
| 102 client_->PictureReady(picture); | |
| 103 } | |
| 104 | |
| 105 void PlatformVideoDecoder::NotifyEndOfBitstreamBuffer( | |
| 106 int32 bitstream_buffer_id) { | |
| 107 DCHECK(RenderThreadImpl::current()); | |
| 108 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); | |
| 109 } | |
| 110 | |
| 111 void PlatformVideoDecoder::NotifyFlushDone() { | |
| 112 DCHECK(RenderThreadImpl::current()); | |
| 113 client_->NotifyFlushDone(); | |
| 114 } | |
| 115 | |
| 116 void PlatformVideoDecoder::NotifyResetDone() { | |
| 117 DCHECK(RenderThreadImpl::current()); | |
| 118 client_->NotifyResetDone(); | |
| 119 } | |
| 120 | |
| 121 } // namespace content | |
| OLD | NEW |