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

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

Issue 65803002: Replace MessageLoopProxy with SingleThreadTaskRunner for media/filters/ + associated code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years 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
« no previous file with comments | « media/filters/video_frame_stream.cc ('k') | media/filters/video_renderer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_FILTERS_VIDEO_RENDERER_IMPL_H_ 5 #ifndef MEDIA_FILTERS_VIDEO_RENDERER_IMPL_H_
6 #define MEDIA_FILTERS_VIDEO_RENDERER_IMPL_H_ 6 #define MEDIA_FILTERS_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_vector.h" 11 #include "base/memory/scoped_vector.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/synchronization/condition_variable.h" 13 #include "base/synchronization/condition_variable.h"
14 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
15 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
16 #include "media/base/decryptor.h" 16 #include "media/base/decryptor.h"
17 #include "media/base/demuxer_stream.h" 17 #include "media/base/demuxer_stream.h"
18 #include "media/base/pipeline_status.h" 18 #include "media/base/pipeline_status.h"
19 #include "media/base/video_decoder.h" 19 #include "media/base/video_decoder.h"
20 #include "media/base/video_frame.h" 20 #include "media/base/video_frame.h"
21 #include "media/base/video_renderer.h" 21 #include "media/base/video_renderer.h"
22 #include "media/filters/video_frame_stream.h" 22 #include "media/filters/video_frame_stream.h"
23 23
24 namespace base { 24 namespace base {
25 class MessageLoopProxy; 25 class SingleThreadTaskRunner;
26 } 26 }
27 27
28 namespace media { 28 namespace media {
29 29
30 // VideoRendererImpl creates its own thread for the sole purpose of timing frame 30 // VideoRendererImpl creates its own thread for the sole purpose of timing frame
31 // presentation. It handles reading from the VideoFrameStream and stores the 31 // presentation. It handles reading from the VideoFrameStream and stores the
32 // results in a queue of decoded frames and executing a callback when a frame is 32 // results in a queue of decoded frames and executing a callback when a frame is
33 // ready for rendering. 33 // ready for rendering.
34 class MEDIA_EXPORT VideoRendererImpl 34 class MEDIA_EXPORT VideoRendererImpl
35 : public VideoRenderer, 35 : public VideoRenderer,
(...skipping 11 matching lines...) Expand all
47 // frame is available for painting. 47 // frame is available for painting.
48 // 48 //
49 // |set_opaque_cb| is executed when the renderer is initialized to inform 49 // |set_opaque_cb| is executed when the renderer is initialized to inform
50 // the player whether the decoded output will be opaque or not. 50 // the player whether the decoded output will be opaque or not.
51 // 51 //
52 // Implementors should avoid doing any sort of heavy work in this method and 52 // Implementors should avoid doing any sort of heavy work in this method and
53 // instead post a task to a common/worker thread to handle rendering. Slowing 53 // instead post a task to a common/worker thread to handle rendering. Slowing
54 // down the video thread may result in losing synchronization with audio. 54 // down the video thread may result in losing synchronization with audio.
55 // 55 //
56 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 56 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
57 VideoRendererImpl(const scoped_refptr<base::MessageLoopProxy>& message_loop, 57 VideoRendererImpl(
58 ScopedVector<VideoDecoder> decoders, 58 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
59 const SetDecryptorReadyCB& set_decryptor_ready_cb, 59 ScopedVector<VideoDecoder> decoders,
60 const PaintCB& paint_cb, 60 const SetDecryptorReadyCB& set_decryptor_ready_cb,
61 const SetOpaqueCB& set_opaque_cb, 61 const PaintCB& paint_cb,
62 bool drop_frames); 62 const SetOpaqueCB& set_opaque_cb,
63 bool drop_frames);
63 virtual ~VideoRendererImpl(); 64 virtual ~VideoRendererImpl();
64 65
65 // VideoRenderer implementation. 66 // VideoRenderer implementation.
66 virtual void Initialize(DemuxerStream* stream, 67 virtual void Initialize(DemuxerStream* stream,
67 const PipelineStatusCB& init_cb, 68 const PipelineStatusCB& init_cb,
68 const StatisticsCB& statistics_cb, 69 const StatisticsCB& statistics_cb,
69 const TimeCB& max_time_cb, 70 const TimeCB& max_time_cb,
70 const NaturalSizeChangedCB& size_changed_cb, 71 const NaturalSizeChangedCB& size_changed_cb,
71 const base::Closure& ended_cb, 72 const base::Closure& ended_cb,
72 const PipelineStatusCB& error_cb, 73 const PipelineStatusCB& error_cb,
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 132
132 // Returns true of all conditions have been met to transition from 133 // Returns true of all conditions have been met to transition from
133 // kPrerolling to kPrerolled. 134 // kPrerolling to kPrerolled.
134 bool ShouldTransitionToPrerolled_Locked(); 135 bool ShouldTransitionToPrerolled_Locked();
135 136
136 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets 137 // Runs |statistics_cb_| with |frames_decoded_| and |frames_dropped_|, resets
137 // them to 0, and then waits on |frame_available_| for up to the 138 // them to 0, and then waits on |frame_available_| for up to the
138 // |wait_duration|. 139 // |wait_duration|.
139 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration); 140 void UpdateStatsAndWait_Locked(base::TimeDelta wait_duration);
140 141
141 scoped_refptr<base::MessageLoopProxy> message_loop_; 142 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
142 base::WeakPtrFactory<VideoRendererImpl> weak_factory_; 143 base::WeakPtrFactory<VideoRendererImpl> weak_factory_;
143 base::WeakPtr<VideoRendererImpl> weak_this_; 144 base::WeakPtr<VideoRendererImpl> weak_this_;
144 145
145 // Used for accessing data members. 146 // Used for accessing data members.
146 base::Lock lock_; 147 base::Lock lock_;
147 148
148 // Provides video frames to VideoRendererImpl. 149 // Provides video frames to VideoRendererImpl.
149 VideoFrameStream video_frame_stream_; 150 VideoFrameStream video_frame_stream_;
150 151
151 // Queue of incoming frames yet to be painted. 152 // Queue of incoming frames yet to be painted.
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 // last call to |statistics_cb_|. These must be accessed under lock. 250 // last call to |statistics_cb_|. These must be accessed under lock.
250 int frames_decoded_; 251 int frames_decoded_;
251 int frames_dropped_; 252 int frames_dropped_;
252 253
253 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl); 254 DISALLOW_COPY_AND_ASSIGN(VideoRendererImpl);
254 }; 255 };
255 256
256 } // namespace media 257 } // namespace media
257 258
258 #endif // MEDIA_FILTERS_VIDEO_RENDERER_IMPL_H_ 259 #endif // MEDIA_FILTERS_VIDEO_RENDERER_IMPL_H_
OLDNEW
« no previous file with comments | « media/filters/video_frame_stream.cc ('k') | media/filters/video_renderer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698