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" 55*0de94e45SMatthias Ringwald #include "classic/obex.h" 56*0de94e45SMatthias Ringwald #include "classic/obex_srm_client.h" 57ac726063SMatthias Ringwald 58ac726063SMatthias Ringwald #if defined __cplusplus 59ac726063SMatthias Ringwald extern "C" { 60ac726063SMatthias Ringwald #endif 61ac726063SMatthias Ringwald 62ac726063SMatthias Ringwald #ifdef ENABLE_AVRCP_COVER_ART 63ac726063SMatthias Ringwald typedef enum { 64ac726063SMatthias Ringwald AVRCP_COVER_ART_INIT = 0, 65ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_SDP_QUERY_COMPLETE, 66ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_GOEP_CONNECT, 67ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_GOEP_CONNECTION, 68ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_CONNECT_REQUEST, 69ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_CONNECT_RESPONSE, 70ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_USER_AUTHENTICATION, 71ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_AUTHENTICATED_CONNECT, 72ac726063SMatthias Ringwald AVRCP_COVER_ART_CONNECTED, 73ac726063SMatthias Ringwald // generic get object 74ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_GET_OBJECT, 75ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_OBJECT, 76ac726063SMatthias Ringwald // disconnect 77ac726063SMatthias Ringwald AVRCP_COVER_ART_W2_SEND_DISCONNECT_REQUEST, 78ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_DISCONNECT_RESPONSE, 79ac726063SMatthias Ringwald // abort operation 80ac726063SMatthias Ringwald AVRCP_COVER_ART_W4_ABORT_COMPLETE, 81ac726063SMatthias Ringwald } avrcp_cover_art_state_t; 82ac726063SMatthias Ringwald 83f3827b09SMatthias Ringwald typedef struct { 84ac726063SMatthias Ringwald btstack_linked_item_t item; 85ac726063SMatthias Ringwald 86ac726063SMatthias Ringwald uint16_t cover_art_cid; 87ac726063SMatthias Ringwald uint16_t avrcp_cid; 88ac726063SMatthias Ringwald bd_addr_t addr; 89ac726063SMatthias Ringwald 90ac726063SMatthias Ringwald btstack_packet_handler_t packet_handler; 91ac726063SMatthias Ringwald 92ac726063SMatthias Ringwald uint8_t *ertm_buffer; 93ac726063SMatthias Ringwald uint32_t ertm_buffer_size; 94ac726063SMatthias Ringwald const l2cap_ertm_config_t * ertm_config; 95ac726063SMatthias Ringwald 96ac726063SMatthias Ringwald uint16_t goep_cid; 97ac726063SMatthias Ringwald goep_client_t goep_client; 98ac726063SMatthias Ringwald 99ac726063SMatthias Ringwald avrcp_cover_art_state_t state; 100ac726063SMatthias Ringwald 101ac726063SMatthias Ringwald // 102ac726063SMatthias Ringwald bool flow_control_enabled; 103ac726063SMatthias Ringwald bool flow_next_triggered; 104ac726063SMatthias Ringwald bool flow_wait_for_user; 105ac726063SMatthias Ringwald 106ac726063SMatthias Ringwald // obex parser 107ac726063SMatthias Ringwald bool obex_parser_waiting_for_response; 108ac726063SMatthias Ringwald obex_parser_t obex_parser; 109ac726063SMatthias Ringwald uint8_t obex_header_buffer[4]; 110ac726063SMatthias Ringwald 111ac726063SMatthias Ringwald // obex srm 112*0de94e45SMatthias Ringwald obex_srm_client_t obex_srm; 113ac726063SMatthias Ringwald 114ac726063SMatthias Ringwald // request 115ac726063SMatthias Ringwald const char * object_type; 116ac726063SMatthias Ringwald const char * image_handle; 117ac726063SMatthias Ringwald const char * image_descriptor; 118ac726063SMatthias Ringwald bool first_request; 119ac726063SMatthias Ringwald 120ac726063SMatthias Ringwald } avrcp_cover_art_client_t; 121ac726063SMatthias Ringwald 122ac726063SMatthias Ringwald /* API_START */ 123ac726063SMatthias Ringwald 124ac726063SMatthias Ringwald /** 125ac726063SMatthias Ringwald * @brief Set up AVRCP Cover Art client 126ac726063SMatthias Ringwald */ 127ac726063SMatthias Ringwald void avrcp_cover_art_client_init(void); 128ac726063SMatthias Ringwald 129ac726063SMatthias Ringwald /** 130ac726063SMatthias Ringwald * @brief Connect to AVRCP Cover Art service on a remote device, emits AVRCP_SUBEVENT_COVER_ART_CONNECTION_ESTABLISHED with status 131ac726063SMatthias Ringwald * @param packet_handler 132ac726063SMatthias Ringwald * @param remote_addr 133ac726063SMatthias Ringwald * @param ertm_buffer 134ac726063SMatthias Ringwald * @param ertm_buffer_size 135ac726063SMatthias Ringwald * @param ertm_config 136ac726063SMatthias Ringwald * @param avrcp_cover_art_cid outgoing parameter, valid if status == ERROR_CODE_SUCCESS 137ac726063SMatthias Ringwald * @return status 138ac726063SMatthias Ringwald */ 139ac726063SMatthias Ringwald uint8_t 140ac726063SMatthias Ringwald avrcp_cover_art_client_connect(avrcp_cover_art_client_t *cover_art_client, btstack_packet_handler_t packet_handler, 141ac726063SMatthias Ringwald bd_addr_t remote_addr, uint8_t *ertm_buffer, uint32_t ertm_buffer_size, 142ac726063SMatthias Ringwald const l2cap_ertm_config_t *ertm_config, uint16_t *avrcp_cover_art_cid); 143ac726063SMatthias Ringwald 144ac726063SMatthias Ringwald /** 145ac726063SMatthias Ringwald * @brief Request cover art thumbnail for cover with a given image handle retrieved via 146ac726063SMatthias Ringwald * - avrcp_controller_get_now_playing_info or 147ac726063SMatthias Ringwald * - avrcp_controller_get_element_attributes(... AVRCP_MEDIA_ATTR_DEFAULT_COVER_ART ...) 148ac726063SMatthias Ringwald * @param avrcp_cover_art_cid 149ac726063SMatthias Ringwald * @param image_handle 150ac726063SMatthias Ringwald * @return status 151ac726063SMatthias Ringwald */ 152ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_get_linked_thumbnail(uint16_t avrcp_cover_art_cid, const char * image_handle); 153ac726063SMatthias Ringwald 154ac726063SMatthias Ringwald /** 155ac726063SMatthias Ringwald * @brief Request cover art image for given image handle retrieved via 156ac726063SMatthias Ringwald * - avrcp_controller_get_now_playing_info or 157ac726063SMatthias Ringwald * - avrcp_controller_get_element_attributes(... AVRCP_MEDIA_ATTR_DEFAULT_COVER_ART ...) 158ac726063SMatthias Ringwald * and given image descriptor 159ac726063SMatthias Ringwald * @param avrcp_cover_art_cid 160ac726063SMatthias Ringwald * @param image_handle 161ac726063SMatthias Ringwald * @param image_descriptor 162ac726063SMatthias Ringwald * @return status 163ac726063SMatthias Ringwald */ 164ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_get_image(uint16_t avrcp_cover_art_cid, const char * image_handle, const char * image_descriptor); 165ac726063SMatthias Ringwald 166ac726063SMatthias Ringwald /** 167ac726063SMatthias Ringwald * @brief Request image properties 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 * @param avrcp_cover_art_cid 171ac726063SMatthias Ringwald * @param image_handle 172ac726063SMatthias Ringwald * @return status 173ac726063SMatthias Ringwald */ 174ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_get_image_properties(uint16_t avrcp_cover_art_cid, const char * image_handle); 175ac726063SMatthias Ringwald 176ac726063SMatthias Ringwald /** 177ac726063SMatthias Ringwald * @brief Disconnect from AVRCP Cover Art service 178ac726063SMatthias Ringwald * @param avrcp_cover_art_cid 179ac726063SMatthias Ringwald * @return status 180ac726063SMatthias Ringwald */ 181ac726063SMatthias Ringwald uint8_t avrcp_cover_art_client_disconnect(uint16_t avrcp_cover_art_cid); 182ac726063SMatthias Ringwald 183ac726063SMatthias Ringwald /** 184ac726063SMatthias Ringwald * @brief De-Init AVRCP Cover Art Client 185ac726063SMatthias Ringwald */ 186ac726063SMatthias Ringwald void avrcp_cover_art_client_deinit(void); 187ac726063SMatthias Ringwald 188ac726063SMatthias Ringwald /* API_END */ 189ac726063SMatthias Ringwald 190ac726063SMatthias Ringwald #endif 191ac726063SMatthias Ringwald 192ac726063SMatthias Ringwald #if defined __cplusplus 193ac726063SMatthias Ringwald } 194ac726063SMatthias Ringwald #endif 195ac726063SMatthias Ringwald 196ac726063SMatthias Ringwald #endif // AVRCP_COVER_ART_CLIENT_H 197