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

Side by Side Diff: media/renderers/video_renderer_impl.h

Issue 1133563010: Add a GpuMemoryBuffer pool that creates hardware backed VideoFrames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address reveman@'s nits. Created 5 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_RENDERERS_VIDEO_RENDERER_IMPL_H_ 5 #ifndef MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 6 #define MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/memory/scoped_vector.h" 12 #include "base/memory/scoped_vector.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/synchronization/condition_variable.h" 14 #include "base/synchronization/condition_variable.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
17 #include "base/timer/timer.h" 17 #include "base/timer/timer.h"
18 #include "media/base/decryptor.h" 18 #include "media/base/decryptor.h"
19 #include "media/base/demuxer_stream.h" 19 #include "media/base/demuxer_stream.h"
20 #include "media/base/media_log.h" 20 #include "media/base/media_log.h"
21 #include "media/base/pipeline_status.h" 21 #include "media/base/pipeline_status.h"
22 #include "media/base/video_decoder.h" 22 #include "media/base/video_decoder.h"
23 #include "media/base/video_frame.h" 23 #include "media/base/video_frame.h"
24 #include "media/base/video_renderer.h" 24 #include "media/base/video_renderer.h"
25 #include "media/base/video_renderer_sink.h" 25 #include "media/base/video_renderer_sink.h"
26 #include "media/filters/decoder_stream.h" 26 #include "media/filters/decoder_stream.h"
27 #include "media/filters/video_renderer_algorithm.h" 27 #include "media/filters/video_renderer_algorithm.h"
28 #include "media/renderers/gpu_video_accelerator_factories.h"
29 #include "media/video/gpu_memory_buffer_video_frame_pool.h"
28 30
29 namespace base { 31 namespace base {
30 class SingleThreadTaskRunner; 32 class SingleThreadTaskRunner;
31 class TickClock; 33 class TickClock;
32 } 34 }
33 35
34 namespace media { 36 namespace media {
35 37
36 // VideoRendererImpl creates its own thread for the sole purpose of timing frame 38 // VideoRendererImpl creates its own thread for the sole purpose of timing frame
37 // presentation. It handles reading from the VideoFrameStream and stores the 39 // presentation. It handles reading from the VideoFrameStream and stores the
38 // results in a queue of decoded frames and executing a callback when a frame is 40 // results in a queue of decoded frames and executing a callback when a frame is
39 // ready for rendering. 41 // ready for rendering.
40 class MEDIA_EXPORT VideoRendererImpl 42 class MEDIA_EXPORT VideoRendererImpl
41 : public VideoRenderer, 43 : public VideoRenderer,
42 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback), 44 public NON_EXPORTED_BASE(VideoRendererSink::RenderCallback),
43 public base::PlatformThread::Delegate { 45 public base::PlatformThread::Delegate {
44 public: 46 public:
45 // |decoders| contains the VideoDecoders to use when initializing. 47 // |decoders| contains the VideoDecoders to use when initializing.
46 // 48 //
47 // Implementors should avoid doing any sort of heavy work in this method and 49 // Implementors should avoid doing any sort of heavy work in this method and
48 // instead post a task to a common/worker thread to handle rendering. Slowing 50 // instead post a task to a common/worker thread to handle rendering. Slowing
49 // down the video thread may result in losing synchronization with audio. 51 // down the video thread may result in losing synchronization with audio.
50 // 52 //
51 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 53 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
52 VideoRendererImpl( 54 VideoRendererImpl(
53 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 55 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
54 VideoRendererSink* sink, 56 VideoRendererSink* sink,
55 ScopedVector<VideoDecoder> decoders, 57 ScopedVector<VideoDecoder> decoders,
56 bool drop_frames, 58 bool drop_frames,
59 const scoped_refptr<GpuVideoAcceleratorFactories>& gpu_factories,
57 const scoped_refptr<MediaLog>& media_log); 60 const scoped_refptr<MediaLog>& media_log);
58 ~VideoRendererImpl() override; 61 ~VideoRendererImpl() override;
59 62
60 // VideoRenderer implementation. 63 // VideoRenderer implementation.
61 void Initialize(DemuxerStream* stream, 64 void Initialize(DemuxerStream* stream,
62 const PipelineStatusCB& init_cb, 65 const PipelineStatusCB& init_cb,
63 const SetDecryptorReadyCB& set_decryptor_ready_cb, 66 const SetDecryptorReadyCB& set_decryptor_ready_cb,
64 const StatisticsCB& statistics_cb, 67 const StatisticsCB& statistics_cb,
65 const BufferingStateCB& buffering_state_cb, 68 const BufferingStateCB& buffering_state_cb,
66 const base::Closure& ended_cb, 69 const base::Closure& ended_cb,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 // StartSink() and StopSink() to ensure background rendering is started. 166 // StartSink() and StopSink() to ensure background rendering is started.
164 VideoRendererSink* const sink_; 167 VideoRendererSink* const sink_;
165 bool sink_started_; 168 bool sink_started_;
166 169
167 // Used for accessing data members. 170 // Used for accessing data members.
168 base::Lock lock_; 171 base::Lock lock_;
169 172
170 // Provides video frames to VideoRendererImpl. 173 // Provides video frames to VideoRendererImpl.
171 scoped_ptr<VideoFrameStream> video_frame_stream_; 174 scoped_ptr<VideoFrameStream> video_frame_stream_;
172 175
176 // Pool of GpuMemoryBuffers and resources used to create hardware frames.
177 scoped_ptr<GpuMemoryBufferVideoFramePool> gpu_memory_buffer_pool_;
178
173 // Flag indicating low-delay mode. 179 // Flag indicating low-delay mode.
174 bool low_delay_; 180 bool low_delay_;
175 181
176 // Queue of incoming frames yet to be painted. 182 // Queue of incoming frames yet to be painted.
177 typedef std::deque<scoped_refptr<VideoFrame>> VideoFrameQueue; 183 typedef std::deque<scoped_refptr<VideoFrame>> VideoFrameQueue;
178 VideoFrameQueue ready_frames_; 184 VideoFrameQueue ready_frames_;
179 185
180 // Keeps track of whether we received the end of stream buffer and finished 186 // Keeps track of whether we received the end of stream buffer and finished
181 // rendering. 187 // rendering.
182 bool received_end_of_stream_; 188 bool received_end_of_stream_;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 282
277 // NOTE: Weak pointers must be invalidated before all other member variables. 283 // NOTE: Weak pointers must be invalidated before all other member variables.
278 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 284 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
279 285
280 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 286 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
281 }; 287 };
282 288
283 } // namespace media 289 } // namespace media
284 290
285 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_ 291 #endif // MEDIA_RENDERERS_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/renderers/mock_gpu_video_accelerator_factories.cc ('k') | media/renderers/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698