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 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 6 #define CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
7 | 7 |
| 8 #include <map> |
8 #include <string> | 9 #include <string> |
| 10 #include <vector> |
9 | 11 |
| 12 #include "base/memory/scoped_ptr.h" |
10 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
11 #include "chromeos/chromeos_export.h" | 14 #include "chromeos/chromeos_export.h" |
12 #include "chromeos/dbus/bluetooth_media_transport_client.h" | 15 #include "chromeos/dbus/bluetooth_media_transport_client.h" |
13 #include "dbus/object_path.h" | 16 #include "dbus/object_path.h" |
14 | 17 |
15 namespace chromeos { | 18 namespace chromeos { |
16 | 19 |
17 class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient | 20 class CHROMEOS_EXPORT FakeBluetoothMediaTransportClient |
18 : public BluetoothMediaTransportClient { | 21 : public BluetoothMediaTransportClient { |
19 public: | 22 public: |
20 struct Properties : public BluetoothMediaTransportClient::Properties { | 23 struct Properties : public BluetoothMediaTransportClient::Properties { |
21 explicit Properties(const PropertyChangedCallback& callback); | 24 explicit Properties(const PropertyChangedCallback& callback); |
22 ~Properties() override; | 25 ~Properties() override; |
23 | 26 |
24 void Get(dbus::PropertyBase* property, | 27 void Get(dbus::PropertyBase* property, |
25 dbus::PropertySet::GetCallback callback) override; | 28 dbus::PropertySet::GetCallback callback) override; |
26 void GetAll() override; | 29 void GetAll() override; |
27 void Set(dbus::PropertyBase* property, | 30 void Set(dbus::PropertyBase* property, |
28 dbus::PropertySet::SetCallback callback) override; | 31 dbus::PropertySet::SetCallback callback) override; |
29 }; | 32 }; |
30 | 33 |
| 34 // The default path of the transport object. |
| 35 static const char kTransportPath[]; |
| 36 |
| 37 // The default properties including device, codec, configuration, state, delay |
| 38 // and volume, owned by a fake media transport object we emulate. |
| 39 static const char kTransportDevicePath[]; |
| 40 static const uint8_t kTransportCodec; |
| 41 static const std::vector<uint8_t> kTransportConfiguration; |
| 42 static const uint16_t kTransportDelay; |
| 43 static const uint16_t kTransportVolume; |
| 44 |
31 FakeBluetoothMediaTransportClient(); | 45 FakeBluetoothMediaTransportClient(); |
32 ~FakeBluetoothMediaTransportClient() override; | 46 ~FakeBluetoothMediaTransportClient() override; |
33 | 47 |
34 // DBusClient override. | 48 // DBusClient override. |
35 void Init(dbus::Bus* bus) override; | 49 void Init(dbus::Bus* bus) override; |
36 | 50 |
37 // BluetoothMediaTransportClient override. | 51 // BluetoothMediaTransportClient override. |
38 void AddObserver(Observer* observer) override; | 52 void AddObserver(Observer* observer) override; |
39 void RemoveObserver(Observer* observer) override; | 53 void RemoveObserver(Observer* observer) override; |
40 Properties* GetProperties(const dbus::ObjectPath& object_path) override; | 54 Properties* GetProperties(const dbus::ObjectPath& object_path) override; |
41 void Acquire(const dbus::ObjectPath& object_path, | 55 void Acquire(const dbus::ObjectPath& object_path, |
42 const AcquireCallback& callback, | 56 const AcquireCallback& callback, |
43 const ErrorCallback& error_callback) override; | 57 const ErrorCallback& error_callback) override; |
44 void TryAcquire(const dbus::ObjectPath& object_path, | 58 void TryAcquire(const dbus::ObjectPath& object_path, |
45 const AcquireCallback& callback, | 59 const AcquireCallback& callback, |
46 const ErrorCallback& error_callback) override; | 60 const ErrorCallback& error_callback) override; |
47 void Release(const dbus::ObjectPath& object_path, | 61 void Release(const dbus::ObjectPath& object_path, |
48 const base::Closure& callback, | 62 const base::Closure& callback, |
49 const ErrorCallback& error_callback) override; | 63 const ErrorCallback& error_callback) override; |
50 | 64 |
| 65 // Makes the transport valid/invalid for a given media endpoint path. The |
| 66 // transport object is assigned to the given endpoint if valid is true, false |
| 67 // otherwise. |
| 68 void SetValid(const dbus::ObjectPath& endpoint_path, bool valid); |
| 69 |
51 private: | 70 private: |
| 71 // Property callback passed while a Properties structure is created. |
| 72 void OnPropertyChanged(const std::string& property_name); |
| 73 |
| 74 // The path of the media transport object. |
| 75 dbus::ObjectPath object_path_; |
| 76 |
| 77 // Indicates whether endpoints are assigned with the transport object. |
| 78 std::map<dbus::ObjectPath, bool> endpoints_; |
| 79 |
| 80 // The fake property set of the media transport object. |
| 81 scoped_ptr<Properties> properties_; |
| 82 |
52 ObserverList<BluetoothMediaTransportClient::Observer> observers_; | 83 ObserverList<BluetoothMediaTransportClient::Observer> observers_; |
53 | 84 |
54 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); | 85 DISALLOW_COPY_AND_ASSIGN(FakeBluetoothMediaTransportClient); |
55 }; | 86 }; |
56 | 87 |
57 } // namespace chromeos | 88 } // namespace chromeos |
58 | 89 |
59 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ | 90 #endif // CHROMEOS_DBUS_FAKE_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_ |
OLD | NEW |