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 <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/shared_memory.h" | 12 #include "base/memory/shared_memory.h" |
13 #include "content/common/gpu/gpu_command_buffer_stub.h" | 13 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 14 #include "content/common/gpu/media/video_decode_accelerator_impl.h" |
14 #include "ipc/ipc_listener.h" | 15 #include "ipc/ipc_listener.h" |
15 #include "ipc/ipc_sender.h" | 16 #include "ipc/ipc_sender.h" |
16 #include "media/video/video_decode_accelerator.h" | 17 #include "media/video/video_decode_accelerator.h" |
17 | 18 |
| 19 namespace base { |
| 20 class MessageLoopProxy; |
| 21 } |
| 22 |
18 namespace content { | 23 namespace content { |
19 | 24 |
20 class GpuVideoDecodeAccelerator | 25 class GpuVideoDecodeAccelerator |
21 : public IPC::Listener, | 26 : public IPC::Listener, |
22 public IPC::Sender, | 27 public IPC::Sender, |
23 public media::VideoDecodeAccelerator::Client, | 28 public media::VideoDecodeAccelerator::Client, |
24 public GpuCommandBufferStub::DestructionObserver { | 29 public GpuCommandBufferStub::DestructionObserver { |
25 public: | 30 public: |
26 // Each of the arguments to the constructor must outlive this object. | 31 // Each of the arguments to the constructor must outlive this object. |
27 // |stub->decoder()| will be made current around any operation that touches | 32 // |stub->decoder()| will be made current around any operation that touches |
(...skipping 20 matching lines...) Expand all Loading... |
48 virtual void OnWillDestroyStub() OVERRIDE; | 53 virtual void OnWillDestroyStub() OVERRIDE; |
49 | 54 |
50 // Function to delegate sending to actual sender. | 55 // Function to delegate sending to actual sender. |
51 virtual bool Send(IPC::Message* message) OVERRIDE; | 56 virtual bool Send(IPC::Message* message) OVERRIDE; |
52 | 57 |
53 // Initialize the accelerator with the given profile and send the | 58 // Initialize the accelerator with the given profile and send the |
54 // |init_done_msg| when done. | 59 // |init_done_msg| when done. |
55 // The renderer process handle is valid as long as we have a channel between | 60 // The renderer process handle is valid as long as we have a channel between |
56 // GPU process and the renderer. | 61 // GPU process and the renderer. |
57 void Initialize(const media::VideoCodecProfile profile, | 62 void Initialize(const media::VideoCodecProfile profile, |
58 IPC::Message* init_done_msg); | 63 IPC::Message* init_done_msg, |
| 64 const scoped_refptr<base::MessageLoopProxy>& io_message_loop); |
59 | 65 |
60 private: | 66 private: |
| 67 class MessageFilter; |
| 68 |
61 // Handlers for IPC messages. | 69 // Handlers for IPC messages. |
62 void OnDecode(base::SharedMemoryHandle handle, int32 id, uint32 size); | 70 void OnDecode(base::SharedMemoryHandle handle, int32 id, uint32 size); |
63 void OnAssignPictureBuffers( | 71 void OnAssignPictureBuffers( |
64 const std::vector<int32>& buffer_ids, | 72 const std::vector<int32>& buffer_ids, |
65 const std::vector<uint32>& texture_ids, | 73 const std::vector<uint32>& texture_ids, |
66 const std::vector<gfx::Size>& sizes); | 74 const std::vector<gfx::Size>& sizes); |
67 void OnReusePictureBuffer( | 75 void OnReusePictureBuffer( |
68 int32 picture_buffer_id); | 76 int32 picture_buffer_id); |
69 void OnFlush(); | 77 void OnFlush(); |
70 void OnReset(); | 78 void OnReset(); |
71 void OnDestroy(); | 79 void OnDestroy(); |
72 | 80 |
| 81 // Called on IO thread when |filter_| has been removed. |
| 82 void OnFilterRemoved(); |
| 83 |
73 // Message to Send() when initialization is done. Is only non-NULL during | 84 // Message to Send() when initialization is done. Is only non-NULL during |
74 // initialization and is owned by the IPC channel underlying the | 85 // initialization and is owned by the IPC channel underlying the |
75 // GpuCommandBufferStub. | 86 // GpuCommandBufferStub. |
76 IPC::Message* init_done_msg_; | 87 IPC::Message* init_done_msg_; |
77 | 88 |
78 // Route ID to communicate with the host. | 89 // Route ID to communicate with the host. |
79 int32 host_route_id_; | 90 int32 host_route_id_; |
80 | 91 |
81 // Unowned pointer to the underlying GpuCommandBufferStub. | 92 // Unowned pointer to the underlying GpuCommandBufferStub. |
82 GpuCommandBufferStub* stub_; | 93 GpuCommandBufferStub* stub_; |
83 | 94 |
84 // The underlying VideoDecodeAccelerator. | 95 // The underlying VideoDecodeAccelerator. |
85 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 96 scoped_ptr<VideoDecodeAcceleratorImpl> video_decode_accelerator_; |
86 | 97 |
87 // Callback for making the relevant context current for GL calls. | 98 // Callback for making the relevant context current for GL calls. |
88 // Returns false if failed. | 99 // Returns false if failed. |
89 base::Callback<bool(void)> make_context_current_; | 100 base::Callback<bool(void)> make_context_current_; |
90 | 101 |
91 // The texture target as requested by ProvidePictureBuffers(). | 102 // The texture target as requested by ProvidePictureBuffers(). |
92 uint32 texture_target_; | 103 uint32 texture_target_; |
93 | 104 |
| 105 // The message filter to run VDA::Decode on IO thread if VDA supports it. |
| 106 scoped_refptr<MessageFilter> filter_; |
| 107 |
| 108 // GPU child message loop. |
| 109 scoped_refptr<base::MessageLoopProxy> child_message_loop_; |
| 110 |
94 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 111 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
95 }; | 112 }; |
96 | 113 |
97 } // namespace content | 114 } // namespace content |
98 | 115 |
99 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 116 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |