1 /* Copyright (c) 2013 The Chromium OS 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 struct cras_bt_transport *cras_bt_transport_create(DBusConnection *conn, 24 const char *object_path); 25 void cras_bt_transport_set_endpoint(struct cras_bt_transport *transport, 26 struct cras_bt_endpoint *endpoint); 27 28 /* Handles the event when BT stack notifies specific transport is removed. 29 * Args: 30 * transport - The transport object representing an A2DP connection. 31 */ 32 void cras_bt_transport_remove(struct cras_bt_transport *transport); 33 34 /* Queries the state if BT stack has removed given transport. 35 * Args: 36 * transport - The transport object representing an A2DP connection. 37 */ 38 int cras_bt_transport_is_removed(struct cras_bt_transport *transport); 39 40 void cras_bt_transport_destroy(struct cras_bt_transport *transport); 41 void cras_bt_transport_reset(); 42 43 struct cras_bt_transport *cras_bt_transport_get(const char *object_path); 44 size_t 45 cras_bt_transport_get_list(struct cras_bt_transport ***transport_list_out); 46 47 const char * 48 cras_bt_transport_object_path(const struct cras_bt_transport *transport); 49 struct cras_bt_device * 50 cras_bt_transport_device(const struct cras_bt_transport *transport); 51 enum cras_bt_device_profile 52 cras_bt_transport_profile(const struct cras_bt_transport *transport); 53 int cras_bt_transport_configuration(const struct cras_bt_transport *transport, 54 void *configuration, int len); 55 enum cras_bt_transport_state 56 cras_bt_transport_state(const struct cras_bt_transport *transport); 57 58 int cras_bt_transport_fd(const struct cras_bt_transport *transport); 59 uint16_t cras_bt_transport_write_mtu(const struct cras_bt_transport *transport); 60 61 void cras_bt_transport_update_properties( 62 struct cras_bt_transport *transport, 63 DBusMessageIter *properties_array_iter, 64 DBusMessageIter *invalidated_array_iter); 65 66 int cras_bt_transport_try_acquire(struct cras_bt_transport *transport); 67 int cras_bt_transport_acquire(struct cras_bt_transport *transport); 68 69 /* Releases the cras_bt_transport. 70 * Args: 71 * transport - The transport object to release 72 * blocking - True to send release dbus message in blocking mode, otherwise 73 * in non-block mode. 74 */ 75 int cras_bt_transport_release(struct cras_bt_transport *transport, 76 unsigned int blocking); 77 78 /* Sets the volume to cras_bt_transport. Note that the volume gets applied 79 * to BT headset only when the transport is in ACTIVE state. 80 * Args: 81 * transport - The transport object to set volume to. 82 * volume - The desired volume value, range in [0-127]. 83 */ 84 int cras_bt_transport_set_volume(struct cras_bt_transport *transport, 85 uint16_t volume); 86 87 #endif /* CRAS_BT_TRANSPORT_H_ */ 88