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

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

Issue 164403: Implemented end-of-stream callback for media::PipelineImpl. (Closed)
Patch Set: Baz Created 11 years, 4 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
« no previous file with comments | « media/filters/audio_renderer_base_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) 2009 The Chromium Authors. All rights reserved. Use of this 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the 2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file. 3 // LICENSE file.
4 4
5 // VideoRendererBase creates its own thread for the sole purpose of timing frame 5 // VideoRendererBase creates its own thread for the sole purpose of timing frame
6 // presentation. It handles reading from the decoder and stores the results in 6 // presentation. It handles reading from the decoder and stores the results in
7 // a queue of decoded frames, calling OnFrameAvailable() on subclasses to notify 7 // a queue of decoded frames, calling OnFrameAvailable() on subclasses to notify
8 // when a frame is ready to display. 8 // when a frame is ready to display.
9 // 9 //
10 // The media filter methods Initialize(), Stop(), SetPlaybackRate() and Seek() 10 // The media filter methods Initialize(), Stop(), SetPlaybackRate() and Seek()
(...skipping 27 matching lines...) Expand all
38 38
39 // MediaFilter implementation. 39 // MediaFilter implementation.
40 virtual void Play(FilterCallback* callback); 40 virtual void Play(FilterCallback* callback);
41 virtual void Pause(FilterCallback* callback); 41 virtual void Pause(FilterCallback* callback);
42 virtual void Stop(); 42 virtual void Stop();
43 virtual void SetPlaybackRate(float playback_rate); 43 virtual void SetPlaybackRate(float playback_rate);
44 virtual void Seek(base::TimeDelta time, FilterCallback* callback); 44 virtual void Seek(base::TimeDelta time, FilterCallback* callback);
45 45
46 // VideoRenderer implementation. 46 // VideoRenderer implementation.
47 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback); 47 virtual void Initialize(VideoDecoder* decoder, FilterCallback* callback);
48 virtual bool HasEnded();
48 49
49 // PlatformThread::Delegate implementation. 50 // PlatformThread::Delegate implementation.
50 virtual void ThreadMain(); 51 virtual void ThreadMain();
51 52
52 // Assigns the current frame, which will never be NULL as long as this filter 53 // Assigns the current frame, which will never be NULL as long as this filter
53 // is initialized. 54 // is initialized.
54 void GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out); 55 void GetCurrentFrame(scoped_refptr<VideoFrame>* frame_out);
55 56
56 protected: 57 protected:
57 // Subclass interface. Called before any other initialization in the base 58 // Subclass interface. Called before any other initialization in the base
(...skipping 26 matching lines...) Expand all
84 // Safe to call from any thread. 85 // Safe to call from any thread.
85 void ScheduleRead_Locked(); 86 void ScheduleRead_Locked();
86 87
87 // Calculates the duration to sleep for based on |current_frame_|'s timestamp, 88 // Calculates the duration to sleep for based on |current_frame_|'s timestamp,
88 // the next frame timestamp (may be NULL), and the provided playback rate. 89 // the next frame timestamp (may be NULL), and the provided playback rate.
89 // 90 //
90 // We don't use |playback_rate_| to avoid locking. 91 // We don't use |playback_rate_| to avoid locking.
91 base::TimeDelta CalculateSleepDuration(VideoFrame* next_frame, 92 base::TimeDelta CalculateSleepDuration(VideoFrame* next_frame,
92 float playback_rate); 93 float playback_rate);
93 94
94 // Allocates YV12 frame based on |width_| and |height_|, and sets its data to
95 // the YUV equivalent of RGB(0,0,0).
96 void CreateBlackFrame(scoped_refptr<VideoFrame>* frame_out);
97
98 // Used for accessing data members. 95 // Used for accessing data members.
99 Lock lock_; 96 Lock lock_;
100 97
101 scoped_refptr<VideoDecoder> decoder_; 98 scoped_refptr<VideoDecoder> decoder_;
102 99
103 // Video dimensions parsed from the decoder's media format. 100 // Video dimensions parsed from the decoder's media format.
104 int width_; 101 int width_;
105 int height_; 102 int height_;
106 103
107 // Queue of incoming frames as well as the current frame since the last time 104 // Queue of incoming frames as well as the current frame since the last time
108 // OnFrameAvailable() was called. 105 // OnFrameAvailable() was called.
109 typedef std::deque< scoped_refptr<VideoFrame> > VideoFrameQueue; 106 typedef std::deque< scoped_refptr<VideoFrame> > VideoFrameQueue;
110 VideoFrameQueue frames_; 107 VideoFrameQueue frames_;
111 scoped_refptr<VideoFrame> current_frame_; 108 scoped_refptr<VideoFrame> current_frame_;
112 109
113 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb: 110 // Used to signal |thread_| as frames are added to |frames_|. Rule of thumb:
114 // always check |state_| to see if it was set to STOPPED after waking up! 111 // always check |state_| to see if it was set to STOPPED after waking up!
115 ConditionVariable frame_available_; 112 ConditionVariable frame_available_;
116 113
117 // Simple state tracking variable. 114 // Simple state tracking variable.
118 enum State { 115 enum State {
119 kUninitialized, 116 kUninitialized,
120 kPaused, 117 kPaused,
121 kSeeking, 118 kSeeking,
122 kPlaying, 119 kPlaying,
120 kEnded,
123 kStopped, 121 kStopped,
124 kError, 122 kError,
125 }; 123 };
126 State state_; 124 State state_;
127 125
128 // Video thread handle. 126 // Video thread handle.
129 PlatformThreadHandle thread_; 127 PlatformThreadHandle thread_;
130 128
131 // Previous time returned from the pipeline. 129 // Previous time returned from the pipeline.
132 base::TimeDelta previous_time_; 130 base::TimeDelta previous_time_;
(...skipping 10 matching lines...) Expand all
143 // Filter callbacks. 141 // Filter callbacks.
144 scoped_ptr<FilterCallback> pause_callback_; 142 scoped_ptr<FilterCallback> pause_callback_;
145 scoped_ptr<FilterCallback> seek_callback_; 143 scoped_ptr<FilterCallback> seek_callback_;
146 144
147 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase); 145 DISALLOW_COPY_AND_ASSIGN(VideoRendererBase);
148 }; 146 };
149 147
150 } // namespace media 148 } // namespace media
151 149
152 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_ 150 #endif // MEDIA_FILTERS_VIDEO_RENDERER_BASE_H_
OLDNEW
« no previous file with comments | « media/filters/audio_renderer_base_unittest.cc ('k') | media/filters/video_renderer_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698