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

Unified 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: Change copyright year and add some functions. 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 side-by-side diff with in-line comments
Download patch
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..5e65266eefbf59c4c2d9dd09cd7cefee1c1bbb06
--- /dev/null
+++ b/device/bluetooth/bluetooth_audio_sink_chromeos.cc
@@ -0,0 +1,205 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
armansito 2015/01/17 02:09:06 nit: 2015
Miao 2015/01/17 04:09:52 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=441581
+ // 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=441581
+ // 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=441581
+ // 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=441581
+ // 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=441581
+ // 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=441581
+ // Update |transport_path_| and store properties if needed.
+}
+
+void BluetoothAudioSinkChromeOS::SelectConfiguration(
+ const std::vector<uint8_t>& capabilities,
+ const SelectConfigurationCallback& callback) {
+ // TODO(mcchou): BUG=441581
+ // Use SelectConfigurationCallback to return the agreed capabilities.
+}
+
+void BluetoothAudioSinkChromeOS::ClearConfiguration(
+ const dbus::ObjectPath& transport_path) {
+ // TODO(mcchou): BUG=441581
+ // Reset the configuration to the default one and close IOBuffer.
+}
+
+void BluetoothAudioSinkChromeOS::Release() {
+ // TODO(mcchou): BUG=441581
+ // 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=441581
+ // 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=441581
+ // 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_));
+}
+
+void BluetoothAudioSinkChromeOS::OnRegisterSucceeded(
+ const base::Closure& callback) {
+ VLOG(1) << "Bluetooth audio sink registerd: " << sequence_number;
+
+ // TODO(mcchou): BUG=441581
+ // Change |state_| to STATE_DISCONNECTED and run the callback after Register
+ // is done successfully.
+}
+
+void BluetoothAudioSinkChromeOS::OnRegisterFailed(
+ const BluetoothAudioSink::ErrorCallback& error_callback,
+ const std::string& error_name,
+ const std::string& error_message) {
+ DCHECK(media_endpoint_);
+ VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message;
+
+ // TODO(mcchou): BUG=441581
+ // Reset |endpoint_path_|, reset |media_endpoint_| and run error_callback with
+ // ERROR_NOT_REGISTERED.
+}
+
+void BluetoothAudioSinkChromeOS::OnAcquireSucceeded(
+ const dbus::FileDescriptor& fd,
+ const uint16_t read_mtu,
+ const uint16_t write_mtu) {
+ // TODO(mcchou): BUG=441581
+ // Set |fd_|, |read_mtu_| and |write_mtu_| if media transport is acquired
+ // successfully.
+}
+
+void BluetoothAudioSinkChromeOS::OnAcquireFailed(
+ const std::string& error_name,
+ const std::string& error_message) {
+ VLOG(1) << "Bluetooth audio sink: " << error_name << ": " << error_message;
+
+ // TODO(mcchou): BUG=441581
+ // Reset |fd_|, |read_mtu_| and |write_mtu|.
+}
+
+dbus::ObjectPath BluetoothAudioSinkChromeOS::GenerateEndpointPath() {
+ // TODO(mcchou): BUG=441581
+ // Generate an unique object path for the new media endpoint.
+}
+
+void BluetoothAudioSinkChromeOS::ReadFromFD() {
+ DCHECK_NE(fd_.value(), -1);
+
+ // TODO(mcchou): BUG=441581
+ // Read from file descriptor using watcher and create a buffer to contain the
+ // data. Notify |Observers_| while there is audio data available.
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698