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 the renderer is not associated with any output device, |device_status| |
40 // It can be null, which means that access to the output device is not | 40 // of OutputDeviceInfo should be set to OUTPUT_DEVICE_STATUS_ERROR_INTERNAL. |
41 // supported. | 41 // Must never be called on the IO thread. |
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 result of the |
| 46 // operation passed as a parameter. The result is a value from the |
| 47 // media::OutputDeviceStatus enum. |
| 48 // There is no guarantee about the thread where |callback| will be invoked. |
| 49 // TODO(olka): make sure callback is always called on the client thread, |
| 50 // update clients accordingly and fix the comment. |
| 51 virtual void SwitchOutputDevice( |
| 52 const std::string& device_id, |
| 53 const url::Origin& security_origin, |
| 54 const media::OutputDeviceStatusCB& callback) = 0; |
43 | 55 |
44 // Time stamp that reflects the current render time. Should not be updated | 56 // Time stamp that reflects the current render time. Should not be updated |
45 // when paused. | 57 // when paused. |
46 virtual base::TimeDelta GetCurrentRenderTime() const = 0; | 58 virtual base::TimeDelta GetCurrentRenderTime() const = 0; |
47 | 59 |
48 // Returns true if the implementation is a local renderer and false | 60 // Returns true if the implementation is a local renderer and false |
49 // otherwise. | 61 // otherwise. |
50 virtual bool IsLocalRenderer() const = 0; | 62 virtual bool IsLocalRenderer() const = 0; |
51 | 63 |
52 protected: | 64 protected: |
53 friend class base::RefCountedThreadSafe<MediaStreamAudioRenderer>; | 65 friend class base::RefCountedThreadSafe<MediaStreamAudioRenderer>; |
54 | 66 |
55 virtual ~MediaStreamAudioRenderer() {} | 67 virtual ~MediaStreamAudioRenderer() {} |
56 }; | 68 }; |
57 | 69 |
58 } // namespace content | 70 } // namespace content |
59 | 71 |
60 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ | 72 #endif // CONTENT_PUBLIC_RENDERER_MEDIA_STREAM_AUDIO_RENDERER_H_ |
OLD | NEW |