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_CLIENT_H_
6 #define CHROMEOS_DBUS_BLUETOOTH_MEDIA_CLIENT_H_
12 #include "base/callback.h"
13 #include "base/values.h"
14 #include "chromeos/chromeos_export.h"
15 #include "chromeos/dbus/dbus_client.h"
16 #include "dbus/object_path.h"
17 #include "dbus/property.h"
21 // BluetoothMediaClient is used to communicate with the Media interface of a
22 // local Bluetooth adapter.
23 class CHROMEOS_EXPORT BluetoothMediaClient
: public DBusClient
{
25 // Properties used to register a Media Endpoint.
26 struct CHROMEOS_EXPORT EndpointProperties
{
28 ~EndpointProperties();
30 // UUID of the profile implemented by the endpoint.
33 // Assigned codec value supported by the endpoint. The byte should match the
34 // codec specification indicated by the UUID.
35 // Since SBC codec is mandatory for A2DP, the default value of codec should
39 // Capabilities of the endpoints. The order of bytes should match the bit
40 // arrangement in the specification indicated by the UUID.
41 std::vector
<uint8_t> capabilities
;
46 virtual ~Observer() {}
48 // Called when the Media object with object path |object_path| is added to
50 virtual void MediaAdded(const dbus::ObjectPath
& object_path
) {}
52 // Called when the Media object with object path |object_path| is removed
54 virtual void MediaRemoved(const dbus::ObjectPath
& object_path
) {}
57 // Constants used to indicate exceptional error conditions.
58 static const char kNoResponseError
[];
60 // The string representation for the 128-bit UUID for A2DP Sink.
61 static const char kBluetoothAudioSinkUUID
[];
63 ~BluetoothMediaClient() override
;
65 // The ErrorCallback is used by media API methods to indicate failure.
66 // It receives two arguments: the name of the error in |error_name| and
67 // an optional message in |error_message|.
68 typedef base::Callback
<void(const std::string
& error_name
,
69 const std::string
& error_message
)> ErrorCallback
;
71 // Adds and removes observers for events on all Media objects. Check the
72 // |object_path| parameter of observer methods to determine which Media object
73 // is issuing the event.
74 virtual void AddObserver(Observer
* observer
) = 0;
75 virtual void RemoveObserver(Observer
* observer
) = 0;
77 // Registers a media endpoint to sender at the D-Bus object path
78 // |endpoint_path|. |properties| specifies profile UUID which the endpoint is
79 // for, Codec implemented by the endpoint and the Capabilities of the
81 virtual void RegisterEndpoint(const dbus::ObjectPath
& object_path
,
82 const dbus::ObjectPath
& endpoint_path
,
83 const EndpointProperties
& properties
,
84 const base::Closure
& callback
,
85 const ErrorCallback
& error_callback
) = 0;
87 // Unregisters the media endpoint with the D-Bus object path |endpoint_path|.
88 virtual void UnregisterEndpoint(const dbus::ObjectPath
& object_path
,
89 const dbus::ObjectPath
& endpoint_path
,
90 const base::Closure
& callback
,
91 const ErrorCallback
& error_callback
) = 0;
93 // TODO(mcchou): The RegisterPlayer and UnregisterPlayer methods are not
94 // included, since they are not used. These two methods may be added later.
96 static BluetoothMediaClient
* Create();
99 BluetoothMediaClient();
102 DISALLOW_COPY_AND_ASSIGN(BluetoothMediaClient
);
105 } // namespace chromeos
107 #endif // CHROMEOS_DBUS_BLUETOOTH_MEDIA_CLIENT_H_