OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chromeos/dbus/fake_bluetooth_media_client.h" | 5 #include "chromeos/dbus/fake_bluetooth_media_client.h" |
6 | 6 |
| 7 #include <string> |
| 8 |
| 9 #include "chromeos/dbus/fake_bluetooth_adapter_client.h" |
| 10 |
| 11 using dbus::ObjectPath; |
| 12 |
| 13 namespace { |
| 14 |
| 15 // Except for |kFailedError|, the other error is defined in BlueZ D-Bus Media |
| 16 // API. |
| 17 const char kFailedError[] = "org.chromium.Error.Failed"; |
| 18 const char kInvalidArgumentsError[] = "org.chromium.Error.InvalidArguments"; |
| 19 |
| 20 } // namespace |
| 21 |
7 namespace chromeos { | 22 namespace chromeos { |
8 | 23 |
9 FakeBluetoothMediaClient::FakeBluetoothMediaClient() { | 24 FakeBluetoothMediaClient::FakeBluetoothMediaClient() { |
10 } | 25 } |
11 | 26 |
12 FakeBluetoothMediaClient::~FakeBluetoothMediaClient() { | 27 FakeBluetoothMediaClient::~FakeBluetoothMediaClient() { |
13 } | 28 } |
14 | 29 |
15 void FakeBluetoothMediaClient::Init(dbus::Bus* bus) { | 30 void FakeBluetoothMediaClient::Init(dbus::Bus* bus) { |
16 } | 31 } |
17 | 32 |
18 void FakeBluetoothMediaClient::AddObserver( | 33 void FakeBluetoothMediaClient::AddObserver( |
19 BluetoothMediaClient::Observer* observer) { | 34 BluetoothMediaClient::Observer* observer) { |
20 DCHECK(observer); | 35 DCHECK(observer); |
21 observers_.AddObserver(observer); | 36 observers_.AddObserver(observer); |
22 } | 37 } |
23 | 38 |
24 void FakeBluetoothMediaClient::RemoveObserver( | 39 void FakeBluetoothMediaClient::RemoveObserver( |
25 BluetoothMediaClient::Observer* observer) { | 40 BluetoothMediaClient::Observer* observer) { |
26 DCHECK(observer); | 41 DCHECK(observer); |
27 observers_.RemoveObserver(observer); | 42 observers_.RemoveObserver(observer); |
28 } | 43 } |
29 | 44 |
30 // TODO(mcchou): Add method definition for |RegisterEndpoint|, | |
31 // |UnregisterEndpoint|, |RegisterPlayer| and |UnregisterPlayer|. | |
32 void FakeBluetoothMediaClient::RegisterEndpoint( | 45 void FakeBluetoothMediaClient::RegisterEndpoint( |
33 const dbus::ObjectPath& object_path, | 46 const ObjectPath& object_path, |
34 const dbus::ObjectPath& endpoint_path, | 47 const ObjectPath& endpoint_path, |
35 const EndpointProperties& properties, | 48 const EndpointProperties& properties, |
36 const base::Closure& callback, | 49 const base::Closure& callback, |
37 const ErrorCallback& error_callback) { | 50 const ErrorCallback& error_callback) { |
38 error_callback.Run("org.bluez.NotImplemented", ""); | 51 VLOG(1) << "RegisterEndpoint: " << endpoint_path.value(); |
| 52 |
| 53 // The object paths of the media client and adapter client should be the same. |
| 54 if (object_path != ObjectPath(FakeBluetoothAdapterClient::kAdapterPath) || |
| 55 properties.uuid != BluetoothMediaClient::kBluetoothAudioSinkUUID || |
| 56 properties.codec != kDefaultCodec || |
| 57 properties.capabilities.empty()) { |
| 58 error_callback.Run(kInvalidArgumentsError, ""); |
| 59 return; |
| 60 } |
| 61 callback.Run(); |
39 } | 62 } |
40 | 63 |
41 void FakeBluetoothMediaClient::UnregisterEndpoint( | 64 void FakeBluetoothMediaClient::UnregisterEndpoint( |
42 const dbus::ObjectPath& object_path, | 65 const ObjectPath& object_path, |
43 const dbus::ObjectPath& endpoint_path, | 66 const ObjectPath& endpoint_path, |
44 const base::Closure& callback, | 67 const base::Closure& callback, |
45 const ErrorCallback& error_callback) { | 68 const ErrorCallback& error_callback) { |
46 error_callback.Run("org.bluez.NotImplemented", ""); | 69 // TODO(mcchou): Come up with some corresponding actions. |
| 70 error_callback.Run(kFailedError, ""); |
47 } | 71 } |
48 | 72 |
49 } // namespace chromeos | 73 } // namespace chromeos |
OLD | NEW |