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

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

Issue 291093013: Revert of Update AudioRenderer API to fire changes in BufferingState. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/mock_filters.h » ('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_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"
12 #include "media/base/media_export.h" 11 #include "media/base/media_export.h"
13 #include "media/base/pipeline_status.h" 12 #include "media/base/pipeline_status.h"
14 13
15 namespace media { 14 namespace media {
16 15
17 class DemuxerStream; 16 class DemuxerStream;
18 17
19 class MEDIA_EXPORT AudioRenderer { 18 class MEDIA_EXPORT AudioRenderer {
20 public: 19 public:
21 // First parameter is the current time that has been rendered. 20 // First parameter is the current time that has been rendered.
22 // Second parameter is the maximum time value that the clock cannot exceed. 21 // Second parameter is the maximum time value that the clock cannot exceed.
23 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB; 22 typedef base::Callback<void(base::TimeDelta, base::TimeDelta)> TimeCB;
24 23
25 // Used to indicate changes in the buffering state of this audio renderer.
26 typedef base::Callback<void(BufferingState)> BufferingStateCB;
27
28 AudioRenderer(); 24 AudioRenderer();
29 virtual ~AudioRenderer(); 25 virtual ~AudioRenderer();
30 26
31 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon 27 // Initialize an AudioRenderer with |stream|, executing |init_cb| upon
32 // completion. 28 // completion.
33 // 29 //
34 // |statistics_cb| is executed periodically with audio rendering stats. 30 // |statistics_cb| is executed periodically with audio rendering stats.
35 // 31 //
32 // |underflow_cb| is executed when the renderer runs out of data to pass to
33 // the audio card during playback. ResumeAfterUnderflow() must be called
34 // to resume playback. Pause(), Preroll(), or Stop() cancels the underflow
35 // condition.
36 //
36 // |time_cb| is executed whenever time has advanced by way of audio rendering. 37 // |time_cb| is executed whenever time has advanced by way of audio rendering.
37 // 38 //
38 // |buffering_state_cb| is executed when audio rendering has either ran out of
39 // data or has enough data to continue playback.
40 //
41 // |ended_cb| is executed when audio rendering has reached the end of stream. 39 // |ended_cb| is executed when audio rendering has reached the end of stream.
42 // 40 //
43 // |error_cb| is executed if an error was encountered. 41 // |error_cb| is executed if an error was encountered.
44 virtual void Initialize(DemuxerStream* stream, 42 virtual void Initialize(DemuxerStream* stream,
45 const PipelineStatusCB& init_cb, 43 const PipelineStatusCB& init_cb,
46 const StatisticsCB& statistics_cb, 44 const StatisticsCB& statistics_cb,
45 const base::Closure& underflow_cb,
47 const TimeCB& time_cb, 46 const TimeCB& time_cb,
48 const BufferingStateCB& buffering_state_cb,
49 const base::Closure& ended_cb, 47 const base::Closure& ended_cb,
50 const PipelineStatusCB& error_cb) = 0; 48 const PipelineStatusCB& error_cb) = 0;
51 49
52 // Signal audio playback to start at the current rate. It is expected that 50 // Signal audio playback to start at the current rate. It is expected that
53 // |time_cb| will eventually start being run with time updates. 51 // |time_cb| will eventually start being run with time updates.
54 virtual void StartRendering() = 0; 52 virtual void StartRendering() = 0;
55 53
56 // Signal audio playback to stop until further notice. It is expected that 54 // Signal audio playback to stop until further notice. It is expected that
57 // |time_cb| will no longer be run. 55 // |time_cb| will no longer be run.
58 virtual void StopRendering() = 0; 56 virtual void StopRendering() = 0;
59 57
60 // Discard any audio data, executing |callback| when completed. 58 // Discard any audio data, executing |callback| when completed.
61 //
62 // Clients should expect |buffering_state_cb| to be called with
63 // BUFFERING_HAVE_NOTHING while flushing is in progress.
64 virtual void Flush(const base::Closure& callback) = 0; 59 virtual void Flush(const base::Closure& callback) = 0;
65 60
66 // Starts playback by reading from |stream| and decoding and rendering audio. 61 // Start prerolling audio data for samples starting at |time|, executing
67 // |timestamp| is the media timestamp playback should start rendering from. 62 // |callback| when completed.
68 // 63 //
69 // Only valid to call after a successful Initialize() or Flush(). 64 // Only valid to call after a successful Initialize() or Flush().
70 virtual void StartPlayingFrom(base::TimeDelta timestamp) = 0; 65 virtual void Preroll(base::TimeDelta time,
66 const PipelineStatusCB& callback) = 0;
71 67
72 // Stop all operations in preparation for being deleted, executing |callback| 68 // Stop all operations in preparation for being deleted, executing |callback|
73 // when complete. 69 // when complete.
74 virtual void Stop(const base::Closure& callback) = 0; 70 virtual void Stop(const base::Closure& callback) = 0;
75 71
76 // Updates the current playback rate. 72 // Updates the current playback rate.
77 virtual void SetPlaybackRate(float playback_rate) = 0; 73 virtual void SetPlaybackRate(float playback_rate) = 0;
78 74
79 // Sets the output volume. 75 // Sets the output volume.
80 virtual void SetVolume(float volume) = 0; 76 virtual void SetVolume(float volume) = 0;
81 77
78 // Resumes playback after underflow occurs.
79 virtual void ResumeAfterUnderflow() = 0;
80
82 private: 81 private:
83 DISALLOW_COPY_AND_ASSIGN(AudioRenderer); 82 DISALLOW_COPY_AND_ASSIGN(AudioRenderer);
84 }; 83 };
85 84
86 } // namespace media 85 } // namespace media
87 86
88 #endif // MEDIA_BASE_AUDIO_RENDERER_H_ 87 #endif // MEDIA_BASE_AUDIO_RENDERER_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/mock_filters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698