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

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

Powered by Google App Engine
This is Rietveld 408576698