16983e65eSMilanka Ringwald /* 26983e65eSMilanka Ringwald * Copyright (C) 2016 BlueKitchen GmbH 36983e65eSMilanka Ringwald * 46983e65eSMilanka Ringwald * Redistribution and use in source and binary forms, with or without 56983e65eSMilanka Ringwald * modification, are permitted provided that the following conditions 66983e65eSMilanka Ringwald * are met: 76983e65eSMilanka Ringwald * 86983e65eSMilanka Ringwald * 1. Redistributions of source code must retain the above copyright 96983e65eSMilanka Ringwald * notice, this list of conditions and the following disclaimer. 106983e65eSMilanka Ringwald * 2. Redistributions in binary form must reproduce the above copyright 116983e65eSMilanka Ringwald * notice, this list of conditions and the following disclaimer in the 126983e65eSMilanka Ringwald * documentation and/or other materials provided with the distribution. 136983e65eSMilanka Ringwald * 3. Neither the name of the copyright holders nor the names of 146983e65eSMilanka Ringwald * contributors may be used to endorse or promote products derived 156983e65eSMilanka Ringwald * from this software without specific prior written permission. 166983e65eSMilanka Ringwald * 4. Any redistribution, use, or modification is done solely for 176983e65eSMilanka Ringwald * personal benefit and not for any commercial purpose or for 186983e65eSMilanka Ringwald * monetary gain. 196983e65eSMilanka Ringwald * 206983e65eSMilanka Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 216983e65eSMilanka Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 226983e65eSMilanka Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23*2fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 24*2fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 256983e65eSMilanka Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 266983e65eSMilanka Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 276983e65eSMilanka Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 286983e65eSMilanka Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 296983e65eSMilanka Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 306983e65eSMilanka Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 316983e65eSMilanka Ringwald * SUCH DAMAGE. 326983e65eSMilanka Ringwald * 336983e65eSMilanka Ringwald * Please inquire about commercial licensing options at 346983e65eSMilanka Ringwald * [email protected] 356983e65eSMilanka Ringwald * 366983e65eSMilanka Ringwald */ 376983e65eSMilanka Ringwald 386983e65eSMilanka Ringwald /* 39fe5a6c4eSMilanka Ringwald * @title AVRCP Target 406983e65eSMilanka Ringwald * 416983e65eSMilanka Ringwald */ 426983e65eSMilanka Ringwald 4380e33422SMatthias Ringwald #ifndef AVRCP_TARGET_H 4480e33422SMatthias Ringwald #define AVRCP_TARGET_H 456983e65eSMilanka Ringwald 466983e65eSMilanka Ringwald #include <stdint.h> 473311c2d5SMatthias Ringwald #include "classic/avrcp.h" 486983e65eSMilanka Ringwald 496983e65eSMilanka Ringwald #if defined __cplusplus 506983e65eSMilanka Ringwald extern "C" { 516983e65eSMilanka Ringwald #endif 526983e65eSMilanka Ringwald 536983e65eSMilanka Ringwald /* API_START */ 546983e65eSMilanka Ringwald 5511014891SMilanka Ringwald typedef enum { 5611014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_PLAYER_OR_RECORDER = 0, 5711014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_MONITOR_OR_AMPLIFIER, 5811014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_TUNER, 5911014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_MENU, 6011014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_PLAYER_APPLICATION_SETTINGS, // AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_PLAYER_OR_RECORDER must be 1 for this feature to be set 6111014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_RESERVED_GROUP_NAVIGATION, // AVRCP_TARGET_SUPPORTED_FEATURE_CATEGORY_PLAYER_OR_RECORDER must be 1 for this feature to be set 6211014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_BROWSING, 6311014891SMilanka Ringwald AVRCP_TARGET_SUPPORTED_FEATURE_MULTIPLE_MEDIA_PLAYE_APPLICATIONS 6411014891SMilanka Ringwald } avrcp_target_supported_feature_t; 656983e65eSMilanka Ringwald 666983e65eSMilanka Ringwald /** 67f65a5459SMilanka Ringwald * @brief AVRCP Target service record. 686983e65eSMilanka Ringwald * @param service 696983e65eSMilanka Ringwald * @param service_record_handle 70e2f25417SMilanka Ringwald * @param supported_features 16-bit bitmap, see AVRCP_FEATURE_MASK_* in avrcp.h 716983e65eSMilanka Ringwald * @param service_name 726983e65eSMilanka Ringwald * @param service_provider_name 736983e65eSMilanka Ringwald */ 744f0111ebSMilanka Ringwald 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); 756983e65eSMilanka Ringwald 763734adacSMilanka Ringwald /** 773734adacSMilanka Ringwald * @brief Set up AVRCP Target service. 783734adacSMilanka Ringwald */ 7901dc6e35SMilanka Ringwald void avrcp_target_init(void); 8001dc6e35SMilanka Ringwald 813734adacSMilanka Ringwald /** 823734adacSMilanka Ringwald * @brief Register callback for the AVRCP Target client. 833734adacSMilanka Ringwald * @param callback 843734adacSMilanka Ringwald */ 8501dc6e35SMilanka Ringwald void avrcp_target_register_packet_handler(btstack_packet_handler_t callback); 8601dc6e35SMilanka Ringwald 873734adacSMilanka Ringwald /** 88d1cf25b1SMatthias Ringwald * @brief Select Player that is controlled by Controller 89d1cf25b1SMatthias Ringwald * @param callback 90d1cf25b1SMatthias Ringwald * @note Callback should return if selected player is valid 91d1cf25b1SMatthias Ringwald */ 92d1cf25b1SMatthias Ringwald void avrcp_target_register_set_addressed_player_handler(bool (*callback)(uint16_t player_id)); 93d1cf25b1SMatthias Ringwald 94d1cf25b1SMatthias Ringwald /** 950346f11dSMilanka Ringwald * @brief Register a list of Company IDs supported by target. 963734adacSMilanka Ringwald * @param avrcp_cid 970346f11dSMilanka Ringwald * @param num_companies 980346f11dSMilanka Ringwald * @param companies 992a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 1003734adacSMilanka Ringwald */ 1010346f11dSMilanka Ringwald uint8_t avrcp_target_support_companies(uint16_t avrcp_cid, uint8_t num_companies, const uint32_t *companies); 10201dc6e35SMilanka Ringwald 1033734adacSMilanka Ringwald /** 1040346f11dSMilanka Ringwald * @brief Register event ID supported by target. 1053734adacSMilanka Ringwald * @param avrcp_cid 1060346f11dSMilanka Ringwald * @param event_id 1070346f11dSMilanka Ringwald * @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, 1083734adacSMilanka Ringwald */ 1090346f11dSMilanka Ringwald uint8_t avrcp_target_support_event(uint16_t avrcp_cid, avrcp_notification_event_id_t event_id); 1103734adacSMilanka Ringwald 1113734adacSMilanka Ringwald /** 1123734adacSMilanka Ringwald * @brief Send a play status. 1133734adacSMilanka Ringwald * @note The avrcp_target_packet_handler will receive AVRCP_SUBEVENT_PLAY_STATUS_QUERY event. Use this function to respond. 1143734adacSMilanka Ringwald * @param avrcp_cid 1153734adacSMilanka Ringwald * @param song_length_ms 1163734adacSMilanka Ringwald * @param song_position_ms 1172a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 1183734adacSMilanka Ringwald */ 119d1207cd8SMilanka Ringwald 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); 120c045af99SMilanka Ringwald 121fe9491e7SMatthias Ringwald /** 1222a59ace6SMilanka Ringwald * @brief Set Now Playing Info that is send to Controller if notifications are enabled 123fe9491e7SMatthias Ringwald * @param avrcp_cid 124fe9491e7SMatthias Ringwald * @param current_track 125fe9491e7SMatthias Ringwald * @param total_tracks 1262a59ace6SMilanka Ringwald * @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 127fe9491e7SMatthias Ringwald */ 12861a3437bSMilanka Ringwald uint8_t avrcp_target_set_now_playing_info(uint16_t avrcp_cid, const avrcp_track_t * current_track, uint16_t total_tracks); 129fe9491e7SMatthias Ringwald 130fe9491e7SMatthias Ringwald /** 1312a59ace6SMilanka Ringwald * @brief Set Playing status and send to Controller 132fe9491e7SMatthias Ringwald * @param avrcp_cid 133fe9491e7SMatthias Ringwald * @param playback_status 1342a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 135fe9491e7SMatthias Ringwald */ 136d1207cd8SMilanka Ringwald uint8_t avrcp_target_set_playback_status(uint16_t avrcp_cid, avrcp_playback_status_t playback_status); 137fe9491e7SMatthias Ringwald 138fe9491e7SMatthias Ringwald /** 1392a59ace6SMilanka Ringwald * @brief Set Unit Info 140fe9491e7SMatthias Ringwald * @param avrcp_cid 141fe9491e7SMatthias Ringwald * @param unit_type 142fe9491e7SMatthias Ringwald * @param company_id 1432a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 144fe9491e7SMatthias Ringwald */ 14561a3437bSMilanka Ringwald uint8_t avrcp_target_set_unit_info(uint16_t avrcp_cid, avrcp_subunit_type_t unit_type, uint32_t company_id); 146fe9491e7SMatthias Ringwald 147fe9491e7SMatthias Ringwald /** 1482a59ace6SMilanka Ringwald * @brief Set Subunit Info 149fe9491e7SMatthias Ringwald * @param avrcp_cid 150fe9491e7SMatthias Ringwald * @param subunit_type 151fe9491e7SMatthias Ringwald * @param subunit_info_data 152fe9491e7SMatthias Ringwald * @param subunit_info_data_size 1532a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 154fe9491e7SMatthias Ringwald */ 15561a3437bSMilanka Ringwald 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); 156d1207cd8SMilanka Ringwald 157fe9491e7SMatthias Ringwald /** 1582a59ace6SMilanka Ringwald * @brief Send Playing Content Changed Notification if enabled 159fe9491e7SMatthias Ringwald * @param avrcp_cid 1602a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 161fe9491e7SMatthias Ringwald */ 162d1207cd8SMilanka Ringwald uint8_t avrcp_target_playing_content_changed(uint16_t avrcp_cid); 163fe9491e7SMatthias Ringwald 164fe9491e7SMatthias Ringwald /** 1652a59ace6SMilanka Ringwald * @brief Send Addressed Player Changed Notification if enabled 166fe9491e7SMatthias Ringwald * @param avrcp_cid 167fe9491e7SMatthias Ringwald * @param player_id 168fe9491e7SMatthias Ringwald * @param uid_counter 1692a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 170fe9491e7SMatthias Ringwald */ 1716568eb54SMilanka Ringwald uint8_t avrcp_target_addressed_player_changed(uint16_t avrcp_cid, uint16_t player_id, uint16_t uid_counter); 1726568eb54SMilanka Ringwald 173fe9491e7SMatthias Ringwald /** 1742a59ace6SMilanka Ringwald * @brief Set Battery Status Changed and send notification if enabled 175fe9491e7SMatthias Ringwald * @param avrcp_cid 176fe9491e7SMatthias Ringwald * @param battery_status 1772a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 178fe9491e7SMatthias Ringwald */ 179d1207cd8SMilanka Ringwald uint8_t avrcp_target_battery_status_changed(uint16_t avrcp_cid, avrcp_battery_status_t battery_status); 180fe9491e7SMatthias Ringwald 181fe9491e7SMatthias Ringwald /** 1822a59ace6SMilanka Ringwald * @brief Overwrite the absolute volume requested by controller with the actual absolute volume. 183b772a0d7SMilanka Ringwald * This function can only be called on AVRCP_SUBEVENT_NOTIFICATION_VOLUME_CHANGED event, which indicates a set absolute volume request by controller. 184b772a0d7SMilanka Ringwald * 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. 185b772a0d7SMilanka Ringwald * 186b772a0d7SMilanka Ringwald * @param avrcp_cid 187b772a0d7SMilanka Ringwald * @param absolute_volume 1882a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 189b772a0d7SMilanka Ringwald */ 190b772a0d7SMilanka Ringwald uint8_t avrcp_target_adjust_absolute_volume(uint16_t avrcp_cid, uint8_t absolute_volume); 191b772a0d7SMilanka Ringwald 192b772a0d7SMilanka Ringwald 193984bbc3eSMilanka Ringwald /** 1942a59ace6SMilanka Ringwald * @brief Set Absolute Volume and send notification if enabled 195fe9491e7SMatthias Ringwald * @param avrcp_cid 196984bbc3eSMilanka Ringwald * @param absolute_volume 1972a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 198fe9491e7SMatthias Ringwald */ 199984bbc3eSMilanka Ringwald uint8_t avrcp_target_volume_changed(uint16_t avrcp_cid, uint8_t absolute_volume); 200fe9491e7SMatthias Ringwald 201fe9491e7SMatthias Ringwald /** 2022a59ace6SMilanka Ringwald * @brief Set Track and send notification if enabled 203fe9491e7SMatthias Ringwald * @param avrcp_cid 204fe9491e7SMatthias Ringwald * @param trackID 2052a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 206fe9491e7SMatthias Ringwald */ 20712b7c8ecSMilanka Ringwald uint8_t avrcp_target_track_changed(uint16_t avrcp_cid, uint8_t * trackID); 20812b7c8ecSMilanka Ringwald 209fe9491e7SMatthias Ringwald /** 2102a59ace6SMilanka Ringwald * @brief Send Operation Rejected message 211fe9491e7SMatthias Ringwald * @param avrcp_cid 212fe9491e7SMatthias Ringwald * @param opid 213fe9491e7SMatthias Ringwald * @param operands_length 214fe9491e7SMatthias Ringwald * @param operand 2152a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 216fe9491e7SMatthias Ringwald */ 217831d3fd5SMilanka Ringwald uint8_t avrcp_target_operation_rejected(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 218fe9491e7SMatthias Ringwald 219fe9491e7SMatthias Ringwald /** 2202a59ace6SMilanka Ringwald * @brief Send Operation Accepted message 221fe9491e7SMatthias Ringwald * @param avrcp_cid 222fe9491e7SMatthias Ringwald * @param opid 223fe9491e7SMatthias Ringwald * @param operands_length 224fe9491e7SMatthias Ringwald * @param operand 2252a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 226fe9491e7SMatthias Ringwald */ 227831d3fd5SMilanka Ringwald uint8_t avrcp_target_operation_accepted(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 228fe9491e7SMatthias Ringwald 229fe9491e7SMatthias Ringwald /** 2302a59ace6SMilanka Ringwald * @brief Send Operation Not Implemented message 231fe9491e7SMatthias Ringwald * @param avrcp_cid 232fe9491e7SMatthias Ringwald * @param opid 233fe9491e7SMatthias Ringwald * @param operands_length 234fe9491e7SMatthias Ringwald * @param operand 2352a59ace6SMilanka Ringwald * @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if connection is not found, otherwise ERROR_CODE_SUCCESS 236fe9491e7SMatthias Ringwald */ 237831d3fd5SMilanka Ringwald uint8_t avrcp_target_operation_not_implemented(uint16_t avrcp_cid, avrcp_operation_id_t opid, uint8_t operands_length, uint8_t operand); 238831d3fd5SMilanka Ringwald 239680af5dcSMatthias Ringwald /** 240680af5dcSMatthias Ringwald * @brief De-Init AVRCP Browsing Target 241680af5dcSMatthias Ringwald */ 242680af5dcSMatthias Ringwald void avrcp_target_deinit(void); 243680af5dcSMatthias Ringwald 2446983e65eSMilanka Ringwald /* API_END */ 245654724deSMilanka Ringwald 246654724deSMilanka Ringwald // Used by AVRCP target and AVRCP browsing target 247654724deSMilanka Ringwald extern avrcp_context_t avrcp_target_context; 248654724deSMilanka Ringwald 2496983e65eSMilanka Ringwald #if defined __cplusplus 2506983e65eSMilanka Ringwald } 2516983e65eSMilanka Ringwald #endif 2526983e65eSMilanka Ringwald 25380e33422SMatthias Ringwald #endif // AVRCP_TARGET_H 254