1 /* Copyright 2016 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_PLAYER_H_ 7 #define CRAS_BT_PLAYER_H_ 8 9 #include <dbus/dbus.h> 10 #include <stdbool.h> 11 12 #include "cras_bt_adapter.h" 13 14 /* Object to hold current metadata. This is not a full list of what BlueZ/MPRIS 15 * supports but a subset because Chromium only provides the following. 16 */ 17 struct cras_bt_player_metadata { 18 char *title; 19 char *artist; 20 char *album; 21 int64_t length; 22 }; 23 24 /* Object to register as media player so that bluetoothd will report hardware 25 * volume from device through bt_transport. Properties of the player are defined 26 * in BlueZ's media API. 27 */ 28 struct cras_bt_player { 29 const char *object_path; 30 char *playback_status; 31 char *identity; 32 const char *loop_status; 33 struct cras_bt_player_metadata *metadata; 34 int64_t position; 35 bool can_go_next; 36 bool can_go_prev; 37 bool can_play; 38 bool can_pause; 39 bool can_control; 40 bool shuffle; 41 void (*message_cb)(const char *message); 42 }; 43 44 /* Creates a player object and register it to bluetoothd. 45 * Args: 46 * conn - The dbus connection. 47 */ 48 int cras_bt_player_create(DBusConnection *conn); 49 50 /* Registers created player to bluetoothd. This is used when an bluetooth 51 * adapter got enumerated. 52 * Args: 53 * conn - The dbus connection. 54 * adapter - The enumerated bluetooth adapter. 55 */ 56 int cras_bt_register_player(DBusConnection *conn, 57 const struct cras_bt_adapter *adapter); 58 59 /* Updates playback status for player and notifies bluetoothd 60 * Args: 61 * conn - The dbus connection. 62 * status - The player playback status. 63 */ 64 int cras_bt_player_update_playback_status(DBusConnection *conn, 65 const char *status); 66 67 /* Updates the player identity and notifies bluetoothd. 68 * Args: 69 * conn - The dbus connection. 70 * identity - The identity of the registered player. This could be the name 71 * of the app or the name of the site playing media. 72 */ 73 int cras_bt_player_update_identity(DBusConnection *conn, const char *identity); 74 75 /* Updates the player current track's position and notifies bluetoothd. 76 * Args: 77 * conn - The dbus connection. 78 * position - The current track position in microseconds. 79 */ 80 int cras_bt_player_update_position(DBusConnection *conn, 81 const dbus_int64_t position); 82 83 /* Updates the player current metadata and notifies bluetoothd. 84 * Args: 85 * conn - The dbus connection. 86 * title - The title associated to the current media session. 87 * artist - The artist associated to the current media session. 88 * album - The album associated to the current media session. 89 * length - The duration in microseconds associated to the current media 90 * session. 91 */ 92 int cras_bt_player_update_metadata(DBusConnection *conn, const char *title, 93 const char *artist, const char *album, 94 const dbus_int64_t length); 95 #endif /* CRAS_BT_PLAYER_H_ */ 96