1 /* 2 * Copyright (C) 2016 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 3. Neither the name of the copyright holders nor the names of 14 * contributors may be used to endorse or promote products derived 15 * from this software without specific prior written permission. 16 * 4. Any redistribution, use, or modification is done solely for 17 * personal benefit and not for any commercial purpose or for 18 * monetary gain. 19 * 20 * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MATTHIAS 24 * RINGWALD OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * Please inquire about commercial licensing options at 34 * [email protected] 35 * 36 */ 37 38 /* 39 * @title AVRCP Target 40 * 41 */ 42 43 #ifndef AVRCP_TARGET_H 44 #define AVRCP_TARGET_H 45 46 #include <stdint.h> 47 #include "classic/avrcp.h" 48 49 #if defined __cplusplus 50 extern "C" { 51 #endif 52 53 /* API_START */ 54 55 typedef enum { 56 AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_PLAYER_OR_RECORDER = 0, 57 AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_MONITOR_OR_AMPLIFIER, 58 AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_TUNER, 59 AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_MENU, 60 AVRCP_TARGET_SUPPORTED_FEATURE_PLAYER_APPLICATION_SETTINGS, // AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_PLAYER_OR_RECORDER must be 1 for this feature to be set 61 AVRCP_TARGET_SUPPORTED_FEATURE_RESERVED_GROUP_NAVIGATION, // AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_PLAYER_OR_RECORDER must be 1 for this feature to be set 62 AVRCP_TARGET_SUPPORTED_FEATURE_BROWSING, 63 AVRCP_TARGET_SUPPORTED_FEATURE_MULTIPLE_MEDIA_PLAYE_APPLICATIONS 64 } avrcp_target_supported_feature_t; 65 66 /** 67 * @brief AVRCP Target service record. 68 * @param service 69 * @param service_record_handle 70 * @param supported_features 16-bit bitmap, see AVRCP_FEATURE_MASK_* in avrcp.h 71 * @param service_name 72 * @param service_provider_name 73 */ 74 void avrcp_target_create_sdp_record(uint8_t * service, uint32_t service_record_handle, uint16_t supported_features, const char * service_name, const char * service_provider_name); 75 76 /** 77 * @brief Set up AVRCP Target service. 78 */ 79 void avrcp_target_init(void); 80 81 /** 82 * @brief Register callback for the AVRCP Target client. 83 * @param callback 84 */ 85 void avrcp_target_register_packet_handler(btstack_packet_handler_t callback); 86 87 /** 88 * @brief Select Player that is controlled by Controller 89 * @param callback 90 * @note Callback should return if selected player is valid 91 */ 92 void avrcp_target_register_set_addressed_player_handler(bool (*callback)(uint16_t player_id)); 93 94 /** 95 * @brief Send a list of Company IDs supported by target. 96 * @note The avrcp_target_packet_handler will receive AVRCP_SUBEVENT_COMPANY_IDS_QUERY event. Use this function to respond. 97 * @param avrcp_cid 98 * @param num_company_ids 99 * @param company_ids 100 * @param company_ids_size 101 * @returns status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 102 */ 103 uint8_t avrcp_target_supported_companies(uint16_t avrcp_cid, uint8_t num_company_ids, const uint8_t *company_ids, uint8_t company_ids_size); 104 105 /** 106 * @brief Send a list of Events supported by target. 107 * @note The avrcp_target_packet_handler will receive AVRCP_SUBEVENT_EVENT_IDS_QUERY event. Use this function to respond. 108 * @param avrcp_cid 109 * @param num_event_ids 110 * @param event_ids 111 * @param event_ids_size 112 * @returns status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 113 */ 114 uint8_t avrcp_target_supported_events(uint16_t avrcp_cid, uint8_t num_event_ids, const uint8_t *event_ids, uint8_t event_ids_size); 115 116 /** 117 * @brief Send a play status. 118 * @note The avrcp_target_packet_handler will receive AVRCP_SUBEVENT_PLAY_STATUS_QUERY event. Use this function to respond. 119 * @param avrcp_cid 120 * @param song_length_ms 121 * @param song_position_ms 122 * @returns status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 123 */ 124 uint8_t avrcp_target_play_status(uint16_t avrcp_cid, uint32_t song_length_ms, uint32_t song_position_ms, avrcp_playback_status_t status); 125 126 /** 127 * @param Set Now Playing Info that is send to Controller if notifications are enabled 128 * @param avrcp_cid 129 * @param current_track 130 * @param total_tracks 131 */ 132 void avrcp_target_set_now_playing_info(uint16_t avrcp_cid, const avrcp_track_t * current_track, uint16_t total_tracks); 133 134 /** 135 * @param Set Playing status and send to Controller 136 * @param avrcp_cid 137 * @param playback_status 138 * @return 139 */ 140 uint8_t avrcp_target_set_playback_status(uint16_t avrcp_cid, avrcp_playback_status_t playback_status); 141 142 /** 143 * @param Set Unit Info 144 * @param avrcp_cid 145 * @param unit_type 146 * @param company_id 147 */ 148 void avrcp_target_set_unit_info(uint16_t avrcp_cid, avrcp_subunit_type_t unit_type, uint32_t company_id); 149 150 /** 151 * @param Set Subunit Info 152 * @param avrcp_cid 153 * @param subunit_type 154 * @param subunit_info_data 155 * @param subunit_info_data_size 156 */ 157 void avrcp_target_set_subunit_info(uint16_t avrcp_cid, avrcp_subunit_type_t subunit_type, const uint8_t * subunit_info_data, uint16_t subunit_info_data_size); 158 159 /** 160 * @param Send Playing Content Changed Notification if enabled 161 * @param avrcp_cid 162 * @return 163 */ 164 uint8_t avrcp_target_playing_content_changed(uint16_t avrcp_cid); 165 166 /** 167 * @param Send Addressed Player Changed Notification if enabled 168 * @param avrcp_cid 169 * @param player_id 170 * @param uid_counter 171 * @return 172 */ 173 uint8_t avrcp_target_addressed_player_changed(uint16_t avrcp_cid, uint16_t player_id, uint16_t uid_counter); 174 175 /** 176 * @param Set Battery Status Changed and send notification if enabled 177 * @param avrcp_cid 178 * @param battery_status 179 * @return 180 */ 181 uint8_t avrcp_target_battery_status_changed(uint16_t avrcp_cid, avrcp_battery_status_t battery_status); 182 183 /** 184 * @param Set Volume and send notification if enabled 185 * @param avrcp_cid 186 * @param volume_percentage 187 * @return 188 */ 189 uint8_t avrcp_target_volume_changed(uint16_t avrcp_cid, uint8_t volume_percentage); 190 191 /** 192 * @param Set Track and send notification if enabled 193 * @param avrcp_cid 194 * @param trackID 195 * @return 196 */ 197 uint8_t avrcp_target_track_changed(uint16_t avrcp_cid, uint8_t * trackID); 198 199 /** 200 * @param Send Operation Rejected message 201 * @param avrcp_cid 202 * @param opid 203 * @param operands_length 204 * @param operand 205 * @return 206 */ 207 uint8_t avrcp_target_operation_rejected(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 208 209 /** 210 * @param Send Operation Accepted message 211 * @param avrcp_cid 212 * @param opid 213 * @param operands_length 214 * @param operand 215 * @return 216 */ 217 uint8_t avrcp_target_operation_accepted(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 218 219 /** 220 * @param Send Operation Not Implemented message 221 * @param avrcp_cid 222 * @param opid 223 * @param operands_length 224 * @param operand 225 * @return 226 */ 227 uint8_t avrcp_target_operation_not_implemented(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 228 229 /** 230 * @brief De-Init AVRCP Browsing Target 231 */ 232 void avrcp_target_deinit(void); 233 234 /* API_END */ 235 236 // Used by AVRCP target and AVRCP browsing target 237 extern avrcp_context_t avrcp_target_context; 238 239 #if defined __cplusplus 240 } 241 #endif 242 243 #endif // AVRCP_TARGET_H 244