| Index: chromeos/dbus/fake_bluetooth_media_transport_client.cc
|
| diff --git a/chromeos/dbus/fake_bluetooth_media_transport_client.cc b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
|
| index 26fb832d431df651c0e8ae47cb248e6ffec021cb..90dc78ba13fec6909ad83429aea09fbedc3c2361 100644
|
| --- a/chromeos/dbus/fake_bluetooth_media_transport_client.cc
|
| +++ b/chromeos/dbus/fake_bluetooth_media_transport_client.cc
|
| @@ -4,10 +4,15 @@
|
|
|
| #include "chromeos/dbus/fake_bluetooth_media_transport_client.h"
|
|
|
| +#include <sstream>
|
| +
|
| #include "base/bind.h"
|
| +#include "base/stl_util.h"
|
| #include "chromeos/dbus/bluetooth_media_client.h"
|
| #include "chromeos/dbus/dbus_thread_manager.h"
|
| +#include "chromeos/dbus/fake_bluetooth_adapter_client.h"
|
| #include "chromeos/dbus/fake_bluetooth_media_client.h"
|
| +#include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h"
|
|
|
| using dbus::ObjectPath;
|
|
|
| @@ -17,15 +22,23 @@ namespace {
|
| const char kBluetoothMediaTransportInterface[] = "org.bluez.MediaTransport1";
|
| const char kNotImplemented[] = "org.bluez.NotImplemented";
|
|
|
| +ObjectPath GenerateTransportPath() {
|
| + static unsigned int sequence_number = 0;
|
| + ++sequence_number;
|
| + std::stringstream path;
|
| + path << chromeos::FakeBluetoothAdapterClient::kAdapterPath
|
| + << chromeos::FakeBluetoothMediaTransportClient::kTransportDevicePath
|
| + << "/fd" << sequence_number;
|
| + return ObjectPath(path.str());
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace chromeos {
|
|
|
| // static
|
| -const char FakeBluetoothMediaTransportClient::kTransportPath[] =
|
| - "/fake/hci0/dev_00_00_00_00_00_00/fd0";
|
| const char FakeBluetoothMediaTransportClient::kTransportDevicePath[] =
|
| - "/fake/hci0/dev_00_00_00_00_00_00";
|
| + "/fake_audio_source";
|
| const uint8_t FakeBluetoothMediaTransportClient::kTransportCodec = 0x00;
|
| const std::vector<uint8_t>
|
| FakeBluetoothMediaTransportClient::kTransportConfiguration = {
|
| @@ -64,8 +77,7 @@ void FakeBluetoothMediaTransportClient::Properties::Set(
|
| callback.Run(false);
|
| }
|
|
|
| -FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient()
|
| - : object_path_(ObjectPath(kTransportPath)) {
|
| +FakeBluetoothMediaTransportClient::FakeBluetoothMediaTransportClient() {
|
| // TODO(mcchou): Multiple endpoints are sharing one property set for now.
|
| // Add property sets accordingly to separate the
|
| // MediaTransportPropertiesChanged events for different endpoints.
|
| @@ -130,20 +142,36 @@ void FakeBluetoothMediaTransportClient::Release(
|
| }
|
|
|
| void FakeBluetoothMediaTransportClient::SetValid(
|
| - const ObjectPath& endpoint_path,
|
| + FakeBluetoothMediaEndpointServiceProvider* endpoint,
|
| bool valid) {
|
| + FakeBluetoothMediaClient* media = static_cast<FakeBluetoothMediaClient*>(
|
| + DBusThreadManager::Get()->GetBluetoothMediaClient());
|
| + DCHECK(media);
|
| +
|
| + ObjectPath endpoint_path(endpoint->object_path());
|
| + if (!media->IsRegistered(endpoint_path))
|
| + return;
|
| +
|
| if (valid) {
|
| - endpoints_[endpoint_path] = valid;
|
| + ObjectPath transport_path = GenerateTransportPath();
|
| + VLOG(1) << "New transport, " << transport_path.value()
|
| + << " is created for endpoint " << endpoint_path.value();
|
| + endpoints_[endpoint_path] = transport_path;
|
| return;
|
| }
|
| - endpoints_.erase(endpoint_path);
|
| -
|
| - // TODO(mcchou): Since there is only one transport path, all observers will
|
| - // be notified. Shades irrelevant observers.
|
|
|
| // Notifies observers about the state change of the transport.
|
| FOR_EACH_OBSERVER(BluetoothMediaTransportClient::Observer, observers_,
|
| - MediaTransportRemoved(object_path_));
|
| + MediaTransportRemoved(endpoints_[endpoint_path]));
|
| + endpoints_.erase(endpoint_path);
|
| + endpoint->ClearConfiguration(GetTransportPath(endpoint_path));
|
| +}
|
| +
|
| +ObjectPath FakeBluetoothMediaTransportClient::GetTransportPath(
|
| + const ObjectPath& endpoint_path) {
|
| + if (ContainsKey(endpoints_, endpoint_path))
|
| + return endpoints_[endpoint_path];
|
| + return ObjectPath("");
|
| }
|
|
|
| void FakeBluetoothMediaTransportClient::OnPropertyChanged(
|
|
|