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

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

Issue 910023002: device/bluetooth:Implement BluetoothMediaEndpointServiceProvider delegate and media-related overrid… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moved the addition/removal of all types of observer to constructor/destructor. Created 5 years, 10 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_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/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h" 14 #include "base/observer_list.h"
15 #include "chromeos/dbus/bluetooth_media_client.h" 15 #include "chromeos/dbus/bluetooth_media_client.h"
16 #include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h" 16 #include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h"
17 #include "chromeos/dbus/bluetooth_media_transport_client.h" 17 #include "chromeos/dbus/bluetooth_media_transport_client.h"
18 #include "dbus/file_descriptor.h" 18 #include "dbus/file_descriptor.h"
19 #include "dbus/object_path.h" 19 #include "dbus/object_path.h"
20 #include "device/bluetooth/bluetooth_adapter.h" 20 #include "device/bluetooth/bluetooth_adapter.h"
21 #include "device/bluetooth/bluetooth_audio_sink.h" 21 #include "device/bluetooth/bluetooth_audio_sink.h"
22 #include "device/bluetooth/bluetooth_export.h" 22 #include "device/bluetooth/bluetooth_export.h"
23 23
24 namespace chromeos { 24 namespace chromeos {
25 25
26 class BluetoothAudioSinkChromeOSTest;
27
26 class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS 28 class DEVICE_BLUETOOTH_EXPORT BluetoothAudioSinkChromeOS
27 : public device::BluetoothAudioSink, 29 : public device::BluetoothAudioSink,
28 public device::BluetoothAdapter::Observer, 30 public device::BluetoothAdapter::Observer,
29 public BluetoothMediaClient::Observer, 31 public BluetoothMediaClient::Observer,
30 public BluetoothMediaTransportClient::Observer, 32 public BluetoothMediaTransportClient::Observer,
31 public BluetoothMediaEndpointServiceProvider::Delegate { 33 public BluetoothMediaEndpointServiceProvider::Delegate {
32 public: 34 public:
33 explicit BluetoothAudioSinkChromeOS( 35 explicit BluetoothAudioSinkChromeOS(
34 scoped_refptr<device::BluetoothAdapter> adapter); 36 scoped_refptr<device::BluetoothAdapter> adapter);
35 37
36 // device::BluetoothAudioSink overrides. 38 // device::BluetoothAudioSink overrides.
39 // Unregisters a BluetoothAudioSink. |callback| should handle
40 // the clean-up after the audio sink is deleted successfully, otherwise
41 // |error_callback| will be called.
42 void Unregister(
43 const base::Closure& callback,
44 const device::BluetoothAudioSink::ErrorCallback& error_callback) override;
37 void AddObserver(BluetoothAudioSink::Observer* observer) override; 45 void AddObserver(BluetoothAudioSink::Observer* observer) override;
38 void RemoveObserver(BluetoothAudioSink::Observer* observer) override; 46 void RemoveObserver(BluetoothAudioSink::Observer* observer) override;
39 device::BluetoothAudioSink::State GetState() const override; 47 device::BluetoothAudioSink::State GetState() const override;
40 uint16_t GetVolume() const override; 48 uint16_t GetVolume() const override;
41 49
42 // device::BluetoothAdapter::Observer overrides. 50 // device::BluetoothAdapter::Observer overrides.
43 void AdapterPresentChanged(device::BluetoothAdapter* adapter, 51 void AdapterPresentChanged(device::BluetoothAdapter* adapter,
44 bool present) override; 52 bool present) override;
45 53
46 // BluetoothMediaClient::Observer overrides. 54 // BluetoothMediaClient::Observer overrides.
47 void MediaRemoved(const dbus::ObjectPath& object_path) override; 55 void MediaRemoved(const dbus::ObjectPath& object_path) override;
48 56
49 // BluetoothMediaTransportClient::Observer overrides. 57 // BluetoothMediaTransportClient::Observer overrides.
50 void MediaTransportRemoved(const dbus::ObjectPath& object_path) override; 58 void MediaTransportRemoved(const dbus::ObjectPath& object_path) override;
51 void MediaTransportPropertyChanged(const dbus::ObjectPath& object_path, 59 void MediaTransportPropertyChanged(const dbus::ObjectPath& object_path,
52 const std::string& property_name) override; 60 const std::string& property_name) override;
53 61
54 // BluetoothMediaEndpointServiceProvider::Delegate overrides. 62 // BluetoothMediaEndpointServiceProvider::Delegate overrides.
55 void SetConfiguration(const dbus::ObjectPath& transport_path, 63 void SetConfiguration(const dbus::ObjectPath& transport_path,
56 const dbus::MessageReader& properties) override; 64 const TransportProperties& properties) override;
57 void SelectConfiguration( 65 void SelectConfiguration(
58 const std::vector<uint8_t>& capabilities, 66 const std::vector<uint8_t>& capabilities,
59 const SelectConfigurationCallback& callback) override; 67 const SelectConfigurationCallback& callback) override;
60 void ClearConfiguration(const dbus::ObjectPath& transport_path) override; 68 void ClearConfiguration(const dbus::ObjectPath& transport_path) override;
61 void Release() override; 69 void Released() override;
62 70
63 // Registers a BluetoothAudioSink. User applications can use |options| to 71 // Registers a BluetoothAudioSink. User applications can use |options| to
64 // configure the audio sink. |callback| will be executed if the audio sink is 72 // configure the audio sink. |callback| will be executed if the audio sink is
65 // successfully registered, otherwise |error_callback| will be called. Called 73 // successfully registered, otherwise |error_callback| will be called. Called
66 // by BluetoothAdapterChromeOS. 74 // by BluetoothAdapterChromeOS.
67 void Register( 75 void Register(
68 const device::BluetoothAudioSink::Options& options, 76 const device::BluetoothAudioSink::Options& options,
69 const base::Closure& callback, 77 const base::Closure& callback,
70 const device::BluetoothAudioSink::ErrorCallback& error_callback); 78 const device::BluetoothAudioSink::ErrorCallback& error_callback);
71 79
72 // Unregisters a BluetoothAudioSink. |callback| should handle 80 // Returns a pointer to the media endpoint object. This function should be
73 // the clean-up after the audio sink is deleted successfully, otherwise 81 // used for testing purpose only.
74 // |error_callback| will be called. 82 BluetoothMediaEndpointServiceProvider* GetEndpointServiceProvider();
75 void Unregister(
76 const base::Closure& callback,
77 const device::BluetoothAudioSink::ErrorCallback& error_callback) override;
78 83
79 private: 84 private:
80 ~BluetoothAudioSinkChromeOS() override; 85 ~BluetoothAudioSinkChromeOS() override;
81 86
82 // Called when the state property of BluetoothMediaTransport has been updated. 87 // Called when the state property of BluetoothMediaTransport has been updated.
83 void StateChanged(device::BluetoothAudioSink::State state); 88 void StateChanged(device::BluetoothAudioSink::State state);
84 89
85 // Called when the volume property of BluetoothMediaTransport has been 90 // Called when the volume property of BluetoothMediaTransport has been
86 // updated. 91 // updated.
87 void VolumeChanged(uint16_t volume); 92 void VolumeChanged(uint16_t volume);
88 93
89 // Called when the registration of Media Endpoint has succeeded. 94 // Called when the registration of Media Endpoint has succeeded.
90 void OnRegisterSucceeded(const base::Closure& callback); 95 void OnRegisterSucceeded(const base::Closure& callback);
91 96
92 // Called when the registration of Media Endpoint failed. 97 // Called when the registration of Media Endpoint failed.
93 void OnRegisterFailed(const BluetoothAudioSink::ErrorCallback& error_callback, 98 void OnRegisterFailed(const BluetoothAudioSink::ErrorCallback& error_callback,
94 const std::string& error_name, 99 const std::string& error_name,
95 const std::string& error_message); 100 const std::string& error_message);
96 101
97 // Reads from the file descriptor acquired via Media Transport object and 102 // Reads from the file descriptor acquired via Media Transport object and
98 // notify |observer_| while the audio data is available. 103 // notify |observer_| while the audio data is available.
99 void ReadFromFD(); 104 void ReadFromFD();
100 105
106 // Helper functions to clean up media, media transport and media endpoint.
107 // Called when the |state_| changes to either STATE_INVALID or
108 // STATE_DISCONNECTED.
109 void ResetMedia();
110 void ResetTransport();
111 void ResetEndpoint();
112
101 // The connection state between the BluetoothAudioSinkChromeOS and the remote 113 // The connection state between the BluetoothAudioSinkChromeOS and the remote
102 // device. 114 // device.
103 device::BluetoothAudioSink::State state_; 115 device::BluetoothAudioSink::State state_;
104 116
105 // The volume control by the remote device during the streaming. 117 // The volume control by the remote device during the streaming.
106 uint16_t volume_; 118 uint16_t volume_;
107 119
108 // Read MTU of the file descriptor acquired via Media Transport object. 120 // Read MTU of the file descriptor acquired via Media Transport object.
109 uint16_t read_mtu_; 121 uint16_t read_mtu_;
110 122
(...skipping 30 matching lines...) Expand all
141 // Note: This should remain the last member so it'll be destroyed and 153 // Note: This should remain the last member so it'll be destroyed and
142 // invalidate its weak pointers before any other members are destroyed. 154 // invalidate its weak pointers before any other members are destroyed.
143 base::WeakPtrFactory<BluetoothAudioSinkChromeOS> weak_ptr_factory_; 155 base::WeakPtrFactory<BluetoothAudioSinkChromeOS> weak_ptr_factory_;
144 156
145 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkChromeOS); 157 DISALLOW_COPY_AND_ASSIGN(BluetoothAudioSinkChromeOS);
146 }; 158 };
147 159
148 } // namespace chromeos 160 } // namespace chromeos
149 161
150 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_ 162 #endif // DEVICE_BLUETOOTH_BLUETOOTH_AUDIO_SINK_CHROMEOS_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/fake_bluetooth_media_transport_client.cc ('k') | device/bluetooth/bluetooth_audio_sink_chromeos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698