Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1062)

Side by Side Diff: device/bluetooth/bluetooth_audio_sink_bluez.h

Issue 1367663002: Add Linux support for the Bluetooth API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@refactor_dbus
Patch Set: rebase Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_BLUEZ_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ 6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_BLUEZ_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 "dbus/file_descriptor.h" 17 #include "dbus/file_descriptor.h"
18 #include "dbus/object_path.h" 18 #include "dbus/object_path.h"
19 #include "device/bluetooth/bluetooth_adapter.h" 19 #include "device/bluetooth/bluetooth_adapter.h"
20 #include "device/bluetooth/bluetooth_audio_sink.h" 20 #include "device/bluetooth/bluetooth_audio_sink.h"
21 #include "device/bluetooth/bluetooth_export.h" 21 #include "device/bluetooth/bluetooth_export.h"
22 #include "device/bluetooth/dbus/bluetooth_media_client.h" 22 #include "device/bluetooth/dbus/bluetooth_media_client.h"
23 #include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h" 23 #include "device/bluetooth/dbus/bluetooth_media_endpoint_service_provider.h"
24 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h" 24 #include "device/bluetooth/dbus/bluetooth_media_transport_client.h"
25 25
26 namespace chromeos { 26 namespace bluez {
27 27
28 class BluetoothAudioSinkChromeOSTest; 28 class BluetoothAudioSinkBlueZTest;
29 29
30 class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS 30 class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkBlueZ
31 : public device::BluetoothAudioSink, 31 : public device::BluetoothAudioSink,
32 public device::BluetoothAdapter::Observer, 32 public device::BluetoothAdapter::Observer,
33 public bluez::BluetoothMediaClient::Observer, 33 public bluez::BluetoothMediaClient::Observer,
34 public bluez::BluetoothMediaTransportClient::Observer, 34 public bluez::BluetoothMediaTransportClient::Observer,
35 public bluez::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 BluetoothAudioSinkBlueZ(
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 BluetoothAdapterBlueZ.
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 bluez::BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider(); 64 bluez::BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider();
65 65
66 private: 66 private:
67 ~BluetoothAudioSinkChromeOS() override; 67 ~BluetoothAudioSinkBlueZ() 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 // bluez::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
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 void OnReleaseFDFailed(const std::string& error_name, 150 void OnReleaseFDFailed(const std::string& error_name,
151 const std::string& error_message); 151 const std::string& error_message);
152 152
153 // Helper functions to clean up media, media transport and media endpoint. 153 // Helper functions to clean up media, media transport and media endpoint.
154 // Called when the |state_| changes to either STATE_INVALID or 154 // Called when the |state_| changes to either STATE_INVALID or
155 // STATE_DISCONNECTED. 155 // STATE_DISCONNECTED.
156 void ResetMedia(); 156 void ResetMedia();
157 void ResetTransport(); 157 void ResetTransport();
158 void ResetEndpoint(); 158 void ResetEndpoint();
159 159
160 // The connection state between the BluetoothAudioSinkChromeOS and the remote 160 // The connection state between the BluetoothAudioSinkBlueZ and the remote
161 // device. 161 // device.
162 device::BluetoothAudioSink::State state_; 162 device::BluetoothAudioSink::State state_;
163 163
164 // The volume control by the remote device during the streaming. The valid 164 // The volume control by the remote device during the streaming. The valid
165 // range of volume is 0-127, and 128 is used to represent invalid volume. 165 // range of volume is 0-127, and 128 is used to represent invalid volume.
166 uint16_t volume_; 166 uint16_t volume_;
167 167
168 // Read MTU of the file descriptor acquired via Media Transport object. 168 // Read MTU of the file descriptor acquired via Media Transport object.
169 uint16_t read_mtu_; 169 uint16_t read_mtu_;
170 170
(...skipping 18 matching lines...) Expand all
189 // Object path of the media object being used. 189 // Object path of the media object being used.
190 dbus::ObjectPath media_path_; 190 dbus::ObjectPath media_path_;
191 191
192 // Object path of the transport object being used. 192 // Object path of the transport object being used.
193 dbus::ObjectPath transport_path_; 193 dbus::ObjectPath transport_path_;
194 194
195 // Object path of the media endpoint object being used. 195 // Object path of the media endpoint object being used.
196 dbus::ObjectPath endpoint_path_; 196 dbus::ObjectPath endpoint_path_;
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 BluetoothAudioSinkBlueZ 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<bluez::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 BluetoothAudioSinkBlueZ 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<BluetoothAudioSinkBlueZ> weak_ptr_factory_;
216 216
217 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkChromeOS); 217 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkBlueZ);
218 }; 218 };
219 219
220 } // namespace chromeos 220 } // namespace bluez
221 221
222 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ 222 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_BLUEZ_H_
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_advertisement_chromeos_unittest.cc ('k') | device/bluetooth/bluetooth_audio_sink_bluez.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698