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

Side by Side Diff: media/base/audio_renderer.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
« no previous file with comments | « no previous file | media/base/pipeline.h » ('j') | media/base/pipeline.cc » ('J')
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_BASE_AUDIO_RENDERER_H_ 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_H_ 6 #define MEDIA_BASE_AUDIO_RENDERER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h" 10 #include "base/time/time.h"
11 #include "media/base/buffering_state.h" 11 #include "media/base/buffering_state.h"
12 #include "media/base/media_export.h" 12 #include "media/base/media_export.h"
13 #include "media/base/pipeline_status.h" 13 #include "media/base/pipeline_status.h"
14 #include "media/base/time_source.h"
14 15
15 namespace media { 16 namespace media {
16 17
17 class DemuxerStream; 18 class DemuxerStream;
18 19
19 class MEDIA_EXPORT AudioRenderer { 20 class MEDIA_EXPORT AudioRenderer : public TimeSource {
20 public: 21 public:
21 // First parameter is the current time that has been rendered. 22 // First parameter is the current time that has been rendered.
22 // Second parameter is the maximum time value that the clock cannot exceed. 23 // Second parameter is the maximum time value that the clock cannot exceed.
23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; 24 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB;
24 25
25 AudioRenderer(); 26 AudioRenderer();
26 virtual ~AudioRenderer(); 27 virtual ~AudioRenderer();
27 28
28 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon 29 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon
29 // completion. 30 // completion.
30 // 31 //
31 // |statistics_cb| is executed periodically with audio rendering stats. 32 // |statistics_cb| is executed periodically with audio rendering stats.
32 // 33 //
33 // |time_cb| is executed whenever time has advanced by way of audio rendering.
34 //
35 // |buffering_state_cb| is executed when audio rendering has either run out of 34 // |buffering_state_cb| is executed when audio rendering has either run out of
36 // data or has enough data to continue playback. 35 // data or has enough data to continue playback.
37 // 36 //
38 // |ended_cb| is executed when audio rendering has reached the end of stream. 37 // |ended_cb| is executed when audio rendering has reached the end of stream.
39 // 38 //
40 // |error_cb| is executed if an error was encountered. 39 // |error_cb| is executed if an error was encountered.
41 virtual void Initialize(DemuxerStream* stream, 40 virtual void Initialize(DemuxerStream* stream,
42 const PipelineStatusCB& init_cb, 41 const PipelineStatusCB& init_cb,
43 const StatisticsCB& statistics_cb, 42 const StatisticsCB& statistics_cb,
44 const TimeCB& time_cb,
45 const BufferingStateCB& buffering_state_cb, 43 const BufferingStateCB& buffering_state_cb,
46 const base::Closure& ended_cb, 44 const base::Closure& ended_cb,
47 const PipelineStatusCB& error_cb) = 0; 45 const PipelineStatusCB& error_cb) = 0;
48 46
49 // Signal audio playback to start at the current rate. It is expected that
50 // |time_cb| will eventually start being run with time updates.
51 virtual void StartRendering() = 0;
52
53 // Signal audio playback to stop until further notice. It is expected that
54 // |time_cb| will no longer be run.
55 virtual void StopRendering() = 0;
56
57 // Discard any audio data, executing |callback| when completed. 47 // Discard any audio data, executing |callback| when completed.
58 // 48 //
59 // Clients should expect |buffering_state_cb| to be called with 49 // Clients should expect |buffering_state_cb| to be called with
60 // BUFFERING_HAVE_NOTHING while flushing is in progress. 50 // BUFFERING_HAVE_NOTHING while flushing is in progress.
61 virtual void Flush(const base::Closure& callback) = 0; 51 virtual void Flush(const base::Closure& callback) = 0;
62 52
63 // Starts playback by reading from |stream| and decoding and rendering audio. 53 // Starts playback by reading from |stream| and decoding and rendering audio.
64 // |timestamp| is the media timestamp playback should start rendering from.
65 // 54 //
66 // Only valid to call after a successful Initialize() or Flush(). 55 // Only valid to call after a successful Initialize() or Flush().
67 virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0; 56 virtual void StartPlaying() = 0;
68 57
69 // Stop all operations in preparation for being deleted, executing |callback| 58 // Stop all operations in preparation for being deleted, executing |callback|
70 // when complete. 59 // when complete.
71 virtual void Stop(const base::Closure& callback) = 0; 60 virtual void Stop(const base::Closure& callback) = 0;
72 61
73 // Updates the current playback rate.
74 virtual void SetPlaybackRate(float playback_rate) = 0;
75
76 // Sets the output volume. 62 // Sets the output volume.
77 virtual void SetVolume(float volume) = 0; 63 virtual void SetVolume(float volume) = 0;
78 64
79 private: 65 private:
80 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); 66 DISALLOW_COPY_AND_ASSIGN(AudioRenderer);
81 }; 67 };
82 68
83 } // namespace media 69 } // namespace media
84 70
85 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ 71 #endif // MEDIA_BASE_AUDIO_RENDERER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/pipeline.h » ('j') | media/base/pipeline.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698