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

Side by Side Diff: media/filters/gpu_video_decoder.h

Issue 16274005: Separate DemuxerStream and VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: VideoFrameStream ready for review. Created 7 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 5 #ifndef MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
7 7
8 #include <list> 8 #include <list>
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "media/base/pipeline_status.h" 14 #include "media/base/pipeline_status.h"
15 #include "media/base/demuxer_stream.h"
16 #include "media/base/video_decoder.h" 15 #include "media/base/video_decoder.h"
17 #include "media/video/video_decode_accelerator.h" 16 #include "media/video/video_decode_accelerator.h"
18 17
19 template <class T> class scoped_refptr; 18 template <class T> class scoped_refptr;
20 19
21 namespace base { 20 namespace base {
22 class MessageLoopProxy; 21 class MessageLoopProxy;
23 class SharedMemory; 22 class SharedMemory;
24 } 23 }
25 24
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 70
72 protected: 71 protected:
73 friend class base::RefCountedThreadSafe<Factories>; 72 friend class base::RefCountedThreadSafe<Factories>;
74 virtual ~Factories(); 73 virtual ~Factories();
75 }; 74 };
76 75
77 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop, 76 GpuVideoDecoder(const scoped_refptr<base::MessageLoopProxy>& message_loop,
78 const scoped_refptr<Factories>& factories); 77 const scoped_refptr<Factories>& factories);
79 78
80 // VideoDecoder implementation. 79 // VideoDecoder implementation.
81 virtual void Initialize(DemuxerStream* stream, 80 virtual void Initialize(const VideoDecoderConfig& config,
82 const PipelineStatusCB& status_cb, 81 const PipelineStatusCB& status_cb,
83 const StatisticsCB& statistics_cb) OVERRIDE; 82 const StatisticsCB& statistics_cb) OVERRIDE;
84 virtual void Read(const ReadCB& read_cb) OVERRIDE; 83 virtual void Decode(const scoped_refptr<DecoderBuffer>& buffer,
84 const ReadCB& read_cb) OVERRIDE;
85 virtual void Reset(const base::Closure& closure) OVERRIDE; 85 virtual void Reset(const base::Closure& closure) OVERRIDE;
86 virtual void Stop(const base::Closure& closure) OVERRIDE; 86 virtual void Stop(const base::Closure& closure) OVERRIDE;
87 virtual bool HasAlpha() const OVERRIDE; 87 virtual bool HasAlpha() const OVERRIDE;
88 virtual bool NeedsBitstreamConversion() const OVERRIDE; 88 virtual bool NeedsBitstreamConversion() const OVERRIDE;
89 virtual bool HasOutputFrameAvailable() const OVERRIDE; 89 virtual bool HasOutputFrameAvailable() const OVERRIDE;
90 90
91 // VideoDecodeAccelerator::Client implementation. 91 // VideoDecodeAccelerator::Client implementation.
92 virtual void NotifyInitializeDone() OVERRIDE; 92 virtual void NotifyInitializeDone() OVERRIDE;
93 virtual void ProvidePictureBuffers(uint32 count, 93 virtual void ProvidePictureBuffers(uint32 count,
94 const gfx::Size& size, 94 const gfx::Size& size,
95 uint32 texture_target) OVERRIDE; 95 uint32 texture_target) OVERRIDE;
96 virtual void DismissPictureBuffer(int32 id) OVERRIDE; 96 virtual void DismissPictureBuffer(int32 id) OVERRIDE;
97 virtual void PictureReady(const media::Picture& picture) OVERRIDE; 97 virtual void PictureReady(const media::Picture& picture) OVERRIDE;
98 virtual void NotifyEndOfBitstreamBuffer(int32 id) OVERRIDE; 98 virtual void NotifyEndOfBitstreamBuffer(int32 id) OVERRIDE;
99 virtual void NotifyFlushDone() OVERRIDE; 99 virtual void NotifyFlushDone() OVERRIDE;
100 virtual void NotifyResetDone() OVERRIDE; 100 virtual void NotifyResetDone() OVERRIDE;
101 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; 101 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE;
102 102
103 protected: 103 protected:
104 virtual ~GpuVideoDecoder(); 104 virtual ~GpuVideoDecoder();
105 105
106 private: 106 private:
107 enum State { 107 enum State {
108 kNormal, 108 kNormal,
109 kDrainingDecoder, 109 kDrainingDecoder,
110 kDecoderDrained, 110 kDecoderDrained,
111 kError 111 kError
112 }; 112 };
113 113
114 // If no demuxer read is in flight and no bitstream buffers are in the
115 // decoder, kick some off demuxing/decoding.
116 void EnsureDemuxOrDecode();
117
118 // Return true if more decode work can be piled on to the VDA. 114 // Return true if more decode work can be piled on to the VDA.
119 bool CanMoreDecodeWorkBeDone(); 115 bool CanMoreDecodeWorkBeDone();
120 116
121 // Callback to pass to demuxer_stream_->Read() for receiving encoded bits.
122 void RequestBufferDecode(DemuxerStream::Status status,
123 const scoped_refptr<DecoderBuffer>& buffer);
124
125 // Enqueue a frame for later delivery (or drop it on the floor if a 117 // Enqueue a frame for later delivery (or drop it on the floor if a
126 // vda->Reset() is in progress) and trigger out-of-line delivery of the oldest 118 // vda->Reset() is in progress) and trigger out-of-line delivery of the oldest
127 // ready frame to the client if there is a pending read. A NULL |frame| 119 // ready frame to the client if there is a pending read. A NULL |frame|
128 // merely triggers delivery, and requires the ready_video_frames_ queue not be 120 // merely triggers delivery, and requires the ready_video_frames_ queue not be
129 // empty. 121 // empty.
130 void EnqueueFrameAndTriggerFrameDelivery( 122 void EnqueueFrameAndTriggerFrameDelivery(
131 const scoped_refptr<VideoFrame>& frame); 123 const scoped_refptr<VideoFrame>& frame);
132 124
133 // Indicate the picture buffer can be reused by the decoder. 125 // Indicate the picture buffer can be reused by the decoder.
134 void ReusePictureBuffer(int64 picture_buffer_id); 126 void ReusePictureBuffer(int64 picture_buffer_id);
(...skipping 24 matching lines...) Expand all
159 // allocate as necessary. Caller does not own returned pointer. 151 // allocate as necessary. Caller does not own returned pointer.
160 SHMBuffer* GetSHM(size_t min_size); 152 SHMBuffer* GetSHM(size_t min_size);
161 153
162 // Return a shared-memory segment to the available pool. 154 // Return a shared-memory segment to the available pool.
163 void PutSHM(SHMBuffer* shm_buffer); 155 void PutSHM(SHMBuffer* shm_buffer);
164 156
165 void DestroyTextures(); 157 void DestroyTextures();
166 158
167 StatisticsCB statistics_cb_; 159 StatisticsCB statistics_cb_;
168 160
169 // Pointer to the demuxer stream that will feed us compressed buffers.
170 DemuxerStream* demuxer_stream_;
171 161
172 bool needs_bitstream_conversion_; 162 bool needs_bitstream_conversion_;
173 163
174 // Message loop on which to fire callbacks and trampoline calls to this class 164 // Message loop on which to fire callbacks and trampoline calls to this class
175 // if they arrive on other loops. 165 // if they arrive on other loops.
176 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_; 166 scoped_refptr<base::MessageLoopProxy> gvd_loop_proxy_;
177 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; 167 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_;
178 base::WeakPtr<GpuVideoDecoder> weak_this_; 168 base::WeakPtr<GpuVideoDecoder> weak_this_;
179 169
180 // Message loop on which to makes all calls to vda_. (beware this loop may be 170 // Message loop on which to makes all calls to vda_. (beware this loop may be
(...skipping 13 matching lines...) Expand all
194 // Used to post tasks from the GVD thread to the VDA thread safely. 184 // Used to post tasks from the GVD thread to the VDA thread safely.
195 base::WeakPtr<VideoDecodeAccelerator> weak_vda_; 185 base::WeakPtr<VideoDecodeAccelerator> weak_vda_;
196 186
197 // Callbacks that are !is_null() only during their respective operation being 187 // Callbacks that are !is_null() only during their respective operation being
198 // asynchronously executed. 188 // asynchronously executed.
199 ReadCB pending_read_cb_; 189 ReadCB pending_read_cb_;
200 base::Closure pending_reset_cb_; 190 base::Closure pending_reset_cb_;
201 191
202 State state_; 192 State state_;
203 193
194 VideoDecoderConfig config_;
195
204 // Is a demuxer read in flight? 196 // Is a demuxer read in flight?
205 bool demuxer_read_in_progress_; 197 bool demuxer_read_in_progress_;
206 198
207 // Shared-memory buffer pool. Since allocating SHM segments requires a 199 // Shared-memory buffer pool. Since allocating SHM segments requires a
208 // round-trip to the browser process, we keep allocation out of the 200 // round-trip to the browser process, we keep allocation out of the
209 // steady-state of the decoder. 201 // steady-state of the decoder.
210 std::vector<SHMBuffer*> available_shm_segments_; 202 std::vector<SHMBuffer*> available_shm_segments_;
211 203
212 // Book-keeping variables. 204 // Book-keeping variables.
213 struct BufferPair { 205 struct BufferPair {
(...skipping 28 matching lines...) Expand all
242 // Set during ProvidePictureBuffers(), used for checking and implementing 234 // Set during ProvidePictureBuffers(), used for checking and implementing
243 // HasAvailableOutputFrames(). 235 // HasAvailableOutputFrames().
244 int available_pictures_; 236 int available_pictures_;
245 237
246 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); 238 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
247 }; 239 };
248 240
249 } // namespace media 241 } // namespace media
250 242
251 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ 243 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698