Index: device/bluetooth/bluetooth_audio_sink.h |
diff --git a/device/bluetooth/bluetooth_audio_sink.h b/device/bluetooth/bluetooth_audio_sink.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..809dbe54db309911b068555b81e547d839031816 |
--- /dev/null |
+++ b/device/bluetooth/bluetooth_audio_sink.h |
@@ -0,0 +1,109 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ |
+#define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ |
+ |
+#include <string> |
+#include <vector> |
+ |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/scoped_ptr.h" |
+ |
+namespace device { |
+ |
+// TODO(mcchou): Define a BluetoothAudioSink specific socket stream abstraction. |
+ |
+// BluetoothAudioSink represents a local audio sink where a remote device can |
+// stream audio data. Once a BluetoothAudioSink is successfully registered. |
armansito
2014/12/03 20:14:12
Please mention A2DP here. BluetoothAudioSink speci
Miao
2014/12/03 22:56:28
Done.
|
+// User applications can obtain a pointer to a BluetoothAudioSink object via |
+// the i[MaÂnterface provided by BluetoothAdapter. The validity of a |
armansito
2014/12/03 20:14:12
interface?
Miao
2014/12/03 22:56:29
I was using secure shell yesterday, and there were
|
+// BluetoothAudioSink depends on whether BluetoothAdapter is present and whether |
+// it is powered. |
+class BluetoothAudioSink : public base::RefCounted<BluetoothAudioSink> { |
+ public: |
+ // Possible values indicating the connection states between the |
+ // BluetoothAu[MaÂdioSink and the remote device. |
armansito
2014/12/03 20:14:12
I keep seeing "[MaÂ" everywhere. Please correct th
Miao
2014/12/03 22:56:29
Done.
|
+ enum AudioSinkState { |
armansito
2014/12/03 20:14:12
nit: Like Options, I would simply call this "State
Miao
2014/12/03 22:56:29
Done.
|
+ STATE_INVALID, // BluetoothAdapter not presented or not powered. |
+ STATE_DISCONNECTED, // Not connected. |
+ STATE_IDLE, // Connected but not streaming. |
+ STATE_PENDING, // Connected, streaming but not acquired. |
+ STATE_ACTIVE, // Co[MaÂnnected, streaming and acquired. |
+ }; |
+ |
+ // Options to configure an A2DP audio sink. |
+ struct Options { |
+ Options(); |
+ ~Options(); |
+ |
+ uint8_t codec; |
+ std::vector<uint8_t> capabilities; |
+ }; |
+ |
+ // Interface for observing changes from a BluetoothAudioSink. |
+ class Observer { |
+ public: |
+ virtual ~Observer() {} |
+ |
+ // Called when the state of the BluetoothAudioSink object is changed. |
+ // |audio_sink| indicates the object being changed, and |audio_sink_state| |
+ // indicates the new state of that object. |
+ virtual void BluetoothAudioSinkStateChanged( |
+ BluetoothAudioSink* audio_sink, |
+ BluetoothAudioSink::AudioSinkState audio_sink_state) = 0; |
+ |
+ // Called when the volume of the BluetoothAudioSink object is changed. |
+ // |audio_sink| indicates the object being changed, and |audio_sink_volume| |
+ // indicates the new volume level of that object. |
+ virtual void BluetoothAudioSinkVolumeChanged( |
+ BluetoothAudioSink* audio_sink, |
+ uint16_t audio_sink_volume) = 0; |
+ |
+ // TODO(mcchou): Add method to monitor the availability of audio data during |
+ // the streaming. This method should associate with BluetoothAudioSink |
+ // specific IOBuffer wrapping fd, read_mtu and write_mtu. |
+ }; |
+ |
+ // The AudioSinkAcquiredCallback is used to pass the scoped_refptr of |
armansito
2014/12/03 20:14:12
nit: "...used to return a BluetoothAudioSink objec
Miao
2014/12/03 22:56:28
Done.
|
+ // a BluetoothAudioSink object after it is registered successfully. |
+ typedef base::Callback<void( |
+ scoped_refptr<BluetoothAudioSink>)> AudioSinkAcquiredCallback; |
+ |
+ // The ErrorCallback is used for the methods that can fail in which case it |
+ // is called. |
+ typedef base::Callback<void(const std::string& error_message)> ErrorCallback; |
+ |
+ virtual ~BluetoothAudioSink(); |
+ |
+ // Adds and removes a observer for events on the BluetoothAudioSink object. If |
+ // monitoring multiple audio sinks, check the |audio_sink| parameter of |
+ // observer methods to determine which audio sink is issuing the event. |
+ virtual void AddObserver(Observer* observer) = 0; |
+ virtual void RemoveObserver(Observer* observer) = 0; |
+ |
+ // Registers a BluetoothAudioSink. User applications can use |options| to |
+ // configure the audio sink. |callback| will be executed if the audio sink is |
+ // successfully registered, otherwise |error_callback| will be called. |
+ virtual void Register(const Options& options, |
armansito
2014/12/03 20:14:12
Remove this method? Won't this be in BluetoothAdap
Miao
2014/12/03 22:56:29
Done.
|
+ const AudioSinkAcquiredCallback& callback, |
+ const ErrorCallback& error_callback) = 0; |
+ |
+ // Unregisters a BluetoothAudioSink. |callback| should handle |
+ // the clean-up after the audio sink is deleted successfully, otherwise |
+ // |error_callback| will be called. |
+ virtual void Unregister(const base::Closure& callback, |
+ const ErrorCallback& error_callback) = 0; |
+ |
+ protected: |
+ BluetoothAudioSink(); |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSink); |
+}; |
+ |
+} // namespace device |
+ |
+#endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_H_ |