From 3ab6fd828ba275968c5e4effc60f13f33a35cd7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?William=20B=C3=A9rub=C3=A9?= Date: Mon, 10 Jun 2024 15:11:31 -0400 Subject: [PATCH] Preparing in prevision of the audio stream handling --- src/hal/hisi/v3_hal.c | 7 ++++--- src/hal/hisi/v3_hal.h | 1 + src/hal/hisi/v4_hal.c | 7 ++++--- src/hal/hisi/v4_hal.h | 1 + src/hal/inge/t31_hal.c | 7 ++++--- src/hal/inge/t31_hal.h | 1 + src/hal/sstar/i6_hal.c | 9 +++++---- src/hal/sstar/i6_hal.h | 1 + src/hal/sstar/i6c_hal.c | 5 +++-- src/hal/sstar/i6c_hal.h | 1 + src/hal/sstar/i6f_hal.c | 13 +++++++------ src/hal/sstar/i6f_hal.h | 1 + src/hal/types.h | 9 +++++++++ src/video.c | 14 +++++++------- 14 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/hal/hisi/v3_hal.c b/src/hal/hisi/v3_hal.c index 1d20b5e..af12e2b 100644 --- a/src/hal/hisi/v3_hal.c +++ b/src/hal/hisi/v3_hal.c @@ -14,6 +14,7 @@ v3_vi_impl v3_vi; v3_vpss_impl v3_vpss; hal_chnstate v3_state[V3_VENC_CHN_NUM] = {0}; +int (*v3_aud_cb)(hal_audframe*); int (*v3_venc_cb)(char, hal_vidstream*); char _v3_aud_chn = 0; @@ -80,9 +81,9 @@ int v3_audio_init(void) config.intf = V3_AUD_INTF_I2S_SLAVE; config.stereoOn = 0; config.expandOn = 0; - config.frmNum = 0; - config.packNumPerFrm = 0; - config.chnNum = 0; + config.frmNum = 40; + config.packNumPerFrm = 640; + config.chnNum = 1; config.syncRxClkOn = 0; if (ret = v3_aud.fnSetDeviceConfig(_v3_aud_dev, &config)) return ret; diff --git a/src/hal/hisi/v3_hal.h b/src/hal/hisi/v3_hal.h index f914b21..16258b8 100644 --- a/src/hal/hisi/v3_hal.h +++ b/src/hal/hisi/v3_hal.h @@ -20,6 +20,7 @@ extern char keepRunning; extern hal_chnstate v3_state[V3_VENC_CHN_NUM]; +extern int (*v3_aud_cb)(hal_audframe*); extern int (*v3_venc_cb)(char, hal_vidstream*); void v3_hal_deinit(void); diff --git a/src/hal/hisi/v4_hal.c b/src/hal/hisi/v4_hal.c index 4997e68..b26914d 100644 --- a/src/hal/hisi/v4_hal.c +++ b/src/hal/hisi/v4_hal.c @@ -14,6 +14,7 @@ v4_vi_impl v4_vi; v4_vpss_impl v4_vpss; hal_chnstate v4_state[V4_VENC_CHN_NUM] = {0}; +int (*v4_aud_cb)(hal_audframe*); int (*v4_venc_cb)(char, hal_vidstream*); char _v4_aud_chn = 0; @@ -81,9 +82,9 @@ int v4_audio_init(void) config.intf = V4_AUD_INTF_I2S_SLAVE; config.stereoOn = 0; config.expandOn = 0; - config.frmNum = 0; - config.packNumPerFrm = 0; - config.chnNum = 0; + config.frmNum = 40; + config.packNumPerFrm = 640; + config.chnNum = 1; config.syncRxClkOn = 0; if (ret = v4_aud.fnSetDeviceConfig(_v4_aud_dev, &config)) return ret; diff --git a/src/hal/hisi/v4_hal.h b/src/hal/hisi/v4_hal.h index b9fa6f3..a991f82 100644 --- a/src/hal/hisi/v4_hal.h +++ b/src/hal/hisi/v4_hal.h @@ -20,6 +20,7 @@ extern char keepRunning; extern hal_chnstate v4_state[V4_VENC_CHN_NUM]; +extern int (*v4_aud_cb)(hal_audframe*); extern int (*v4_venc_cb)(char, hal_vidstream*); void v4_hal_deinit(void); diff --git a/src/hal/inge/t31_hal.c b/src/hal/inge/t31_hal.c index 98cb2b5..36fa9e1 100644 --- a/src/hal/inge/t31_hal.c +++ b/src/hal/inge/t31_hal.c @@ -8,6 +8,7 @@ t31_sys_impl t31_sys; t31_venc_impl t31_venc; hal_chnstate t31_state[T31_VENC_CHN_NUM] = {0}; +int (*t31_aud_cb)(hal_audframe*); int (*t31_venc_cb)(char, hal_vidstream*); t31_isp_snr _t31_isp_snr; @@ -63,9 +64,9 @@ int t31_audio_init(void) config.rate = 48000; config.bit = T31_AUD_BIT_16; config.mode = T31_AUD_SND_MONO; - config.frmNum = 0; - config.packNumPerFrm = 0; - config.chnNum = 0; + config.frmNum = 40; + config.packNumPerFrm = 640; + config.chnNum = 1; if (ret = t31_aud.fnSetDeviceConfig(_t31_aud_dev, &config)) return ret; } diff --git a/src/hal/inge/t31_hal.h b/src/hal/inge/t31_hal.h index 4f5057d..44c42c7 100644 --- a/src/hal/inge/t31_hal.h +++ b/src/hal/inge/t31_hal.h @@ -13,6 +13,7 @@ extern char keepRunning; extern hal_chnstate t31_state[T31_VENC_CHN_NUM]; +extern int (*t31_aud_cb)(hal_audframe*); extern int (*t31_venc_cb)(char, hal_vidstream*); void t31_hal_deinit(void); diff --git a/src/hal/sstar/i6_hal.c b/src/hal/sstar/i6_hal.c index ee94550..2c351ae 100644 --- a/src/hal/sstar/i6_hal.c +++ b/src/hal/sstar/i6_hal.c @@ -10,6 +10,7 @@ i6_vif_impl i6_vif; i6_vpe_impl i6_vpe; hal_chnstate i6_state[I6_VENC_CHN_NUM] = {0}; +int (*i6_aud_cb)(hal_audframe*); int (*i6_venc_cb)(char, hal_vidstream*); i6_snr_pad _i6_snr_pad; @@ -80,10 +81,10 @@ int i6_audio_init(void) config.bit24On = 0; config.intf = I6_AUD_INTF_I2S_SLAVE; config.sound = I6_AUD_SND_MONO; - config.frmNum = 0; - config.packNumPerFrm = 0; - config.codecChnNum = 0; - config.chnNum = 0; + config.frmNum = 40; + config.packNumPerFrm = 640; + config.codecChnNum = 1; + config.chnNum = 1; config.i2s.clock = I6_AUD_CLK_OFF; config.i2s.leftJustOn = 0; config.i2s.syncRxClkOn = 0; diff --git a/src/hal/sstar/i6_hal.h b/src/hal/sstar/i6_hal.h index 89257ae..855853d 100644 --- a/src/hal/sstar/i6_hal.h +++ b/src/hal/sstar/i6_hal.h @@ -12,6 +12,7 @@ extern char keepRunning; +extern int (*i6_aud_cb)(hal_audframe*); extern int (*i6_venc_cb)(char, hal_vidstream*); void i6_hal_deinit(void); diff --git a/src/hal/sstar/i6c_hal.c b/src/hal/sstar/i6c_hal.c index 8c21293..04ca1bb 100644 --- a/src/hal/sstar/i6c_hal.c +++ b/src/hal/sstar/i6c_hal.c @@ -10,6 +10,7 @@ i6c_venc_impl i6c_venc; i6c_vif_impl i6c_vif; hal_chnstate i6c_state[I6C_VENC_CHN_NUM] = {0}; +int (*i6c_aud_cb)(hal_audframe*); int (*i6c_venc_cb)(char, hal_vidstream*); i6c_snr_pad _i6c_snr_pad; @@ -78,7 +79,7 @@ int i6c_audio_init(void) { i6c_aud_cnf config; config.reserved = 0; - config.sound = I6C_AUD_SND_STEREO; + config.sound = I6C_AUD_SND_MONO; config.rate = 48000; config.periodSize = 0x600; config.interleavedOn = 1; @@ -94,7 +95,7 @@ int i6c_audio_init(void) config.rate = 48000; config.clock = I6C_AUD_CLK_OFF; config.syncRxClkOn = 1; - config.tdmSlotNum = 2; + config.tdmSlotNum = 1; if (ret = i6c_aud.fnSetI2SConfig(input, &config)) return ret; if (ret = i6c_aud.fnAttachToDevice(_i6c_aud_dev, &input, 1)) diff --git a/src/hal/sstar/i6c_hal.h b/src/hal/sstar/i6c_hal.h index 6a51548..304d430 100644 --- a/src/hal/sstar/i6c_hal.h +++ b/src/hal/sstar/i6c_hal.h @@ -12,6 +12,7 @@ extern char keepRunning; +extern int (*i6c_aud_cb)(hal_audframe*); extern int (*i6c_venc_cb)(char, hal_vidstream*); void i6c_hal_deinit(void); diff --git a/src/hal/sstar/i6f_hal.c b/src/hal/sstar/i6f_hal.c index b73abaf..b758bbc 100644 --- a/src/hal/sstar/i6f_hal.c +++ b/src/hal/sstar/i6f_hal.c @@ -10,6 +10,7 @@ i6f_venc_impl i6f_venc; i6f_vif_impl i6f_vif; hal_chnstate i6f_state[I6F_VENC_CHN_NUM] = {0}; +int (*i6f_aud_cb)(hal_audframe*); int (*i6f_venc_cb)(char, hal_vidstream*); i6f_snr_pad _i6f_snr_pad; @@ -81,15 +82,15 @@ int i6f_audio_init(void) config.rate = 48000; config.bit = I6F_AUD_BIT_16; config.intf = I6F_AUD_INTF_I2S_SLAVE; - config.sound = I6F_AUD_SND_STEREO; - config.frmNum = 0; - config.packNumPerFrm = 0; - config.codecChnNum = 0; - config.chnNum = 0; + config.sound = I6F_AUD_SND_MONO; + config.frmNum = 40; + config.packNumPerFrm = 640; + config.codecChnNum = 1; + config.chnNum = 1; config.i2s.clock = I6F_AUD_CLK_OFF; config.i2s.leftJustOn = 0; config.i2s.syncRxClkOn = 1; - config.i2s.tdmSlotNum = 2; + config.i2s.tdmSlotNum = 1; config.i2s.bit = I6F_AUD_BIT_32; if (ret = i6f_aud.fnSetDeviceConfig(_i6f_aud_dev, &config)) return ret; diff --git a/src/hal/sstar/i6f_hal.h b/src/hal/sstar/i6f_hal.h index 4d53d38..e6031fb 100644 --- a/src/hal/sstar/i6f_hal.h +++ b/src/hal/sstar/i6f_hal.h @@ -10,6 +10,7 @@ extern char keepRunning; +extern int (*i6f_aud_cb)(hal_audframe*); extern int (*i6f_venc_cb)(char, hal_vidstream*); void i6f_hal_deinit(void); diff --git a/src/hal/types.h b/src/hal/types.h index 6a51be3..72fb794 100644 --- a/src/hal/types.h +++ b/src/hal/types.h @@ -55,6 +55,15 @@ typedef enum { HAL_VIDPROFILE_HIGH } hal_vidprofile; +typedef struct { + unsigned char *data[8]; + unsigned int length[8]; + unsigned int seq; + unsigned int timestamp; + char channelCnt; + char interleavedOn; +} hal_audframe; + typedef struct { int fileDesc; char enable; diff --git a/src/video.c b/src/video.c index ebbe4af..af879ed 100644 --- a/src/video.c +++ b/src/video.c @@ -16,7 +16,7 @@ pthread_mutex_t mutex; pthread_t ispPid = 0; pthread_t vencPid = 0; -int save_stream(char index, hal_vidstream *stream) { +int save_video_stream(char index, hal_vidstream *stream) { int ret; switch (chnState[index].payload) { @@ -178,12 +178,12 @@ int start_sdk() { } switch (plat) { - case HAL_PLATFORM_I6: i6_venc_cb = save_stream; break; - case HAL_PLATFORM_I6C: i6c_venc_cb = save_stream; break; - case HAL_PLATFORM_I6F: i6f_venc_cb = save_stream; break; - case HAL_PLATFORM_V3: v3_venc_cb = save_stream; break; - case HAL_PLATFORM_V4: v4_venc_cb = save_stream; break; - case HAL_PLATFORM_T31: t31_venc_cb = save_stream; break; + case HAL_PLATFORM_I6: i6_venc_cb = save_video_stream; break; + case HAL_PLATFORM_I6C: i6c_venc_cb = save_video_stream; break; + case HAL_PLATFORM_I6F: i6f_venc_cb = save_video_stream; break; + case HAL_PLATFORM_V3: v3_venc_cb = save_video_stream; break; + case HAL_PLATFORM_V4: v4_venc_cb = save_video_stream; break; + case HAL_PLATFORM_T31: t31_venc_cb = save_video_stream; break; } switch (plat) {