| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 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 DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ |
| 6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/files/file.h" | 12 #include "base/files/file.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/observer_list.h" | 16 #include "base/observer_list.h" |
| 17 #include "chromeos/dbus/bluetooth_media_client.h" | |
| 18 #include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h" | |
| 19 #include "chromeos/dbus/bluetooth_media_transport_client.h" | |
| 20 #include "dbus/file_descriptor.h" | 17 #include "dbus/file_descriptor.h" |
| 21 #include "dbus/object_path.h" | 18 #include "dbus/object_path.h" |
| 22 #include "device/bluetooth/bluetooth_adapter.h" | 19 #include "device/bluetooth/bluetooth_adapter.h" |
| 23 #include "device/bluetooth/bluetooth_audio_sink.h" | 20 #include "device/bluetooth/bluetooth_audio_sink.h" |
| 24 #include "device/bluetooth/bluetooth_export.h" | 21 #include "device/bluetooth/bluetooth_export.h" |
| 22 #include "device/bluetooth/dbus/bluetooth_media_client.h" |
| 23 #include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" |
| 24 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" |
| 25 | 25 |
| 26 namespace chromeos { | 26 namespace chromeos { |
| 27 | 27 |
| 28 class BluetoothAudioSinkChromeOSTest; | 28 class BluetoothAudioSinkChromeOSTest; |
| 29 | 29 |
| 30 class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS | 30 class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS |
| 31 : public device::BluetoothAudioSink, | 31 : public device::BluetoothAudioSink, |
| 32 public device::BluetoothAdapter::Observer, | 32 public device::BluetoothAdapter::Observer, |
| 33 public BluetoothMediaClient::Observer, | 33 public bluez::BluetoothMediaClient::Observer, |
| 34 public BluetoothMediaTransportClient::Observer, | 34 public bluez::BluetoothMediaTransportClient::Observer, |
| 35 public BluetoothMediaEndpointServiceProvider::Delegate, | 35 public bluez::BluetoothMediaEndpointServiceProvider::Delegate, |
| 36 public base::MessageLoopForIO::Watcher { | 36 public base::MessageLoopForIO::Watcher { |
| 37 public: | 37 public: |
| 38 explicit BluetoothAudioSinkChromeOS( | 38 explicit BluetoothAudioSinkChromeOS( |
| 39 scoped_refptr<device::BluetoothAdapter> adapter); | 39 scoped_refptr<device::BluetoothAdapter> adapter); |
| 40 | 40 |
| 41 // device::BluetoothAudioSink overrides. | 41 // device::BluetoothAudioSink overrides. |
| 42 // Unregisters a BluetoothAudioSink. |callback| should handle | 42 // Unregisters a BluetoothAudioSink. |callback| should handle |
| 43 // the clean-up after the audio sink is deleted successfully, otherwise | 43 // the clean-up after the audio sink is deleted successfully, otherwise |
| 44 // |error_callback| will be called. | 44 // |error_callback| will be called. |
| 45 void Unregister( | 45 void Unregister( |
| 46 const base::Closure& callback, | 46 const base::Closure& callback, |
| 47 const device::BluetoothAudioSink::ErrorCallback& error_callback) override; | 47 const device::BluetoothAudioSink::ErrorCallback& error_callback) override; |
| 48 void AddObserver(BluetoothAudioSink::Observer* observer) override; | 48 void AddObserver(BluetoothAudioSink::Observer* observer) override; |
| 49 void RemoveObserver(BluetoothAudioSink::Observer* observer) override; | 49 void RemoveObserver(BluetoothAudioSink::Observer* observer) override; |
| 50 device::BluetoothAudioSink::State GetState() const override; | 50 device::BluetoothAudioSink::State GetState() const override; |
| 51 uint16_t GetVolume() const override; | 51 uint16_t GetVolume() const override; |
| 52 | 52 |
| 53 // Registers a BluetoothAudioSink. User applications can use |options| to | 53 // Registers a BluetoothAudioSink. User applications can use |options| to |
| 54 // configure the audio sink. |callback| will be executed if the audio sink is | 54 // configure the audio sink. |callback| will be executed if the audio sink is |
| 55 // successfully registered, otherwise |error_callback| will be called. Called | 55 // successfully registered, otherwise |error_callback| will be called. Called |
| 56 // by BluetoothAdapterChromeOS. | 56 // by BluetoothAdapterChromeOS. |
| 57 void Register( | 57 void Register( |
| 58 const device::BluetoothAudioSink::Options& options, | 58 const device::BluetoothAudioSink::Options& options, |
| 59 const base::Closure& callback, | 59 const base::Closure& callback, |
| 60 const device::BluetoothAudioSink::ErrorCallback& error_callback); | 60 const device::BluetoothAudioSink::ErrorCallback& error_callback); |
| 61 | 61 |
| 62 // Returns a pointer to the media endpoint object. This function should be | 62 // Returns a pointer to the media endpoint object. This function should be |
| 63 // used for testing purpose only. | 63 // used for testing purpose only. |
| 64 BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider(); | 64 bluez::BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider(); |
| 65 | 65 |
| 66 private: | 66 private: |
| 67 ~BluetoothAudioSinkChromeOS() override; | 67 ~BluetoothAudioSinkChromeOS() override; |
| 68 | 68 |
| 69 // device::BluetoothAdapter::Observer overrides. | 69 // device::BluetoothAdapter::Observer overrides. |
| 70 void AdapterPresentChanged(device::BluetoothAdapter* adapter, | 70 void AdapterPresentChanged(device::BluetoothAdapter* adapter, |
| 71 bool present) override; | 71 bool present) override; |
| 72 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, | 72 void AdapterPoweredChanged(device::BluetoothAdapter* adapter, |
| 73 bool powered) override; | 73 bool powered) override; |
| 74 | 74 |
| 75 // BluetoothMediaClient::Observer overrides. | 75 // bluez::BluetoothMediaClient::Observer overrides. |
| 76 void MediaRemoved(const dbus::ObjectPath& object_path) override; | 76 void MediaRemoved(const dbus::ObjectPath& object_path) override; |
| 77 | 77 |
| 78 // BluetoothMediaTransportClient::Observer overrides. | 78 // bluez::BluetoothMediaTransportClient::Observer overrides. |
| 79 void MediaTransportRemoved(const dbus::ObjectPath& object_path) override; | 79 void MediaTransportRemoved(const dbus::ObjectPath& object_path) override; |
| 80 void MediaTransportPropertyChanged(const dbus::ObjectPath& object_path, | 80 void MediaTransportPropertyChanged(const dbus::ObjectPath& object_path, |
| 81 const std::string& property_name) override; | 81 const std::string& property_name) override; |
| 82 | 82 |
| 83 // BluetoothMediaEndpointServiceProvider::Delegate overrides. | 83 // bluez::BluetoothMediaEndpointServiceProvider::Delegate overrides. |
| 84 void SetConfiguration(const dbus::ObjectPath& transport_path, | 84 void SetConfiguration(const dbus::ObjectPath& transport_path, |
| 85 const TransportProperties& properties) override; | 85 const TransportProperties& properties) override; |
| 86 void SelectConfiguration( | 86 void SelectConfiguration( |
| 87 const std::vector<uint8_t>& capabilities, | 87 const std::vector<uint8_t>& capabilities, |
| 88 const SelectConfigurationCallback& callback) override; | 88 const SelectConfigurationCallback& callback) override; |
| 89 void ClearConfiguration(const dbus::ObjectPath& transport_path) override; | 89 void ClearConfiguration(const dbus::ObjectPath& transport_path) override; |
| 90 void Released() override; | 90 void Released() override; |
| 91 | 91 |
| 92 // base::MessageLoopForIO::Watcher overrides. | 92 // base::MessageLoopForIO::Watcher overrides. |
| 93 void OnFileCanReadWithoutBlocking(int fd) override; | 93 void OnFileCanReadWithoutBlocking(int fd) override; |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 | 197 |
| 198 // BT adapter which the audio sink binds to. |adapter_| should outlive | 198 // BT adapter which the audio sink binds to. |adapter_| should outlive |
| 199 // a BluetoothAudioSinkChromeOS object. | 199 // a BluetoothAudioSinkChromeOS object. |
| 200 scoped_refptr<device::BluetoothAdapter> adapter_; | 200 scoped_refptr<device::BluetoothAdapter> adapter_; |
| 201 | 201 |
| 202 // Options used to initiate Media Endpoint and select configuration for the | 202 // Options used to initiate Media Endpoint and select configuration for the |
| 203 // transport. | 203 // transport. |
| 204 device::BluetoothAudioSink::Options options_; | 204 device::BluetoothAudioSink::Options options_; |
| 205 | 205 |
| 206 // Media Endpoint object owned by the audio sink object. | 206 // Media Endpoint object owned by the audio sink object. |
| 207 scoped_ptr<BluetoothMediaEndpointServiceProvider> media_endpoint_; | 207 scoped_ptr<bluez::BluetoothMediaEndpointServiceProvider> media_endpoint_; |
| 208 | 208 |
| 209 // List of observers interested in event notifications from us. Objects in | 209 // List of observers interested in event notifications from us. Objects in |
| 210 // |observers_| are expected to outlive a BluetoothAudioSinkChromeOS object. | 210 // |observers_| are expected to outlive a BluetoothAudioSinkChromeOS object. |
| 211 base::ObserverList<BluetoothAudioSink::Observer> observers_; | 211 base::ObserverList<BluetoothAudioSink::Observer> observers_; |
| 212 | 212 |
| 213 // Note: This should remain the last member so it'll be destroyed and | 213 // Note: This should remain the last member so it'll be destroyed and |
| 214 // invalidate its weak pointers before any other members are destroyed. | 214 // invalidate its weak pointers before any other members are destroyed. |
| 215 base::WeakPtrFactory<BluetoothAudioSinkChromeOS> weak_ptr_factory_; | 215 base::WeakPtrFactory<BluetoothAudioSinkChromeOS> weak_ptr_factory_; |
| 216 | 216 |
| 217 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkChromeOS); | 217 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkChromeOS); |
| 218 }; | 218 }; |
| 219 | 219 |
| 220 } // namespace chromeos | 220 } // namespace chromeos |
| 221 | 221 |
| 222 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ | 222 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ |
| OLD | NEW |