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

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

Issue 787743002: device/bluetooth: Add BluetoothAudioSinkChromeOS. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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 2014 The Chromium Authors. All rights reserved.
armansito 2015/01/07 01:13:34 nit: This should be 2015 now ;)
Miao 2015/01/17 02:02:59 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "device/bluetooth/bluetooth_audio_sink_chromeos.h"
6
7 #include "base/logging.h"
8
9 namespace chromeos {
10
11 BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS(
12 BluetoothAdapterChromeOS* adapter)
13 : state_(device::BluetoothAudioSink::STATE_INVALID),
14 volume_(0),
15 adapter_(adapter) {
16 adapter_->AddObserver(this);
17 }
18
19 BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() {
20 DCHECK(adapter_);
21 adapter_->RemoveObserver(this);
22 }
23
24 void BluetoothAudioSinkChromeOS::AddObserver(
25 device::BluetoothAudioSink::Observer* observer) {
26 DCHECK(observer);
27 observers_.AddObserver(observer);
28 }
29
30 void BluetoothAudioSinkChromeOS::RemoveObserver(
31 device::BluetoothAudioSink::Observer* observer) {
32 DCHECK(observer);
33 observers_.RemoveObserver(observer);
34 }
35
36 device::BluetoothAudioSink::State BluetoothAudioSinkChromeOS::GetState() const {
37 return state_;
38 }
39
40 uint16_t BluetoothAudioSinkChromeOS::GetVolume() const {
41 return volume_;
42 }
43
44 void BluetoothAudioSinkChromeOS::AdapterPresentChanged(
45 device::BluetoothAdapter* adapter,
46 bool present) {
47 // TODO(mcchou): BUG=429016
48 // If |persent| is true, change state to |STATE_DISCONNECTED| and call
49 // StateChanged(). Otherwise, change state to |STATE_INVALID| and call
50 // StateChanged.
51 }
52
53 void BluetoothAudioSinkChromeOS::AdapterPoweredChanged(
54 device::BluetoothAdapter* adapter,
55 bool powered) {
56 // TODO(mcchou): BUG=429016
57 // If |powered| is true, change state to |STATE_DISCONNECTED| and call
58 // StateChanged(). Otherwise, change state to |STATE_INVALID| and call
59 // StateChanged.
60 }
61
62 void BluetoothAudioSinkChromeOS::MediaAdded(
63 const dbus::ObjectPath& object_path) {
64 // Do nothing for now.
65 }
66
67 void BluetoothAudioSinkChromeOS::MediaRemoved(
68 const dbus::ObjectPath& object_path) {
69 // TODO(mcchou): BUG=429016
70 // Check if |object_path| equals to |media_path_|. If true, change the state
71 // of the audio sink, call StateChanged and reset the audio sink.
72 }
73
74 void BluetoothAudioSinkChromeOS::MediaTransportAdded(
75 const dbus::ObjectPath& object_path) {
76 // Do nothing for now.
77 }
78
79 void BluetoothAudioSinkChromeOS::MediaTransportRemoved(
80 const dbus::ObjectPath& object_path) {
81 // TODO(mcchou): BUG=429016
82 // Check if |object_path| equals to |transport_path_|. If true, change the
83 // state of the audio sink, call StateChanged and reset the audio sink.
84 }
85
86 void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged(
87 const dbus::ObjectPath& object_path,
88 const std::string& property_name) {
89 // TODO(mcchou): BUG=429016
90 // Call StateChanged and VolumeChanged accordingly if there is any change on
91 // state/volume.
92 }
93
94 void BluetoothAudioSinkChromeOS::SetConfiguration(
95 const dbus::ObjectPath& transport_path,
96 const dbus::MessageReader& properties) {
97 // TODO(mcchou): BUG=429016
98 // Update |transport_path_| and store properties if needed.
99 }
100
101 void BluetoothAudioSinkChromeOS::SelectConfiguration(
102 const std::vector<uint8_t>& capabilities,
103 const SelectConfigurationCallback& callback) {
104 // TODO(mcchou): BUG=429016
105 // Use SelectConfigurationCallback to return the agreed capabilities.
106 }
107
108 void BluetoothAudioSinkChromeOS::ClearConfiguration(
109 const dbus::ObjectPath& transport_path) {
110 // TODO(mcchou): BUG=429016
111 // Reset the configuration to the default one and close IOBuffer.
112 }
113
114 void BluetoothAudioSinkChromeOS::Release() {
115 // TODO(mcchou): BUG=429016
116 // Let the audio sink does the clean-up and do nothing here.
117 }
118
119 void Register(
120 const device::BluetoothAudioSink::Options& options,
121 const base::Closure& callback,
122 const device::BluetoothAudioSink::ErrorCallback& error_callback) {
123 // TODO(mcchou): BUG=429016
124 // Get Media object, initiate an Media Endpoint with options, and return the
125 // audio sink via callback. Add the audio sink as observer of both Media and
126 // Media Transport.
127 }
128
129 void Unregister(
130 const base::Closure& callback,
131 const device::BluetoothAudioSink::ErrorCallback& error_callback) {
132 // TODO(mcchou): BUG=429016
133 // Clean |observers_| and transport_path_ and reset state_ and volume.
134 }
135
136 void BluetoothAudioSinkChromeOS::StateChanged(
137 device::BluetoothAudioSink::State state) {
138 DCHECK_NE(state, state_);
139 VLOG(1) << "Bluetooth audio sink state changed: " << state;
140 state_ = state;
141 FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_,
142 BluetoothAudioSinkStateChanged(this, state_));
143 }
144
145 void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) {
146 DCHECK_NE(volume, volume_);
147 VLOG(1) << "Bluetooth audio sink volume changed: " << volume;
148 volume_ = volume;
149 FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_,
150 BluetoothAudioSinkVolumeChanged(this, volume_));
151 }
152
153 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698