Add ianwen to watch list for related projects
[chromium-blink-merge.git] / content / public / renderer / media_stream_audio_renderer.h
blob4b4fe37b62e58fe4ee697b40c493bbafa1ab0371
1 // Copyright 2013 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.
5 #ifndef CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_
6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_
8 #include <string>
10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/time/time.h"
13 #include "media/base/audio_renderer_sink.h"
14 #include "url/gurl.h"
16 namespace content {
18 class MediaStreamAudioRenderer
19 : public base::RefCountedThreadSafe<MediaStreamAudioRenderer> {
20 public:
21 // Starts rendering audio.
22 virtual void Start() = 0;
24 // Stops rendering audio.
25 virtual void Stop() = 0;
27 // Resumes rendering audio after being paused.
28 virtual void Play() = 0;
30 // Temporarily suspends rendering audio. The audio stream might still be
31 // active but new audio data is not provided to the consumer.
32 virtual void Pause() = 0;
34 // Sets the output volume.
35 virtual void SetVolume(float volume) = 0;
37 // Attempts to switch the audio output device.
38 // Once the attempt is finished, |callback| is invoked with the
39 // result of the operation passed as a parameter. The result is a value from
40 // the media::SwitchOutputDeviceResult enum.
41 // There is no guarantee about the thread where |callback| will
42 // be invoked, so users are advised to use media::BindToCurrentLoop() to
43 // ensure that |callback| runs on the correct thread.
44 // Note also that copy constructors and destructors for arguments bound to
45 // |callback| may run on arbitrary threads as |callback| is moved across
46 // threads. It is advisable to bind arguments such that they are released by
47 // |callback| when it runs in order to avoid surprises.
48 virtual void SwitchOutputDevice(
49 const std::string& device_id,
50 const GURL& security_origin,
51 const media::SwitchOutputDeviceCB& callback) = 0;
53 // Time stamp that reflects the current render time. Should not be updated
54 // when paused.
55 virtual base::TimeDelta GetCurrentRenderTime() const = 0;
57 // Returns true if the implementation is a local renderer and false
58 // otherwise.
59 virtual bool IsLocalRenderer() const = 0;
61 protected:
62 friend class base::RefCountedThreadSafe<MediaStreamAudioRenderer>;
64 virtual ~MediaStreamAudioRenderer() {}
67 } // namespace content
69 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_