Update V8 to version 4.6.54.
[chromium-blink-merge.git] / chromeos / dbus / bluetooth_media_endpoint_service_provider.h
blobfffaa5330d6f4308a52ee8b3ca5e19ba989590fd
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_ENDPOINT_SERVICE_PROVIDER_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_
8 #include <string>
9 #include <vector>
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "dbus/bus.h"
14 #include "dbus/message.h"
15 #include "dbus/object_path.h"
17 namespace chromeos {
19 // BluetoothMediaEndpointServiceProvider is used to provide a D-Bus object that
20 // the Bluetooth daemon can commuicate with to serve as a media source/sink.
22 // Instantiate with a chosen D-Bus object path and a delegate object, and pass
23 // the D-Bus object path as |endpoint_path| argument to the
24 // chromeos::BluetoothMediaClient::RegisterEndoint() method.
26 // After initiating a connection between an audio source and an audio sink, the
27 // Bluetooth daemon will make calls to this endpoint object and they will be
28 // passed to user's Delegate object for handling. For SelectConfiguration method
29 // the response is returned using the SelectConfiguration callback.
30 class CHROMEOS_EXPORT BluetoothMediaEndpointServiceProvider {
31 public:
32 // Delegate is the interface for reacting to endpoint requests. User
33 // applications will implement this interface to handle either A2DP Sink or
34 // Source.
35 class Delegate {
36 public:
37 // Transport-specific properties.
38 struct CHROMEOS_EXPORT TransportProperties {
39 TransportProperties();
40 ~TransportProperties();
42 // The path to the device object which the transport is connected to.
43 dbus::ObjectPath device;
45 // The UUID of the profile which the transport is for.
46 std::string uuid;
48 // The Codec value agreed by the remote device and used by the media
49 // transport.
50 uint8_t codec;
52 // The configuration used by the media transport.
53 std::vector<uint8_t> configuration;
55 // The state of the transport. The values can be one of the following:
56 // "idle": not streaming
57 // "pending": streaming but not acquired
58 // "active": streaming and acquired
59 std::string state;
61 // The unit of transport is in 1/10 millisecond. Optional.
62 scoped_ptr<uint16_t> delay;
64 // The volume level of the transport. Optional.
65 scoped_ptr<uint16_t> volume;
67 private:
68 DISALLOW_COPY_AND_ASSIGN(TransportProperties);
71 virtual ~Delegate() {}
73 // SelectConfigurationCallback is used for the SelectConfiguration() method,
74 // it should be called with two arguements, the |configuration| which is
75 // agreed by the application and the |length| of |configuration|.
76 typedef base::Callback<void(const std::vector<uint8_t>&)>
77 SelectConfigurationCallback;
79 // This method will be called after an Audio Source receives the agreed
80 // capabilities from the Audio Sink to set the configuration for the
81 // media transport object. |transport_path| is the path to the
82 // MediaTransport object, and |properties| are the properties for that
83 // MediaTransport object.
84 virtual void SetConfiguration(const dbus::ObjectPath& transport_path,
85 const TransportProperties& properties) = 0;
87 // This method will be called when an Audio Source connects to an Audio Sink
88 // and asks it to decide the configuration to be used during the oncoming
89 // streaming. Audio Sources provide |capabilities| as a reference, where
90 // a user application can use these |capabilities| to figure out
91 // a well-matched configuration and return it to the Audio Source via
92 // |callback|.
93 virtual void SelectConfiguration(
94 const std::vector<uint8_t>& capabilities,
95 const SelectConfigurationCallback& callback) = 0;
97 // This method will be called when an Audio Source disconnects from an Audio
98 // Sink. A user application is supposed to clear any of its resources which
99 // it keeps for that particular connection. |transport_path| is the Media
100 // Transport object which has been kept by an endpoint during the
101 // connection.
102 virtual void ClearConfiguration(const dbus::ObjectPath& transport_path) = 0;
104 // This method will be called when the Bluetooth daemon unregisters the
105 // Media Endpoint. Media Endpoint objects can use this method to clean up
106 // tasks. There is no need to unregister the endpoint, since when this
107 // method gets called, that endpoint has been unregistered. This corresponds
108 // to the org.bluez.MediaEndpoint1.Release and is renamed to avoid
109 // a conflict with base::RefCounted<T>.
110 virtual void Released() = 0;
113 virtual ~BluetoothMediaEndpointServiceProvider();
115 // Creates the instance where |bus| is the D-Bus bus connection to export the
116 // object onto, |object_path| is the object path that it should have and
117 // |delegate| is the object to which all method calls will be passed and
118 // responses generated from.
119 static BluetoothMediaEndpointServiceProvider* Create(
120 dbus::Bus* bus,
121 const dbus::ObjectPath& object_path,
122 Delegate* delegate);
124 protected:
125 BluetoothMediaEndpointServiceProvider();
127 private:
128 DISALLOW_COPY_AND_ASSIGN(BluetoothMediaEndpointServiceProvider);
131 } // namespace chromeos
133 #endif // CHROMEOS_DBUS_BLUETOOTH_MEDIA_ENDPOINT_SERVICE_PROVIDER_H_