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

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

Issue 787743002: device/bluetooth: Add BluetoothAudioSinkChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unused variable. Created 5 years, 11 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_
6 #define DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_
7
8 #include <stdint.h>
9 #include <string>
10 #include <vector>
11
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "chromeos/dbus/bluetooth_media_client.h"
16 #include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h"
17 #include "chromeos/dbus/bluetooth_media_transport_client.h"
18 #include "dbus/file_descriptor.h"
19 #include "dbus/object_path.h"
20 #include "device/bluetooth/bluetooth_adapter.h"
21 #include "device/bluetooth/bluetooth_adapter_chromeos.h"
22 #include "device/bluetooth/bluetooth_audio_sink.h"
23 #include "device/bluetooth/bluetooth_export.h"
24
25 namespace chromeos {
26
27 class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS
28 : public device::BluetoothAudioSink,
29 public device::BluetoothAdapter::Observer,
30 public BluetoothMediaClient::Observer,
31 public BluetoothMediaTransportClient::Observer,
32 public BluetoothMediaEndpointServiceProvider::Delegate {
33 public:
34 explicit BluetoothAudioSinkChromeOS(BluetoothAdapterChromeOS* adapter);
35
36 // device::BluetoothAudioSink overrides.
37 void AddObserver(BluetoothAudioSink::Observer* observer) override;
38 void RemoveObserver(BluetoothAudioSink::Observer* observer) override;
39 device::BluetoothAudioSink::State GetState() const override;
40 uint16_t GetVolume() const override;
41
42 // device::BluetoothAdapter::Observer overrides.
43 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
44 bool present) override;
45 void AdapterPoweredChanged(device::BluetoothAdapter* adapter,
46 bool powered) override;
47
48 // BluetoothMediaClient::Observer overrides.
49 void MediaAdded(const dbus::ObjectPath& object_path) override;
Miao 2015/01/22 03:45:08 Removed.
50 void MediaRemoved(const dbus::ObjectPath& object_path) override;
51
52 // BluetoothMediaTransportClient::Observer overrides.
53 void MediaTransportAdded(const dbus::ObjectPath& object_path) override;
Miao 2015/01/22 03:45:08 Removed.
54 void MediaTransportRemoved(const dbus::ObjectPath& object_path) override;
55 void MediaTransportPropertyChanged(const dbus::ObjectPath& object_path,
56 const std::string& property_name) override;
57
58 // BluetoothMediaEndpointServiceProvider::Delegate overrides.
59 void SetConfiguration(const dbus::ObjectPath& transport_path,
60 const dbus::MessageReader& properties) override;
61 void SelectConfiguration(
62 const std::vector<uint8_t>& capabilities,
63 const SelectConfigurationCallback& callback) override;
64 void ClearConfiguration(const dbus::ObjectPath& transport_path) override;
65 void Release() override;
66
67 // Registers a BluetoothAudioSink. User applications can use |options| to
68 // configure the audio sink. |callback| will be executed if the audio sink is
69 // successfully registered, otherwise |error_callback| will be called. Called
70 // from BluetoothAdapterChromeOS.
71 void Register(
72 const device::BluetoothAudioSink::Options& options,
73 const base::Closure& callback,
74 const device::BluetoothAudioSink::ErrorCallback& error_callback);
75
76 // Unregisters a BluetoothAudioSink. |callback| should handle
77 // the clean-up after the audio sink is deleted successfully, otherwise
78 // |error_callback| will be called.
79 void Unregister(
80 const base::Closure& callback,
81 const device::BluetoothAudioSink::ErrorCallback& error_callback) override;
82
83 private:
84 ~BluetoothAudioSinkChromeOS() override;
85
86 // Called when the state property of BluetoothMediaTransport has been updated.
87 void StateChanged(device::BluetoothAudioSink::State state);
88
89 // Called when the volume property of BluetoothMediaTransport has been
90 // updated.
91 void VolumeChanged(uint16_t volume);
92
93 // Reads from the file descriptor acquired via Media Transport object and
94 // notify |observer_| while the audio data is available.
95 void ReadFromFD();
96
97 // The connection state between the BluetoothAudioSinkChromeOS and the remote
98 // device.
99 device::BluetoothAudioSink::State state_;
100
101 // Indicates whether the adapter is present.
102 bool present_;
103
104 // Indicates whether the adapter is powered.
105 bool powered_;
106
107 // The volume control by the remote device during the streaming.
108 uint16_t volume_;
109
110 // Read MTU of the file descriptor acquired via Media Transport object.
111 uint16_t read_mtu_;
112
113 // Write MTU of the file descriptor acquired via Media Transport object.
114 uint16_t write_mtu_;
115
116 // File descriptor acquired via Media Transport object.
117 dbus::FileDescriptor fd_;
118
119 // Object path of the media object being used.
120 dbus::ObjectPath media_path_;
121
122 // Object path of the transport object being used.
123 dbus::ObjectPath transport_path_;
124
125 // Object path of the media endpoint object being used.
126 dbus::ObjectPath endpoint_path_;
127
128 // BT adapter which the audio sink binds to. |adapter_| should outlive
129 // a BluetoothAudioSinkChromeOS object.
130 BluetoothAdapterChromeOS* adapter_;
131
132 // Options used to initiate Media Endpoint and select configuration for the
133 // transport.
134 device::BluetoothAudioSink::Options options_;
135
136 // Media Endpoint object owned by the audio sink object.
137 scoped_ptr<BluetoothMediaEndpointServiceProvider> media_endpoint_;
138
139 // List of observers interested in event notifications from us. Objects in
140 // |observers_| are expected to outlive a BluetoothAudioSinkChromeOS object.
141 ObserverList<BluetoothAudioSink::Observer> observers_;
142
143 // Note: This should remain the last member so it'll be destroyed and
144 // invalidate its weak pointers before any other members are destroyed.
145 base::WeakPtrFactory<BluetoothAudioSinkChromeOS> weak_ptr_factory_;
146
147 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkChromeOS);
148 };
149
150 } // namespace chromeos
151
152 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698