mirror of
https://github.com/gtxaspec/wz_mini_hacks.git
synced 2024-11-25 14:57:19 +00:00
fix rtsp audio for channel 1
This commit is contained in:
parent
b9c96a63a2
commit
43f6ed9fda
@ -215,6 +215,7 @@ Huge credit to @mnakada for his libcallback library: [https://github.com/mnakada
|
|||||||
|
|
||||||
## Latest Updates
|
## Latest Updates
|
||||||
|
|
||||||
|
* 05-15-22: fixed rtsp audio for low-res rtsp stream, patched libcallback sources for audio channel 1.
|
||||||
* 05-15-22: patched libcallback to support both video streams from the camera. Added support for them in run_mmc.sh.
|
* 05-15-22: patched libcallback to support both video streams from the camera. Added support for them in run_mmc.sh.
|
||||||
* 05-14-22: Added ability to specify RTSP bitrate parameters. Note that changing bitrate in the mobile app will briefly reset the bitrate for the RTSP stream.
|
* 05-14-22: Added ability to specify RTSP bitrate parameters. Note that changing bitrate in the mobile app will briefly reset the bitrate for the RTSP stream.
|
||||||
* 05-14-22: Update v4l2rtspserver, tinyalsa, alsa-lib. Patch busybox for older official FW's failing to run scripts, fix choppy/static audio in libcallback
|
* 05-14-22: Update v4l2rtspserver, tinyalsa, alsa-lib. Patch busybox for older official FW's failing to run scripts, fix choppy/static audio in libcallback
|
||||||
|
Binary file not shown.
@ -377,15 +377,15 @@ if [[ "$RTSP_HI_RES_ENABLED" == "true" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
|
if [[ "$RTSP_HI_RES_ENC_PARAMETER" != "" ]]; then
|
||||||
watch -n5 -t "/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER" > /dev/null 2>&1 &
|
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:44:4:$RTSP_HI_RES_ENC_PARAMETER" > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then
|
if [[ "$RTSP_HI_RES_MAX_BITRATE" != "" ]]; then
|
||||||
watch -n5 -t "/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_MAX_BITRATE" > /dev/null 2>&1 &
|
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:48:4:$RTSP_HI_RES_MAX_BITRATE" > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then
|
if [[ "$RTSP_HI_RES_TARGET_BITRATE" != "" ]]; then
|
||||||
watch -n5 -t "/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_TARGET_BITRATE" > /dev/null 2>&1 &
|
watch -n10 -t "/system/bin/impdbg --enc_rc_s 0:52:4:$RTSP_HI_RES_TARGET_BITRATE" > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -410,22 +410,22 @@ if [[ "$RTSP_LOW_RES_ENABLED" == "true" ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]]; then
|
if [[ "$RTSP_LOW_RES_ENABLE_AUDIO" == "true" ]]; then
|
||||||
LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -C 1 -a S16_LE /dev/video2,hw:Loopback,0 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_LOW_RES_PORT &
|
LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -C 1 -a S16_LE /dev/video2,hw:Loopback,1 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_LOW_RES_PORT &
|
||||||
else
|
else
|
||||||
echo "rtsp audio disabled"
|
echo "rtsp audio disabled"
|
||||||
LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -s /dev/video2 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_LOW_RES_PORT &
|
LD_LIBRARY_PATH=/media/mmc/wz_mini/lib /media/mmc/wz_mini/bin/v4l2rtspserver -s /dev/video2 -U $RTSP_LOGIN:$RTSP_PASSWORD -P $RTSP_LOW_RES_PORT &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
|
if [[ "$RTSP_LOW_RES_ENC_PARAMETER" != "" ]]; then
|
||||||
watch -n5 -t "/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 &
|
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:44:4:$RTSP_LOW_RES_ENC_PARAMETER" > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then
|
if [[ "$RTSP_LOW_RES_MAX_BITRATE" != "" ]]; then
|
||||||
watch -n5 -t "/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 &
|
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:48:4:$RTSP_LOW_RES_MAX_BITRATE" > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then
|
if [[ "$RTSP_LOW_RES_TARGET_BITRATE" != "" ]]; then
|
||||||
watch -n5 -t "/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_TARGET_BITRATE" > /dev/null 2>&1 &
|
watch -n10 -t "/system/bin/impdbg --enc_rc_s 1:52:4:$RTSP_LOW_RES_TARGET_BITRATE" > /dev/null 2>&1 &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -19,6 +19,9 @@ static uint32_t (*real_local_sdk_audio_set_pcm_frame_callback)(int ch, void *cal
|
|||||||
static void *audio_pcm_cb = NULL;
|
static void *audio_pcm_cb = NULL;
|
||||||
static int AudioCaptureEnable = 0;
|
static int AudioCaptureEnable = 0;
|
||||||
|
|
||||||
|
static void *audio_pcm_cb1 = NULL;
|
||||||
|
static int AudioCaptureEnable1 = 0;
|
||||||
|
|
||||||
char *AudioCapture(int fd, char *tokenPtr) {
|
char *AudioCapture(int fd, char *tokenPtr) {
|
||||||
|
|
||||||
char *p = strtok_r(NULL, " \t\r\n", &tokenPtr);
|
char *p = strtok_r(NULL, " \t\r\n", &tokenPtr);
|
||||||
@ -28,14 +31,25 @@ char *AudioCapture(int fd, char *tokenPtr) {
|
|||||||
fprintf(stderr, "[command] audio capute on\n", p);
|
fprintf(stderr, "[command] audio capute on\n", p);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
if(!strcmp(p, "on1")) {
|
||||||
|
AudioCaptureEnable1 = 1;
|
||||||
|
fprintf(stderr, "[command] audio capute on\n", p);
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
if(!strcmp(p, "off")) {
|
if(!strcmp(p, "off")) {
|
||||||
AudioCaptureEnable = 0;
|
AudioCaptureEnable = 0;
|
||||||
fprintf(stderr, "[command] audio capute off\n", p);
|
fprintf(stderr, "[command] audio capute off\n", p);
|
||||||
return "ok";
|
return "ok";
|
||||||
}
|
}
|
||||||
|
if(!strcmp(p, "off1")) {
|
||||||
|
AudioCaptureEnable1 = 0;
|
||||||
|
fprintf(stderr, "[command] audio capute off\n", p);
|
||||||
|
return "ok";
|
||||||
|
}
|
||||||
return "error";
|
return "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//channel 0
|
||||||
static uint32_t audio_pcm_capture(struct frames_st *frames) {
|
static uint32_t audio_pcm_capture(struct frames_st *frames) {
|
||||||
|
|
||||||
static struct pcm *pcm = NULL;
|
static struct pcm *pcm = NULL;
|
||||||
@ -60,10 +74,10 @@ static uint32_t audio_pcm_capture(struct frames_st *frames) {
|
|||||||
};
|
};
|
||||||
pcm = pcm_open(card, device, flags, &config);
|
pcm = pcm_open(card, device, flags, &config);
|
||||||
if(pcm == NULL) {
|
if(pcm == NULL) {
|
||||||
fprintf(stderr, "failed to allocate memory for PCM\n");
|
fprintf(stderr, "failed to allocate memory for PCM CH0\n");
|
||||||
} else if(!pcm_is_ready(pcm)) {
|
} else if(!pcm_is_ready(pcm)) {
|
||||||
pcm_close(pcm);
|
pcm_close(pcm);
|
||||||
fprintf(stderr, "failed to open PCM\n");
|
fprintf(stderr, "failed to open PCM CH0\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,16 +91,68 @@ static uint32_t audio_pcm_capture(struct frames_st *frames) {
|
|||||||
return ((framecb)audio_pcm_cb)(frames);
|
return ((framecb)audio_pcm_cb)(frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//channel1
|
||||||
|
static uint32_t audio_pcm_capture1(struct frames_st *frames) {
|
||||||
|
|
||||||
|
static struct pcm *pcm = NULL;
|
||||||
|
static int firstEntry = 0;
|
||||||
|
uint32_t *buf = frames->buf;
|
||||||
|
|
||||||
|
if(!firstEntry) {
|
||||||
|
firstEntry++;
|
||||||
|
unsigned int card = 0;
|
||||||
|
unsigned int device = 0;
|
||||||
|
int flags = PCM_OUT | PCM_MMAP;
|
||||||
|
const struct pcm_config config = {
|
||||||
|
.channels = 1,
|
||||||
|
.rate = 8000,
|
||||||
|
.format = PCM_FORMAT_S16_LE,
|
||||||
|
.period_size = 128,
|
||||||
|
.period_count = 8,
|
||||||
|
.start_threshold = 320,
|
||||||
|
.silence_threshold = 0,
|
||||||
|
.silence_size = 0,
|
||||||
|
.stop_threshold = 320 * 4
|
||||||
|
};
|
||||||
|
pcm = pcm_open(card, device, flags, &config);
|
||||||
|
if(pcm == NULL) {
|
||||||
|
fprintf(stderr, "failed to allocate memory for PCM CH1\n");
|
||||||
|
} else if(!pcm_is_ready(pcm)) {
|
||||||
|
pcm_close(pcm);
|
||||||
|
fprintf(stderr, "failed to open PCM CH1\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(pcm && AudioCaptureEnable1) {
|
||||||
|
int avail = pcm_mmap_avail(pcm);
|
||||||
|
int delay = pcm_get_delay(pcm);
|
||||||
|
int ready = pcm_is_ready(pcm);
|
||||||
|
int err = pcm_writei(pcm, buf, pcm_bytes_to_frames(pcm, frames->length));
|
||||||
|
if(err < 0) fprintf(stderr, "pcm_writei err=%d\n", err);
|
||||||
|
}
|
||||||
|
return ((framecb)audio_pcm_cb1)(frames);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t local_sdk_audio_set_pcm_frame_callback(int ch, void *callback) {
|
uint32_t local_sdk_audio_set_pcm_frame_callback(int ch, void *callback) {
|
||||||
|
|
||||||
fprintf(stderr, "local_sdk_audio_set_pcm_frame_callback streamChId=%d, callback=0x%x\n", ch, callback);
|
fprintf(stderr, "local_sdk_audio_set_pcm_frame_callback streamChId=%d, callback=0x%x\n", ch, callback);
|
||||||
|
|
||||||
static int ch_count = 0;
|
static int ch_count = 0;
|
||||||
|
|
||||||
if( (ch == 0) && ch_count == 0) {
|
if( (ch == 0) && ch_count == 0) {
|
||||||
audio_pcm_cb = callback;
|
audio_pcm_cb = callback;
|
||||||
fprintf(stderr,"enc func injection save audio_pcm_cb=0x%x\n", audio_pcm_cb);
|
fprintf(stderr,"enc func injection CH0 save audio_pcm_cb=0x%x\n", audio_pcm_cb);
|
||||||
callback = audio_pcm_capture;
|
callback = audio_pcm_capture;
|
||||||
}
|
}
|
||||||
ch_count=ch_count+1
|
|
||||||
|
if( (ch == 1) && ch_count == 1) {
|
||||||
|
audio_pcm_cb1 = callback;
|
||||||
|
fprintf(stderr,"enc func injection CH1 save audio_pcm_cb=0x%x\n", audio_pcm_cb1);
|
||||||
|
callback = audio_pcm_capture1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ch_count=ch_count+1;
|
||||||
|
|
||||||
return real_local_sdk_audio_set_pcm_frame_callback(ch, callback);
|
return real_local_sdk_audio_set_pcm_frame_callback(ch, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user