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

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

Issue 14348007: Reland: Remove reference counting from media::VideoDecoder and friends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixes Created 7 years, 8 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
« no previous file with comments | « media/filters/video_frame_stream_unittest.cc ('k') | media/filters/video_renderer_base.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 (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_VIDEO_RENDERER_BASE_H_ 5 #ifndef MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_
6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ 6 #define MEDIA_FILTERS_VIDEO_RENDERER_BASE_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/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
12 #include "base/synchronization/condition_variable.h" 13 #include "base/synchronization/condition_variable.h"
13 #include "base/synchronization/lock.h" 14 #include "base/synchronization/lock.h"
14 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
15 #include "media/base/decryptor.h" 16 #include "media/base/decryptor.h"
16 #include "media/base/demuxer_stream.h" 17 #include "media/base/demuxer_stream.h"
17 #include "media/base/pipeline_status.h" 18 #include "media/base/pipeline_status.h"
18 #include "media/base/video_decoder.h" 19 #include "media/base/video_decoder.h"
19 #include "media/base/video_frame.h" 20 #include "media/base/video_frame.h"
20 #include "media/base/video_renderer.h" 21 #include "media/base/video_renderer.h"
(...skipping 15 matching lines...) Expand all
36 class MEDIA_EXPORT VideoRendererBase 37 class MEDIA_EXPORT VideoRendererBase
37 : public VideoRenderer, 38 : public VideoRenderer,
38 public base::PlatformThread::Delegate { 39 public base::PlatformThread::Delegate {
39 public: 40 public:
40 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB; 41 typedef base::Callback<void(const scoped_refptr<VideoFrame>&)> PaintCB;
41 typedef base::Callback<void(bool)> SetOpaqueCB; 42 typedef base::Callback<void(bool)> SetOpaqueCB;
42 43
43 // Maximum duration of the last frame. 44 // Maximum duration of the last frame.
44 static base::TimeDelta kMaxLastFrameDuration(); 45 static base::TimeDelta kMaxLastFrameDuration();
45 46
47 // |decoders| contains the VideoDecoders to use when initializing.
48 //
46 // |paint_cb| is executed on the video frame timing thread whenever a new 49 // |paint_cb| is executed on the video frame timing thread whenever a new
47 // frame is available for painting. 50 // frame is available for painting.
48 // 51 //
49 // |set_opaque_cb| is executed when the renderer is initialized to inform 52 // |set_opaque_cb| is executed when the renderer is initialized to inform
50 // the player whether the decoder's output will be opaque or not. 53 // the player whether the decoder's output will be opaque or not.
51 // 54 //
52 // Implementors should avoid doing any sort of heavy work in this method and 55 // 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 56 // 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. 57 // down the video thread may result in losing synchronization with audio.
55 // 58 //
56 // Setting |drop_frames_| to true causes the renderer to drop expired frames. 59 // Setting |drop_frames_| to true causes the renderer to drop expired frames.
57 VideoRendererBase(const scoped_refptr<base::MessageLoopProxy>& message_loop, 60 VideoRendererBase(const scoped_refptr<base::MessageLoopProxy>& message_loop,
61 ScopedVector<VideoDecoder> decoders,
58 const SetDecryptorReadyCB& set_decryptor_ready_cb, 62 const SetDecryptorReadyCB& set_decryptor_ready_cb,
59 const PaintCB& paint_cb, 63 const PaintCB& paint_cb,
60 const SetOpaqueCB& set_opaque_cb, 64 const SetOpaqueCB& set_opaque_cb,
61 bool drop_frames); 65 bool drop_frames);
62 virtual ~VideoRendererBase(); 66 virtual ~VideoRendererBase();
63 67
64 // VideoRenderer implementation. 68 // VideoRenderer implementation.
65 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream, 69 virtual void Initialize(const scoped_refptr<DemuxerStream>& stream,
66 const VideoDecoderList& decoders,
67 const PipelineStatusCB& init_cb, 70 const PipelineStatusCB& init_cb,
68 const StatisticsCB& statistics_cb, 71 const StatisticsCB& statistics_cb,
69 const TimeCB& max_time_cb, 72 const TimeCB& max_time_cb,
70 const NaturalSizeChangedCB& size_changed_cb, 73 const NaturalSizeChangedCB& size_changed_cb,
71 const base::Closure& ended_cb, 74 const base::Closure& ended_cb,
72 const PipelineStatusCB& error_cb, 75 const PipelineStatusCB& error_cb,
73 const TimeDeltaCB& get_time_cb, 76 const TimeDeltaCB& get_time_cb,
74 const TimeDeltaCB& get_duration_cb) OVERRIDE; 77 const TimeDeltaCB& get_duration_cb) OVERRIDE;
75 virtual void Play(const base::Closure& callback) OVERRIDE; 78 virtual void Play(const base::Closure& callback) OVERRIDE;
76 virtual void Pause(const base::Closure& callback) OVERRIDE; 79 virtual void Pause(const base::Closure& callback) OVERRIDE;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 // changes. 125 // changes.
123 // 126 //
124 // A read is scheduled to replace the frame. 127 // A read is scheduled to replace the frame.
125 void PaintNextReadyFrame_Locked(); 128 void PaintNextReadyFrame_Locked();
126 129
127 // Drops the next frame from |ready_frames_| and runs |statistics_cb_|. 130 // Drops the next frame from |ready_frames_| and runs |statistics_cb_|.
128 // 131 //
129 // A read is scheduled to replace the frame. 132 // A read is scheduled to replace the frame.
130 void DropNextReadyFrame_Locked(); 133 void DropNextReadyFrame_Locked();
131 134
135 void ResetDecoder();
136 void StopDecoder(const base::Closure& callback);
137
132 void TransitionToPrerolled_Locked(); 138 void TransitionToPrerolled_Locked();
133 139
134 scoped_refptr<base::MessageLoopProxy> message_loop_; 140 scoped_refptr<base::MessageLoopProxy> message_loop_;
135 base::WeakPtrFactory<VideoRendererBase> weak_factory_; 141 base::WeakPtrFactory<VideoRendererBase> weak_factory_;
136 base::WeakPtr<VideoRendererBase> weak_this_; 142 base::WeakPtr<VideoRendererBase> weak_this_;
137 143
144 scoped_ptr<VideoDecoderSelector> decoder_selector_;
145
138 // Used for accessing data members. 146 // Used for accessing data members.
139 base::Lock lock_; 147 base::Lock lock_;
140 148
141 // Provides video frames to VideoRendererBase. 149 // Provides video frames to VideoRendererBase.
142 scoped_refptr<VideoFrameStream> video_frame_stream_; 150 scoped_refptr<VideoFrameStream> video_frame_stream_;
143 151
144 // Queue of incoming frames yet to be painted. 152 // Queue of incoming frames yet to be painted.
145 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue; 153 typedef std::deque<scoped_refptr<VideoFrame> > VideoFrameQueue;
146 VideoFrameQueue ready_frames_; 154 VideoFrameQueue ready_frames_;
147 155
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 // either for calling |paint_cb_| or for dropping. Set to kNoTimestamp() 247 // either for calling |paint_cb_| or for dropping. Set to kNoTimestamp()
240 // during flushing. 248 // during flushing.
241 base::TimeDelta last_timestamp_; 249 base::TimeDelta last_timestamp_;
242 250
243 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); 251 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase);
244 }; 252 };
245 253
246 } // namespace media 254 } // namespace media
247 255
248 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ 256 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_
OLDNEW
« no previous file with comments | « media/filters/video_frame_stream_unittest.cc ('k') | media/filters/video_renderer_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698