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_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <map> | 10 #include <map> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
16 #include "base/memory/shared_memory.h" | 16 #include "base/memory/shared_memory.h" |
17 #include "base/synchronization/waitable_event.h" | 17 #include "base/synchronization/waitable_event.h" |
| 18 #include "content/common/gpu/gpu_command_buffer_stub.h" |
18 #include "gpu/command_buffer/service/texture_manager.h" | 19 #include "gpu/command_buffer/service/texture_manager.h" |
19 #include "gpu/config/gpu_info.h" | 20 #include "gpu/config/gpu_info.h" |
20 #include "gpu/ipc/service/gpu_command_buffer_stub.h" | |
21 #include "ipc/ipc_listener.h" | 21 #include "ipc/ipc_listener.h" |
22 #include "ipc/ipc_sender.h" | 22 #include "ipc/ipc_sender.h" |
23 #include "media/video/video_decode_accelerator.h" | 23 #include "media/video/video_decode_accelerator.h" |
24 #include "ui/gfx/geometry/size.h" | 24 #include "ui/gfx/geometry/size.h" |
25 | 25 |
26 namespace gpu { | 26 namespace gpu { |
27 struct GpuPreferences; | 27 struct GpuPreferences; |
28 } // namespace gpu | 28 } // namespace gpu |
29 | 29 |
30 namespace content { | 30 namespace content { |
31 | 31 |
32 class GpuVideoDecodeAccelerator | 32 class GpuVideoDecodeAccelerator |
33 : public IPC::Listener, | 33 : public IPC::Listener, |
34 public IPC::Sender, | 34 public IPC::Sender, |
35 public media::VideoDecodeAccelerator::Client, | 35 public media::VideoDecodeAccelerator::Client, |
36 public gpu::GpuCommandBufferStub::DestructionObserver { | 36 public GpuCommandBufferStub::DestructionObserver { |
37 public: | 37 public: |
38 // Each of the arguments to the constructor must outlive this object. | 38 // Each of the arguments to the constructor must outlive this object. |
39 // |stub->decoder()| will be made current around any operation that touches | 39 // |stub->decoder()| will be made current around any operation that touches |
40 // the underlying VDA so that it can make GL calls safely. | 40 // the underlying VDA so that it can make GL calls safely. |
41 GpuVideoDecodeAccelerator( | 41 GpuVideoDecodeAccelerator( |
42 int32_t host_route_id, | 42 int32_t host_route_id, |
43 gpu::GpuCommandBufferStub* stub, | 43 GpuCommandBufferStub* stub, |
44 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); | 44 const scoped_refptr<base::SingleThreadTaskRunner>& io_task_runner); |
45 | 45 |
46 // Static query for the capabilities, which includes the supported profiles. | 46 // Static query for the capabilities, which includes the supported profiles. |
47 // This query calls the appropriate platform-specific version. The returned | 47 // This query calls the appropriate platform-specific version. The returned |
48 // capabilities will not contain duplicate supported profile entries. | 48 // capabilities will not contain duplicate supported profile entries. |
49 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( | 49 static gpu::VideoDecodeAcceleratorCapabilities GetCapabilities( |
50 const gpu::GpuPreferences& gpu_preferences); | 50 const gpu::GpuPreferences& gpu_preferences); |
51 | 51 |
52 // IPC::Listener implementation. | 52 // IPC::Listener implementation. |
53 bool OnMessageReceived(const IPC::Message& message) override; | 53 bool OnMessageReceived(const IPC::Message& message) override; |
(...skipping 12 matching lines...) Expand all Loading... |
66 void NotifyError(media::VideoDecodeAccelerator::Error error) override; | 66 void NotifyError(media::VideoDecodeAccelerator::Error error) override; |
67 | 67 |
68 // GpuCommandBufferStub::DestructionObserver implementation. | 68 // GpuCommandBufferStub::DestructionObserver implementation. |
69 void OnWillDestroyStub() override; | 69 void OnWillDestroyStub() override; |
70 | 70 |
71 // Function to delegate sending to actual sender. | 71 // Function to delegate sending to actual sender. |
72 bool Send(IPC::Message* message) override; | 72 bool Send(IPC::Message* message) override; |
73 | 73 |
74 // Initialize VDAs from the set of VDAs supported for current platform until | 74 // Initialize VDAs from the set of VDAs supported for current platform until |
75 // one of them succeeds for given |config|. Send the |init_done_msg| when | 75 // one of them succeeds for given |config|. Send the |init_done_msg| when |
76 // done. filter_ is passed to gpu::GpuCommandBufferStub channel only if the | 76 // done. filter_ is passed to GpuCommandBufferStub channel only if the chosen |
77 // chosen VDA can decode on IO thread. | 77 // VDA can decode on IO thread. |
78 bool Initialize(const media::VideoDecodeAccelerator::Config& config); | 78 bool Initialize(const media::VideoDecodeAccelerator::Config& config); |
79 | 79 |
80 private: | 80 private: |
81 typedef scoped_ptr<media::VideoDecodeAccelerator> ( | 81 typedef scoped_ptr<media::VideoDecodeAccelerator> ( |
82 GpuVideoDecodeAccelerator::*CreateVDAFp)(); | 82 GpuVideoDecodeAccelerator::*CreateVDAFp)(); |
83 | 83 |
84 class MessageFilter; | 84 class MessageFilter; |
85 | 85 |
86 #if defined(OS_WIN) | 86 #if defined(OS_WIN) |
87 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(); | 87 scoped_ptr<media::VideoDecodeAccelerator> CreateDXVAVDA(); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) | 126 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY)) || defined(OS_MACOSX) |
127 // Helper to bind |image| to the texture specified by |client_texture_id|. | 127 // Helper to bind |image| to the texture specified by |client_texture_id|. |
128 void BindImage(uint32_t client_texture_id, | 128 void BindImage(uint32_t client_texture_id, |
129 uint32_t texture_target, | 129 uint32_t texture_target, |
130 scoped_refptr<gl::GLImage> image); | 130 scoped_refptr<gl::GLImage> image); |
131 #endif | 131 #endif |
132 | 132 |
133 // Route ID to communicate with the host. | 133 // Route ID to communicate with the host. |
134 const int32_t host_route_id_; | 134 const int32_t host_route_id_; |
135 | 135 |
136 // Unowned pointer to the underlying gpu::GpuCommandBufferStub. |this| is | 136 // Unowned pointer to the underlying GpuCommandBufferStub. |this| is |
137 // registered as a DestuctionObserver of |stub_| and will self-delete when | 137 // registered as a DestuctionObserver of |stub_| and will self-delete when |
138 // |stub_| is destroyed. | 138 // |stub_| is destroyed. |
139 gpu::GpuCommandBufferStub* const stub_; | 139 GpuCommandBufferStub* const stub_; |
140 | 140 |
141 // The underlying VideoDecodeAccelerator. | 141 // The underlying VideoDecodeAccelerator. |
142 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 142 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; |
143 | 143 |
144 // Callback for making the relevant context current for GL calls. | 144 // Callback for making the relevant context current for GL calls. |
145 // Returns false if failed. | 145 // Returns false if failed. |
146 base::Callback<bool(void)> make_context_current_; | 146 base::Callback<bool(void)> make_context_current_; |
147 | 147 |
148 // The texture dimensions as requested by ProvidePictureBuffers(). | 148 // The texture dimensions as requested by ProvidePictureBuffers(). |
149 gfx::Size texture_dimensions_; | 149 gfx::Size texture_dimensions_; |
(...skipping 28 matching lines...) Expand all Loading... |
178 | 178 |
179 // A map from picture buffer ID to TextureRef that have not been cleared. | 179 // A map from picture buffer ID to TextureRef that have not been cleared. |
180 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; | 180 std::map<int32_t, scoped_refptr<gpu::gles2::TextureRef>> uncleared_textures_; |
181 | 181 |
182 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 182 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
183 }; | 183 }; |
184 | 184 |
185 } // namespace content | 185 } // namespace content |
186 | 186 |
187 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 187 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |