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