CARPLAY版本整理

This commit is contained in:
2025-01-21 16:49:37 +08:00
commit f0fb64e4e6
26542 changed files with 13719676 additions and 0 deletions

View File

@ -0,0 +1,25 @@
#ifndef _AUDIO_CALLBACKS_H
#define _AUDIO_CALLBACKS_H
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*audio_start_callback_f)(void *ctx, int handle, int type, int rate, int bits, int channels);
typedef void (*audio_stop_callback_f)(void *ctx, int handle, int type);
typedef void ( *audio_reset_DSP_mode_callback_f)(void *ctx, int mode);
typedef struct audio_callbacks
{
audio_start_callback_f audio_start_callback;
audio_stop_callback_f audio_stop_callback;
audio_reset_DSP_mode_callback_f audio_reset_DSP_mode_callback;
void *ctx;
}audio_callbacks_t;
void audio_register_callbacks(void *cb);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,272 @@
#ifndef __CARPLAY_IF_H_H
#define __CARPLAY_IF_H_H
#ifdef __cplusplus
extern "C" {
#endif
/*#ifndef CARLINK_LINK_TYPE
#define CARLINK_LINK_TYPE
typedef enum
{
CARPLAY = 0x00,
CARLIFE,
ANDROID_CARLIFE,
ANDROID_MIRROR = 3,
IOS_CARLIFE,
ANDROID_AUTO = 5,
ECLINK = 0x06,
CARPLAY_WIRELESS
}Link_TYPE;
#endif*/
typedef enum
{
CALL_ACCEPT = 2,
CALL_DROP = 3,
}CALL;
typedef enum
{
MEDIA_NONE = 0,
MEDIA_PLAY,
MEDIA_PAUSE,
MEDIA_PLAY_PAUSE,
MEDIA_NEXT,
MEDIA_PREVIOUS
}MEDIA;
typedef enum
{
AUDIO_MEDIA = 0,
AUDIO_TELEPHONE,
AUDIO_RECOGNITION,
AUDIO_ALERT,
AUDIO_REC,
AUDIO_ALT,
AUDIO_AUX_IN,
AUDIO_AUX_OUT
} AUDIO_TYPE;
/*
typedef enum _IAP2_LINK_STATUS
{
IAP2_INIT = -1,
IAP2_USB_HOST_INSERTED,
IAP2_USB_HOST_REMOVE,
IAP2_USB_SWITCH_FAIL,
IAP2_CONNECT,
IAP2_DISCONNECT,
}IAP2_LINK_STATUS;*/
#ifndef AirplayModeStateAlias
#define AirplayModeStateAlias
typedef int CarplayEntity;
#define CarplayEntity_NotApplicable 0
#define CarplayEntity_Controller 1
#define CarplayEntity_Accessory 2
typedef int CarplayTransferType;
#define CarplayTransferType_NotApplicable 0
#define CarplayTransferType_Take 1 // Transfer ownership permanently.
#define CarplayTransferType_Untake 2 // Release permanent ownership.
#define CarplayTransferType_Borrow 3 // Transfer ownership temporarily.
#define CarplayTransferType_Unborrow 4 // Release temporary ownership.
typedef int CarplayTransferPriority;
#define CarplayTransferPriority_NotApplicable 0
#define CarplayTransferPriority_NiceToHave 100 // Transfer succeeds only if constraint is <= Anytime.
#define CarplayTransferPriority_UserInitiated 500 // Transfer succeeds only if constraint is <= UserInitiated.
typedef int CarplayConstraint;
#define CarplayConstraint_NotApplicable 0
#define CarplayConstraint_Anytime 100 // Resource may be taken/borrowed at any time.
#define CarplayConstraint_UserInitiated 500 // Resource may be taken/borrowed if user initiated.
#define CarplayConstraint_Never 1000 // Resource may never be taken/borrowed.
typedef int CarplayTriState;
#define CarplayTriState_NotApplicable 0
#define CarplayTriState_False -1
#define CarplayTriState_True 1
typedef int CarplaySpeechMode;
#define CarplaySpeechMode_NotApplicable 0
#define CarplaySpeechMode_None -1 // No speech-related states are active.
#define CarplaySpeechMode_Speaking 1 // Device is speaking to the user.
#define CarplaySpeechMode_Recognizing 2 // Device is recording audio to recognize speech from the user.
typedef struct
{
CarplayEntity entity;
CarplaySpeechMode mode;
}CarPlaySpeechState;
typedef struct
{
CarplayEntity screen; // Owner of the screen.
CarplayEntity permScreen; // Permanent owner of screen.
CarplayEntity mainAudio; // Owner of main audio.
CarplayEntity permMainAudio; // Permanent owner of main audio.
CarplayEntity phoneCall; // Owner of phone call.
CarPlaySpeechState speech; // Owner of speech and its mode.
CarplayEntity turnByTurn; // Owner of navigation.
} CarPlayModeState;
#endif
typedef void ( *CarplaySessionStarted_f )(void *ctx);
typedef void ( *CarplaySessionStop_f )(void *ctx);
typedef void ( *CarplaySessionModesChanged_f )(void *ctx, const CarPlayModeState * inState);
typedef void ( *CarplaySessionRequestUI_f )(void *ctx);
typedef void ( *CarplaySessionDuckAudio_f)(void *ctx, double inDurationSecs, double inVolume);
typedef void ( *CarplaySessionUnduckAudio_f)(void *ctx, double inDurationSecs);
typedef void ( *CarplayDisableBtSession_f)(void *ctx);
typedef void ( *CarplayNotifyDeviceName_f)(void *ctx, const char *name, int len);
typedef void ( *CarplayBonjourServiceFound_f)(void *ctx, char phone_bt_mac[6]);
typedef void ( *CarplayViewAreaUpdateNotify_f)(void *ctx, int index);
//typedef void ( *CarplayMsgNotify_f)(void *ctx, int id, int para1, int para2, const char* msg, int msgLen);
typedef void ( *CarplayMsgNotify_f)(void *ctx, const char* msg, int msgLen);
typedef struct carplay_session_callbacks
{
CarplaySessionStarted_f SessionStarted;
CarplaySessionStop_f SessionStop;
CarplaySessionModesChanged_f SessionModesChanged;
CarplaySessionRequestUI_f SessionRequestUI;
CarplaySessionDuckAudio_f SessionDuckAudio;
CarplaySessionUnduckAudio_f SessionUnduckAudio;
CarplayDisableBtSession_f DisableBtSession;
CarplayNotifyDeviceName_f NotifyDeviceName;
CarplayBonjourServiceFound_f BonjourServiceFound;
CarplayViewAreaUpdateNotify_f ViewAreaUpdateNotify;
CarplayMsgNotify_f MsgNotify;
void *ctx;
}carplay_session_callbacks_t;
typedef carplay_session_callbacks_t carplaySessionCbs;
/*
* @brief 初始化carplay的基本信息,整个程序的生命周期里面调用一次;
*/
int carplay_init();
void carplay_uninit();
/*
* @brief 注册carplay plugin的回调函数;
* @param cbs指向carplay_session_callbacks_t类型的变量;
*/
void carplay_register_callbacks(void *cbs);
/*
* @brief 启动carplay;
*/
int carplay_start();
void start_carplay_client_connect();
/*
* @brief 停止carplay;
*/
void carplay_stop();
/*
* @brief 设置要连接手机的蓝牙mac地址,无线连接的时候使用;
* @param bt_addr 蓝牙mac地址;
*/
void carplay_wl_set_iphone_mac_addr(char bt_addr[6]);
/*
* @brief 发送电话按键给苹果;
* @param button 类型见enum CALL;
*/
void Telephone_button_Update(unsigned button);
/*
* @brief 发送多媒体按键给苹果;
* @param button 类型见enum MEDIA;
*/
void Media_button_Update(unsigned button);
/*
* @brief 发送siri按键给苹果;
* @param button 1表示按下启动siri,0表示释放来结束siri;
*/
void send_siri_cmd(int button);
void send_single_touchscreen_x_y_2_carplay(unsigned short x, unsigned short y, unsigned char pressed);
void send_mul_touchscreen_x_y_2_carplay(
unsigned char finger_idx1, unsigned char pressed1,
unsigned short x1, unsigned short y1,
unsigned char finger_idx2, unsigned char pressed2,
unsigned short x2, unsigned short y2
);
/*
* @brief 发送旋钮信息给苹果;
*/
void KnobUpdate(char gSelectButtonPressed,
char gHomeButtonPressed,
char gBackButtonPressed,
double gXPosition,
double gYPosition,
char gWheelPositionRelative
);
/*
* @brief 请求iphone启动一个应用;
* @param bundleId app的包名;
* @param alert app启动的时候时候弹出警告对话框;
*/
int apple_app_launcher(char * bundleId, char alert);
/*
* @brief 要求iphone发送关键帧;
*/
void force_key_frame();
/*
* @brief 设置夜间模式;
* @param inNightMode 1表示进入夜间模式,0表示退出夜间模式
*/
void set_night_mode(char inNightMode);
/*
* @brief 请求苹果手机输出视频数据;
*/
void request_UI(char *url);
/*
*
*/
void borrow_screen(int priority, int unborrow_constraint);
void unborrow_screen(void);
void take_screen(int priority, int take_constraint, int borrow_constraint);
void untake_screen(void);
void borrow_audio(int priority, int unborrow_constraint);
void unborrow_audio(void);
void take_audio(int priority, int take_constraint, int borrow_constraint);
void untake_audio(void);
void carplay_send_change_modes(CarplayTransferType inScreenType,
CarplayTransferPriority inScreenPriority,
CarplayConstraint inScreenTake,
CarplayConstraint inScreenBorrow,
CarplayTransferType inAudioType,
CarplayTransferPriority inAudioPriority,
CarplayConstraint inAudioTake,
CarplayConstraint inAudioBorrow,
CarplayTriState inPhone,
CarplaySpeechMode inSpeech,
CarplayTriState inTurnByTurn);
int carplay_ipc_start();
void carplay_ipc_stop();
void process_play_stream(int handle, void *buffer, int len, int frames, unsigned long long timestamp);
void process_record_stream(int handle, void *buffer, int len, int frames, unsigned long long timestamp);
int carplay_get_iphone_ip_addr(char *ipaddr);
void carplay_wl_set_iphone_mac_addr(char bt_addr[6]);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,80 @@
#ifndef __IAP_H_H
#define __IAP_H_H
#ifdef __cplusplus
extern "C" {
#endif
typedef enum _IAP2_LINK_STATUS
{
IAP2_INIT = -1,
IAP2_USB_HOST_INSERTED,
IAP2_CONNECT,
IAP2_ID_OK,
IAP2_USB_HOST_REMOVE,
IAP2_USB_SWITCH_FAIL,
IAP2_ID_FAIL,
IAP2_DISCONNECT
}IAP2_LINK_STATUS;
typedef void (*iap2_link_status_cb_f)(void *ctx, IAP2_LINK_STATUS status);
typedef void (*iap2_msg_time_update_cb_f)(void *ctx, long long time, int zone_offset);
typedef void (*iap2_msg_time_zone_update_cb_f)(void *ctx, long long time, int16_t zone, int8_t daylightOff);
typedef void (*iap2_msg_gps_cb_f)(void *ctx, unsigned char session, int start);
typedef void (*iap2_msg_gps_gprmc_data_status_cb_f)(void *ctx, int value_a, int value_v, int value_x);
typedef void (*iap2_msg_identify_cb_f)(void *ctx, int type, int ok);
typedef void (*iap2_msg_wl_carplay_update_cb_f)(void *ctx, int status);
typedef int (*iap2_usb_switch_cb_f)(void *ctx, int state);
typedef int (*iap2_write_data_cb_f)(void *ctx, char *buf, int len);
typedef void (*iap2_msg_language_update_cb_f)(void *ctx, const char *lang);
typedef void (*iap2_msg_call_state_update_cb_f)(void *ctx,
const char *remoteId,
const char *displayName,
int status,
int direction,
const char *uuid,
const char *addrBookId,
const char *label,
int service);
typedef void (*iap2_msg_nowplaying_update_cb_f)(void *ctx,
int playback_status, int elapsed_time,
uint8_t* media_item_title, int media_item_title_len,
uint8_t* media_item_album_title, int media_item_album_title_len,
uint8_t* media_item_artist, int media_item_artist_len,
int song_length_ms);
typedef void (*iap2_msg_msg_json_cb_f)(void *ctx, const char* buf, int len);
typedef struct iap2_callbacks_st
{
iap2_link_status_cb_f iap2_link_status_cb;
iap2_msg_time_update_cb_f iap2_msg_time_update_cb;
iap2_msg_gps_cb_f iap2_msg_gps_cb;
iap2_msg_gps_gprmc_data_status_cb_f iap2_msg_gps_gprmc_data_status_cb;
iap2_msg_identify_cb_f iap2_msg_identify_cb;
iap2_msg_wl_carplay_update_cb_f iap2_msg_wl_carplay_update_cb;
iap2_msg_language_update_cb_f iap2_msg_language_update_cb;
iap2_msg_call_state_update_cb_f iap2_msg_call_state_update_cb;
iap2_usb_switch_cb_f iap2_usb_switch_cb;
iap2_write_data_cb_f iap2_write_data_cb;
iap2_msg_time_zone_update_cb_f iap2_msg_time_zone_update_cb;
iap2_msg_nowplaying_update_cb_f iap2_msg_nowplaying_update_cb;
iap2_msg_msg_json_cb_f iap2_msg_msg_json_cb;
void *ctx;
}iap2_callbacks;
void iap2_register_callbacks(iap2_callbacks *pcb);
int iap2_start();
int iap2_start_wifi_session();
int force_iap2_bt_start();
void iap2_stop();
int apple_send_pascd(unsigned char session, char *data);
int iap2_read_data_proc(char *buf, int len);
int apple_start_update_call_state(int start);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,154 @@
#ifndef MYCOMMON_H_H
#define MYCOMMON_H_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdbool.h>
#include <stdint.h>
#ifndef CARLINK_LINK_TYPE
#define CARLINK_LINK_TYPE
typedef enum
{
CARPLAY = 0x00,
CARLIFE,
ANDROID_CARLIFE,
ANDROID_MIRROR = 3,
IOS_CARLIFE,
ANDROID_AUTO = 5,
ECLINK = 0x06,
CARPLAY_WIRELESS,
AUTO_WIRELESS
}Link_TYPE;
#endif
//general function
typedef enum __USB_MODE
{
UNDEFINED = 0,
HOST,
PERIPHERAL,
OTG
}USB_MODE;
#define LOGV(...) printf(__VA_ARGS__); printf("\r\n");
struct view_area
{
short w;
short h;
short x;
short y;
};
typedef struct __carplay_cfg_info
{
char *iap2_name;
char *iap2_modelIdentifier;
char *iap2_manfacturer;
char *iap2_serialnumber;
char *iap2_sw_ver;
char *iap2_hw_ver;
char *iap2_vehicleInfo_name;
char *iap2_product_uuid;
char *iap2_usb_serial_num;
char *manfacturer;
char *oem_icon_label;
char *oem_icon_path;
char *os_info;
char *iOSVersionMin;
char *limited_ui_elements;
char *guuid;
char *devid;
char link_type;
char btmac[6];
bool oem_icon_visible;
bool limited_ui;
bool right_hand_driver;
bool night_mode;
bool has_knob;
bool has_telbutton;
bool has_mediabutton;
bool has_proxsensor;
bool has_EnhancedReqCarUI;
bool has_ETCSupported;
bool HiFiTouch;
bool LoFiTouch;
unsigned short usb_country_code;
unsigned short tp_verndor_code;
unsigned short tp_product_code;
unsigned short tel_verndor_code;
unsigned short tel_product_code;
unsigned short knob_verndor_code;
unsigned short knob_product_code;
unsigned short proxsensor_verndor_code;
unsigned short proxsensor_product_code;
short width;//pixel
short height;
short fps;
short screen_width_phy;//mm
short screen_height_phy;
char encrypt_ic_i2c_bus_num;
char encrypt_ic_addr;
char usb_idx;
char need_sw_aec;
char aec_delay;
bool tvout_enable;
bool use_remote_audio;
char video_type;
short icurrent;
int duck_vol;
char enable_iap_carplay_sess;
char *keychain_path_dir;
char* wifi_ssid;
char* wifi_passwd;
char* public_key;
char* src_version;
char ip_v4_addr[4];
char wifi_channel;
short net_port;
char carplay_net_ready;
char disable_bonjour;
char iap_carplay_rej;
bool enable_enhanced_siri;
bool enable_single_ui;
bool disable_carplay_audio;
short mfi_ic_i2c_bus_num;
short mfi_ic_addr;
bool is_old_carplay_ver;
struct view_area area[3];
char view_area_index;
}carplay_cfg_info;
#if 0
typedef struct __auto_cfg_info
{
short width;//pixel
short height;
short fps;
char* wifi_ssid;
char* wifi_passwd;
char wifi_channel;
bool disable_carplay_audio;
} auto_cfg_info;
#endif
extern carplay_cfg_info *g_link_info;
//extern auto_cfg_info *g_auto_link_info;
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,26 @@
#ifndef _VIDEO_CALLBACKS_H
#define _VIDEO_CALLBACKS_H
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*video_start_callback_f)(void *ctx);
typedef void (*video_stop_callback_f)(void *ctx);
typedef int (*video_proc_data_callback_f)(void *ctx, char *buf, int len);
typedef struct video_callbacks
{
video_start_callback_f video_start_callback;
video_stop_callback_f video_stop_callback;
video_proc_data_callback_f video_proc_data_callback;
void *ctx;
}video_callbacks_t;
void video_register_callbacks(void *cb);
#ifdef __cplusplus
}
#endif
#endif