1*ac726063SMatthias Ringwald /* 2*ac726063SMatthias Ringwald * Copyright (C) 2023 BlueKitchen GmbH 3*ac726063SMatthias Ringwald * 4*ac726063SMatthias Ringwald * Redistribution and use in source and binary forms, with or without 5*ac726063SMatthias Ringwald * modification, are permitted provided that the following conditions 6*ac726063SMatthias Ringwald * are met: 7*ac726063SMatthias Ringwald * 8*ac726063SMatthias Ringwald * 1. Redistributions of source code must retain the above copyright 9*ac726063SMatthias Ringwald * notice, this list of conditions and the following disclaimer. 10*ac726063SMatthias Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11*ac726063SMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 12*ac726063SMatthias Ringwald * documentation and/or other materials provided with the distribution. 13*ac726063SMatthias Ringwald * 3. Neither the name of the copyright holders nor the names of 14*ac726063SMatthias Ringwald * contributors may be used to endorse or promote products derived 15*ac726063SMatthias Ringwald * from this software without specific prior written permission. 16*ac726063SMatthias Ringwald * 4. Any redistribution, use, or modification is done solely for 17*ac726063SMatthias Ringwald * personal benefit and not for any commercial purpose or for 18*ac726063SMatthias Ringwald * monetary gain. 19*ac726063SMatthias Ringwald * 20*ac726063SMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21*ac726063SMatthias Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22*ac726063SMatthias Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*ac726063SMatthias Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*ac726063SMatthias Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25*ac726063SMatthias Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26*ac726063SMatthias Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27*ac726063SMatthias Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28*ac726063SMatthias Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29*ac726063SMatthias Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30*ac726063SMatthias Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31*ac726063SMatthias Ringwald * SUCH DAMAGE. 32*ac726063SMatthias Ringwald * 33*ac726063SMatthias Ringwald * Please inquire about commercial licensing options at 34*ac726063SMatthias Ringwald * [email protected] 35*ac726063SMatthias Ringwald * 36*ac726063SMatthias Ringwald */ 37*ac726063SMatthias Ringwald 38*ac726063SMatthias Ringwald /** 39*ac726063SMatthias Ringwald * @title AVRCP Cover Art Client 40*ac726063SMatthias Ringwald * 41*ac726063SMatthias Ringwald */ 42*ac726063SMatthias Ringwald 43*ac726063SMatthias Ringwald #ifndef AVRCP_COVER_ART_CLIENT_H 44*ac726063SMatthias Ringwald #define AVRCP_COVER_ART_CLIENT_H 45*ac726063SMatthias Ringwald 46*ac726063SMatthias Ringwald #include <stdint.h> 47*ac726063SMatthias Ringwald 48*ac726063SMatthias Ringwald #include "bluetooth.h" 49*ac726063SMatthias Ringwald #include "btstack_config.h" 50*ac726063SMatthias Ringwald #include "btstack_defines.h" 51*ac726063SMatthias Ringwald #include "classic/goep_client.h" 52*ac726063SMatthias Ringwald #include "btstack_linked_list.h" 53*ac726063SMatthias Ringwald #include "classic/obex_parser.h" 54*ac726063SMatthias Ringwald #include "l2cap.h" 55*ac726063SMatthias Ringwald 56*ac726063SMatthias Ringwald #if defined __cplusplus 57*ac726063SMatthias Ringwald extern "C" { 58*ac726063SMatthias Ringwald #endif 59*ac726063SMatthias Ringwald 60*ac726063SMatthias Ringwald #ifdef ENABLE_AVRCP_COVER_ART 61*ac726063SMatthias Ringwald typedef enum { 62*ac726063SMatthias Ringwald AVRCP_COVER_ART_INIT = 0, 63*ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_SDP_QUERY_COMPLETE, 64*ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_GOEP_CONNECT, 65*ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_GOEP_CONNECTION, 66*ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_CONNECT_REQUEST, 67*ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_CONNECT_RESPONSE, 68*ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_USER_AUTHENTICATION, 69*ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_AUTHENTICATED_CONNECT, 70*ac726063SMatthias Ringwald AVRCP_COVER_ART_CONNECTED, 71*ac726063SMatthias Ringwald // generic get object 72*ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_GET_OBJECT, 73*ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_OBJECT, 74*ac726063SMatthias Ringwald // disconnect 75*ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_DISCONNECT_REQUEST, 76*ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_DISCONNECT_RESPONSE, 77*ac726063SMatthias Ringwald // abort operation 78*ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_ABORT_COMPLETE, 79*ac726063SMatthias Ringwald } avrcp_cover_art_state_t; 80*ac726063SMatthias Ringwald 81*ac726063SMatthias Ringwald typedef struct { 82*ac726063SMatthias Ringwald uint8_t srm_value; 83*ac726063SMatthias Ringwald uint8_t srmp_value; 84*ac726063SMatthias Ringwald } avrcp_cover_art_obex_srm_t; 85*ac726063SMatthias Ringwald 86*ac726063SMatthias Ringwald typedef enum { 87*ac726063SMatthias Ringwald SRM_DISABLED, 88*ac726063SMatthias Ringwald SRM_W4_CONFIRM, 89*ac726063SMatthias Ringwald SRM_ENABLED_BUT_WAITING, 90*ac726063SMatthias Ringwald SRM_ENABLED 91*ac726063SMatthias Ringwald } avrcp_cover_art_srm_state_t; 92*ac726063SMatthias Ringwald 93*ac726063SMatthias Ringwald typedef struct { 94*ac726063SMatthias Ringwald btstack_linked_item_t item; 95*ac726063SMatthias Ringwald 96*ac726063SMatthias Ringwald uint16_t cover_art_cid; 97*ac726063SMatthias Ringwald uint16_t avrcp_cid; 98*ac726063SMatthias Ringwald bd_addr_t addr; 99*ac726063SMatthias Ringwald 100*ac726063SMatthias Ringwald btstack_packet_handler_t packet_handler; 101*ac726063SMatthias Ringwald 102*ac726063SMatthias Ringwald uint8_t *ertm_buffer; 103*ac726063SMatthias Ringwald uint32_t ertm_buffer_size; 104*ac726063SMatthias Ringwald const l2cap_ertm_config_t * ertm_config; 105*ac726063SMatthias Ringwald 106*ac726063SMatthias Ringwald uint16_t goep_cid; 107*ac726063SMatthias Ringwald goep_client_t goep_client; 108*ac726063SMatthias Ringwald 109*ac726063SMatthias Ringwald avrcp_cover_art_state_t state; 110*ac726063SMatthias Ringwald 111*ac726063SMatthias Ringwald // 112*ac726063SMatthias Ringwald bool flow_control_enabled; 113*ac726063SMatthias Ringwald bool flow_next_triggered; 114*ac726063SMatthias Ringwald bool flow_wait_for_user; 115*ac726063SMatthias Ringwald 116*ac726063SMatthias Ringwald // obex parser 117*ac726063SMatthias Ringwald bool obex_parser_waiting_for_response; 118*ac726063SMatthias Ringwald obex_parser_t obex_parser; 119*ac726063SMatthias Ringwald uint8_t obex_header_buffer[4]; 120*ac726063SMatthias Ringwald 121*ac726063SMatthias Ringwald // obex srm 122*ac726063SMatthias Ringwald avrcp_cover_art_obex_srm_t obex_srm; 123*ac726063SMatthias Ringwald avrcp_cover_art_srm_state_t srm_state; 124*ac726063SMatthias Ringwald 125*ac726063SMatthias Ringwald // request 126*ac726063SMatthias Ringwald const char * object_type; 127*ac726063SMatthias Ringwald const char * image_handle; 128*ac726063SMatthias Ringwald const char * image_descriptor; 129*ac726063SMatthias Ringwald bool first_request; 130*ac726063SMatthias Ringwald 131*ac726063SMatthias Ringwald } avrcp_cover_art_client_t; 132*ac726063SMatthias Ringwald 133*ac726063SMatthias Ringwald /* API_START */ 134*ac726063SMatthias Ringwald 135*ac726063SMatthias Ringwald /** 136*ac726063SMatthias Ringwald * @brief Set up AVRCP Cover Art client 137*ac726063SMatthias Ringwald */ 138*ac726063SMatthias Ringwald void avrcp_cover_art_client_init(void); 139*ac726063SMatthias Ringwald 140*ac726063SMatthias Ringwald /** 141*ac726063SMatthias Ringwald * @brief Connect to AVRCP Cover Art service on a remote device, emits AVRCP_SUBEVENT_COVER_ART_CONNECTION_ESTABLISHED with status 142*ac726063SMatthias Ringwald * @param packet_handler 143*ac726063SMatthias Ringwald * @param remote_addr 144*ac726063SMatthias Ringwald * @param ertm_buffer 145*ac726063SMatthias Ringwald * @param ertm_buffer_size 146*ac726063SMatthias Ringwald * @param ertm_config 147*ac726063SMatthias Ringwald * @param avrcp_cover_art_cid outgoing parameter, valid if status == ERROR_CODE_SUCCESS 148*ac726063SMatthias Ringwald * @return status 149*ac726063SMatthias Ringwald */ 150*ac726063SMatthias Ringwald uint8_t 151*ac726063SMatthias Ringwald avrcp_cover_art_client_connect(avrcp_cover_art_client_t *cover_art_client, btstack_packet_handler_t packet_handler, 152*ac726063SMatthias Ringwald bd_addr_t remote_addr, uint8_t *ertm_buffer, uint32_t ertm_buffer_size, 153*ac726063SMatthias Ringwald const l2cap_ertm_config_t *ertm_config, uint16_t *avrcp_cover_art_cid); 154*ac726063SMatthias Ringwald 155*ac726063SMatthias Ringwald /** 156*ac726063SMatthias Ringwald * @brief Request cover art thumbnail for cover with a given image handle retrieved via 157*ac726063SMatthias Ringwald * - avrcp_controller_get_now_playing_info or 158*ac726063SMatthias Ringwald * - avrcp_controller_get_element_attributes(... AVRCP_MEDIA_ATTR_DEFAULT_COVER_ART ...) 159*ac726063SMatthias Ringwald * @param avrcp_cover_art_cid 160*ac726063SMatthias Ringwald * @param image_handle 161*ac726063SMatthias Ringwald * @return status 162*ac726063SMatthias Ringwald */ 163*ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_get_linked_thumbnail(uint16_t avrcp_cover_art_cid, const char * image_handle); 164*ac726063SMatthias Ringwald 165*ac726063SMatthias Ringwald /** 166*ac726063SMatthias Ringwald * @brief Request cover art image for given image handle retrieved via 167*ac726063SMatthias Ringwald * - avrcp_controller_get_now_playing_info or 168*ac726063SMatthias Ringwald * - avrcp_controller_get_element_attributes(... AVRCP_MEDIA_ATTR_DEFAULT_COVER_ART ...) 169*ac726063SMatthias Ringwald * and given image descriptor 170*ac726063SMatthias Ringwald * @param avrcp_cover_art_cid 171*ac726063SMatthias Ringwald * @param image_handle 172*ac726063SMatthias Ringwald * @param image_descriptor 173*ac726063SMatthias Ringwald * @return status 174*ac726063SMatthias Ringwald */ 175*ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_get_image(uint16_t avrcp_cover_art_cid, const char * image_handle, const char * image_descriptor); 176*ac726063SMatthias Ringwald 177*ac726063SMatthias Ringwald /** 178*ac726063SMatthias Ringwald * @brief Request image properties for given image handle retrieved via 179*ac726063SMatthias Ringwald * - avrcp_controller_get_now_playing_info or 180*ac726063SMatthias Ringwald * - avrcp_controller_get_element_attributes(... AVRCP_MEDIA_ATTR_DEFAULT_COVER_ART ...) 181*ac726063SMatthias Ringwald * @param avrcp_cover_art_cid 182*ac726063SMatthias Ringwald * @param image_handle 183*ac726063SMatthias Ringwald * @return status 184*ac726063SMatthias Ringwald */ 185*ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_get_image_properties(uint16_t avrcp_cover_art_cid, const char * image_handle); 186*ac726063SMatthias Ringwald 187*ac726063SMatthias Ringwald /** 188*ac726063SMatthias Ringwald * @brief Disconnect from AVRCP Cover Art service 189*ac726063SMatthias Ringwald * @param avrcp_cover_art_cid 190*ac726063SMatthias Ringwald * @return status 191*ac726063SMatthias Ringwald */ 192*ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_disconnect(uint16_t avrcp_cover_art_cid); 193*ac726063SMatthias Ringwald 194*ac726063SMatthias Ringwald /** 195*ac726063SMatthias Ringwald * @brief De-Init AVRCP Cover Art Client 196*ac726063SMatthias Ringwald */ 197*ac726063SMatthias Ringwald void avrcp_cover_art_client_deinit(void); 198*ac726063SMatthias Ringwald 199*ac726063SMatthias Ringwald /* API_END */ 200*ac726063SMatthias Ringwald 201*ac726063SMatthias Ringwald #endif 202*ac726063SMatthias Ringwald 203*ac726063SMatthias Ringwald #if defined __cplusplus 204*ac726063SMatthias Ringwald } 205*ac726063SMatthias Ringwald #endif 206*ac726063SMatthias Ringwald 207*ac726063SMatthias Ringwald #endif // AVRCP_COVER_ART_CLIENT_H 208