| 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 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | 5 #ifndef CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ |
| 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | 6 #define CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | 15 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 16 #include "ipc/ipc_listener.h" | 16 #include "ipc/ipc_listener.h" |
| 17 #include "media/video/video_decode_accelerator.h" | 17 #include "media/video/video_decode_accelerator.h" |
| 18 #include "ui/gfx/geometry/size.h" | 18 #include "ui/gfx/geometry/size.h" |
| 19 | 19 |
| 20 namespace gpu { |
| 21 class GpuChannelHost; |
| 22 } |
| 23 |
| 20 namespace content { | 24 namespace content { |
| 21 class GpuChannelHost; | |
| 22 | 25 |
| 23 // This class is used to talk to VideoDecodeAccelerator in the Gpu process | 26 // This class is used to talk to VideoDecodeAccelerator in the Gpu process |
| 24 // through IPC messages. | 27 // through IPC messages. |
| 25 class GpuVideoDecodeAcceleratorHost | 28 class GpuVideoDecodeAcceleratorHost |
| 26 : public IPC::Listener, | 29 : public IPC::Listener, |
| 27 public media::VideoDecodeAccelerator, | 30 public media::VideoDecodeAccelerator, |
| 28 public CommandBufferProxyImpl::DeletionObserver, | 31 public gpu::CommandBufferProxyImpl::DeletionObserver, |
| 29 public base::NonThreadSafe { | 32 public base::NonThreadSafe { |
| 30 public: | 33 public: |
| 31 // |this| is guaranteed not to outlive |channel| and |impl|. (See comments | 34 // |this| is guaranteed not to outlive |channel| and |impl|. (See comments |
| 32 // for |channel_| and |impl_|.) | 35 // for |channel_| and |impl_|.) |
| 33 GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel, | 36 GpuVideoDecodeAcceleratorHost(gpu::GpuChannelHost* channel, |
| 34 CommandBufferProxyImpl* impl); | 37 gpu::CommandBufferProxyImpl* impl); |
| 35 | 38 |
| 36 // IPC::Listener implementation. | 39 // IPC::Listener implementation. |
| 37 void OnChannelError() override; | 40 void OnChannelError() override; |
| 38 bool OnMessageReceived(const IPC::Message& message) override; | 41 bool OnMessageReceived(const IPC::Message& message) override; |
| 39 | 42 |
| 40 // media::VideoDecodeAccelerator implementation. | 43 // media::VideoDecodeAccelerator implementation. |
| 41 bool Initialize(const Config& config, Client* client) override; | 44 bool Initialize(const Config& config, Client* client) override; |
| 42 void SetCdm(int cdm_id) override; | 45 void SetCdm(int cdm_id) override; |
| 43 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 46 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
| 44 void AssignPictureBuffers( | 47 void AssignPictureBuffers( |
| 45 const std::vector<media::PictureBuffer>& buffers) override; | 48 const std::vector<media::PictureBuffer>& buffers) override; |
| 46 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 49 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
| 47 void Flush() override; | 50 void Flush() override; |
| 48 void Reset() override; | 51 void Reset() override; |
| 49 void Destroy() override; | 52 void Destroy() override; |
| 50 | 53 |
| 51 // CommandBufferProxyImpl::DeletionObserver implemetnation. | 54 // gpu::CommandBufferProxyImpl::DeletionObserver implemetnation. |
| 52 void OnWillDeleteImpl() override; | 55 void OnWillDeleteImpl() override; |
| 53 | 56 |
| 54 private: | 57 private: |
| 55 // Only Destroy() should be deleting |this|. | 58 // Only Destroy() should be deleting |this|. |
| 56 ~GpuVideoDecodeAcceleratorHost() override; | 59 ~GpuVideoDecodeAcceleratorHost() override; |
| 57 | 60 |
| 58 // Notify |client_| of an error. Posts a task to avoid re-entrancy. | 61 // Notify |client_| of an error. Posts a task to avoid re-entrancy. |
| 59 void PostNotifyError(Error); | 62 void PostNotifyError(Error); |
| 60 | 63 |
| 61 void Send(IPC::Message* message); | 64 void Send(IPC::Message* message); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 73 const gfx::Rect& visible_rect, | 76 const gfx::Rect& visible_rect, |
| 74 bool allow_overlay, | 77 bool allow_overlay, |
| 75 bool size_changed); | 78 bool size_changed); |
| 76 void OnFlushDone(); | 79 void OnFlushDone(); |
| 77 void OnResetDone(); | 80 void OnResetDone(); |
| 78 void OnNotifyError(uint32_t error); | 81 void OnNotifyError(uint32_t error); |
| 79 | 82 |
| 80 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU | 83 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU |
| 81 // process. |channel_| outlives |impl_|, so the reference is always valid as | 84 // process. |channel_| outlives |impl_|, so the reference is always valid as |
| 82 // long as it is not NULL. | 85 // long as it is not NULL. |
| 83 GpuChannelHost* channel_; | 86 gpu::GpuChannelHost* channel_; |
| 84 | 87 |
| 85 // Route ID for the associated decoder in the GPU process. | 88 // Route ID for the associated decoder in the GPU process. |
| 86 int32_t decoder_route_id_; | 89 int32_t decoder_route_id_; |
| 87 | 90 |
| 88 // The client that will receive callbacks from the decoder. | 91 // The client that will receive callbacks from the decoder. |
| 89 Client* client_; | 92 Client* client_; |
| 90 | 93 |
| 91 // Unowned reference to the CommandBufferProxyImpl that created us. |this| | 94 // Unowned reference to the gpu::CommandBufferProxyImpl that created us. |
| 92 // registers as a DeletionObserver of |impl_|, the so reference is always | 95 // |this| registers as a DeletionObserver of |impl_|, the so reference is |
| 93 // valid as long as it is not NULL. | 96 // always valid as long as it is not NULL. |
| 94 CommandBufferProxyImpl* impl_; | 97 gpu::CommandBufferProxyImpl* impl_; |
| 95 | 98 |
| 96 // Requested dimensions of the buffer, from ProvidePictureBuffers(). | 99 // Requested dimensions of the buffer, from ProvidePictureBuffers(). |
| 97 gfx::Size picture_buffer_dimensions_; | 100 gfx::Size picture_buffer_dimensions_; |
| 98 | 101 |
| 99 // WeakPtr factory for posting tasks back to itself. | 102 // WeakPtr factory for posting tasks back to itself. |
| 100 base::WeakPtrFactory<GpuVideoDecodeAcceleratorHost> weak_this_factory_; | 103 base::WeakPtrFactory<GpuVideoDecodeAcceleratorHost> weak_this_factory_; |
| 101 | 104 |
| 102 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); | 105 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); |
| 103 }; | 106 }; |
| 104 | 107 |
| 105 } // namespace content | 108 } // namespace content |
| 106 | 109 |
| 107 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | 110 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ |
| OLD | NEW |