| Index: chromeos/dbus/bluetooth_media_endpoint_service_provider.cc
|
| diff --git a/chromeos/dbus/bluetooth_media_endpoint_service_provider.cc b/chromeos/dbus/bluetooth_media_endpoint_service_provider.cc
|
| index 6a2de74643d084b8057a91a686d397f5b599cb2d..c8a3f38bdbe4b306f37b9f74421b3c07bbe6ac8e 100644
|
| --- a/chromeos/dbus/bluetooth_media_endpoint_service_provider.cc
|
| +++ b/chromeos/dbus/bluetooth_media_endpoint_service_provider.cc
|
| @@ -4,13 +4,12 @@
|
|
|
| #include "chromeos/dbus/bluetooth_media_endpoint_service_provider.h"
|
|
|
| -#include <string>
|
| -
|
| #include "base/bind.h"
|
| #include "base/logging.h"
|
| #include "base/memory/ref_counted.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/threading/platform_thread.h"
|
| +#include "chromeos/dbus/bluetooth_media_transport_client.h"
|
| #include "chromeos/dbus/dbus_thread_manager.h"
|
| #include "chromeos/dbus/fake_bluetooth_media_endpoint_service_provider.h"
|
| #include "dbus/bus.h"
|
| @@ -23,12 +22,15 @@ namespace {
|
| // Bluetooth Media Endpoint service identifier.
|
| const char kBluetoothMediaEndpointInterface[] = "org.bluez.MediaEndpoint1";
|
|
|
| -// Bluetooth Media Endpoint methods.
|
| +// Method names in Bluetooth Media Endpoint interface.
|
| const char kSetConfiguration[] = "SetConfiguration";
|
| const char kSelectConfiguration[] = "SelectConfiguration";
|
| const char kClearConfiguration[] = "ClearConfiguration";
|
| const char kRelease[] = "Release";
|
|
|
| +const uint8_t kInvalidCodec = 0xff;
|
| +const char kInvalidState[] = "unknown";
|
| +
|
| } // namespace
|
|
|
| namespace chromeos {
|
| @@ -118,15 +120,55 @@ class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProviderImpl
|
|
|
| dbus::MessageReader reader(method_call);
|
| dbus::ObjectPath transport_path;
|
| - dbus::MessageReader properties(method_call);
|
| + dbus::MessageReader property_reader(method_call);
|
| if (!reader.PopObjectPath(&transport_path) ||
|
| - !reader.PopArray(&properties)) {
|
| + !reader.PopArray(&property_reader)) {
|
| LOG(WARNING) << "SetConfiguration called with incorrect parameters: "
|
| << method_call->ToString();
|
| return;
|
| }
|
|
|
| - delegate_->SetConfiguration(transport_path, properties);
|
| + // Parses |properties| and passes the property set as a
|
| + // Delegate::TransportProperties structure to |delegate_|.
|
| + Delegate::TransportProperties properties;
|
| + while (property_reader.HasMoreData()) {
|
| + dbus::MessageReader dict_entry_reader(nullptr);
|
| + std::string key;
|
| + if (!property_reader.PopDictEntry(&dict_entry_reader) ||
|
| + !dict_entry_reader.PopString(&key)) {
|
| + LOG(WARNING) << "SetConfiguration called with incorrect parameters: "
|
| + << method_call->ToString();
|
| + } else if (key == BluetoothMediaTransportClient::kDeviceProperty) {
|
| + dict_entry_reader.PopVariantOfObjectPath(&properties.device);
|
| + } else if (key == BluetoothMediaTransportClient::kUUIDProperty) {
|
| + dict_entry_reader.PopVariantOfString(&properties.uuid);
|
| + } else if (key == BluetoothMediaTransportClient::kCodecProperty) {
|
| + dict_entry_reader.PopVariantOfByte(&properties.codec);
|
| + } else if (key == BluetoothMediaTransportClient::kConfigurationProperty) {
|
| + dbus::MessageReader variant_reader(nullptr);
|
| + const uint8_t* bytes = nullptr;
|
| + size_t length = 0;
|
| + dict_entry_reader.PopVariant(&variant_reader);
|
| + variant_reader.PopArrayOfBytes(&bytes, &length);
|
| + properties.configuration.assign(bytes, bytes + length);
|
| + } else if (key == BluetoothMediaTransportClient::kStateProperty) {
|
| + dict_entry_reader.PopVariantOfString(&properties.state);
|
| + } else if (key == BluetoothMediaTransportClient::kDelayProperty) {
|
| + properties.delay.reset(new uint16_t());
|
| + dict_entry_reader.PopVariantOfUint16(properties.delay.get());
|
| + } else if (key == BluetoothMediaTransportClient::kVolumeProperty) {
|
| + properties.volume.reset(new uint16_t());
|
| + dict_entry_reader.PopVariantOfUint16(properties.volume.get());
|
| + }
|
| + }
|
| +
|
| + if (properties.codec != kInvalidCodec &&
|
| + properties.state != kInvalidState) {
|
| + delegate_->SetConfiguration(transport_path, properties);
|
| + } else {
|
| + LOG(WARNING) << "SetConfiguration called with incorrect parameters: "
|
| + << method_call->ToString();
|
| + }
|
|
|
| response_sender.Run(dbus::Response::FromMethodCall(method_call));
|
| }
|
| @@ -188,7 +230,7 @@ class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProviderImpl
|
| DCHECK(OnOriginThread());
|
| DCHECK(delegate_);
|
|
|
| - delegate_->Release();
|
| + delegate_->Released();
|
|
|
| response_sender.Run(dbus::Response::FromMethodCall(method_call));
|
| }
|
| @@ -241,11 +283,22 @@ class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProviderImpl
|
| DISALLOW_COPY_AND_ASSIGN(BluetoothMediaEndpointServiceProviderImpl);
|
| };
|
|
|
| +BluetoothMediaEndpointServiceProvider::Delegate::TransportProperties::
|
| + TransportProperties()
|
| + : codec(kInvalidCodec),
|
| + state(kInvalidState) {
|
| +}
|
| +
|
| +BluetoothMediaEndpointServiceProvider::Delegate::TransportProperties::
|
| + ~TransportProperties() {
|
| +}
|
| +
|
| BluetoothMediaEndpointServiceProvider::BluetoothMediaEndpointServiceProvider() {
|
| }
|
|
|
| -BluetoothMediaEndpointServiceProvider::~BluetoothMediaEndpointServiceProvider()
|
| -{}
|
| +BluetoothMediaEndpointServiceProvider::
|
| + ~BluetoothMediaEndpointServiceProvider() {
|
| +}
|
|
|
| BluetoothMediaEndpointServiceProvider*
|
| BluetoothMediaEndpointServiceProvider::Create(
|
|
|