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

Side by Side Diff: media/base/pipeline.h

Issue 379343005: Introduce media::TimeSource. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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_BASE_PIPELINE_H_ 5 #ifndef MEDIA_BASE_PIPELINE_H_
6 #define MEDIA_BASE_PIPELINE_H_ 6 #define MEDIA_BASE_PIPELINE_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 15 matching lines...) Expand all
26 class SingleThreadTaskRunner; 26 class SingleThreadTaskRunner;
27 class TimeDelta; 27 class TimeDelta;
28 } 28 }
29 29
30 namespace media { 30 namespace media {
31 31
32 class FilterCollection; 32 class FilterCollection;
33 class MediaLog; 33 class MediaLog;
34 class TextRenderer; 34 class TextRenderer;
35 class TextTrackConfig; 35 class TextTrackConfig;
36 class TimeDeltaInterpolator; 36 class TimeSource;
37 class VideoRenderer; 37 class VideoRenderer;
38 class WallClockTimeSource;
38 39
39 // Metadata describing a pipeline once it has been initialized. 40 // Metadata describing a pipeline once it has been initialized.
40 struct PipelineMetadata { 41 struct PipelineMetadata {
41 PipelineMetadata() 42 PipelineMetadata()
42 : has_audio(false), has_video(false), video_rotation(VIDEO_ROTATION_0) {} 43 : has_audio(false), has_video(false), video_rotation(VIDEO_ROTATION_0) {}
43 44
44 bool has_audio; 45 bool has_audio;
45 bool has_video; 46 bool has_video;
46 gfx::Size natural_size; 47 gfx::Size natural_size;
47 VideoRotation video_rotation; 48 VideoRotation video_rotation;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 // Return true if loading progress has been made since the last time this 173 // Return true if loading progress has been made since the last time this
173 // method was called. 174 // method was called.
174 bool DidLoadingProgress(); 175 bool DidLoadingProgress();
175 176
176 // Gets the current pipeline statistics. 177 // Gets the current pipeline statistics.
177 PipelineStatistics GetStatistics() const; 178 PipelineStatistics GetStatistics() const;
178 179
179 void set_underflow_disabled_for_testing(bool disabled) { 180 void set_underflow_disabled_for_testing(bool disabled) {
180 underflow_disabled_for_testing_ = disabled; 181 underflow_disabled_for_testing_ = disabled;
181 } 182 }
182 void SetTimeDeltaInterpolatorForTesting(TimeDeltaInterpolator* interpolator);
183 void SetErrorForTesting(PipelineStatus status); 183 void SetErrorForTesting(PipelineStatus status);
184 184
185 private: 185 private:
186 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges); 186 FRIEND_TEST_ALL_PREFIXES(PipelineTest, GetBufferedTimeRanges);
187 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback); 187 FRIEND_TEST_ALL_PREFIXES(PipelineTest, EndedCallback);
188 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo); 188 FRIEND_TEST_ALL_PREFIXES(PipelineTest, AudioStreamShorterThanVideo);
189 friend class MediaLog; 189 friend class MediaLog;
190 190
191 // Pipeline states, as described above. 191 // Pipeline states, as described above.
192 enum State { 192 enum State {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 void SetError(PipelineStatus error); 225 void SetError(PipelineStatus error);
226 226
227 // Callbacks executed when a renderer has ended. 227 // Callbacks executed when a renderer has ended.
228 void OnAudioRendererEnded(); 228 void OnAudioRendererEnded();
229 void OnVideoRendererEnded(); 229 void OnVideoRendererEnded();
230 void OnTextRendererEnded(); 230 void OnTextRendererEnded();
231 231
232 // Callback executed by filters to update statistics. 232 // Callback executed by filters to update statistics.
233 void OnUpdateStatistics(const PipelineStatistics& stats); 233 void OnUpdateStatistics(const PipelineStatistics& stats);
234 234
235 // Callback executed by audio renderer to update clock time.
236 void OnAudioTimeUpdate(base::TimeDelta time, base::TimeDelta max_time);
237
238 // Callback executed by video renderer to update clock time.
239 void OnVideoTimeUpdate(base::TimeDelta max_time);
240
241 // The following "task" methods correspond to the public methods, but these 235 // The following "task" methods correspond to the public methods, but these
242 // methods are run as the result of posting a task to the Pipeline's 236 // methods are run as the result of posting a task to the Pipeline's
243 // task runner. 237 // task runner.
244 void StartTask(); 238 void StartTask();
245 239
246 // Stops and destroys all filters, placing the pipeline in the kStopped state. 240 // Stops and destroys all filters, placing the pipeline in the kStopped state.
247 void StopTask(const base::Closure& stop_cb); 241 void StopTask(const base::Closure& stop_cb);
248 242
249 // Carries out stopping and destroying all filters, placing the pipeline in 243 // Carries out stopping and destroying all filters, placing the pipeline in
250 // the kStopped state. 244 // the kStopped state.
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 // - A waiting to non-waiting transition indicates preroll has completed 304 // - A waiting to non-waiting transition indicates preroll has completed
311 // and StartPlayback() should be called 305 // and StartPlayback() should be called
312 // - A non-waiting to waiting transition indicates underflow has occurred 306 // - A non-waiting to waiting transition indicates underflow has occurred
313 // and PausePlayback() should be called 307 // and PausePlayback() should be called
314 void BufferingStateChanged(BufferingState* buffering_state, 308 void BufferingStateChanged(BufferingState* buffering_state,
315 BufferingState new_buffering_state); 309 BufferingState new_buffering_state);
316 bool WaitingForEnoughData() const; 310 bool WaitingForEnoughData() const;
317 void PausePlayback(); 311 void PausePlayback();
318 void StartPlayback(); 312 void StartPlayback();
319 313
320 void PauseClockAndStopRendering_Locked();
321 void StartClockIfWaitingForTimeUpdate_Locked();
322
323 // Task runner used to execute pipeline tasks. 314 // Task runner used to execute pipeline tasks.
324 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 315 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
325 316
326 // MediaLog to which to log events. 317 // MediaLog to which to log events.
327 scoped_refptr<MediaLog> media_log_; 318 scoped_refptr<MediaLog> media_log_;
328 319
329 // Lock used to serialize access for the following data members. 320 // Lock used to serialize access for the following data members.
330 mutable base::Lock lock_; 321 mutable base::Lock lock_;
331 322
332 // Whether or not the pipeline is running. 323 // Whether or not the pipeline is running.
(...skipping 12 matching lines...) Expand all
345 float volume_; 336 float volume_;
346 337
347 // Current playback rate (>= 0.0f). This value is set immediately via 338 // Current playback rate (>= 0.0f). This value is set immediately via
348 // SetPlaybackRate() and a task is dispatched on the task runner to notify 339 // SetPlaybackRate() and a task is dispatched on the task runner to notify
349 // the filters. 340 // the filters.
350 float playback_rate_; 341 float playback_rate_;
351 342
352 // Current duration as reported by |demuxer_|. 343 // Current duration as reported by |demuxer_|.
353 base::TimeDelta duration_; 344 base::TimeDelta duration_;
354 345
355 // base::TickClock used by |interpolator_|.
356 base::DefaultTickClock default_tick_clock_;
357
358 // Tracks the most recent media time update and provides interpolated values
359 // as playback progresses.
360 scoped_ptr<TimeDeltaInterpolator> interpolator_;
361
362 enum InterpolationState {
363 // Audio (if present) is not rendering. Time isn't being interpolated.
364 INTERPOLATION_STOPPED,
365
366 // Audio (if present) is rendering. Time isn't being interpolated.
367 INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE,
368
369 // Audio (if present) is rendering. Time is being interpolated.
370 INTERPOLATION_STARTED,
371 };
372
373 InterpolationState interpolation_state_;
374
375 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that 346 // Status of the pipeline. Initialized to PIPELINE_OK which indicates that
376 // the pipeline is operating correctly. Any other value indicates that the 347 // the pipeline is operating correctly. Any other value indicates that the
377 // pipeline is stopped or is stopping. Clients can call the Stop() method to 348 // pipeline is stopped or is stopping. Clients can call the Stop() method to
378 // reset the pipeline state, and restore this to PIPELINE_OK. 349 // reset the pipeline state, and restore this to PIPELINE_OK.
379 PipelineStatus status_; 350 PipelineStatus status_;
380 351
381 // The following data members are only accessed by tasks posted to 352 // The following data members are only accessed by tasks posted to
382 // |task_runner_|. 353 // |task_runner_|.
383 354
384 // Member that tracks the current state. 355 // Member that tracks the current state.
(...skipping 28 matching lines...) Expand all
413 384
414 // Holds the initialized demuxer. Used for seeking. Owned by client. 385 // Holds the initialized demuxer. Used for seeking. Owned by client.
415 Demuxer* demuxer_; 386 Demuxer* demuxer_;
416 387
417 // Holds the initialized renderers. Used for setting the volume, 388 // Holds the initialized renderers. Used for setting the volume,
418 // playback rate, and determining when playback has finished. 389 // playback rate, and determining when playback has finished.
419 scoped_ptr<AudioRenderer> audio_renderer_; 390 scoped_ptr<AudioRenderer> audio_renderer_;
420 scoped_ptr<VideoRenderer> video_renderer_; 391 scoped_ptr<VideoRenderer> video_renderer_;
421 scoped_ptr<TextRenderer> text_renderer_; 392 scoped_ptr<TextRenderer> text_renderer_;
422 393
394 TimeSource* time_source_;
395 scoped_ptr<WallClockTimeSource> wall_clock_time_source_;
396
423 PipelineStatistics statistics_; 397 PipelineStatistics statistics_;
424 398
425 scoped_ptr<SerialRunner> pending_callbacks_; 399 scoped_ptr<SerialRunner> pending_callbacks_;
426 400
427 bool underflow_disabled_for_testing_; 401 bool underflow_disabled_for_testing_;
428 402
429 base::ThreadChecker thread_checker_; 403 base::ThreadChecker thread_checker_;
430 404
431 DISALLOW_COPY_AND_ASSIGN(Pipeline); 405 DISALLOW_COPY_AND_ASSIGN(Pipeline);
432 }; 406 };
433 407
434 } // namespace media 408 } // namespace media
435 409
436 #endif // MEDIA_BASE_PIPELINE_H_ 410 #endif // MEDIA_BASE_PIPELINE_H_
OLDNEW
« no previous file with comments | « media/base/audio_renderer.h ('k') | media/base/pipeline.cc » ('j') | media/base/pipeline.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698