OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 22 matching lines...) Expand all Loading... | |
33 STATE_INVALID, // BluetoothAdapter not presented or not powered. | 33 STATE_INVALID, // BluetoothAdapter not presented or not powered. |
34 STATE_DISCONNECTED, // Not connected. | 34 STATE_DISCONNECTED, // Not connected. |
35 STATE_IDLE, // Connected but not streaming. | 35 STATE_IDLE, // Connected but not streaming. |
36 STATE_PENDING, // Connected, streaming but not acquired. | 36 STATE_PENDING, // Connected, streaming but not acquired. |
37 STATE_ACTIVE, // Connected, streaming and acquired. | 37 STATE_ACTIVE, // Connected, streaming and acquired. |
38 }; | 38 }; |
39 | 39 |
40 // Possible types of error raised by Audio Sink object. | 40 // Possible types of error raised by Audio Sink object. |
41 enum ErrorCode { | 41 enum ErrorCode { |
42 ERROR_UNSUPPORTED_PLATFORM, // A2DP sink not supported on current platform. | 42 ERROR_UNSUPPORTED_PLATFORM, // A2DP sink not supported on current platform. |
43 ERROR_INVALID_ADAPTER, // BluetoothAdapter not presented/powered. | 43 ERROR_INVALID_ADAPTER, // BluetoothAdapter not present/powered. |
44 ERROR_NOT_REGISTERED, // BluetoothAudioSink not registered. | 44 ERROR_NOT_REGISTERED, // BluetoothAudioSink not registered. |
45 ERROR_NOT_UNREGISTERED, // BluetoothAudioSink not unregistered. | |
45 }; | 46 }; |
46 | 47 |
47 // Options to configure an A2DP audio sink. | 48 // Options to configure an A2DP audio sink. |
48 struct Options { | 49 struct Options { |
49 Options(); | 50 Options(); |
50 ~Options(); | 51 ~Options(); |
51 | 52 |
52 uint8_t codec; | 53 uint8_t codec; |
53 std::vector<uint8_t> capabilities; | 54 std::vector<uint8_t> capabilities; |
54 }; | 55 }; |
(...skipping 19 matching lines...) Expand all Loading... | |
74 | 75 |
75 // TODO(mcchou): Add method to monitor the availability of audio data during | 76 // TODO(mcchou): Add method to monitor the availability of audio data during |
76 // the streaming. This method should associate with BluetoothAudioSink | 77 // the streaming. This method should associate with BluetoothAudioSink |
77 // specific IOBuffer wrapping fd, read_mtu and write_mtu. | 78 // specific IOBuffer wrapping fd, read_mtu and write_mtu. |
78 }; | 79 }; |
79 | 80 |
80 // The ErrorCallback is used for the methods that can fail in which case it | 81 // The ErrorCallback is used for the methods that can fail in which case it |
81 // is called. | 82 // is called. |
82 typedef base::Callback<void(ErrorCode)> ErrorCallback; | 83 typedef base::Callback<void(ErrorCode)> ErrorCallback; |
83 | 84 |
85 // Possible volumes for media transport are 0-127, and 128 is used to | |
86 // represent invalid volume. | |
87 static const uint16_t kInvalidVolume; | |
88 | |
84 // Unregisters the audio sink. An audio sink will unregister itself | 89 // Unregisters the audio sink. An audio sink will unregister itself |
85 // automatically in its destructor, but calling Unregister is recommended, | 90 // automatically in its destructor, but calling Unregister is recommended, |
86 // since user applications can be notified of an error returned by the call. | 91 // since user applications can be notified of an error returned by the call. |
87 virtual void Unregister(const base::Closure& callback, | 92 virtual void Unregister(const base::Closure& callback, |
88 const ErrorCallback& error_callback) = 0; | 93 const ErrorCallback& error_callback) = 0; |
89 | 94 |
90 // Adds and removes an observer for events on the BluetoothAudioSink object. | 95 // Adds and removes an observer for events on the BluetoothAudioSink object. |
91 // If monitoring multiple audio sinks, check the |audio_sink| parameter of | 96 // If monitoring multiple audio sinks, check the |audio_sink| parameter of |
92 // observer methods to determine which audio sink is issuing the event. | 97 // observer methods to determine which audio sink is issuing the event. |
93 virtual void AddObserver(Observer* observer) = 0; | 98 virtual void AddObserver(Observer* observer) = 0; |
94 virtual void RemoveObserver(Observer* observer) = 0; | 99 virtual void RemoveObserver(Observer* observer) = 0; |
95 | 100 |
96 // Getters for state and volume. | 101 // Getters for state and volume. |
97 virtual State GetState() const = 0; | 102 virtual State GetState() const = 0; |
103 | |
104 // Returns the current volume level of the audio sink. The possible volumes | |
105 // are 0-128, where 0-127 are valid volumes and 128 represents invalid volume. | |
armansito
2015/02/24 23:42:09
nit: Say that if volume is unknown, "kInvalidVolum
Miao
2015/02/26 02:17:46
Done.
| |
98 virtual uint16_t GetVolume() const = 0; | 106 virtual uint16_t GetVolume() const = 0; |
99 | 107 |
100 protected: | 108 protected: |
101 friend class base::RefCounted<BluetoothAudioSink>; | 109 friend class base::RefCounted<BluetoothAudioSink>; |
102 BluetoothAudioSink(); | 110 BluetoothAudioSink(); |
103 | 111 |
104 // The destructor invokes Unregister() to ensure the audio sink will be | 112 // The destructor invokes Unregister() to ensure the audio sink will be |
105 // unregistered even if the user applications fail to do so. | 113 // unregistered even if the user applications fail to do so. |
106 virtual ~BluetoothAudioSink(); | 114 virtual ~BluetoothAudioSink(); |
107 | 115 |
108 private: | 116 private: |
109 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSink); | 117 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSink); |
110 }; | 118 }; |
111 | 119 |
112 } // namespace device | 120 } // namespace device |
113 | 121 |
114 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | 122 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ |
OLD | NEW |