1 /* Copyright (c) 2013 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. 4 */ 5 6 #ifndef CRAS_BT_TRANSPORT_H_ 7 #define CRAS_BT_TRANSPORT_H_ 8 9 #include <dbus/dbus.h> 10 #include <stdint.h> 11 12 #include "cras_bt_device.h" 13 14 struct cras_bt_endpoint; 15 struct cras_bt_transport; 16 17 enum cras_bt_transport_state { 18 CRAS_BT_TRANSPORT_STATE_IDLE, 19 CRAS_BT_TRANSPORT_STATE_PENDING, 20 CRAS_BT_TRANSPORT_STATE_ACTIVE 21 }; 22 23 24 struct cras_bt_transport *cras_bt_transport_create(DBusConnection *conn, 25 const char *object_path); 26 void cras_bt_transport_set_endpoint(struct cras_bt_transport *transport, 27 struct cras_bt_endpoint *endpoint); 28 void cras_bt_transport_destroy(struct cras_bt_transport *transport); 29 void cras_bt_transport_reset(); 30 31 struct cras_bt_transport *cras_bt_transport_get(const char *object_path); 32 size_t cras_bt_transport_get_list( 33 struct cras_bt_transport ***transport_list_out); 34 35 const char *cras_bt_transport_object_path( 36 const struct cras_bt_transport *transport); 37 struct cras_bt_device *cras_bt_transport_device( 38 const struct cras_bt_transport *transport); 39 enum cras_bt_device_profile cras_bt_transport_profile( 40 const struct cras_bt_transport *transport); 41 int cras_bt_transport_configuration(const struct cras_bt_transport *transport, 42 void *configuration, int len); 43 enum cras_bt_transport_state cras_bt_transport_state( 44 const struct cras_bt_transport *transport); 45 46 int cras_bt_transport_fd(const struct cras_bt_transport *transport); 47 uint16_t cras_bt_transport_write_mtu(const struct cras_bt_transport *transport); 48 49 void cras_bt_transport_update_properties( 50 struct cras_bt_transport *transport, 51 DBusMessageIter *properties_array_iter, 52 DBusMessageIter *invalidated_array_iter); 53 54 int cras_bt_transport_try_acquire(struct cras_bt_transport *transport); 55 int cras_bt_transport_acquire(struct cras_bt_transport *transport); 56 57 /* Releases the cras_bt_transport. 58 * Args: 59 * transport - The transport object to release 60 * blocking - True to send release dbus message in blocking mode, otherwise 61 * in non-block mode. 62 */ 63 int cras_bt_transport_release(struct cras_bt_transport *transport, 64 unsigned int blocking); 65 66 /* Sets the volume to cras_bt_transport. Note that the volume gets applied 67 * to BT headset only when the transport is in ACTIVE state. 68 * Args: 69 * transport - The transport object to set volume to. 70 * volume - The desired volume value, range in [0-127]. 71 */ 72 int cras_bt_transport_set_volume(struct cras_bt_transport *transport, 73 uint16_t volume); 74 75 #endif /* CRAS_BT_TRANSPORT_H_ */ 76