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 "content/common/gpu/client/command_buffer_proxy_impl.h" |
16 #include "ipc/ipc_listener.h" | 16 #include "content/common/gpu/client/ipc/gpu_video_decode_accelerator_host_ipc_tr
ansport.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 content { | 20 namespace content { |
21 class GpuChannelHost; | 21 class GpuChannelHost; |
22 | 22 |
23 // This class is used to talk to VideoDecodeAccelerator in the Gpu process | 23 // This class is used to talk to VideoDecodeAccelerator in the Gpu process |
24 // through IPC messages. | 24 // through IPC messages. |
25 class GpuVideoDecodeAcceleratorHost | 25 class GpuVideoDecodeAcceleratorHost |
26 : public IPC::Listener, | 26 : public media::VideoDecodeAccelerator, |
27 public media::VideoDecodeAccelerator, | |
28 public CommandBufferProxyImpl::DeletionObserver, | 27 public CommandBufferProxyImpl::DeletionObserver, |
| 28 public GpuVideoDecodeAcceleratorHostIPCTransport::Client, |
29 public base::NonThreadSafe { | 29 public base::NonThreadSafe { |
30 public: | 30 public: |
31 // |this| is guaranteed not to outlive |channel| and |impl|. (See comments | 31 // |this| is guaranteed not to outlive |channel| and |impl|. (See comments |
32 // for |channel_| and |impl_|.) | 32 // for |channel_| and |impl_|.) |
33 GpuVideoDecodeAcceleratorHost(GpuChannelHost* channel, | 33 GpuVideoDecodeAcceleratorHost( |
34 CommandBufferProxyImpl* impl); | 34 GpuChannelHost* channel, |
35 | 35 scoped_ptr<GpuVideoDecodeAcceleratorHostIPCTransport> transport, |
36 // IPC::Listener implementation. | 36 CommandBufferProxyImpl* impl); |
37 void OnChannelError() override; | |
38 bool OnMessageReceived(const IPC::Message& message) override; | |
39 | 37 |
40 // media::VideoDecodeAccelerator implementation. | 38 // media::VideoDecodeAccelerator implementation. |
41 bool Initialize(const Config& config, Client* client) override; | 39 bool Initialize(const Config& config, |
| 40 media::VideoDecodeAccelerator::Client* client) override; |
42 void SetCdm(int cdm_id) override; | 41 void SetCdm(int cdm_id) override; |
43 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 42 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
44 void AssignPictureBuffers( | 43 void AssignPictureBuffers( |
45 const std::vector<media::PictureBuffer>& buffers) override; | 44 const std::vector<media::PictureBuffer>& buffers) override; |
46 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 45 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
47 void Flush() override; | 46 void Flush() override; |
48 void Reset() override; | 47 void Reset() override; |
49 void Destroy() override; | 48 void Destroy() override; |
50 | 49 |
51 // CommandBufferProxyImpl::DeletionObserver implemetnation. | 50 // CommandBufferProxyImpl::DeletionObserver implemetnation. |
52 void OnWillDeleteImpl() override; | 51 void OnWillDeleteImpl() override; |
53 | 52 |
54 private: | 53 private: |
55 // Only Destroy() should be deleting |this|. | 54 // Only Destroy() should be deleting |this|. |
56 ~GpuVideoDecodeAcceleratorHost() override; | 55 ~GpuVideoDecodeAcceleratorHost() override; |
57 | 56 |
58 // Notify |client_| of an error. Posts a task to avoid re-entrancy. | 57 // Notify |client_| of an error. Posts a task to avoid re-entrancy. |
59 void PostNotifyError(Error); | 58 void PostNotifyError(media::VideoDecodeAccelerator::Error error); |
60 | |
61 void Send(IPC::Message* message); | |
62 | 59 |
63 // IPC handlers, proxying media::VideoDecodeAccelerator::Client for the GPU | 60 // IPC handlers, proxying media::VideoDecodeAccelerator::Client for the GPU |
64 // process. Should not be called directly. | 61 // process. Should not be called directly. |
65 void OnCdmAttached(bool success); | 62 void OnCdmAttached(bool success) override; |
66 void OnBitstreamBufferProcessed(int32_t bitstream_buffer_id); | 63 void OnBitstreamBufferProcessed(int32_t bitstream_buffer_id) override; |
67 void OnProvidePictureBuffer(uint32_t num_requested_buffers, | 64 void OnProvidePictureBuffer(uint32_t num_requested_buffers, |
68 const gfx::Size& dimensions, | 65 const gfx::Size& dimensions, |
69 uint32_t texture_target); | 66 uint32_t texture_target) override; |
70 void OnDismissPictureBuffer(int32_t picture_buffer_id); | 67 void OnDismissPictureBuffer(int32_t picture_buffer_id) override; |
71 void OnPictureReady(int32_t picture_buffer_id, | 68 void OnPictureReady(int32_t picture_buffer_id, |
72 int32_t bitstream_buffer_id, | 69 int32_t bitstream_buffer_id, |
73 const gfx::Rect& visible_rect, | 70 const gfx::Rect& visible_rect, |
74 bool allow_overlay); | 71 bool allow_overlay) override; |
75 void OnFlushDone(); | 72 void OnFlushDone() override; |
76 void OnResetDone(); | 73 void OnResetDone() override; |
77 void OnNotifyError(uint32_t error); | 74 void OnNotifyError(uint32_t error) override; |
78 | 75 |
79 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU | 76 // Unowned reference to the GpuChannelHost to send IPC messages to the GPU |
80 // process. |channel_| outlives |impl_|, so the reference is always valid as | 77 // process. |channel_| outlives |impl_|, so the reference is always valid as |
81 // long as it is not NULL. | 78 // long as it is not NULL. |
82 GpuChannelHost* channel_; | 79 GpuChannelHost* channel_; |
83 | 80 |
84 // Route ID for the associated decoder in the GPU process. | 81 scoped_ptr<GpuVideoDecodeAcceleratorHostIPCTransport> transport_; |
85 int32_t decoder_route_id_; | |
86 | 82 |
87 // The client that will receive callbacks from the decoder. | 83 // The client that will receive callbacks from the decoder. |
88 Client* client_; | 84 media::VideoDecodeAccelerator::Client* client_; |
89 | 85 |
90 // Unowned reference to the CommandBufferProxyImpl that created us. |this| | 86 // Unowned reference to the CommandBufferProxyImpl that created us. |this| |
91 // registers as a DeletionObserver of |impl_|, the so reference is always | 87 // registers as a DeletionObserver of |impl_|, the so reference is always |
92 // valid as long as it is not NULL. | 88 // valid as long as it is not NULL. |
93 CommandBufferProxyImpl* impl_; | 89 CommandBufferProxyImpl* impl_; |
94 | 90 |
95 // Requested dimensions of the buffer, from ProvidePictureBuffers(). | 91 // Requested dimensions of the buffer, from ProvidePictureBuffers(). |
96 gfx::Size picture_buffer_dimensions_; | 92 gfx::Size picture_buffer_dimensions_; |
97 | 93 |
98 // WeakPtr factory for posting tasks back to itself. | 94 // WeakPtr factory for posting tasks back to itself. |
99 base::WeakPtrFactory<GpuVideoDecodeAcceleratorHost> weak_this_factory_; | 95 base::WeakPtrFactory<GpuVideoDecodeAcceleratorHost> weak_this_factory_; |
100 | 96 |
101 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); | 97 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); |
102 }; | 98 }; |
103 | 99 |
104 } // namespace content | 100 } // namespace content |
105 | 101 |
106 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | 102 #endif // CONTENT_COMMON_GPU_CLIENT_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ |
OLD | NEW |