[Android WebView] Fix webview perf bot switchover to use org.chromium.webview_shell...
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_media_transport_client.h
blob4476ae7afed011e95bfb950014e6e6c3b77b9e5f
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
14 #include "dbus/file_descriptor.h"
15 #include "dbus/object_path.h"
16 #include "dbus/property.h"
18 namespace chromeos {
20 class CHROMEOS_EXPORT BluetoothMediaTransportClient : public DBusClient {
21 public:
22 struct Properties : public dbus::PropertySet {
23 // The path to the device object which the transport is connected to.
24 // Read-only.
25 dbus::Property<dbus::ObjectPath> device;
27 // UUID of the profile which the transport is for. Read-only.
28 dbus::Property<std::string> uuid;
30 // Assigned codec value supported by the media transport. Read-only.
31 dbus::Property<uint8_t> codec;
33 // The configuration used by the media transport. Read-only.
34 dbus::Property<std::vector<uint8_t>> configuration;
36 // The state of the transport. Read-only.
37 // The values can be one of the following:
38 // "idle": not streaming
39 // "pending": streaming but not acquired
40 // "active": streaming and acquired
41 dbus::Property<std::string> state;
43 // The unit of transport delay is in 1/10 of millisecond. This property is
44 // only writeable when the transport was aquired by the sender. Optional.
45 dbus::Property<uint16_t> delay;
47 // The volume level of the transport. This property is only writable when
48 // the transport was aquired by the sender. Optional.
49 dbus::Property<uint16_t> volume;
51 Properties(dbus::ObjectProxy* object_proxy,
52 const std::string& interface_name,
53 const PropertyChangedCallback& callback);
54 ~Properties() override;
57 class Observer {
58 public:
59 virtual ~Observer() {}
61 // Called when the Media Transport with object path |object_path| is added
62 // to the system.
63 virtual void MediaTransportAdded(const dbus::ObjectPath& object_path) {}
65 // Called when the Media Transport with object path |object_path| is removed
66 // from the system.
67 virtual void MediaTransportRemoved(const dbus::ObjectPath& object_path) {}
69 // Called when the Media Transport with object path |object_path| has
70 // a change in the value of the property with name |property_name|.
71 virtual void MediaTransportPropertyChanged(
72 const dbus::ObjectPath& object_path,
73 const std::string& property_name) {}
76 // TODO(mcchou): Move all static constants to service_constants.h.
77 // Constants used for the names of Media Transport's properties.
78 static const char kDeviceProperty[];
79 static const char kUUIDProperty[];
80 static const char kCodecProperty[];
81 static const char kConfigurationProperty[];
82 static const char kStateProperty[];
83 static const char kDelayProperty[];
84 static const char kVolumeProperty[];
86 // All possible states of a valid media transport object.
87 static const char kStateIdle[];
88 static const char kStatePending[];
89 static const char kStateActive[];
91 ~BluetoothMediaTransportClient() override;
93 // The ErrorCallback is used by media transport API methods to indicate
94 // failure. It receives two arguments: the name of the error in |error_name|
95 // and an optional message in |error_message|.
96 typedef base::Callback<void(const std::string& error_name,
97 const std::string& error_message)> ErrorCallback;
99 // The AcquireCallback is used by |Acquire| method of media tansport API tp
100 // indicate the success of the method.
101 typedef base::Callback<void(dbus::FileDescriptor* fd,
102 const uint16_t read_mtu,
103 const uint16_t write_mtu)> AcquireCallback;
105 // Adds and removes observers for events on all remote Media Transports. Check
106 // the |object_path| parameter of observer methods to determine which Media
107 // Transport is issuing the event.
108 virtual void AddObserver(Observer* observer) = 0;
109 virtual void RemoveObserver(Observer* observer) = 0;
111 virtual Properties* GetProperties(const dbus::ObjectPath& object_path) = 0;
113 // Acquires transport file descriptor and the MTU for read and write.
114 virtual void Acquire(const dbus::ObjectPath& object_path,
115 const AcquireCallback& callback,
116 const ErrorCallback& error_callback) = 0;
118 // Acquires transport file descriptor only if the transport is in "pending"
119 // state at the time the message is received by BlueZ. Otherwise no request
120 // will be sent to the remote device and the function will just fail with
121 // org.bluez.Error.NotAvailable.
122 virtual void TryAcquire(const dbus::ObjectPath& object_path,
123 const AcquireCallback& callback,
124 const ErrorCallback& error_callback) = 0;
126 // Releases the file descriptor of the transport.
127 virtual void Release(const dbus::ObjectPath& object_path,
128 const base::Closure& callback,
129 const ErrorCallback& error_callback) = 0;
131 static BluetoothMediaTransportClient* Create();
133 protected:
134 BluetoothMediaTransportClient();
136 private:
137 DISALLOW_COPY_AND_ASSIGN(BluetoothMediaTransportClient);
140 } // namespace chromeos
142 #endif // CHROMEOS_DBUS_BLUETOOTH_MEDIA_TRANSPORT_CLIENT_H_