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