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 Register a list of Company IDs supported by target. 96 * @param avrcp_cid 97 * @param num_companies 98 * @param companies 99 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 100 */ 101 uint8_t avrcp_target_support_companies(uint16_t avrcp_cid, uint8_t num_companies, const uint32_t *companies); 102 103 /** 104 * @brief Register event ID supported by target. 105 * @param avrcp_cid 106 * @param event_id 107 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE for unsupported event id, otherwise ERROR_CODE_SUCCESS, 108 */ 109 uint8_t avrcp_target_support_event(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 110 111 /** 112 * @brief Send a play status. 113 * @note The avrcp_target_packet_handler will receive AVRCP_SUBEVENT_PLAY_STATUS_QUERY event. Use this function to respond. 114 * @param avrcp_cid 115 * @param song_length_ms 116 * @param song_position_ms 117 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 118 */ 119 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); 120 121 /** 122 * @brief Set Now Playing Info that is send to Controller if notifications are enabled 123 * @param avrcp_cid 124 * @param current_track 125 * @param total_tracks 126 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, ERROR_CODE_COMMAND_DISALLOWED if no track is provided, otherwise ERROR_CODE_SUCCESS 127 */ 128 uint8_t avrcp_target_set_now_playing_info(uint16_t avrcp_cid, const avrcp_track_t * current_track, uint16_t total_tracks); 129 130 /** 131 * @brief Set Playing status and send to Controller 132 * @param avrcp_cid 133 * @param playback_status 134 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 135 */ 136 uint8_t avrcp_target_set_playback_status(uint16_t avrcp_cid, avrcp_playback_status_t playback_status); 137 138 /** 139 * @brief Set Unit Info 140 * @param avrcp_cid 141 * @param unit_type 142 * @param company_id 143 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 144 */ 145 uint8_t avrcp_target_set_unit_info(uint16_t avrcp_cid, avrcp_subunit_type_t unit_type, uint32_t company_id); 146 147 /** 148 * @brief Set Subunit Info 149 * @param avrcp_cid 150 * @param subunit_type 151 * @param subunit_info_data 152 * @param subunit_info_data_size 153 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 154 */ 155 uint8_t 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); 156 157 /** 158 * @brief Send Playing Content Changed Notification if enabled 159 * @param avrcp_cid 160 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 161 */ 162 uint8_t avrcp_target_playing_content_changed(uint16_t avrcp_cid); 163 164 /** 165 * @brief Send Addressed Player Changed Notification if enabled 166 * @param avrcp_cid 167 * @param player_id 168 * @param uid_counter 169 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 170 */ 171 uint8_t avrcp_target_addressed_player_changed(uint16_t avrcp_cid, uint16_t player_id, uint16_t uid_counter); 172 173 /** 174 * @brief Set Battery Status Changed and send notification if enabled 175 * @param avrcp_cid 176 * @param battery_status 177 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 178 */ 179 uint8_t avrcp_target_battery_status_changed(uint16_t avrcp_cid, avrcp_battery_status_t battery_status); 180 181 /** 182 * @brief Overwrite the absolute volume requested by controller with the actual absolute volume. 183 * This function can only be called on AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED event, which indicates a set absolute volume request by controller. 184 * If the absolute volume requested by controller does not match the granularity of volume control the TG provides, you can use this function to adjust the actual value. 185 * 186 * @param avrcp_cid 187 * @param absolute_volume 188 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 189 */ 190 uint8_t avrcp_target_adjust_absolute_volume(uint16_t avrcp_cid, uint8_t absolute_volume); 191 192 193 /** 194 * @brief Set Absolute Volume and send notification if enabled 195 * @param avrcp_cid 196 * @param absolute_volume 197 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 198 */ 199 uint8_t avrcp_target_volume_changed(uint16_t avrcp_cid, uint8_t absolute_volume); 200 201 /** 202 * @brief Set Track and send notification if enabled 203 * @param avrcp_cid 204 * @param trackID 205 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 206 */ 207 uint8_t avrcp_target_track_changed(uint16_t avrcp_cid, uint8_t * trackID); 208 209 /** 210 * @brief Send Operation Rejected message 211 * @param avrcp_cid 212 * @param opid 213 * @param operands_length 214 * @param operand 215 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 216 */ 217 uint8_t avrcp_target_operation_rejected(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 218 219 /** 220 * @brief Send Operation Accepted message 221 * @param avrcp_cid 222 * @param opid 223 * @param operands_length 224 * @param operand 225 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 226 */ 227 uint8_t avrcp_target_operation_accepted(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 228 229 /** 230 * @brief Send Operation Not Implemented message 231 * @param avrcp_cid 232 * @param opid 233 * @param operands_length 234 * @param operand 235 * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 236 */ 237 uint8_t avrcp_target_operation_not_implemented(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 238 239 /** 240 * @brief De-Init AVRCP Browsing Target 241 */ 242 void avrcp_target_deinit(void); 243 244 /* API_END */ 245 246 // Used by AVRCP target and AVRCP browsing target 247 extern avrcp_context_t avrcp_target_context; 248 249 #if defined __cplusplus 250 } 251 #endif 252 253 #endif // AVRCP_TARGET_H 254