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 #ifndef CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | 5 #ifndef CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ |
6 #define CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | 6 #define CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/shared_memory.h" | 11 #include "base/shared_memory.h" |
12 #include "ipc/ipc_channel.h" | 12 #include "ipc/ipc_channel.h" |
13 #include "media/video/video_decode_accelerator.h" | 13 #include "media/video/video_decode_accelerator.h" |
14 | 14 |
15 class MessageLoop; | 15 class MessageLoop; |
16 class MessageRouter; | 16 class MessageRouter; |
17 namespace gpu { | |
18 class CommandBufferHelper; | |
19 } | |
17 | 20 |
18 // This class is used to talk to VideoDecodeAccelerator in the Gpu process | 21 // This class is used to talk to VideoDecodeAccelerator in the Gpu process |
19 // through IPC messages. | 22 // through IPC messages. |
20 class GpuVideoDecodeAcceleratorHost : public IPC::Channel::Listener, | 23 class GpuVideoDecodeAcceleratorHost |
21 public media::VideoDecodeAccelerator { | 24 : public IPC::Channel::Listener, |
25 public media::VideoDecodeAccelerator { | |
22 public: | 26 public: |
23 // |router| is used to dispatch IPC messages to this object. | 27 // |router| is used to dispatch IPC messages to this object. |
24 // |ipc_sender| is used to send IPC messages to Gpu process. | 28 // |ipc_sender| is used to send IPC messages to Gpu process. |
25 GpuVideoDecodeAcceleratorHost(MessageRouter* router, | 29 GpuVideoDecodeAcceleratorHost(MessageRouter* router, |
26 IPC::Message::Sender* ipc_sender, | 30 IPC::Message::Sender* ipc_sender, |
27 int32 decoder_host_id, | 31 int32 decoder_host_id, |
28 uint32 command_buffer_route_id, | 32 int32 command_buffer_route_id, |
33 gpu::CommandBufferHelper* cmd_buffer_helper, | |
29 media::VideoDecodeAccelerator::Client* client); | 34 media::VideoDecodeAccelerator::Client* client); |
30 virtual ~GpuVideoDecodeAcceleratorHost(); | 35 virtual ~GpuVideoDecodeAcceleratorHost(); |
31 | 36 |
32 // IPC::Channel::Listener implementation. | 37 // IPC::Channel::Listener implementation. |
33 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 38 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
34 virtual void OnChannelError() OVERRIDE; | 39 virtual void OnChannelError() OVERRIDE; |
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
36 | 41 |
37 // media::VideoDecodeAccelerator implementation. | 42 // media::VideoDecodeAccelerator implementation. |
38 virtual bool GetConfigs( | 43 virtual bool GetConfigs( |
39 const std::vector<uint32>& requested_configs, | 44 const std::vector<uint32>& requested_configs, |
40 std::vector<uint32>* matched_configs) OVERRIDE; | 45 std::vector<uint32>* matched_configs) OVERRIDE; |
41 virtual bool Initialize(const std::vector<uint32>& configs) OVERRIDE; | 46 virtual bool Initialize(const std::vector<uint32>& configs) OVERRIDE; |
42 virtual bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 47 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
43 virtual void AssignGLESBuffers( | 48 virtual void AssignGLESBuffers( |
44 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; | 49 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; |
45 virtual void AssignSysmemBuffers( | 50 virtual void AssignSysmemBuffers( |
46 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; | 51 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; |
47 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 52 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
48 virtual bool Flush() OVERRIDE; | 53 virtual void Flush() OVERRIDE; |
49 virtual bool Abort() OVERRIDE; | 54 virtual void Abort() OVERRIDE; |
50 | 55 |
51 private: | 56 private: |
57 // Insert a token into the command buffer and return a <read,write> token pair | |
58 // suitable for sending over IPC. | |
59 std::pair<int32, int32> SyncTokens(); | |
60 | |
52 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id); | 61 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id); |
53 void OnProvidePictureBuffer( | 62 void OnProvidePictureBuffer( |
54 uint32 num_requested_buffers, const gfx::Size& buffer_size, int32 mem_type); | 63 uint32 num_requested_buffers, const gfx::Size& buffer_size, int32 mem_type); |
55 void OnDismissPictureBuffer(int32 picture_buffer_id); | 64 void OnDismissPictureBuffer(int32 picture_buffer_id); |
56 void OnCreateDone(int32 decoder_id); | 65 void OnCreateDone(int32 decoder_id); |
57 void OnInitializeDone(); | 66 void OnInitializeDone(); |
58 void OnPictureReady(int32 picture_buffer_id, | 67 void OnPictureReady(int32 picture_buffer_id, |
59 int32 bitstream_buffer_id, | 68 int32 bitstream_buffer_id, |
60 const gfx::Size& visible_size, | 69 const gfx::Size& visible_size, |
61 const gfx::Size& decoded_size); | 70 const gfx::Size& decoded_size); |
62 void OnFlushDone(); | 71 void OnFlushDone(); |
63 void OnAbortDone(); | 72 void OnAbortDone(); |
64 void OnEndOfStream(); | 73 void OnEndOfStream(); |
65 void OnErrorNotification(uint32 error); | 74 void OnErrorNotification(uint32 error); |
66 | 75 |
67 // A router used to send us IPC messages. | 76 // A router used to send us IPC messages. |
68 MessageRouter* router_; | 77 MessageRouter* router_; |
69 | 78 |
70 // Sends IPC messages to the Gpu process. | 79 // Sends IPC messages to the Gpu process. |
71 IPC::Message::Sender* ipc_sender_; | 80 IPC::Message::Sender* ipc_sender_; |
72 | 81 |
73 // ID of this GpuVideoDecodeAcceleratorHost. | 82 // ID of this GpuVideoDecodeAcceleratorHost. |
74 int32 decoder_host_id_; | 83 int32 decoder_host_id_; |
75 | 84 |
76 // ID of VideoDecodeAccelerator in the Gpu process. | 85 // ID of VideoDecodeAccelerator in the Gpu process. |
77 int32 decoder_id_; | 86 int32 decoder_id_; |
78 | 87 |
79 // Route ID for the command buffer associated with the context the GPU Video | 88 // Route ID for the command buffer associated with the context the GPU Video |
80 // Decoder uses. | 89 // Decoder uses. |
81 uint32 command_buffer_route_id_; | 90 int32 command_buffer_route_id_; |
91 | |
92 // Helper for the command buffer associated with the context the GPU Video | |
93 // Decoder uses. | |
94 gpu::CommandBufferHelper* cmd_buffer_helper_; | |
piman
2011/06/28 01:19:22
Note for later: in the out-of-process plugin case,
Ami GONE FROM CHROMIUM
2011/06/28 21:00:53
Done.
| |
82 | 95 |
83 // Temporarily store configs here in between Create and Initialize phase. | 96 // Temporarily store configs here in between Create and Initialize phase. |
84 std::vector<uint32> configs_; | 97 std::vector<uint32> configs_; |
85 | 98 |
86 // Reference to the client that will receive callbacks from the decoder. | 99 // Reference to the client that will receive callbacks from the decoder. |
87 media::VideoDecodeAccelerator::Client* client_; | 100 media::VideoDecodeAccelerator::Client* client_; |
88 | 101 |
102 // MessageLoop on which this object was created. All Send()'s are trampolined | |
103 // to this loop if they are not issued on it by the client. | |
104 MessageLoop* message_loop_; | |
piman
2011/06/28 01:19:22
I'm pretty sure using a MessageLoop directly isn't
Ami GONE FROM CHROMIUM
2011/06/28 21:00:53
Done.
| |
105 | |
89 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); | 106 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); |
90 }; | 107 }; |
91 | 108 |
92 #endif // CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ | 109 #endif // CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ |
OLD | NEW |