| 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_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(Profile profile) { | 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 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 33 DCHECK(render_thread); | |
| 34 | 33 |
| 35 // 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 |
| 36 // 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. |
| 37 GpuChannelHost* channel = | 36 GpuChannelHost* channel = |
| 38 render_thread->EstablishGpuChannelSync( | 37 render_thread->EstablishGpuChannelSync( |
| 39 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); | 38 content::CAUSE_FOR_GPU_LAUNCH_VIDEODECODEACCELERATOR_INITIALIZE); |
| 40 | 39 |
| 41 if (!channel) | 40 if (!channel) |
| 42 return false; | 41 return false; |
| 43 | 42 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 76 } |
| 78 | 77 |
| 79 void PlatformVideoDecoderImpl::Destroy() { | 78 void PlatformVideoDecoderImpl::Destroy() { |
| 80 DCHECK(decoder_); | 79 DCHECK(decoder_); |
| 81 decoder_->Destroy(); | 80 decoder_->Destroy(); |
| 82 client_ = NULL; | 81 client_ = NULL; |
| 83 decoder_ = NULL; | 82 decoder_ = NULL; |
| 84 } | 83 } |
| 85 | 84 |
| 86 void PlatformVideoDecoderImpl::NotifyEndOfStream() { | 85 void PlatformVideoDecoderImpl::NotifyEndOfStream() { |
| 87 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 86 DCHECK(RenderThreadImpl::current()); |
| 88 client_->NotifyEndOfStream(); | 87 client_->NotifyEndOfStream(); |
| 89 } | 88 } |
| 90 | 89 |
| 91 void PlatformVideoDecoderImpl::NotifyError( | 90 void PlatformVideoDecoderImpl::NotifyError( |
| 92 VideoDecodeAccelerator::Error error) { | 91 VideoDecodeAccelerator::Error error) { |
| 93 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 92 DCHECK(RenderThreadImpl::current()); |
| 94 client_->NotifyError(error); | 93 client_->NotifyError(error); |
| 95 } | 94 } |
| 96 | 95 |
| 97 void PlatformVideoDecoderImpl::ProvidePictureBuffers( | 96 void PlatformVideoDecoderImpl::ProvidePictureBuffers( |
| 98 uint32 requested_num_of_buffers, | 97 uint32 requested_num_of_buffers, |
| 99 const gfx::Size& dimensions) { | 98 const gfx::Size& dimensions) { |
| 100 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 99 DCHECK(RenderThreadImpl::current()); |
| 101 client_->ProvidePictureBuffers(requested_num_of_buffers, dimensions); | 100 client_->ProvidePictureBuffers(requested_num_of_buffers, dimensions); |
| 102 } | 101 } |
| 103 | 102 |
| 104 void PlatformVideoDecoderImpl::DismissPictureBuffer(int32 picture_buffer_id) { | 103 void PlatformVideoDecoderImpl::DismissPictureBuffer(int32 picture_buffer_id) { |
| 105 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 104 DCHECK(RenderThreadImpl::current()); |
| 106 client_->DismissPictureBuffer(picture_buffer_id); | 105 client_->DismissPictureBuffer(picture_buffer_id); |
| 107 } | 106 } |
| 108 | 107 |
| 109 void PlatformVideoDecoderImpl::PictureReady(const media::Picture& picture) { | 108 void PlatformVideoDecoderImpl::PictureReady(const media::Picture& picture) { |
| 110 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 109 DCHECK(RenderThreadImpl::current()); |
| 111 client_->PictureReady(picture); | 110 client_->PictureReady(picture); |
| 112 } | 111 } |
| 113 | 112 |
| 114 void PlatformVideoDecoderImpl::NotifyInitializeDone() { | 113 void PlatformVideoDecoderImpl::NotifyInitializeDone() { |
| 115 NOTREACHED() << "GpuVideoDecodeAcceleratorHost::Initialize is synchronous!"; | 114 NOTREACHED() << "GpuVideoDecodeAcceleratorHost::Initialize is synchronous!"; |
| 116 } | 115 } |
| 117 | 116 |
| 118 void PlatformVideoDecoderImpl::NotifyEndOfBitstreamBuffer( | 117 void PlatformVideoDecoderImpl::NotifyEndOfBitstreamBuffer( |
| 119 int32 bitstream_buffer_id) { | 118 int32 bitstream_buffer_id) { |
| 120 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 119 DCHECK(RenderThreadImpl::current()); |
| 121 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); | 120 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); |
| 122 } | 121 } |
| 123 | 122 |
| 124 void PlatformVideoDecoderImpl::NotifyFlushDone() { | 123 void PlatformVideoDecoderImpl::NotifyFlushDone() { |
| 125 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 124 DCHECK(RenderThreadImpl::current()); |
| 126 client_->NotifyFlushDone(); | 125 client_->NotifyFlushDone(); |
| 127 } | 126 } |
| 128 | 127 |
| 129 void PlatformVideoDecoderImpl::NotifyResetDone() { | 128 void PlatformVideoDecoderImpl::NotifyResetDone() { |
| 130 DCHECK_EQ(RenderThread::current()->message_loop(), MessageLoop::current()); | 129 DCHECK(RenderThreadImpl::current()); |
| 131 client_->NotifyResetDone(); | 130 client_->NotifyResetDone(); |
| 132 } | 131 } |
| OLD | NEW |