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_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/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 "ipc/ipc_message.h" | 13 #include "ipc/ipc_message.h" |
14 #include "media/video/video_decode_accelerator.h" | 14 #include "media/video/video_decode_accelerator.h" |
15 | 15 |
| 16 namespace gpu { |
| 17 class ReadWriteTokens; |
| 18 } |
| 19 |
| 20 class GpuCommandBufferStub; |
| 21 |
16 class GpuVideoDecodeAccelerator | 22 class GpuVideoDecodeAccelerator |
17 : public base::RefCountedThreadSafe<GpuVideoDecodeAccelerator>, | 23 : public base::RefCountedThreadSafe<GpuVideoDecodeAccelerator>, |
18 public IPC::Channel::Listener, | 24 public IPC::Channel::Listener, |
19 public IPC::Message::Sender, | 25 public IPC::Message::Sender, |
20 public media::VideoDecodeAccelerator::Client { | 26 public media::VideoDecodeAccelerator::Client { |
21 public: | 27 public: |
22 GpuVideoDecodeAccelerator(IPC::Message::Sender* sender, int32 host_route_id); | 28 GpuVideoDecodeAccelerator(IPC::Message::Sender* sender, |
| 29 int32 host_route_id, |
| 30 int32 decoder_route_id, |
| 31 GpuCommandBufferStub* stub); |
23 virtual ~GpuVideoDecodeAccelerator(); | 32 virtual ~GpuVideoDecodeAccelerator(); |
24 | 33 |
25 // IPC::Channel::Listener implementation. | 34 // IPC::Channel::Listener implementation. |
26 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
27 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 36 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
28 virtual void OnChannelError() OVERRIDE; | 37 virtual void OnChannelError() OVERRIDE; |
29 | 38 |
30 // media::VideoDecodeAccelerator::Client implementation. | 39 // media::VideoDecodeAccelerator::Client implementation. |
31 virtual void ProvidePictureBuffers( | 40 virtual void ProvidePictureBuffers( |
32 uint32 requested_num_of_buffers, | 41 uint32 requested_num_of_buffers, |
(...skipping 12 matching lines...) Expand all Loading... |
45 virtual bool Send(IPC::Message* message); | 54 virtual bool Send(IPC::Message* message); |
46 | 55 |
47 void set_video_decode_accelerator( | 56 void set_video_decode_accelerator( |
48 media::VideoDecodeAccelerator* accelerator) { | 57 media::VideoDecodeAccelerator* accelerator) { |
49 DCHECK(!video_decode_accelerator_.get()); | 58 DCHECK(!video_decode_accelerator_.get()); |
50 video_decode_accelerator_.reset(accelerator); | 59 video_decode_accelerator_.reset(accelerator); |
51 } | 60 } |
52 | 61 |
53 void AssignGLESBuffers(const std::vector<media::GLESBuffer>& buffers); | 62 void AssignGLESBuffers(const std::vector<media::GLESBuffer>& buffers); |
54 | 63 |
| 64 // Callback to be fired when the underlying stub receives a new token. |
| 65 void OnSetToken(int32 token); |
| 66 |
55 private: | 67 private: |
| 68 // Defers |msg| for later processing if it specifies a write token that hasn't |
| 69 // come to pass yet, and set |*deferred| to true. Return false if the message |
| 70 // failed to parse. |
| 71 bool DeferMessageIfNeeded(const IPC::Message& msg, bool* deferred); |
| 72 |
56 // Handlers for IPC messages. | 73 // Handlers for IPC messages. |
57 void OnGetConfigs(const std::vector<uint32>& config, | 74 void OnGetConfigs( |
58 std::vector<uint32>* configs); | 75 const gpu::ReadWriteTokens& /* tokens */, |
59 void OnInitialize(const std::vector<uint32>& configs); | 76 const std::vector<uint32>& config, |
60 void OnDecode(int32 id, base::SharedMemoryHandle handle, int32 size); | 77 std::vector<uint32>* configs); |
61 void OnAssignSysmemBuffers(const std::vector<int32>& buffer_ids, | 78 void OnInitialize( |
62 const std::vector<base::SharedMemoryHandle>& data, | 79 const gpu::ReadWriteTokens& /* tokens */, |
63 const std::vector<gfx::Size>& sizes); | 80 const std::vector<uint32>& configs); |
64 void OnReusePictureBuffer(int32 picture_buffer_id); | 81 void OnDecode( |
65 void OnFlush(); | 82 const gpu::ReadWriteTokens& /* tokens */, |
66 void OnAbort(); | 83 base::SharedMemoryHandle handle, int32 id, int32 size); |
| 84 void OnAssignTextures( |
| 85 const gpu::ReadWriteTokens& /* tokens */, |
| 86 const std::vector<int32>& buffer_ids, |
| 87 const std::vector<uint32>& texture_ids, |
| 88 const std::vector<gfx::Size>& sizes); |
| 89 void OnAssignSysmemBuffers( |
| 90 const gpu::ReadWriteTokens& /* tokens */, |
| 91 const std::vector<int32> buffer_ids, |
| 92 const std::vector<base::SharedMemoryHandle> data, |
| 93 const std::vector<gfx::Size> sizes); |
| 94 void OnReusePictureBuffer( |
| 95 const gpu::ReadWriteTokens& /* tokens */, |
| 96 int32 picture_buffer_id); |
| 97 void OnFlush(const gpu::ReadWriteTokens& /* tokens */); |
| 98 void OnAbort(const gpu::ReadWriteTokens& /* tokens */); |
67 | 99 |
68 // Pointer to the IPC message sender. | 100 // Pointer to the IPC message sender. |
69 IPC::Message::Sender* sender_; | 101 IPC::Message::Sender* sender_; |
70 | 102 |
71 // Route ID to communicate with the host. | 103 // Route ID to communicate with the host. |
72 int32 route_id_; | 104 int32 host_route_id_; |
| 105 |
| 106 // Route ID of the decoder. |
| 107 int32 decoder_route_id_; |
| 108 |
| 109 // Messages deferred for later processing when their tokens have come to pass. |
| 110 std::vector<IPC::Message*> deferred_messages_; |
| 111 |
| 112 // Unowned pointer to the underlying GpuCommandBufferStub. |
| 113 GpuCommandBufferStub* stub_; |
73 | 114 |
74 // Pointer to the underlying VideoDecodeAccelerator. | 115 // Pointer to the underlying VideoDecodeAccelerator. |
75 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; | 116 scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_; |
76 | 117 |
77 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); | 118 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator); |
78 }; | 119 }; |
79 | 120 |
80 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ | 121 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |