Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / media / base / audio_renderer.h
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
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BASE_AUDIO_RENDERER_H_
6 #define MEDIA_BASE_AUDIO_RENDERER_H_
7
8 #include "base/callback.h"
9 #include "base/time/time.h"
10 #include "media/base/buffering_state.h"
11 #include "media/base/media_export.h"
12 #include "media/base/pipeline_status.h"
13
14 namespace media {
15
16 class DemuxerStream;
17 class TimeSource;
18
19 class MEDIA_EXPORT AudioRenderer {
20  public:
21   AudioRenderer();
22
23   // Stop all operations and fire all pending callbacks.
24   virtual ~AudioRenderer();
25
26   // Initialize an AudioRenderer with |stream|, executing |init_cb| upon
27   // completion.
28   //
29   // |statistics_cb| is executed periodically with audio rendering stats.
30   //
31   // |buffering_state_cb| is executed when audio rendering has either run out of
32   // data or has enough data to continue playback.
33   //
34   // |ended_cb| is executed when audio rendering has reached the end of stream.
35   //
36   // |error_cb| is executed if an error was encountered.
37   virtual void Initialize(DemuxerStream* stream,
38                           const PipelineStatusCB& init_cb,
39                           const StatisticsCB& statistics_cb,
40                           const BufferingStateCB& buffering_state_cb,
41                           const base::Closure& ended_cb,
42                           const PipelineStatusCB& error_cb) = 0;
43
44   // Returns the TimeSource associated with audio rendering.
45   virtual TimeSource* GetTimeSource() = 0;
46
47   // Discard any audio data, executing |callback| when completed.
48   //
49   // Clients should expect |buffering_state_cb| to be called with
50   // BUFFERING_HAVE_NOTHING while flushing is in progress.
51   virtual void Flush(const base::Closure& callback) = 0;
52
53   // Starts playback by reading from |stream| and decoding and rendering audio.
54   //
55   // Only valid to call after a successful Initialize() or Flush().
56   virtual void StartPlaying() = 0;
57
58   // Sets the output volume.
59   virtual void SetVolume(float volume) = 0;
60
61  private:
62   DISALLOW_COPY_AND_ASSIGN(AudioRenderer);
63 };
64
65 }  // namespace media
66
67 #endif  // MEDIA_BASE_AUDIO_RENDERER_H_