Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/memory/scoped_ptr.h" | |
| 14 | |
| 15 namespace device { | |
| 16 | |
| 17 // TODO(mcchou): Define a BluetoothAudioSink specific socket stream abstraction. | |
| 18 | |
| 19 // BluetoothAudioSink represents a local A2DP audio sink where a remote device | |
| 20 // can stream audio data. Once a BluetoothAudioSink is successfully registered. | |
|
armansito
2014/12/03 23:34:52
nit: "Once a BluetoothAudioSink is successfully re
Miao
2014/12/04 02:34:06
Done.
| |
| 21 // User applications can obtain a pointer to a BluetoothAudioSink object via | |
| 22 // the interface provided by BluetoothAdapter. The validity of a | |
| 23 // BluetoothAudioSink depends on whether BluetoothAdapter is present and whether | |
| 24 // it is powered. | |
| 25 class BluetoothAudioSink : public base::RefCounted<BluetoothAudioSink> { | |
| 26 public: | |
| 27 // Possible values indicating the connection states between the | |
| 28 // BluetoothAudioSink and the remote device. | |
| 29 enum State { | |
| 30 STATE_INVALID, // BluetoothAdapter not presented or not powered. | |
| 31 STATE_DISCONNECTED, // Not connected. | |
| 32 STATE_IDLE, // Connected but not streaming. | |
| 33 STATE_PENDING, // Connected, streaming but not acquired. | |
| 34 STATE_ACTIVE, // Co[MaÂnnected, streaming and acquired. | |
| 35 }; | |
| 36 | |
| 37 // Options to configure an A2DP audio sink. | |
| 38 struct Options { | |
| 39 Options(); | |
| 40 ~Options(); | |
| 41 | |
| 42 uint8_t codec; | |
| 43 std::vector<uint8_t> capabilities; | |
| 44 }; | |
| 45 | |
| 46 // Interface for observing changes from a BluetoothAudioSink. | |
| 47 class Observer { | |
| 48 public: | |
| 49 virtual ~Observer() {} | |
| 50 | |
| 51 // Called when the state of the BluetoothAudioSink object is changed. | |
| 52 // |audio_sink| indicates the object being changed, and |audio_sink_state| | |
|
armansito
2014/12/03 23:34:53
nit: s/audio_sink_state/state/
Miao
2014/12/04 02:34:06
Done.
| |
| 53 // indicates the new state of that object. | |
| 54 virtual void BluetoothAudioSinkStateChanged( | |
| 55 BluetoothAudioSink* audio_sink, | |
| 56 BluetoothAudioSink::State audio_sink_state) = 0; | |
|
armansito
2014/12/03 23:34:52
nit: s/audio_sink_state/state/
Miao
2014/12/04 02:34:06
Done.
| |
| 57 | |
| 58 // Called when the volume of the BluetoothAudioSink object is changed. | |
| 59 // |audio_sink| indicates the object being changed, and |audio_sink_volume| | |
|
armansito
2014/12/03 23:34:53
nit: s/audio_sink_volume/volume/
Miao
2014/12/04 02:34:06
Done.
| |
| 60 // indicates the new volume level of that object. | |
| 61 virtual void BluetoothAudioSinkVolumeChanged( | |
| 62 BluetoothAudioSink* audio_sink, | |
| 63 uint16_t audio_sink_volume) = 0; | |
|
armansito
2014/12/03 23:34:53
nit: s/audio_sink_volume/volume/
Miao
2014/12/04 02:34:06
Done.
| |
| 64 | |
| 65 // TODO(mcchou): Add method to monitor the availability of audio data during | |
| 66 // the streaming. This method should associate with BluetoothAudioSink | |
| 67 // specific IOBuffer wrapping fd, read_mtu and write_mtu. | |
| 68 }; | |
| 69 | |
| 70 // The AudioSinkAcquiredCallback is used to return a BluetoothAudioSink object | |
| 71 // after it is registered successfully. | |
| 72 typedef base::Callback<void( | |
| 73 scoped_refptr<BluetoothAudioSink>)> AudioSinkAcquiredCallback; | |
| 74 | |
| 75 // The ErrorCallback is used for the methods that can fail in which case it | |
| 76 // is called. | |
| 77 typedef base::Callback<void(const std::string& error_message)> ErrorCallback; | |
| 78 | |
| 79 virtual ~BluetoothAudioSink(); | |
| 80 | |
| 81 // Adds and removes a observer for events on the BluetoothAudioSink object. If | |
| 82 // monitoring multiple audio sinks, check the |audio_sink| parameter of | |
| 83 // observer methods to determine which audio sink is issuing the event. | |
| 84 virtual void AddObserver(Observer* observer) = 0; | |
| 85 virtual void RemoveObserver(Observer* observer) = 0; | |
| 86 | |
|
armansito
2014/12/03 23:34:53
I would add getters for volume and state:
virtual
Miao
2014/12/04 02:34:06
Done.
| |
| 87 protected: | |
| 88 BluetoothAudioSink(); | |
| 89 | |
| 90 private: | |
| 91 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSink); | |
| 92 }; | |
| 93 | |
| 94 } // namespace device | |
| 95 | |
| 96 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ | |
| OLD | NEW |