Index: device/bluetooth/bluetooth_audio_sink_chromeos.cc |
diff --git a/device/bluetooth/bluetooth_audio_sink_chromeos.cc b/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..0e1baede7ea68d8b41fb7d70c8b304c43c7d6abb |
--- /dev/null |
+++ b/device/bluetooth/bluetooth_audio_sink_chromeos.cc |
@@ -0,0 +1,153 @@ |
+// 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.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "device/bluetooth/bluetooth_audio_sink_chromeos.h" |
+ |
+#include "base/logging.h" |
+ |
+namespace chromeos { |
+ |
+BluetoothAudioSinkChromeOS::BluetoothAudioSinkChromeOS( |
+ BluetoothAdapterChromeOS* adapter) |
+ : state_(device::BluetoothAudioSink::STATE_INVALID), |
+ volume_(0), |
+ adapter_(adapter) { |
+ adapter_->AddObserver(this); |
+} |
+ |
+BluetoothAudioSinkChromeOS::~BluetoothAudioSinkChromeOS() { |
+ DCHECK(adapter_); |
+ adapter_->RemoveObserver(this); |
+} |
+ |
+void BluetoothAudioSinkChromeOS::AddObserver( |
+ device::BluetoothAudioSink::Observer* observer) { |
+ DCHECK(observer); |
+ observers_.AddObserver(observer); |
+} |
+ |
+void BluetoothAudioSinkChromeOS::RemoveObserver( |
+ device::BluetoothAudioSink::Observer* observer) { |
+ DCHECK(observer); |
+ observers_.RemoveObserver(observer); |
+} |
+ |
+device::BluetoothAudioSink::State BluetoothAudioSinkChromeOS::GetState() const { |
+ return state_; |
+} |
+ |
+uint16_t BluetoothAudioSinkChromeOS::GetVolume() const { |
+ return volume_; |
+} |
+ |
+void BluetoothAudioSinkChromeOS::AdapterPresentChanged( |
+ device::BluetoothAdapter* adapter, |
+ bool present) { |
+ // TODO(mcchou): BUG=429016 |
+ // If |persent| is true, change state to |STATE_DISCONNECTED| and call |
+ // StateChanged(). Otherwise, change state to |STATE_INVALID| and call |
+ // StateChanged. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::AdapterPoweredChanged( |
+ device::BluetoothAdapter* adapter, |
+ bool powered) { |
+ // TODO(mcchou): BUG=429016 |
+ // If |powered| is true, change state to |STATE_DISCONNECTED| and call |
+ // StateChanged(). Otherwise, change state to |STATE_INVALID| and call |
+ // StateChanged. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::MediaAdded( |
+ const dbus::ObjectPath& object_path) { |
+ // Do nothing for now. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::MediaRemoved( |
+ const dbus::ObjectPath& object_path) { |
+ // TODO(mcchou): BUG=429016 |
+ // Check if |object_path| equals to |media_path_|. If true, change the state |
+ // of the audio sink, call StateChanged and reset the audio sink. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::MediaTransportAdded( |
+ const dbus::ObjectPath& object_path) { |
+ // Do nothing for now. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::MediaTransportRemoved( |
+ const dbus::ObjectPath& object_path) { |
+ // TODO(mcchou): BUG=429016 |
+ // Check if |object_path| equals to |transport_path_|. If true, change the |
+ // state of the audio sink, call StateChanged and reset the audio sink. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::MediaTransportPropertyChanged( |
+ const dbus::ObjectPath& object_path, |
+ const std::string& property_name) { |
+ // TODO(mcchou): BUG=429016 |
+ // Call StateChanged and VolumeChanged accordingly if there is any change on |
+ // state/volume. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::SetConfiguration( |
+ const dbus::ObjectPath& transport_path, |
+ const dbus::MessageReader& properties) { |
+ // TODO(mcchou): BUG=429016 |
+ // Update |transport_path_| and store properties if needed. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::SelectConfiguration( |
+ const std::vector<uint8_t>& capabilities, |
+ const SelectConfigurationCallback& callback) { |
+ // TODO(mcchou): BUG=429016 |
+ // Use SelectConfigurationCallback to return the agreed capabilities. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::ClearConfiguration( |
+ const dbus::ObjectPath& transport_path) { |
+ // TODO(mcchou): BUG=429016 |
+ // Reset the configuration to the default one and close IOBuffer. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::Release() { |
+ // TODO(mcchou): BUG=429016 |
+ // Let the audio sink does the clean-up and do nothing here. |
+} |
+ |
+void Register( |
+ const device::BluetoothAudioSink::Options& options, |
+ const base::Closure& callback, |
+ const device::BluetoothAudioSink::ErrorCallback& error_callback) { |
+ // TODO(mcchou): BUG=429016 |
+ // Get Media object, initiate an Media Endpoint with options, and return the |
+ // audio sink via callback. Add the audio sink as observer of both Media and |
+ // Media Transport. |
+} |
+ |
+void Unregister( |
+ const base::Closure& callback, |
+ const device::BluetoothAudioSink::ErrorCallback& error_callback) { |
+ // TODO(mcchou): BUG=429016 |
+ // Clean |observers_| and transport_path_ and reset state_ and volume. |
+} |
+ |
+void BluetoothAudioSinkChromeOS::StateChanged( |
+ device::BluetoothAudioSink::State state) { |
+ DCHECK_NE(state, state_); |
+ VLOG(1) << "Bluetooth audio sink state changed: " << state; |
+ state_ = state; |
+ FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_, |
+ BluetoothAudioSinkStateChanged(this, state_)); |
+} |
+ |
+void BluetoothAudioSinkChromeOS::VolumeChanged(uint16_t volume) { |
+ DCHECK_NE(volume, volume_); |
+ VLOG(1) << "Bluetooth audio sink volume changed: " << volume; |
+ volume_ = volume; |
+ FOR_EACH_OBSERVER(device::BluetoothAudioSink::Observer, observers_, |
+ BluetoothAudioSinkVolumeChanged(this, volume_)); |
+} |
+ |
+} // namespace chromeos |