OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ | 5 #ifndef CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ |
6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ | 6 #define CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "media/base/output_device.h" | 13 #include "media/base/output_device_info.h" |
14 #include "url/gurl.h" | 14 #include "url/origin.h" |
15 | 15 |
16 namespace content { | 16 namespace content { |
17 | 17 |
18 class MediaStreamAudioRenderer | 18 class MediaStreamAudioRenderer |
19 : public base::RefCountedThreadSafe<MediaStreamAudioRenderer> { | 19 : public base::RefCountedThreadSafe<MediaStreamAudioRenderer> { |
20 public: | 20 public: |
21 // Starts rendering audio. | 21 // Starts rendering audio. |
22 virtual void Start() = 0; | 22 virtual void Start() = 0; |
23 | 23 |
24 // Stops rendering audio. | 24 // Stops rendering audio. |
25 virtual void Stop() = 0; | 25 virtual void Stop() = 0; |
26 | 26 |
27 // Resumes rendering audio after being paused. | 27 // Resumes rendering audio after being paused. |
28 virtual void Play() = 0; | 28 virtual void Play() = 0; |
29 | 29 |
30 // Temporarily suspends rendering audio. The audio stream might still be | 30 // Temporarily suspends rendering audio. The audio stream might still be |
31 // active but new audio data is not provided to the consumer. | 31 // active but new audio data is not provided to the consumer. |
32 virtual void Pause() = 0; | 32 virtual void Pause() = 0; |
33 | 33 |
34 // Sets the output volume. | 34 // Sets the output volume. |
35 virtual void SetVolume(float volume) = 0; | 35 virtual void SetVolume(float volume) = 0; |
36 | 36 |
37 // Returns a pointer to the internal output device. | 37 // Returns current output device information. If the information is not |
38 // The pointer is not to be owned by the caller and is valid only during | 38 // available yet, this method may block until it becomes available. |
39 // the lifetime of the MediaStreamAudioRenderer. | 39 // If output device is not supported, |device_status| of |
40 // It can be null, which means that access to the output device is not | 40 // OutputDeviceInfo should be set to OUTPUT_DEVICE_STATUS_ERROR_INTERNAL. |
41 // supported. | 41 // Must never be called on the IO thread. |
miu
2016/03/24 21:32:02
nit: You can probably omit the "never be called on
o1ka
2016/03/29 13:39:53
I would probably leave it as it is now: Since the
| |
42 virtual media::OutputDevice* GetOutputDevice() = 0; | 42 virtual media::OutputDeviceInfo GetOutputDeviceInfo() = 0; |
43 | |
44 // Attempts to switch the audio output device. | |
45 // Once the attempt is finished, |callback| is invoked with the | |
46 // result of the operation passed as a parameter. The result is a value from | |
47 // the media::OutputDeviceStatus enum. | |
48 // There is no guarantee about the thread where |callback| will | |
49 // be invoked, so users are advised to use media::BindToCurrentLoop() to | |
miu
2016/03/24 21:32:02
Because this is a public interface, it's usually b
o1ka
2016/03/29 13:39:53
I just copied the old SwitchOutputDevice() comment
miu
2016/03/29 19:46:27
I suppose it's fine to leave it alone for this cha
o1ka
2016/03/30 14:02:42
Agree. We need to come back to it after a couple o
| |
50 // ensure that |callback| runs on the correct thread. | |
51 // Note also that copy constructors and destructors for arguments bound to | |
miu
2016/03/24 21:32:02
You can remove lines 51-54. This is generally und
o1ka
2016/03/29 13:39:54
Done.
| |
52 // |callback| may run on arbitrary threads as |callback| is moved across | |
53 // threads. It is advisable to bind arguments such that they are released by | |
54 // |callback| when it runs in order to avoid surprises. | |
55 virtual void SwitchOutputDevice( | |
56 const std::string& device_id, | |
57 const url::Origin& security_origin, | |
58 const media::OutputDeviceStatusCB& callback) = 0; | |
43 | 59 |
44 // Time stamp that reflects the current render time. Should not be updated | 60 // Time stamp that reflects the current render time. Should not be updated |
45 // when paused. | 61 // when paused. |
46 virtual base::TimeDelta GetCurrentRenderTime() const = 0; | 62 virtual base::TimeDelta GetCurrentRenderTime() const = 0; |
47 | 63 |
48 // Returns true if the implementation is a local renderer and false | 64 // Returns true if the implementation is a local renderer and false |
49 // otherwise. | 65 // otherwise. |
50 virtual bool IsLocalRenderer() const = 0; | 66 virtual bool IsLocalRenderer() const = 0; |
51 | 67 |
52 protected: | 68 protected: |
53 friend class base::RefCountedThreadSafe<MediaStreamAudioRenderer>; | 69 friend class base::RefCountedThreadSafe<MediaStreamAudioRenderer>; |
54 | 70 |
55 virtual ~MediaStreamAudioRenderer() {} | 71 virtual ~MediaStreamAudioRenderer() {} |
56 }; | 72 }; |
57 | 73 |
58 } // namespace content | 74 } // namespace content |
59 | 75 |
60 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ | 76 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ |
OLD | NEW |