Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: content/renderer/gpu/gpu_video_decode_accelerator_host.h

Issue 7260008: Implement proper synchronization between HW video decode IPC and CommandBuffer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "base/threading/non_thread_safe.h"
12 #include "ipc/ipc_channel.h" 13 #include "ipc/ipc_channel.h"
13 #include "media/video/video_decode_accelerator.h" 14 #include "media/video/video_decode_accelerator.h"
14 15
15 class MessageLoop; 16 class MessageLoop;
16 class MessageRouter; 17 class MessageRouter;
18 namespace gpu {
19 class CommandBufferHelper;
20 class ReadWriteTokens;
21 }
17 22
18 // 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
19 // through IPC messages. 24 // through IPC messages.
20 class GpuVideoDecodeAcceleratorHost : public IPC::Channel::Listener, 25 class GpuVideoDecodeAcceleratorHost
21 public media::VideoDecodeAccelerator { 26 : public IPC::Channel::Listener,
27 public media::VideoDecodeAccelerator,
28 public base::NonThreadSafe {
22 public: 29 public:
23 // |router| is used to dispatch IPC messages to this object. 30 // |router| is used to dispatch IPC messages to this object.
24 // |ipc_sender| is used to send IPC messages to Gpu process. 31 // |ipc_sender| is used to send IPC messages to Gpu process.
25 GpuVideoDecodeAcceleratorHost(MessageRouter* router, 32 GpuVideoDecodeAcceleratorHost(MessageRouter* router,
26 IPC::Message::Sender* ipc_sender, 33 IPC::Message::Sender* ipc_sender,
27 int32 decoder_host_id, 34 int32 decoder_host_id,
28 uint32 command_buffer_route_id, 35 int32 command_buffer_route_id,
36 gpu::CommandBufferHelper* cmd_buffer_helper,
29 media::VideoDecodeAccelerator::Client* client); 37 media::VideoDecodeAccelerator::Client* client);
30 virtual ~GpuVideoDecodeAcceleratorHost(); 38 virtual ~GpuVideoDecodeAcceleratorHost();
31 39
32 // IPC::Channel::Listener implementation. 40 // IPC::Channel::Listener implementation.
33 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 41 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
34 virtual void OnChannelError() OVERRIDE; 42 virtual void OnChannelError() OVERRIDE;
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
36 44
37 // media::VideoDecodeAccelerator implementation. 45 // media::VideoDecodeAccelerator implementation.
38 virtual bool GetConfigs( 46 virtual bool GetConfigs(
39 const std::vector<uint32>& requested_configs, 47 const std::vector<uint32>& requested_configs,
40 std::vector<uint32>* matched_configs) OVERRIDE; 48 std::vector<uint32>* matched_configs) OVERRIDE;
41 virtual bool Initialize(const std::vector<uint32>& configs) OVERRIDE; 49 virtual bool Initialize(const std::vector<uint32>& configs) OVERRIDE;
42 virtual bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; 50 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
43 virtual void AssignGLESBuffers( 51 virtual void AssignGLESBuffers(
44 const std::vector<media::GLESBuffer>& buffers) OVERRIDE; 52 const std::vector<media::GLESBuffer>& buffers) OVERRIDE;
45 virtual void AssignSysmemBuffers( 53 virtual void AssignSysmemBuffers(
46 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE; 54 const std::vector<media::SysmemBuffer>& buffers) OVERRIDE;
47 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; 55 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
48 virtual bool Flush() OVERRIDE; 56 virtual void Flush() OVERRIDE;
49 virtual bool Abort() OVERRIDE; 57 virtual void Abort() OVERRIDE;
50 58
51 private: 59 private:
60 // Insert a token into the command buffer and return a token-pair suitable for
61 // sending over IPC for synchronization with the command buffer.
62 gpu::ReadWriteTokens SyncTokens();
63
52 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id); 64 void OnBitstreamBufferProcessed(int32 bitstream_buffer_id);
53 void OnProvidePictureBuffer( 65 void OnProvidePictureBuffer(
54 uint32 num_requested_buffers, const gfx::Size& buffer_size, int32 mem_type); 66 uint32 num_requested_buffers, const gfx::Size& buffer_size, int32 mem_type);
55 void OnDismissPictureBuffer(int32 picture_buffer_id); 67 void OnDismissPictureBuffer(int32 picture_buffer_id);
56 void OnCreateDone(int32 decoder_id); 68 void OnCreateDone(int32 decoder_id);
57 void OnInitializeDone(); 69 void OnInitializeDone();
58 void OnPictureReady(int32 picture_buffer_id, 70 void OnPictureReady(int32 picture_buffer_id,
59 int32 bitstream_buffer_id, 71 int32 bitstream_buffer_id,
60 const gfx::Size& visible_size, 72 const gfx::Size& visible_size,
61 const gfx::Size& decoded_size); 73 const gfx::Size& decoded_size);
62 void OnFlushDone(); 74 void OnFlushDone();
63 void OnAbortDone(); 75 void OnAbortDone();
64 void OnEndOfStream(); 76 void OnEndOfStream();
65 void OnErrorNotification(uint32 error); 77 void OnErrorNotification(uint32 error);
66 78
67 // A router used to send us IPC messages. 79 // A router used to send us IPC messages.
68 MessageRouter* router_; 80 MessageRouter* router_;
69 81
70 // Sends IPC messages to the Gpu process. 82 // Sends IPC messages to the Gpu process.
71 IPC::Message::Sender* ipc_sender_; 83 IPC::Message::Sender* ipc_sender_;
72 84
73 // ID of this GpuVideoDecodeAcceleratorHost. 85 // ID of this GpuVideoDecodeAcceleratorHost.
74 int32 decoder_host_id_; 86 int32 decoder_host_id_;
75 87
76 // ID of VideoDecodeAccelerator in the Gpu process. 88 // ID of VideoDecodeAccelerator in the Gpu process.
77 int32 decoder_id_; 89 int32 decoder_id_;
78 90
79 // Route ID for the command buffer associated with the context the GPU Video 91 // Route ID for the command buffer associated with the context the GPU Video
80 // Decoder uses. 92 // Decoder uses.
81 uint32 command_buffer_route_id_; 93 // TODO(fischman): storing route_id's for GPU process entities in the renderer
94 // process is vulnerable to GPU process crashing & being respawned, and
95 // attempting to use an outdated or reused route id.
96 int32 command_buffer_route_id_;
97
98 // Helper for the command buffer associated with the context the GPU Video
99 // Decoder uses.
100 // TODO(fischman): in the out-of-process case, this won't work
101 // (context3d->gles2_impl() will be NULL), and will have to be replaced with a
102 // dedicated message such as WaitForToken, which will serialize subsequent
103 // message processing behind it.
104 gpu::CommandBufferHelper* cmd_buffer_helper_;
82 105
83 // Temporarily store configs here in between Create and Initialize phase. 106 // Temporarily store configs here in between Create and Initialize phase.
84 std::vector<uint32> configs_; 107 std::vector<uint32> configs_;
85 108
86 // Reference to the client that will receive callbacks from the decoder. 109 // Reference to the client that will receive callbacks from the decoder.
87 media::VideoDecodeAccelerator::Client* client_; 110 media::VideoDecodeAccelerator::Client* client_;
88 111
89 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost); 112 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecodeAcceleratorHost);
90 }; 113 };
91 114
92 #endif // CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_ 115 #endif // CONTENT_RENDERER_GPU_GPU_VIDEO_DECODE_ACCELERATOR_HOST_H_
OLDNEW
« no previous file with comments | « content/renderer/gpu/gpu_channel_host.cc ('k') | content/renderer/gpu/gpu_video_decode_accelerator_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698