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

Side by Side Diff: content/renderer/gpu_video_decoder_host.h

Issue 7066035: Moved GPU related files in content/renderer into gpu subdirectory. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_RENDERER_GPU_VIDEO_DECODER_HOST_H_
6 #define CONTENT_RENDERER_GPU_VIDEO_DECODER_HOST_H_
7
8 #include <deque>
9 #include <map>
10
11 #include "base/memory/singleton.h"
12 #include "base/shared_memory.h"
13 #include "content/renderer/gpu_channel_host.h"
14 #include "media/base/buffers.h"
15 #include "media/base/video_frame.h"
16 #include "media/video/video_decode_engine.h"
17
18 using media::VideoFrame;
19 using media::Buffer;
20
21 class MessageRouter;
22 struct GpuVideoDecoderInitDoneParam;
23
24 // This class is used to talk to GpuVideoDecoder in the GPU process through
25 // IPC messages. It implements the interface of VideoDecodeEngine so users
26 // view it as a regular video decode engine, the implementation is a portal
27 // to the GPU process.
28 //
29 // THREAD SEMANTICS
30 //
31 // All methods of this class can be accessed on any thread. A message loop
32 // needs to be provided to class through Initialize() for accessing the
33 // IPC channel. Event handlers are called on that message loop.
34 //
35 // Since this class is not refcounted, it is important to delete this
36 // object only after OnUninitializeCompelte() is called.
37 class GpuVideoDecoderHost : public media::VideoDecodeEngine,
38 public IPC::Channel::Listener {
39 public:
40 // |router| is used to dispatch IPC messages to this object.
41 // |ipc_sender| is used to send IPC messages to GPU process.
42 // It is important that the above two objects are accessed on the
43 // |message_loop_|.
44 GpuVideoDecoderHost(MessageRouter* router,
45 IPC::Message::Sender* ipc_sender,
46 int context_route_id,
47 int32 decoder_host_id);
48 virtual ~GpuVideoDecoderHost();
49
50 // IPC::Channel::Listener.
51 virtual void OnChannelConnected(int32 peer_pid) {}
52 virtual void OnChannelError();
53 virtual bool OnMessageReceived(const IPC::Message& message);
54
55 // media::VideoDecodeEngine implementation.
56 virtual void Initialize(MessageLoop* message_loop,
57 VideoDecodeEngine::EventHandler* event_handler,
58 media::VideoDecodeContext* context,
59 const media::VideoDecoderConfig& config);
60 virtual void ConsumeVideoSample(scoped_refptr<Buffer> buffer);
61 virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> frame);
62 virtual void Uninitialize();
63 virtual void Flush();
64 virtual void Seek();
65
66 private:
67 typedef std::map<int32, scoped_refptr<media::VideoFrame> > VideoFrameMap;
68
69 // Internal states.
70 enum GpuVideoDecoderHostState {
71 kStateUninitialized,
72 kStateNormal,
73 kStateError,
74 kStateFlushing,
75 };
76
77 // Takes care of sending IPC message to create a video decoder.
78 void CreateVideoDecoder();
79
80 // Handlers for messages received from the GPU process.
81 void OnCreateVideoDecoderDone(int32 decoder_id);
82 void OnInitializeDone(const GpuVideoDecoderInitDoneParam& param);
83 void OnUninitializeDone();
84 void OnFlushDone();
85 void OnPrerollDone();
86 void OnEmptyThisBufferACK();
87 void OnProduceVideoSample();
88 void OnConsumeVideoFrame(int32 frame_id, int64 timestamp,
89 int64 duration, int32 flags);
90 void OnAllocateVideoFrames(int32 n, uint32 width,
91 uint32 height, int32 format);
92 void OnReleaseAllVideoFrames();
93
94 // Handler for VideoDecodeContext. This method is called when video frames
95 // allocation is done.
96 void OnAllocateVideoFramesDone();
97
98 // Send a message to the GPU process to inform that a video frame is
99 // allocated.
100 void SendVideoFrameAllocated(int32 frame_id,
101 scoped_refptr<media::VideoFrame> frame);
102
103 // Send a video sample to the GPU process and tell it to use the buffer for
104 // video decoding.
105 void SendConsumeVideoSample();
106
107 // Look up the frame_id for |frame| and send a message to the GPU process
108 // to use that video frame to produce an output.
109 void SendProduceVideoFrame(scoped_refptr<media::VideoFrame> frame);
110
111 // A router used to send us IPC messages.
112 MessageRouter* router_;
113
114 // Sends IPC messages to the GPU process.
115 IPC::Message::Sender* ipc_sender_;
116
117 // Route ID of the GLES2 context in the GPU process.
118 int context_route_id_;
119
120 // Message loop that this object runs on.
121 MessageLoop* message_loop_;
122
123 // We expect that the client of us will always available during our life span.
124 EventHandler* event_handler_;
125
126 // A Context for allocating video frame textures.
127 media::VideoDecodeContext* context_;
128
129 // Dimensions of the video.
130 int width_;
131 int height_;
132
133 // Current state of video decoder.
134 GpuVideoDecoderHostState state_;
135
136 // ID of this GpuVideoDecoderHost.
137 int32 decoder_host_id_;
138
139 // ID of GpuVideoDecoder in the GPU process.
140 int32 decoder_id_;
141
142 // We are not able to push all received buffer to gpu process at once.
143 std::deque<scoped_refptr<Buffer> > input_buffer_queue_;
144
145 // Currently we do not use ring buffer in input buffer, therefore before
146 // GPU process had finished access it, we should not touch it.
147 bool input_buffer_busy_;
148
149 // Transfer buffers for both input and output.
150 // TODO(jiesun): remove output buffer when hardware composition is ready.
151 scoped_ptr<base::SharedMemory> input_transfer_buffer_;
152
153 // Frame ID for the newly generated video frame.
154 int32 current_frame_id_;
155
156 // The list of video frames allocated by VideoDecodeContext.
157 std::vector<scoped_refptr<media::VideoFrame> > video_frames_;
158
159 // The mapping between video frame ID and a video frame.
160 VideoFrameMap video_frame_map_;
161
162 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoderHost);
163 };
164
165 #endif // CONTENT_RENDERER_GPU_VIDEO_DECODER_HOST_H_
OLDNEW
« no previous file with comments | « content/renderer/gpu_video_decode_accelerator_host.cc ('k') | content/renderer/gpu_video_decoder_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698