OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 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_OUTPUT_DEVICE_H_ | 5 #ifndef MEDIA_BASE_OUTPUT_DEVICE_H_ |
6 #define MEDIA_BASE_OUTPUT_DEVICE_H_ | 6 #define MEDIA_BASE_OUTPUT_DEVICE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "media/audio/audio_parameters.h" | 11 #include "media/audio/audio_parameters.h" |
12 #include "media/base/media_export.h" | 12 #include "media/base/media_export.h" |
13 #include "url/origin.h" | 13 #include "url/origin.h" |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // Result of an audio output device switch operation | 17 // Result of an audio output device switch operation |
18 enum OutputDeviceStatus { | 18 enum OutputDeviceStatus { |
19 OUTPUT_DEVICE_STATUS_OK = 0, | 19 OUTPUT_DEVICE_STATUS_OK = 0, |
20 OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND, | 20 OUTPUT_DEVICE_STATUS_ERROR_NOT_FOUND, |
21 OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED, | 21 OUTPUT_DEVICE_STATUS_ERROR_NOT_AUTHORIZED, |
22 OUTPUT_DEVICE_STATUS_ERROR_INTERNAL, | 22 OUTPUT_DEVICE_STATUS_ERROR_INTERNAL, |
23 OUTPUT_DEVICE_STATUS_LAST = OUTPUT_DEVICE_STATUS_ERROR_INTERNAL, | 23 OUTPUT_DEVICE_STATUS_LAST = OUTPUT_DEVICE_STATUS_ERROR_INTERNAL, |
24 }; | 24 }; |
25 | 25 |
26 typedef base::Callback<void(OutputDeviceStatus)> SwitchOutputDeviceCB; | 26 typedef base::Callback<void(OutputDeviceStatus)> SwitchOutputDeviceCB; |
Guido Urdaneta
2016/03/17 17:38:24
You should move this typedef to audio_renderer_sin
o1ka
2016/03/18 10:45:40
As we discussed, this type is used in SwitchOutput
| |
27 | 27 |
28 // OutputDevice is an interface that allows performing operations related | 28 // OutputDevice is an interface that allows performing operations related |
29 // audio output devices. | 29 // audio output devices. |
30 | 30 |
31 class OutputDevice { | 31 class OutputDevice { |
32 public: | 32 public: |
33 // Attempts to switch the audio output device. | |
34 // Once the attempt is finished, |callback| is invoked with the | |
35 // result of the operation passed as a parameter. The result is a value from | |
36 // the media::SwitchOutputDeviceResult enum. | |
37 // There is no guarantee about the thread where |callback| will | |
38 // be invoked, so users are advised to use media::BindToCurrentLoop() to | |
39 // ensure that |callback| runs on the correct thread. | |
40 // Note also that copy constructors and destructors for arguments bound to | |
41 // |callback| may run on arbitrary threads as |callback| is moved across | |
42 // threads. It is advisable to bind arguments such that they are released by | |
43 // |callback| when it runs in order to avoid surprises. | |
44 virtual void SwitchOutputDevice(const std::string& device_id, | |
45 const url::Origin& security_origin, | |
46 const SwitchOutputDeviceCB& callback) = 0; | |
47 | |
48 // Returns the device's audio output parameters. | 33 // Returns the device's audio output parameters. |
49 // The return value is undefined if the device status (as returned by | 34 // The return value is undefined if the device status (as returned by |
50 // GetDeviceStatus()) is different from OUTPUT_DEVICE_STATUS_OK. | 35 // GetDeviceStatus()) is different from OUTPUT_DEVICE_STATUS_OK. |
51 // If the parameters are not available, this method may block until they | 36 // If the parameters are not available, this method may block until they |
52 // become available. | 37 // become available. |
53 // This method must never be called on the IO thread. | 38 // This method must never be called on the IO thread. |
54 virtual AudioParameters GetOutputParameters() = 0; | 39 virtual AudioParameters GetOutputParameters() = 0; |
55 | 40 |
56 // Returns the status of output device. | 41 // Returns the status of output device. |
57 // If the status is not available, this method may block until it becomes | 42 // If the status is not available, this method may block until it becomes |
58 // available. Must never be called on the IO thread. | 43 // available. Must never be called on the IO thread. |
59 virtual OutputDeviceStatus GetDeviceStatus() = 0; | 44 virtual OutputDeviceStatus GetDeviceStatus() = 0; |
60 | 45 |
46 // Returns the device ID. | |
47 virtual std::string GetDeviceId() = 0; | |
48 | |
61 protected: | 49 protected: |
62 virtual ~OutputDevice() {} | 50 virtual ~OutputDevice() {} |
63 }; | 51 }; |
64 | 52 |
65 } // namespace media | 53 } // namespace media |
66 | 54 |
67 #endif // MEDIA_BASE_OUTPUT_DEVICE_H_ | 55 #endif // MEDIA_BASE_OUTPUT_DEVICE_H_ |
OLD | NEW |