[Feature][T106][task-view-97] add interface for voice call to rtp,
modification in cap, modification in lynq
Only Configure: No
Affected branch: unknown
Affected module: voice call and at
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: yes
Doc Update: no
Change-Id: I5554fa1ad4012ca466cf3ac3cc62900eff3fd55c
(cherry picked from commit d7588405e8622dff30020604e9d5d989b7d43a04)
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
index c15e093..6888b39 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
@@ -316,6 +316,7 @@
lynq-wifi-demo \
lynq-adc-demo \
lynq-at-test \
+ lynq-vb-demo \
lynq-monitor-demo \
"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c
new file mode 100755
index 0000000..6fde401
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/lynq_vb_demo.c
@@ -0,0 +1,778 @@
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+//#include "voice_ipc.h"
+
+#define _USE_VOICE_BUFFER
+#include "voice_lib.h"
+#include <fcntl.h>
+#include <signal.h>
+#include <semaphore.h>
+#include <sys/types.h>
+#include <pthread.h>
+
+/*command max len*/
+#define VOICE_CMD_MAX_LEN 64
+
+#define EXIT_CMD_STOP "stop\n"
+#define EXIT_CMD_Q "q\n"
+#define EXIT_CMD_EXIT "exit\n"
+
+#define REQ_VOICE_BUFFER_TEST_START "voice_buffer_test_start"
+#define REQ_VOICE_BUFFER_TEST_STOP "voice_buffer_test_stop"
+#define REQ_VOICE_BUFFER_LOOP_TEST_START "voice_buffer_loop_test_start"
+#define REQ_VOICE_BUFFER_LOOP_TEST_STOP "voice_buffer_loop_test_stop"
+#define REQ_VOICE_BUFFER_RTP_TEST_START "voice_buffer_rtp_test_start"
+#define REQ_VOICE_BUFFER_RTP_TEST_STOP "voice_buffer_rtp_test_stop"
+
+
+
+#define VBUFFER_TX_FILE_NAME "/mnt/userdata/tx.pcm"
+#define VBUFFER_RX_FILE_NAME "/mnt/userdata/rx.pcm"
+#define VBUFFER_TX16_FILE_NAME "/mnt/userdata/tx16.pcm"
+#define VBUFFER_RX16_FILE_NAME "/mnt/userdata/rx16.pcm"
+
+
+
+#define VB_MAX_INT 0x7fffffff
+#define VB_MIN_INT 0
+#define VB_INT_OVERFLOW(x) if((x < VB_MIN_INT)||(x > VB_MAX_INT)) x = 0;
+
+#define RX_FILE_LEN_MAX 0x100000
+
+
+
+typedef int (vb_thread_proc)(void*);
+struct vbuf_info_t
+{
+ int fd;
+ pthread_t rx_test_thread;
+ pthread_t tx_test_thread;
+ pthread_t loop_test_thread;
+ int quit;
+ char *tx_buf;
+ char *rx_buf;
+ int buf_size;
+ char *tx_filename;
+ char *rx_filename;
+ FILE *tx_file;
+ FILE *rx_file;
+ int tx_filesize;
+ int rx_filesize;
+ int fs;
+};
+
+static struct vbuf_info_t vbuf_rec;
+
+static void printUsage(const char *Opt)
+{
+ printf("Usage: %s\n", Opt);
+
+ printf("voice_buffer_test_start value: 8000,16000\n");
+ printf("voice_buffer_test_stop no value input\n");
+ printf("voice_buffer_loop_test_start value: 8000,16000\n");
+ printf("voice_buffer_loop_test_stop no value input\n");
+ printf("\n");
+}
+
+static int vbuffer_start_flag = 0;
+static int tx_optcount = 0;
+static int rx_optcount = 0;
+static int first_rderr_flag = 0;
+static int first_wrerr_flag = 0;
+
+
+
+//whole rx path
+static int vb_rx_test_thread_func(void *arg)
+{
+ int ret;
+
+ char* buf = vbuf_rec.rx_buf;
+ int size = vbuf_rec.buf_size;
+ int bytes_read = 0;
+ int r_size;
+
+
+ printf( "%s: start size=%d! \n",__func__,size);
+ memset (buf,0, size);
+
+ while (!vbuf_rec.quit)
+ {
+ rx_optcount ++;
+ VB_INT_OVERFLOW(rx_optcount);
+ if((rx_optcount%1000) == 0){
+ printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
+
+ }
+ else if(rx_optcount == 1000000){
+ printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
+ rx_optcount = 0;
+
+ }
+
+ //read form ps
+ r_size = voice_buffer_read(vbuf_rec.fd, buf, size);
+ if(r_size <= 0)
+ {
+ first_rderr_flag++;
+ VB_INT_OVERFLOW(first_rderr_flag);
+ continue ;
+ }
+ else{
+ first_rderr_flag = 0;
+
+ }
+
+ if(vbuf_rec.rx_file != NULL)
+ {
+ r_size = fwrite(buf, 1,size, vbuf_rec.rx_file);
+
+ if (r_size != size) {
+ //printf("Error fwrite size not eq,r_size=%d,size=%d\n",r_size,size);
+ }
+ else{
+
+ bytes_read += size;
+ if(bytes_read >= vbuf_rec.rx_filesize){
+ fseek(vbuf_rec.rx_file, 0, SEEK_SET);
+ bytes_read = 0;
+ printf("fwrite over write maxsize(%d)!!!\n",vbuf_rec.rx_filesize);
+
+ }
+ }
+ }
+
+
+ }
+
+ return 0;
+}
+
+static int vb_tx_test_thread_func(void *arg)
+{
+ int ret;
+ int num_read;
+
+
+ char* buf = vbuf_rec.tx_buf;
+
+ int size = vbuf_rec.buf_size;
+ int w_size;
+
+ printf("%s: start size=%d! \n",__func__,size);
+
+
+ memset(buf, 0,size);
+ while (!vbuf_rec.quit)
+ {
+
+ if(vbuf_rec.tx_file != NULL)
+ {
+
+ num_read = fread(buf,1,size, vbuf_rec.tx_file);
+
+ if (num_read != size) {
+ //printf("Error fread size not eq,num_read=%d,size=%d\n",num_read,size);
+ }
+ if (num_read <= 0) {
+ printf("Error fread size not eq,num_read=%d,size=%d\n",num_read,size);
+ fseek(vbuf_rec.tx_file, 0, SEEK_SET);
+ }
+ }
+ tx_optcount ++;
+ VB_INT_OVERFLOW(tx_optcount);
+
+ w_size = voice_buffer_write(vbuf_rec.fd, buf, size);
+ if(w_size <= 0)
+ {
+ first_wrerr_flag++;
+
+ VB_INT_OVERFLOW(first_wrerr_flag);
+
+ continue;
+ }
+ else{
+ first_wrerr_flag = 0;
+
+ }
+
+ }
+ return 0;
+}
+
+
+static int vb_thread_create( const char *name,pthread_t *thread_t, vb_thread_proc *proc,
+ int stack_size, unsigned priority,void *arg )
+{
+ pthread_attr_t thread_attr;
+ int ret;
+ int default_size;
+
+ struct sched_param param;
+ int policy = SCHED_FIFO;
+
+ printf("%s: start! \n",__func__);
+
+ /* Init thread attributes */
+ pthread_attr_init(&thread_attr);
+ /* Create the thread. */
+
+ ret = pthread_create( thread_t, &thread_attr,proc, arg);
+ if (ret != 0)
+ {
+ printf("%s: pthread_create fail,ret=%d! \n",__func__,ret);
+
+ pthread_attr_destroy(&thread_attr);
+ return ret;
+ }
+
+ pthread_attr_getstacksize(&thread_attr, &default_size);
+ printf("%s: pthread_attr_getstacksize(%d)! \n",__func__,default_size);
+
+ pthread_attr_destroy(&thread_attr);
+
+ printf("%s: end \n",__func__);
+ return 0;
+}
+
+
+int voice_buffer_stream_test_start(int fs)
+{
+ int ret = 0;
+ int buf_size = 320;
+ tx_optcount = 0;
+ rx_optcount = 0;
+ int* buf_int;
+
+ int i;
+
+ if(vbuffer_start_flag == 1){
+ printf(" VB already start,return \n");
+
+ return 0;
+ }
+
+ vbuffer_start_flag = 1;
+
+
+
+ if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){
+ printf(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);
+ }
+
+ if(fs == 8000){
+
+ buf_size = 320;
+ }
+ else if(fs == 16000){
+
+ buf_size = 640;
+ }
+ else
+ {
+ buf_size = 320;
+ }
+ printf("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);
+
+ printf("%s:open tx and rx file \n",__func__);
+ if(fs == 8000){
+
+ vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";
+ vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";
+
+ }
+ else if(fs == 16000){
+
+ vbuf_rec.tx_filename = VBUFFER_TX16_FILE_NAME;//"/cache/tx16.pcm";
+ vbuf_rec.rx_filename = VBUFFER_RX16_FILE_NAME;//"/cache/rx16.pcm";
+
+ }
+ else
+ {
+ vbuf_rec.tx_filename = VBUFFER_TX_FILE_NAME;//"/cache/tx.pcm";
+ vbuf_rec.rx_filename = VBUFFER_RX_FILE_NAME;//"/cache/rx.pcm";
+
+ }
+
+
+
+
+ vbuf_rec.tx_file = fopen(vbuf_rec.tx_filename , "rb");
+ if (!vbuf_rec.tx_file) {
+ printf("Unable to open file '%s'\n", vbuf_rec.tx_filename);
+ //return -1;
+ }
+
+
+ vbuf_rec.rx_file = fopen(vbuf_rec.rx_filename, "wb");
+ if (!vbuf_rec.rx_file) {
+ printf(stderr, "Unable to create file '%s'\n", vbuf_rec.rx_filename);
+ //fclose(vbuf_rec.tx_file);
+
+ //return -1;
+ }
+ vbuf_rec.rx_filesize = RX_FILE_LEN_MAX;
+ printf("%s : vbuf_rec.rx_filesize(%d) \n",__func__,vbuf_rec.rx_filesize);
+
+ vbuf_rec.rx_buf = (char*) malloc(buf_size);
+ if(!vbuf_rec.rx_buf) {
+ printf("%s : malloc buf fail,return \n",__func__);
+ goto err;
+ }
+ vbuf_rec.tx_buf = (char*) malloc(buf_size);
+ if(!vbuf_rec.tx_buf) {
+ free(vbuf_rec.rx_buf);
+ printf("%s : malloc buf fail,return \n",__func__);
+ vbuf_rec.rx_buf = NULL;
+ goto err;
+ }
+ vbuf_rec.buf_size = buf_size;
+
+ vbuf_rec.quit = 0;
+
+ printf("%s : vb open start \n",__func__);
+
+
+ vbuf_rec.fd = voice_buffer_open();
+ if(vbuf_rec.fd <= 0){
+ printf("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);
+ ret = -1;
+ goto err;
+
+ }
+ printf("%s :voice_buffer_open end \n",__func__);
+
+ printf("%s :rx tx vb_thread_create start \n",__func__);
+ ret = vb_thread_create ("vb_playback_test",&vbuf_rec.rx_test_thread, vb_rx_test_thread_func,
+ 4*1024,35,NULL);
+ if (ret != 0)
+ {
+ printf("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);
+ goto err;
+ }
+
+ printf("%s :rx vb_thread_create end \n",__func__);
+
+ ret = vb_thread_create ( "vbuf_record_test", &vbuf_rec.tx_test_thread, vb_tx_test_thread_func,
+ 4*1024,35,NULL);
+ if (ret != 0)
+ {
+
+ printf("%s :tx vb_thread_create fail ret=%d,return \n",__func__,ret);
+ vbuf_rec.quit = 1;
+ pthread_join(vbuf_rec.rx_test_thread,NULL);
+ vbuf_rec.rx_test_thread = NULL;
+ goto err;
+ }
+ printf("%s :tx vb_thread_create end \n",__func__);
+
+ return 0;
+
+err:
+ free(vbuf_rec.rx_buf);
+ vbuf_rec.rx_buf = NULL;
+ free(vbuf_rec.tx_buf);
+ vbuf_rec.tx_buf = NULL;
+
+ fclose(vbuf_rec.tx_file);
+ vbuf_rec.tx_file = NULL;
+ fclose(vbuf_rec.rx_file);
+ vbuf_rec.rx_file = NULL;
+
+ return ret;
+}
+
+
+//Stop stream
+int voice_buffer_stream_test_stop(void)
+{
+ int ret = 0;
+ printf("%s:rx tx thread exit start \n",__func__);
+ if(vbuf_rec.quit == 1) {
+ printf("%s,already stop ,return\n",__func__);
+
+ }
+
+ vbuf_rec.quit = 1;
+ voice_buffer_stop(vbuf_rec.fd);
+ if (vbuf_rec.tx_test_thread)
+ {
+ pthread_join (vbuf_rec.tx_test_thread,NULL);
+ vbuf_rec.tx_test_thread = NULL;
+
+ }
+
+ if (vbuf_rec.rx_test_thread)
+ {
+ pthread_join (vbuf_rec.rx_test_thread,NULL);
+ vbuf_rec.rx_test_thread = NULL;
+ }
+
+ printf("voice_buffer_close start \n");
+ ret = voice_buffer_close(vbuf_rec.fd);
+ if(ret != 0)
+ {
+ printf("%s : vb close fail \n",__func__);
+ }
+ vbuf_rec.fd = -1;
+
+ if(vbuf_rec.tx_file != NULL)
+ {
+ fclose(vbuf_rec.tx_file);
+ printf("%s : vb close ,close tx file \n",__func__);
+ vbuf_rec.tx_file = NULL;
+ }
+
+ if(vbuf_rec.rx_file != NULL)
+ {
+
+ fclose(vbuf_rec.rx_file);
+ printf("%s : vb close ,close rx file \n",__func__);
+ vbuf_rec.rx_file = NULL;
+
+ }
+
+ free(vbuf_rec.rx_buf);
+ vbuf_rec.rx_buf = NULL;
+
+ free(vbuf_rec.tx_buf);
+ vbuf_rec.tx_buf = NULL;
+
+
+ vbuffer_start_flag = 0;
+ printf("Stopping vb stream end\n");
+ return 0;
+}
+
+
+static int vb_loop_test_thread_func(void *arg)
+{
+ int ret;
+
+ char* buf = vbuf_rec.rx_buf;
+ int size = vbuf_rec.buf_size;
+
+ //char* buf = vbuf_rec.tx_buf;
+
+ //int size = vbuf_rec.buf_size;
+ int w_size;
+ int r_size;
+
+
+ printf( "%s: start size=%d! \n",__func__,size);
+ memset (buf,0, size);
+
+ while (!vbuf_rec.quit)
+ {
+ rx_optcount ++;
+ VB_INT_OVERFLOW(rx_optcount);
+ if((rx_optcount%1000) == 0){
+ printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
+
+ }
+ else if(rx_optcount == 1000000){
+ printf("%s: rx_optcount=%d! \n",__func__,rx_optcount);
+ rx_optcount = 0;
+
+ }
+
+ //read form ps
+ r_size = voice_buffer_read(vbuf_rec.fd, vbuf_rec.rx_buf, size);
+ if(r_size <= 0)
+ {
+ first_rderr_flag++;
+ VB_INT_OVERFLOW(first_rderr_flag);
+ continue ;
+ }
+ else{
+ first_rderr_flag = 0;
+ }
+ memcpy(vbuf_rec.tx_buf,vbuf_rec.rx_buf,size);
+ w_size = voice_buffer_write(vbuf_rec.fd, vbuf_rec.tx_buf, size);
+ if(w_size <= 0)
+ {
+ first_wrerr_flag++;
+
+ VB_INT_OVERFLOW(first_wrerr_flag);
+
+ continue;
+ }
+ else{
+ first_wrerr_flag = 0;
+ }
+
+ }
+
+ return 0;
+}
+
+
+int voice_buffer_stream_loop_test_start(int fs)
+{
+ int ret = 0;
+ int buf_size = 320;
+ tx_optcount = 0;
+ rx_optcount = 0;
+ int* buf_int;
+
+ int i;
+
+ if(vbuffer_start_flag == 1){
+ printf(" VB already start,return \n");
+
+ return 0;
+ }
+
+ if((vbuf_rec.fd != -1)&&(vbuf_rec.fd != 0)){
+ printf(" VB fd already get, vbuf_rec.fd=%d return \n",vbuf_rec.fd);
+ }
+
+ vbuffer_start_flag = 1;
+
+ if(fs == 8000){
+
+ buf_size = 320;
+ }
+ else if(fs == 16000){
+
+ buf_size = 640;
+ }
+ else
+ {
+ buf_size = 320;
+ }
+ printf("Starting vb stream fs=%d buf_size=%d \n",fs,buf_size);
+
+ vbuf_rec.rx_buf = (char*) malloc(buf_size);
+ if(!vbuf_rec.rx_buf) {
+ printf("%s : malloc buf fail,return \n",__func__);
+ return -1;
+ }
+ vbuf_rec.tx_buf = (char*) malloc(buf_size);
+ if(!vbuf_rec.tx_buf) {
+ free(vbuf_rec.rx_buf);
+ printf("%s : malloc buf fail,return \n",__func__);
+ vbuf_rec.rx_buf = NULL;
+ return -1;
+ }
+ vbuf_rec.buf_size = buf_size;
+
+ vbuf_rec.quit = 0;
+
+ printf("%s : vb open start \n",__func__);
+
+
+ vbuf_rec.fd = voice_buffer_open();
+ if(vbuf_rec.fd <= 0){
+ printf("%s : vb open fail fd=%d,return \n",__func__,vbuf_rec.fd);
+ ret = -1;
+ goto err;
+
+ }
+ printf("%s :loop vb_thread_create start \n",__func__);
+ ret = vb_thread_create ("vb_playback_test",&vbuf_rec.loop_test_thread, vb_loop_test_thread_func,
+ 4*1024,35,NULL);
+ if (ret != 0)
+ {
+ printf("%s :rx vb_thread_create fail ret=%d,return \n",__func__,ret);
+ goto err;
+ }
+
+ printf("%s :rx vb_thread_create end \n",__func__);
+
+ return 0;
+
+err:
+ free(vbuf_rec.rx_buf);
+ vbuf_rec.rx_buf = NULL;
+ free(vbuf_rec.tx_buf);
+ vbuf_rec.tx_buf = NULL;
+
+ return ret;
+}
+
+int voice_buffer_stream_loop_test_stop(void)
+{
+ int ret = 0;
+ printf("%s:loop thread exit start \n",__func__);
+ if(vbuf_rec.quit == 1) {
+ printf("%s,already stop ,return\n",__func__);
+
+ }
+
+ vbuf_rec.quit = 1;
+ voice_buffer_stop(vbuf_rec.fd);
+ if (vbuf_rec.loop_test_thread)
+ {
+ pthread_join (vbuf_rec.loop_test_thread,NULL);
+ vbuf_rec.tx_test_thread = NULL;
+
+ }
+
+ printf("voice_buffer_close start \n");
+ ret = voice_buffer_close(vbuf_rec.fd);
+ if(ret != 0)
+ {
+ printf("%s : vb close fail \n",__func__);
+ }
+ vbuf_rec.fd = -1;
+ free(vbuf_rec.rx_buf);
+ vbuf_rec.rx_buf = NULL;
+
+ free(vbuf_rec.tx_buf);
+ vbuf_rec.tx_buf = NULL;
+
+
+ vbuffer_start_flag = 0;
+ printf("Stopping vb stream end\n");
+ return 0;
+}
+
+int voice_buffer_rtp_test_start(int fs)
+{
+ return voice_buffer_stream_test_start(fs);
+}
+
+
+
+int voice_buffer_rtp_test_stop(void)
+{
+ return voice_buffer_stream_test_stop();
+}
+
+void voice_buffer_cmd_proc(char *cmdstr)
+{
+ int ret = 0;
+ char data[VOICE_CMD_MAX_LEN];
+ int cmdstr_len = strlen(cmdstr) -1; //-strlen("\r")
+ int value = 0;
+ int *p_value = &value;
+
+ cmdstr[cmdstr_len] = '\0'; //+strlen("\0")
+
+ ret = sscanf(cmdstr, "%s", data);
+ if(1 != ret){
+ printf("data sscanf failed!(%d)\n", ret);
+ return;
+ }
+ if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_START, strlen(REQ_VOICE_BUFFER_TEST_START))){
+
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("%s,value sscanf failed!(%d)\n",data, ret);
+ return;
+ }
+
+ printf("%s set value %d\n", data, value);
+ ret = voice_buffer_stream_test_start(value);
+
+ printf("%s return ret=%d\n", data, ret);
+
+ }
+ else if(0 == strncmp(data, REQ_VOICE_BUFFER_TEST_STOP, strlen(REQ_VOICE_BUFFER_TEST_STOP))){
+ ret = voice_buffer_stream_test_stop();
+ printf("%s return %d\n", data, ret);
+ }
+ else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_START, strlen(REQ_VOICE_BUFFER_LOOP_TEST_START))){
+
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("%s,value sscanf failed!(%d)\n",data, ret);
+ return;
+ }
+
+ printf("%s set value %d\n", data, value);
+ ret = voice_buffer_stream_loop_test_start(value);
+
+ printf("%s return ret=%d\n", data, ret);
+
+ }
+ else if(0 == strncmp(data, REQ_VOICE_BUFFER_LOOP_TEST_STOP, strlen(REQ_VOICE_BUFFER_LOOP_TEST_STOP))){
+ printf("voice_buffer_stream_loop_test_stop \n");
+ ret = voice_buffer_stream_loop_test_stop();
+ printf("%s return %d\n", data, ret);
+ }
+ if(0 == strncmp(data, REQ_VOICE_BUFFER_RTP_TEST_START, strlen(REQ_VOICE_BUFFER_RTP_TEST_START))){
+
+ ret = sscanf(cmdstr, "%*s %d", &value);
+ if(1 != ret){
+ printf("%s,value sscanf failed!(%d)\n",data, ret);
+ return;
+ }
+
+ printf("%s set value %d\n", data, value);
+ ret = voice_buffer_rtp_test_start(value);
+
+ printf("%s return ret=%d\n", data, ret);
+
+ }
+ else if(0 == strncmp(data, REQ_VOICE_BUFFER_RTP_TEST_STOP, strlen(REQ_VOICE_BUFFER_RTP_TEST_STOP))){
+ ret = voice_buffer_rtp_test_stop();
+ printf("%s return %d\n", data, ret);
+ }
+ else{
+ printf("Request unknow.\n");
+ printUsage(cmdstr);
+ }
+}
+
+void signal_handle_func(int sig)
+{
+ printf("sig(%d) signal_handle_func exit ",sig);
+ exit(0);
+}
+
+void signal_handle_func_term(int sig)
+{
+ printf("sig(%d) signal_handle_func exit ",sig);
+ voice_buffer_stream_loop_test_stop();
+ voice_buffer_stream_test_stop();
+ voice_buffer_rtp_test_stop();
+ exit(0);
+}
+
+
+int main(int argc, char **argv)
+{
+ char cmdstr[VOICE_CMD_MAX_LEN];
+ printf("voice_demo start\n");
+
+ signal(SIGINT, signal_handle_func);
+ signal(SIGQUIT, signal_handle_func);
+ signal(SIGTERM, signal_handle_func_term);
+ signal(SIGPIPE, signal_handle_func);
+
+ memset(&vbuf_rec,0,sizeof(vbuf_rec));
+
+ while(1){
+ memset(cmdstr, 0, VOICE_CMD_MAX_LEN);
+
+ printf("Please input an voice_demo command:\n");
+
+ if(NULL != fgets(cmdstr, VOICE_CMD_MAX_LEN - 1, stdin)){
+ if(0 == strcmp(EXIT_CMD_STOP, cmdstr) ||
+ 0 == strcmp(EXIT_CMD_Q, cmdstr) ||
+ 0 == strcmp(EXIT_CMD_EXIT, cmdstr)){
+ break;
+ }
+
+ printf("len:%d, cmdstr:%s\n", strlen(cmdstr), cmdstr);
+
+ if(1 >= strlen(cmdstr)){
+ continue;
+ }
+
+ voice_buffer_cmd_proc(cmdstr);
+ }
+ }
+
+ printf("voice_demo end\n");
+
+ return 0;
+}
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile
new file mode 100755
index 0000000..6a6f960
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/files/makefile
@@ -0,0 +1,47 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+ -g -Os \
+ -flto \
+ -fpermissive \
+ -fPIC \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+LOCAL_CFLAGS += -Werror=implicit-function-declaration
+
+$(warning ################# rock ROOT: $(ROOT),includedir:$(includedir),)
+
+LOCAL_PATH = .
+
+LOCAL_C_INCLUDES = \
+ -I. \
+ -I$(ROOT)$(includedir)/ \
+
+
+
+LOCAL_LIBS := \
+ -L. \
+ -ldl \
+ -lpthread \
+ -lvoice \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq_vb_demo
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+ $(CC) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+ $(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+ $(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb
new file mode 100755
index 0000000..b01d3b0
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-vb-demo/lynq-vb-demo.bb
@@ -0,0 +1,29 @@
+#inherit externalsrc package
+
+DESCRIPTION = "lynq-vb-demo"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"
+DEPENDS += "libvoice"
+SRC_URI = "file://lynq_vb_demo.c \
+ file://makefile \
+"
+
+SRC-DIR = "${S}/../lynq-vb-demo"
+FILES_${PN} += "${bindir}/"
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+S = "${WORKDIR}"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+ if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+ else
+ oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+ fi
+}
+
+do_install() {
+ install -d ${D}${bindir}/
+ install -m 0755 ${S}/lynq_vb_demo ${D}${bindir}/
+}
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/cc.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/cc.cpp
index 213c61a..46ee24a 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/cc.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/cc.cpp
@@ -47,6 +47,7 @@
/*Warren add for t800 ril servie 2021/12/23 start*/
#include "lynq_interface.h"
#include <binder/Parcel.h>
+#include "call_rtp.h"
#ifdef LED_SUPPORT
#include "led.h"
#endif
@@ -187,16 +188,17 @@
}
int mixer_set(int value )
{
- RLOGD("lynq this is function:%s,line%d",__FUNCTION__,__LINE__);
- #if LYNQ_CC_SUPPORT
- int ret;
//set mixer ctl to om:1 or off:0
if(value){
- ret = set_mixer_ctrl_value_int(isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name, value);
- RLOGD("mixer_set(%s) = %d, ret: %d", (isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name), value, ret);
- } else {
- //setEcallAudioPathOn(false);
+ //ret = set_mixer_ctrl_value_int(isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name, value);
+
+ exe_set_voice_audio_mode(exe_get_voice_audio_mode());
+
+ // RLOGD("mixer_set(%s) = %d, ret: %d", (isEcallAudioPath() ? g_mixer_name_ecall: g_mixer_name), value, ret);
+ } else {
+ exe_set_voice_audio_mode(AUDIO_MODE_ALL_CLOSE);
+/*
ret = get_mixer_ctrl_value_int(g_mixer_name);
RLOGD("mixer_set(get_mixer_ctrl_value_int: %s) = %d", g_mixer_name, ret);
if(ret > 0) {
@@ -206,11 +208,9 @@
ret = set_mixer_ctrl_value_int(g_mixer_name_ecall, value);
RLOGD("mixer_set(%s) = %d", g_mixer_name_ecall, ret);
}
+*/
}
-
- return ret;
- #endif //LYNQ_CC_SUPPORT
return 0;//LYNQ_CC_SUPPORT
}
int mixer_reset_set(int value )
@@ -459,7 +459,7 @@
}
}
p.setDataPosition(pos);
- setEcallAudioPathOn(false);
+// setEcallAudioPathOn(false);
pRI->pCI->dispatchFunction(p, pRI);
inCallstatus = CALL_ON;
return 0;
@@ -763,7 +763,7 @@
writeStringToParcel(p, (const char *)argv[3+ParticipantsNumber]);//clir
p.setDataPosition(pos);
- setEcallAudioPathOn(false);
+// setEcallAudioPathOn(false);
pRI->pCI->dispatchFunction(p, pRI);
return 0;
}
@@ -787,7 +787,7 @@
#endif
p.setDataPosition(pos);
- setEcallAudioPathOn(false);
+// setEcallAudioPathOn(false);
pRI->pCI->dispatchFunction(p, pRI);
return 0;
}
@@ -1143,7 +1143,7 @@
}
}
p.setDataPosition(pos);
- setEcallAudioPathOn(false);
+//setEcallAudioPathOn(false);
pRI->pCI->dispatchFunction(p, pRI);
return 0;
}
@@ -1537,25 +1537,15 @@
//void callStateChange(void)
void speechonoff(int callnum)
{
- RLOGD("lynq this is function:%s,line%d",__FUNCTION__,__LINE__);
- #if LYNQ_CC_SUPPORT
static int callIndex = 0;
RLOGD("callnum = %d, Call State Change then judge speech on/off!", callnum);
callIndex = callnum;
-#ifdef GSW_RIL_CFG
- if( callIndex >= 1 && speechStatus == SPEECH_OFF) { //speech on
+ lock_rtp_audio_mtx();
+ if( callIndex > 0 && speechStatus == SPEECH_OFF) { //speech on
//RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 phonecall)");
//system("pactl set-card-profile 0 phonecall");
//RLOGD("DemoAPP Call shell command end");
- set_codec(1); //hqing add for Geely demand on 11/07/2022, init cs call, open codec
-#endif
-
-#ifdef MOBILETEK_RIL_CFG
- if( callIndex == 1 && speechStatus == SPEECH_OFF) { //speech on
- //RLOGD("DemoAPP Call shell command (pactl set-card-profile 0 phonecall)");
- //system("pactl set-card-profile 0 phonecall");
- //RLOGD("DemoAPP Call shell command end");
-#endif
+// set_codec(LYNQ_CALL, CODEC_OPEN); //hqing add for Geely demand on 11/07/2022, init cs call, open codec
if (get_audio_path() == 0) {
mixer_set(1);
speechStatus = NORMAL_SPEECH_ON;
@@ -1564,6 +1554,7 @@
speechStatus = BT_SPEECH_ON;
}
inCallstatus = CALL_ON;
+ unlock_rtp_audio_mtx();
RLOGD("[speech]: set on");
sendCallMsg(true); //for Power Manager test
} else if (callIndex == 0
@@ -1571,8 +1562,8 @@
|| speechStatus == BT_SPEECH_ON)) { //speech off
StopRecord();
sendCallMsg(false); // for Power Manager test.
- dtmf_stop(dtmf_handle);
- dtmf_handle = NULL;
+// dtmf_stop(dtmf_handle);
+// dtmf_handle = NULL;
if (speechStatus == NORMAL_SPEECH_ON) {
mixer_set(0);
} else {
@@ -1584,17 +1575,15 @@
speechStatus = SPEECH_OFF;
inCallstatus = CALL_OFF;
resetMute();
-#ifdef GSW_RIL_CFG
- set_codec(0); //hqing add for Geely demand on 11/07/2022, after cs call, close codec for power Manager
-#endif
+ unlock_rtp_audio_mtx();
+// set_codec(LYNQ_CALL, CODEC_CLOSE); //hqing add for Geely demand on 11/07/2022, after cs call, close codec for power Manager
RLOGD("[speech]: set off");
} else {
+ unlock_rtp_audio_mtx();
RLOGD("callIndex is %d, speechStatus is %d.",callIndex, speechStatus);
}
return;
-#endif //LYNQ_CC_SUPPORT
-return;//LYNQ_CC_SUPPORT
}
//RIL_REQUEST_SET_MUTE
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/commands.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/commands.h
index 168d776..8e74197 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/commands.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/commands.h
@@ -240,6 +240,11 @@
{"RIL_REQUEST_DEMO_LOCAL_SET_GOST_DEFAULT",gostTransmitDefaultSet,"Set gost ecall default",-1},
#endif /*ECALL_SUPPORT*/
+ //rtp
+ {"LYNQ_REQUEST_SET_VOICE_AUDIO_MODE",set_voice_audio_mode,"set voice audio mode",LYNQ_REQUEST_SET_VOICE_AUDIO_MODE},
+
+ {"LYNQ_REQUEST_GET_VOICE_AUDIO_MODE",get_voice_audio_mode,"get voice audio mode",LYNQ_REQUEST_GET_VOICE_AUDIO_MODE},
+
#ifdef MODE_DSDS
{"SET_DEFAULT_SIM_ALL",set_default_sim_all, "set default sim_all", -1},
{"GET_DEFAULT_SIM_ALL",get_default_sim_all, "get default sim_all", -1},
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp
index dd0b7ff..5951ee3 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.cpp
@@ -70,7 +70,6 @@
static ECALL_TYPE ecall_type = ECALL_TYPE::EN16454_ECALL;
static bool inNeedRegister = false;
static bool gostFastEcallFlg = false;
-static bool is_ecall_audio_path = false;
int gost_sms_argc = 0;
std::vector<std::string> gost_sms_argv;
@@ -158,11 +157,6 @@
static int g_ecall_test=0;
static int g_reset_timer =6;
-bool isEcallAudioPath() {
- RLOGD("%s , is_ecall_audio_path: %d", __FUNCTION__, is_ecall_audio_path);
- return is_ecall_audio_path;
-}
-
bool isEcallAutoanswerTimerFinish() {
struct itimerspec timespec;
if(timer_gettime(sAutoAnsTimer, ×pec) == -1) {
@@ -185,21 +179,7 @@
}
return false;
}
-
-void setEcallAudioPathOn(bool on) {
- RLOGD("%s() , is_ecall_audio_path: %d, on: %d", __FUNCTION__, is_ecall_audio_path, on);
-
- if((is_ecall_audio_path != on) && (isEcallAutoanswerTimerFinish())) {
- is_ecall_audio_path = on;
- }
- RLOGD("%s() , is_ecall_audio_path: %d", __FUNCTION__, is_ecall_audio_path);
-}
-
void autoAnswerEcall(bool on) {
- RLOGD("%s() , is_ecall_audio_path: %d, on: %d", __FUNCTION__, is_ecall_audio_path, on);
- if(is_ecall_audio_path != on) {
- is_ecall_audio_path = on;
- }
if(on) {
char* argv[2] = {"", "1"};
autoAnswerCall(2, argv, RIL_SOCKET_ID(0), NULL); //unused socket id;
@@ -424,8 +404,7 @@
}
else if(sig.sival_int == redial_sig_value) {
redial_tag = REDIAL_EXPIRES;
- RequestInfo* pRI = creatRILInfoAndInit(RIL_REQUEST_ECALL_RESET_IVS, UDP,RIL_SOCKET_ID(fast_ecall_socket_id));
- resetIVS(0, NULL, RIL_SOCKET_ID(fast_ecall_socket_id), pRI);
+ resetEcallIVSandAudio(UDP, RIL_SOCKET_ID(fast_ecall_socket_id));
fast_argc = 0;
fast_argv.clear();
@@ -632,7 +611,7 @@
stop_ecall_timer(sRedialTimer, redial_sig_value);
redial_tag = REDIAL_SUCCESS;
- resetEcallIVSandAudio(RSPD, soc_id);
+ resetEcallIVSandAudio(RSPD, RIL_SOCKET_ID(fast_ecall_socket_id));
saveEcallRecord(p_cur->ind);
act_fecall_socid = soc_id;
@@ -724,8 +703,7 @@
stop_ecall_timer(sT6,sT6_sig_value);
stop_ecall_timer(sT7,sT7_sig_value);
ecall_test_sub_recover();
- RequestInfo* pRI = creatRILInfoAndInit(RIL_REQUEST_ECALL_RESET_IVS, UDP, soc_id);
- resetIVS(0, NULL, soc_id, pRI);
+ resetEcallIVSandAudio(UDP, soc_id);
redialFastEcall(soc_id);
}
else { /* redial_tag == REDIAL_SUCCESS || redial_tag == REDIAL_EXPIRES */
@@ -1012,7 +990,7 @@
//RIL_REQUEST_ECALL_RESET_IVS
int resetIVS(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI) {
android::Parcel p;
-
+/*
if (getSpeechStatus() == SPEECH_OFF) {
if (get_audio_path() == 0) {
setSpeechAndStatus(1);
@@ -1020,7 +998,7 @@
setSpeechAndStatus(2);
}
}
-
+*/
//paramter none
pRI->pCI->dispatchFunction(p, pRI);
return 0;
@@ -1096,7 +1074,7 @@
p.writeInt32(1);
p.writeInt32(type);
p.setDataPosition(pos);
- setEcallAudioPathOn(true);
+// setEcallAudioPathOn(true);
pRI->pCI->dispatchFunction(p, pRI);
return 0;
}
@@ -1169,7 +1147,7 @@
p.setDataPosition(pos);
normal_ecall_tag = true;
- setEcallAudioPathOn(true);
+// setEcallAudioPathOn(true);
act_fecall_socid = -1;
act_feCall_Id = -1;
pRI->pCI->dispatchFunction(p, pRI);
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.h
index 7c5e668..8439cc4 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ecall/eCall.h
@@ -95,8 +95,6 @@
int gostEcallResendMsd(bool flg);
void gostSetInNeedRegister(bool flags);
void gostFastEcallFlgSet(bool flags);
-bool isEcallAudioPath();
-void setEcallAudioPathOn(bool on);
void init_redial_flag();
#endif /*ECALL_SUPPORT*/
#endif
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_interface.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_interface.h
index 95a50ce..db8e782 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_interface.h
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/lynq_interface.h
@@ -24,6 +24,9 @@
#define LYNQ_REQUEST_CHANGE_SCREEN_STATE (LYNQ_REQUEST_VENDOR_BASE + 14)/*jb.qi add for two sim suspend 2022/9/19*/
#define LYNQ_REQUEST_CHANGE_RADIO (LYNQ_REQUEST_VENDOR_BASE + 15)
#define LYNQ_REQUEST_CHANGE_SLEEP_STATE (LYNQ_REQUEST_VENDOR_BASE + 16)/*jb.qi change for suspend 2024/2/23 start*/
+#define LYNQ_REQUEST_SET_VOICE_AUDIO_MODE (LYNQ_REQUEST_VENDOR_BASE + 28)
+#define LYNQ_REQUEST_GET_VOICE_AUDIO_MODE (LYNQ_REQUEST_VENDOR_BASE + 21)
+
#ifdef ECALL_SUPPORT
#define RIL_UNSOL_ECALL_T2_TIMER_OUT 9000
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/makefile b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/makefile
index 70aac91..848b70a 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/makefile
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/makefile
@@ -105,6 +105,7 @@
-I$(LOCAL_PATH)/factory \
-I$(LOCAL_PATH)/temp \
-I$(LOCAL_PATH)/led/include \
+ -I$(LOCAL_PATH)/rtp \
-I$(ROOT)$(includedir)/logger \
-I$(ROOT)$(includedir)/liblog \
-I$(ROOT)$(includedir)/liblynq-thermal \
@@ -157,7 +158,7 @@
endif
-SOURCES = $(wildcard util/*.cpp *.cpp ecall/*.cpp ecall/gost/*.cpp ecall/gost/utils/*.cpp ecall/gost/sslp/*.cpp ecall/gost/sslp/auth/*.cpp ecall/gost/sslp/firmware/*.cpp ecall/gost/sslp/commands/*.cpp ecall/gost/sslp/ecall/*.cpp ecall/gost/sslp/teledata/*.cpp data/*.cpp sms/*.cpp sms/gsm/*.cpp sms/cdma/*.cpp atci/*.cpp stateManager/*.cpp sms/lynqSmsManager/*.cpp led/*.cpp)
+SOURCES = $(wildcard util/*.cpp *.cpp ecall/*.cpp ecall/gost/*.cpp ecall/gost/utils/*.cpp ecall/gost/sslp/*.cpp ecall/gost/sslp/auth/*.cpp ecall/gost/sslp/firmware/*.cpp ecall/gost/sslp/commands/*.cpp ecall/gost/sslp/ecall/*.cpp ecall/gost/sslp/teledata/*.cpp data/*.cpp sms/*.cpp sms/gsm/*.cpp sms/cdma/*.cpp atci/*.cpp stateManager/*.cpp sms/lynqSmsManager/*.cpp led/*.cpp rtp/*.cpp)
EXECUTABLE = lynq-ril-service
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
index 71bce71..19b2854 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
@@ -99,6 +99,7 @@
#include <include/lynq_uci.h>
#endif
#include "lynq_shm.h"
+#include "call_rtp.h"
#define LOG_TAG "DEMO_RIL"
#define WAIT_TIME_FOR_SIM_SWITCH 30
@@ -5331,6 +5332,8 @@
case LYNQ_REQUEST_SET_DEFAULT_SIM_ALL:return "SET_DEFAULT_SIM_ALL";
case LYNQ_REQUEST_CHANGE_SCREEN_STATE:return "LYNQ_REQUEST_CHANGE_SCREEN_STATE";/*jb.qi add for two sim sleep 2022/9/19*/
case LYNQ_REQUEST_CHANGE_RADIO:return "LYNQ_REQUEST_CHANGE_RADIO";/*lei add for factory test of sleep 2022/9/19*/
+ case LYNQ_REQUEST_SET_VOICE_AUDIO_MODE:return "LYNQ_REQUEST_SET_VOICE_AUDIO_MODE";
+ case LYNQ_REQUEST_GET_VOICE_AUDIO_MODE:return "LYNQ_REQUEST_GET_VOICE_AUDIO_MODE";
case RIL_REQUEST_GET_MSISDN:return "RIL_REQUEST_GET_MSISDN";
case RIL_REQUEST_RESET_SIMCARD:return "RIL_REQUEST_RESET_SIMCARD";
case LYNQ_REQUEST_CHANGE_SLEEP_STATE: return "LYNQ_REQUEST_CHANGE_SLEEP_STATE";/*jb.qi change for suspend 2024/2/23 */
@@ -5800,6 +5803,8 @@
mbtk_netled_init();
#endif
mixer_init();
+ lynq_init_rtp();
+
if(utils::is_support_dsds()) {
for(int i = 0; i < 2 ; i++) {
init(i);
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.cpp
new file mode 100755
index 0000000..981292e
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.cpp
@@ -0,0 +1,794 @@
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <string.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <binder/Parcel.h>
+#include <log/log.h>
+#include <cutils/jstring.h>
+#include <pthread.h>
+#include "liblog/lynq_deflog.h"
+#include <sys/time.h>
+#include <string.h>
+//#include "lynq_call.h"
+//#include "lynq_module_common.h"
+//#include "lynq_call_common.h"
+#include "common.h"
+#include "call_rtp.h"
+#include "call_rtp_inner.h"
+#include "lynq_interface.h"
+#include "ecall/eCall.h"
+#include "cc.h"
+#include "lynq_at.h"
+
+#undef LOG_TAG
+#define LOG_TAG "ECALL_RTP"
+
+#if 0
+static lynq_rtp_client_info g_rtp_client_info;
+static lynq_rtp_server_info g_rtp_server_info;
+
+static pthread_t g_rtp_thread[RTP_MODE_MAX];
+static bool g_rtp_thread_valid[RTP_MODE_MAX]={0};
+#endif
+
+static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER;
+
+static LYNQ_Audio_Mode s_current_audio_mode=AUDIO_MODE_CODEC;
+
+int lock_rtp_audio_mtx()
+{
+ return pthread_mutex_lock(&mtx);
+}
+
+int unlock_rtp_audio_mtx()
+{
+ return pthread_mutex_unlock(&mtx);
+}
+
+
+int set_voice_audio_mode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ android::Parcel p;
+ int setValue = 0;
+
+ if(argc < 2) {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_VOICE_AUDIO_MODE,0,2);
+ android::LYNQ_RIL_respSocket_sp(p,pRI);
+ free(pRI);
+ RLOGW("%s fail! argc is %d",__FUNCTION__,argc);
+ return -1;
+ }
+
+ setValue = atoi(argv[1]);
+ RLOGD("%s %d start",__FUNCTION__,setValue);
+ if(setValue < AUDIO_MODE_CODEC || setValue > AUDIO_MODE_ALL_CLOSE ) {
+ RLOGW("Warning: parameter %d is over-range!",setValue);
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_VOICE_AUDIO_MODE,0,3);
+ android::LYNQ_RIL_respSocket_sp(p,pRI);
+ free(pRI);
+ return -1;
+ }
+
+ int s = lock_rtp_audio_mtx();
+ if(s != 0) {
+ RLOGE("%s lock_rtp_audio_mtx fail",__FUNCTION__);
+ }
+
+ LYNQ_Audio_Mode old_audio_mode;
+ old_audio_mode=s_current_audio_mode;
+ s_current_audio_mode=(LYNQ_Audio_Mode) setValue;
+#if 0
+ if((get_call_status() == CALL_ON) && getSpeechStatus() == NORMAL_SPEECH_ON)
+ {
+
+ if(s_current_audio_mode!=old_audio_mode)
+ {
+ RLOGD("%s, change mode in real time",__FUNCTION__);
+ if(exe_set_voice_audio_mode(s_current_audio_mode)
+ {
+ s_current_audio_mode=old_audio_mode;
+ s = unlock_rtp_audio_mtx();
+ if(s != 0) {
+ RLOGE("%s, unlock_rtp_audio_mtx fail",__FUNCTION__);
+ }
+
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_VOICE_AUDIO_MODE,0,5);
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_ERROR;
+ }
+ }
+ }
+#endif
+ s = unlock_rtp_audio_mtx();
+ if(s != 0) {
+ RLOGE("%s, unlock_rtp_audio_mtx fail",__FUNCTION__);
+ }
+
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_VOICE_AUDIO_MODE,0,0);
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ RLOGD("%s %d finish",__FUNCTION__,setValue);
+ return RESULT_OK;
+}
+
+#if 0
+int set_remote_rtp_ip(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ RLOGD("%s start!",__FUNCTION__);
+ android::Parcel p;
+
+ if(argc < 2) {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_REMOTE_RTP_IP,0,2);
+ android::LYNQ_RIL_respSocket_sp(p,pRI);
+ free(pRI);
+ RLOGW("Warning: no %s!",__FUNCTION__);
+ return -1;
+ }
+
+ if(exe_set_remote_rtp_ip(argv[1],strlen(argv[1])+1)==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_REMOTE_RTP_IP,0,0);
+ RLOGD(">>>>%s<<<< success value is %s!\n", __FUNCTION__, argv[1]);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_REMOTE_RTP_IP,0,4);
+ RLOGD(">>>>%s <<<< failure value is %s!\n",__FUNCTION__, argv[1]);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+int set_vlan_info(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ RLOGD("%s start!",__FUNCTION__);
+ android::Parcel p;
+ const char* vlan_info="";
+
+ if(argc >1)
+ {
+ vlan_info=argv[1];
+ }
+
+ if(exe_set_vlan_info(vlan_info,strlen(vlan_info)+1)==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_VLAN_INFO,0,0);
+ RLOGD(">>>>%s<<<< success value is %s!\n", __FUNCTION__, vlan_info);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_VLAN_INFO,0,4);
+ RLOGE(">>>>%s <<<< failure value is %s!\n",__FUNCTION__, vlan_info);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+
+int set_rtp_port(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ RLOGD("%s start!",__FUNCTION__);
+ android::Parcel p;
+
+ if(argc < 3)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_RTP_PORT,0,2);
+ android::LYNQ_RIL_respSocket_sp(p,pRI);
+ free(pRI);
+ RLOGW("Warning: no %s!",__FUNCTION__);
+ return -1;
+ }
+
+ if(exe_set_rtp_port((LYNQ_Rtp_Mode)(atoi(argv[1])),atoi(argv[2]))==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_RTP_PORT,0,0);
+ RLOGD(">>>>%s<<<< success value is %s %s!\n", __FUNCTION__, argv[1],argv[2]);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_RTP_PORT,0,4);
+ RLOGE(">>>>%s <<<< failure value is %s %s!\n",__FUNCTION__, argv[1],argv[2]);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+
+ return RESULT_OK;
+}
+
+
+int set_rtp_param(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ RLOGD("%s start!",__FUNCTION__);
+ android::Parcel p;
+
+ if(argc < 4) {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_RTP_PARAM,0,2);
+ android::LYNQ_RIL_respSocket_sp(p,pRI);
+ free(pRI);
+ RLOGW("Warning: no %s!",__FUNCTION__);
+ return -1;
+ }
+
+ if(exe_set_rtp_param(atoi(argv[1]),atoi(argv[2]),atoi(argv[3]))==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_RTP_PARAM,0,0);
+ RLOGD(">>>>%s<<<< success value is %s %s %s!\n", __FUNCTION__, argv[1],argv[2],argv[3]);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_RTP_PARAM,0,4);
+ RLOGE(">>>>%s <<<< failure value is %s %s %s!\n",__FUNCTION__, argv[1],argv[2],argv[3]);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+
+ return RESULT_OK;
+}
+
+int set_call_rtp_ssrc(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ RLOGD("%s start!",__FUNCTION__);
+ android::Parcel p;
+
+ if(argc < 3) {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_CALL_RTP_SSRC,0,2);
+ android::LYNQ_RIL_respSocket_sp(p,pRI);
+ free(pRI);
+ RLOGW("Warning: no %s!",__FUNCTION__);
+ return -1;
+ }
+
+ if(exe_set_call_rtp_ssrc(atoi(argv[1]),strtoul(argv[2],0,0))==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_CALL_RTP_SSRC,0,0);
+ RLOGD(">>>>%s<<<< success value is %s %s!\n", __FUNCTION__, argv[1],argv[2]);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_CALL_RTP_SSRC,0,4);
+ RLOGE(">>>>%s <<<< failure value is %s %s!\n",__FUNCTION__, argv[1],argv[2]);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+
+ return RESULT_OK;
+}
+#endif
+
+int get_voice_audio_mode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ android::Parcel p;
+ int mode = exe_get_voice_audio_mode();
+
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_VOICE_AUDIO_MODE,0,0);
+
+ #ifdef MOBILETEK_TARGET_PLATFORM_T106
+ p.writeInt32(1);
+ #endif
+
+ p.writeInt32(mode);
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+
+#if 0
+int get_remote_rtp_ip(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ char rtp_ip[MAX_IP_LENGTH]={0};
+
+ android::Parcel p;
+ if(exe_get_remote_rtp_ip(rtp_ip,MAX_IP_LENGTH)==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_REMOTE_RTP_IP,0,0);
+ p.writeInt32(1);
+ android::writeStringToParcel(p,rtp_ip);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_REMOTE_RTP_IP,0,2);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+
+int get_vlan_info(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ char vlan_info[MAX_VLAN_INFO_LENGTH]={0};
+
+ android::Parcel p;
+ if(exe_get_vlan_info(vlan_info,MAX_VLAN_INFO_LENGTH)==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_VLAN_INFO,0,0);
+ p.writeInt32(1);
+ android::writeStringToParcel(p,vlan_info);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_VLAN_INFO,0,2);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+
+int get_rtp_port(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ int rtp_port;
+ android::Parcel p;
+
+
+ if(argc < 2) {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_SET_RTP_PORT,0,2);
+ android::LYNQ_RIL_respSocket_sp(p,pRI);
+ free(pRI);
+ RLOGW("Warning: no %s!",__FUNCTION__);
+ return RESULT_ERROR;
+ }
+ if(exe_get_rtp_port((LYNQ_Rtp_Mode) (atoi(argv[1])),&rtp_port)==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_VLAN_INFO,0,0);
+ p.writeInt32(rtp_port);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_VLAN_INFO,0,3);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+
+int get_rtp_param(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ int clock_rate, channels, latency;
+ android::Parcel p;
+
+ if(exe_get_rtp_param(&clock_rate, &channels, &latency)==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_RTP_PARAM,0,0);
+ p.writeInt32(clock_rate);
+ p.writeInt32(channels);
+ p.writeInt32(latency);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_RTP_PARAM,0,2);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+
+int get_call_rtp_ssrc(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI)
+{
+ android::Parcel p;
+
+ int ssrc_mode;
+ unsigned int ssrc;
+
+ if(exe_get_call_rtp_ssrc(&ssrc_mode, &ssrc)==RESULT_OK)
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_CALL_RTP_SSRC,0,0);
+ p.writeInt32(ssrc_mode);
+ p.writeUint32(ssrc);
+ }
+ else
+ {
+ android::lynqAssemblyParcelheader(p,socket_id,pRI->uToken,LYNQ_REQUEST_GET_CALL_RTP_SSRC,0,2);
+ }
+
+ android::LYNQ_RIL_respSocket(p,(void *)pRI);
+ free(pRI);
+ return RESULT_OK;
+}
+#endif
+
+void lynq_init_rtp()
+{
+ exe_set_voice_audio_mode(AUDIO_MODE_INIT);
+
+ RLOGD("lynq init rtp success!!!");
+ return;
+}
+
+/*Audio Path setting begin*/
+/*sub function*/
+#if 0
+void exe_set_rtp_mixer_ctrl(int audio_mode)
+{
+ char cmd[256];
+ RLOGD("set_rtp_mixer_ctrl, audio mode is %d", audio_mode);
+ if(audio_mode==AUDIO_MODE_RTP)
+ {
+ sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on_ecall\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -D mtk_phonecall cset name=\"M2M_Speech_on\" %d", 1);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH1 DL2_CH1\" %d", 1);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH2 DL2_CH2\" %d", 1);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"UL2_CH1 PCM_2_CAP_CH1\" %d", 1);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"UL2_CH2 PCM_2_CAP_CH1\" %d", 1);
+ system(cmd);
+ }
+ else if(audio_mode==AUDIO_MODE_CODEC)
+ {
+ sprintf(cmd, "amixer -D mtk_phonecall cset name=\"M2M_Speech_on\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH1 DL2_CH1\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH2 DL2_CH2\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"UL2_CH1 PCM_2_CAP_CH1\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"UL2_CH2 PCM_2_CAP_CH1\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on_ecall\" %d", 1);
+ system(cmd);
+ }
+ else
+ {
+ if(audio_mode==AUDIO_MODE_INIT)
+ {
+ sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on\" %d", 0);
+ system(cmd);
+ }
+ sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on_ecall\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -D mtk_phonecall cset name=\"M2M_Speech_on\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH1 DL2_CH1\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH2 DL2_CH2\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"UL2_CH1 PCM_2_CAP_CH1\" %d", 0);
+ system(cmd);
+ sprintf(cmd, "amixer -c0 cset name=\"UL2_CH2 PCM_2_CAP_CH1\" %d", 0);
+ system(cmd);
+ }
+}
+
+static int record_count=0;
+void* exe_start_rtp_cmd(void *arg)
+{
+ int* rtp_mode= (int*) arg;
+ char cmd[384];
+ char vlan_para_string[sizeof(RTP_VLAN_INFO_FORMAT)+MAX_VLAN_INFO_LENGTH-2/*sizeof "%s"*/]={0};
+ char ssrc_para_string[sizeof(RTP_SSRC_INFO_FORMAT)+MAX_SSRC_INFO_LENGTH-2/*sizeof "%u"*/]={0};
+ RLOGD("exe_start_rtp_cmd: rtp_mode is %d",(*rtp_mode));
+ if ((*rtp_mode) == RTP_CLIENT)
+ {
+ if(g_ril_test==RIL_STUB_TEST_SWTICH_RTP_RECORD)
+ {
+ system("sleep 30");
+ }
+ else
+ {
+ sprintf(cmd,RTP_FROM_CMD, \
+ g_rtp_client_info.port,g_rtp_client_info.clockrate,g_rtp_client_info.channels, \
+ g_rtp_client_info.latency);
+ RLOGD("start from rtp play: cmd is %s",cmd);
+ system(cmd);
+ }
+ }
+ else if ((*rtp_mode) == RTP_SERVER)
+ {
+ if(g_ril_test==RIL_STUB_TEST_SWTICH_RTP_RECORD)
+ {
+ const char* record_fmt="arecord -D hw:0,6 -c 2 -d 10 -r 32000 -f S16_LE --period-size=1280 --buffer-size=5120 /tmp/record_%d.wav";
+ sprintf(cmd,record_fmt,record_count);
+ RLOGD("start to rtp play: cmd is %s",cmd);
+ record_count++;
+ system(cmd);
+ }
+ else
+ {
+ if(strlen(g_rtp_server_info.vlan_info)>0)
+ {
+ sprintf(vlan_para_string,RTP_VLAN_INFO_FORMAT,g_rtp_server_info.vlan_info);
+ }
+
+ if(g_rtp_server_info.ssrc_mode == Rtp_Ssrc_specific)
+ {
+ sprintf(ssrc_para_string,RTP_SSRC_INFO_FORMAT,g_rtp_server_info.ssrc);
+ }
+ sprintf(cmd,RTP_TO_CMD, \
+ g_rtp_client_info.channels, g_rtp_client_info.clockrate, ssrc_para_string, g_rtp_server_info.ip,vlan_para_string,g_rtp_server_info.port);
+
+ RLOGD("start to rtp play: cmd is %s",cmd);
+ system(cmd);
+ }
+
+ }
+ return NULL;
+}
+
+int exe_start_rtp_thread(int rtp_mode)
+{
+ int ret;
+ pthread_attr_t attr;
+ static int start_mode[RTP_MODE_MAX]={0,1};
+
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ ret = pthread_create(&(g_rtp_thread[rtp_mode]),&attr,exe_start_rtp_cmd,&(start_mode[rtp_mode]));
+ if(ret != 0)
+ {
+ g_rtp_thread_valid[rtp_mode]=0;
+ RLOGE("rtp create %d pthread error, ret is %d",rtp_mode, ret);
+ return ret;
+ }
+ g_rtp_thread_valid[rtp_mode]=1;
+ return RESULT_OK;
+}
+#endif
+
+/*set*/
+int exe_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode)
+{
+ int ret;
+ int i;
+
+ char* cmd1="AT+VOICE_BUFFER=1,1";
+ char* cmd2="AT+VOICE_PROCESS=0";
+ char* cmd3="AT+VOICE_BUFFER=0,0";
+ char* cmd4="AT+VOICE_PROCESS=1";
+ char* argv[2]={0};
+
+ char cmd[256];
+
+
+ RLOGD("%s %d",__FUNCTION__,audio_mode);
+ if(audio_mode==AUDIO_MODE_RTP)
+ {
+ sprintf(cmd, "%s", "killall lynq_vb_demo");
+ system(cmd);
+ argv[1] = cmd1;
+ lynqSendAt(2,argv,1011);
+ argv[1] = cmd4;
+ lynqSendAt(2,argv,1012);
+ sprintf(cmd, "echo voice_buffer_rtp_test_start %d | lynq_vb_demo &", 16000);
+ system(cmd);
+ }
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+ else if(audio_mode==AUDIO_MODE_FILE)
+ {
+ sprintf(cmd, "%s", "killall lynq_vb_demo");
+ system(cmd);
+ argv[1] = cmd1;
+ lynqSendAt(2,argv,1011);
+ argv[1] = cmd4;
+ lynqSendAt(2,argv,1012);
+ sprintf(cmd, "echo voice_buffer_test_start %d | lynq_vb_demo &", 16000);
+ system(cmd);
+ }
+ else if(audio_mode==AUDIO_MODE_LOOP_BACK)
+ {
+ sprintf(cmd, "%s", "killall lynq_vb_demo");
+ system(cmd);
+ argv[1] = cmd1;
+ lynqSendAt(2,argv,1011);
+ argv[1] = cmd2;
+ lynqSendAt(2,argv,1012);
+ sprintf(cmd, "echo voice_buffer_loop_test_start %d | lynq_vb_demo &", 16000);
+ system(cmd);
+ }
+#endif
+#if 0
+ else if(audio_mode==AUDIO_MODE_CODEC)
+ {
+
+ for(i=0;i<RTP_MODE_MAX;i++)
+ {
+ if(g_rtp_thread_valid[i])
+ {
+ ret = pthread_cancel(g_rtp_thread[i]);
+ RLOGD("pthread cancel rtp %d ret = %d",i,ret);
+ ret = pthread_join(g_rtp_thread[i],NULL);
+ RLOGD("pthread join rtp %d ret = %d",i,ret);
+ g_rtp_thread_valid[i] = 0;
+ }
+ else
+ {
+ RLOGD("rtp thread %d needn't stop",i);
+ }
+ }
+ exe_set_rtp_mixer_ctrl(audio_mode);
+
+ }
+#endif
+ else // audio_mode==AUDIO_MODE_ALL_CLOSE /AUDIO_MODE_INIT/AUDIO_MODE_CODEC
+ {
+ sprintf(cmd, "%s", "killall lynq_vb_demo");
+ system(cmd);
+ argv[1] = cmd4;
+ lynqSendAt(2,argv,1013);
+ argv[1] = cmd3;
+ lynqSendAt(2,argv,1014);
+
+/*
+ for(i=0;i<RTP_MODE_MAX;i++)
+ {
+ if(g_rtp_thread_valid[i])
+ {
+ ret = pthread_cancel(g_rtp_thread[i]);
+ RLOGD("pthread cancel rtp %d ret = %d",i,ret);
+ ret = pthread_join(g_rtp_thread[i],NULL);
+ RLOGD("pthread join rtp %d ret = %d",i,ret);
+ g_rtp_thread_valid[i] = 0;
+ }
+ else
+ {
+ RLOGD("rtp thread %d needn't stop",i);
+ }
+ }
+ exe_set_rtp_mixer_ctrl(audio_mode);
+*/
+ }
+ RLOGD("%s %d suc",__FUNCTION__,audio_mode);
+ return RESULT_OK;
+
+}
+
+#if 0
+int exe_set_remote_rtp_ip(const char* ip, const int ip_length)
+{
+ if (NULL == ip)
+ {
+ RLOGE("ip is NULL!!!");
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+ if ((ip_length < strlen(ip)+1) || (ip_length > MAX_IP_LENGTH))
+ {
+ RLOGE("incoming ip length error %d", ip_length);
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+
+ bzero(g_rtp_server_info.ip,MAX_IP_LENGTH);
+ strcpy(g_rtp_server_info.ip,ip);
+
+ RLOGD("exe_set_remote_rtp_ip suc: ip is %s, length is %d", ip,ip_length);
+
+ return RESULT_OK;
+}
+int exe_set_vlan_info(const char* vlan_info, const int vlan_info_length)
+{
+ if (NULL == vlan_info)
+ {
+ RLOGE("vlan_info is NULL!!!");
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+
+ if ((vlan_info_length < strlen(vlan_info)+1) || (vlan_info_length > MAX_VLAN_INFO_LENGTH))
+ {
+ RLOGE("incoming vlan_info error, vlan info length %d", vlan_info_length);
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+
+
+ bzero(g_rtp_server_info.vlan_info,MAX_VLAN_INFO_LENGTH);
+ strcpy(g_rtp_server_info.vlan_info,vlan_info);
+
+ RLOGD("exe_set_vlan_info suc: vlan is %s, length is %d", vlan_info,vlan_info_length);
+
+ return RESULT_OK;
+}
+int exe_set_rtp_port(const LYNQ_Rtp_Mode rtp_mode, const int port)
+{
+ if (port < 0)
+ {
+ RLOGE("invalid port number %d", port);
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+ if (rtp_mode == 0)
+ {
+ g_rtp_client_info.port = port;
+ }
+ else if (rtp_mode == 1)
+ {
+ g_rtp_server_info.port = port;
+ }
+ RLOGD("exe_set_rtp_port suc: LYNQ_Rtp_Mode is %d, port is %d", rtp_mode, port);
+ return RESULT_OK;
+}
+int exe_set_rtp_param(const int clock_rate,const int channels,const int latency)
+{
+ g_rtp_client_info.clockrate = clock_rate;
+ g_rtp_client_info.channels = channels;
+ g_rtp_client_info.latency = latency;
+ RLOGD("exe_set_rtp_param suc: clockrate is %d, channels is %d, latency is %d", clock_rate, channels, latency);
+ return RESULT_OK;
+}
+int exe_set_call_rtp_ssrc(const int ssrc_mode,const unsigned int ssrc)
+{
+ if(ssrc_mode < Rtp_Ssrc_random || ssrc_mode > Rtp_Ssrc_specific)
+ {
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+ g_rtp_server_info.ssrc_mode = ssrc_mode;
+ g_rtp_server_info.ssrc = ssrc ;
+ RLOGD("%s suc: param is %d %u", __func__, ssrc_mode, ssrc);
+ return RESULT_OK;
+}
+#endif
+
+/*get*/
+LYNQ_Audio_Mode exe_get_voice_audio_mode()
+{
+ return s_current_audio_mode;
+}
+
+#if 0
+int exe_get_remote_rtp_ip(char* ip, const int ip_length)
+{
+ if(ip_length < strlen(g_rtp_server_info.ip)+1)
+ {
+ RLOGE("ip length %d is shorter than saved ip length %d",ip_length,strlen(g_rtp_server_info.ip)+1);
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+
+ bzero(ip,ip_length);
+ strcpy(ip,g_rtp_server_info.ip);
+
+ return RESULT_OK;
+}
+int exe_get_vlan_info(char* vlan_info, const int vlan_info_length)
+{
+ if(vlan_info_length < strlen(g_rtp_server_info.vlan_info)+1)
+ {
+ RLOGE("vlan info length %d is shorter than saved vlan info length %d",vlan_info_length,strlen(g_rtp_server_info.vlan_info)+1);
+ return LYNQ_E_PARAMETER_ANONALY;
+ }
+
+ bzero(vlan_info,vlan_info_length);
+ strcpy(vlan_info,g_rtp_server_info.vlan_info);
+
+ return RESULT_OK;
+}
+int exe_get_rtp_port(const LYNQ_Rtp_Mode rtp_mode, int* port)
+{
+ if (rtp_mode == 0)
+ {
+ *port = g_rtp_client_info.port;
+ }
+ else if (rtp_mode == 1)
+ {
+ *port = g_rtp_server_info.port;
+ }
+ return RESULT_OK;
+}
+int exe_get_rtp_param(int* clock_rate, int* channels, int* latency)//only for client mode
+{
+ *clock_rate = g_rtp_client_info.clockrate;
+ *channels = g_rtp_client_info.channels ;
+ *latency = g_rtp_client_info.latency;
+
+ return RESULT_OK;
+}
+int exe_get_call_rtp_ssrc(int* ssrc_mode, unsigned int* ssrc)
+{
+ *ssrc_mode = g_rtp_server_info.ssrc_mode;
+ *ssrc = g_rtp_server_info.ssrc ;
+
+ return RESULT_OK;
+}
+#endif
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.h
new file mode 100755
index 0000000..784c765
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp.h
@@ -0,0 +1,36 @@
+#ifndef CALL_RTP_H
+#define CALL_RTP 1
+
+void lynq_init_rtp();
+int set_voice_audio_mode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int set_remote_rtp_ip(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int set_vlan_info(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int set_rtp_port(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int set_rtp_param(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int set_call_rtp_ssrc(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int get_voice_audio_mode(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int get_remote_rtp_ip(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int get_vlan_info(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int get_rtp_port(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int get_rtp_param(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+int get_call_rtp_ssrc(int argc, char **argv, RIL_SOCKET_ID socket_id, RequestInfo *pRI);
+
+
+typedef enum{
+ AUDIO_MODE_CODEC = 0, /* Codec */
+ AUDIO_MODE_RTP, /* RTP */
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+ AUDIO_MODE_FILE,
+ AUDIO_MODE_LOOP_BACK,
+#endif
+ AUDIO_MODE_INIT,
+ AUDIO_MODE_ALL_CLOSE,
+}LYNQ_Audio_Mode;
+int exe_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode);
+LYNQ_Audio_Mode exe_get_voice_audio_mode();
+
+
+int lock_rtp_audio_mtx();
+int unlock_rtp_audio_mtx();
+
+#endif
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp_inner.h b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp_inner.h
new file mode 100755
index 0000000..11b51a3
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/rtp/call_rtp_inner.h
@@ -0,0 +1,68 @@
+#ifndef CALL_RTP_INNER_H
+#define CALL_RTP_INNER_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_IP_LENGTH 128
+#define MAX_VLAN_INFO_LENGTH 32
+#define MAX_SSRC_INFO_LENGTH 10 /*2^32=4294967296, 10 digit*/
+
+typedef enum{
+ RTP_CLIENT = 0,
+ RTP_SERVER =1,
+ RTP_MODE_MAX
+}LYNQ_Rtp_Mode;
+
+#define RTP_FROM_CMD "gst-launch-1.0 -v udpsrc port=%d caps=\'application/x-rtp, media=(string)audio, clock-rate=(int)%d, channels=(int)%d\' ! rtpjitterbuffer latency=%d ! rtpL16depay ! audioconvert ! alsasink device=\'hw:0,2\'"
+#define RTP_TO_CMD "gst-launch-1.0 -v alsasrc device=\'hw:0,6\' ! audioconvert ! audio/x-raw,format=S16BE, channels=%d ! audioresample ! audio/x-raw, rate=%d ! rtpL16pay ! %s udpsink host=%s %s auto-multicast=true port=%d"
+#define RTP_VLAN_INFO_FORMAT "multicast-iface=\"%s\""
+#define RTP_SSRC_INFO_FORMAT " rtpmux name=mux ssrc=%u !"
+
+#define USER_LOG_TAG "LYNQ_CALL"
+
+#define RESULT_OK (0)
+#define RESULT_ERROR (-1)
+#define LYNQ_E_PARAMETER_ANONALY 7000
+
+typedef enum{
+ Rtp_Ssrc_random = 0,
+ Rtp_Ssrc_specific =1,
+}LYNQ_Rtp_Ssrc_Mode;
+
+typedef struct
+{
+ char ip[MAX_IP_LENGTH];
+ int port;
+ int ssrc_mode;
+ unsigned int ssrc;
+ char vlan_info[MAX_VLAN_INFO_LENGTH];
+}lynq_rtp_server_info;
+
+typedef struct
+{
+ int port;
+ int clockrate;
+ int latency;
+ int channels;
+}lynq_rtp_client_info;
+
+/*set*/
+int exe_set_remote_rtp_ip(const char* ip, const int ip_length);
+int exe_set_vlan_info(const char* vlan_info, const int vlan_info_length);
+int exe_set_rtp_port(const LYNQ_Rtp_Mode rtp_mode, const int port);
+int exe_set_rtp_param(const int clock_rate,const int channels,const int latency); //only for client
+int exe_set_call_rtp_ssrc(const int ssrc_mode, const unsigned int ssrc);
+/*get*/
+int exe_get_remote_rtp_ip(char* ip, const int ip_length);
+int exe_get_vlan_info(char* vlan_info, const int vlan_info_length);
+int exe_get_rtp_port(const LYNQ_Rtp_Mode rtp_mode, int* port);
+int exe_get_rtp_param(int* clock_rate,int* channels, int* latency);//only for client
+int exe_get_call_rtp_ssrc(int* ssrc_mod, unsigned int* ssrc);
+/*Audio Path setting end*/
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-call/include/libcall/lynq_call.h b/cap/zx297520v3/src/lynq/lib/liblynq-call/include/libcall/lynq_call.h
index 01df12e..fd50c3c 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-call/include/libcall/lynq_call.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-call/include/libcall/lynq_call.h
@@ -167,7 +167,7 @@
int lynq_set_call_rtp_ssrc(const LYNQ_Rtp_Ssrc_Mode ssrc_mode, const unsigned int ssrc);
/*get*/
-LYNQ_Audio_Mode lynq_get_voice_audio_mode();
+int lynq_get_voice_audio_mode(LYNQ_Audio_Mode* voice_audio_mode);
int lynq_get_remote_rtp_ip(char* ip, const int ip_length);
int lynq_get_vlan_info(char* vlan_info, const int vlan_info_length);
int lynq_get_rtp_port(const LYNQ_Rtp_Mode rtp_mode, int* port);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp
index 05550f1..3540ac0 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp
@@ -811,7 +811,7 @@
return LYNQ_E_INNER_ERROR;
}
- lynq_init_rtp();
+
g_module_init_flag = MODULE_RUNNING;
return 0;
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_common.h b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_common.h
index 21077df..e65f243 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_common.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_common.h
@@ -19,5 +19,5 @@
void urc_ecall_msg_process(Parcel *p);
#endif
-void lynq_init_rtp();
+int lynq_get_common_request(int request_id, int* status);
#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_rtp.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_rtp.cpp
index 4d6c1b3..d532c14 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_rtp.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call_rtp.cpp
@@ -17,375 +17,50 @@
#include "lynq_call.h"
#include "lynq_module_common.h"
#include "lynq_call_common.h"
-
-#define RTP_FROM_CMD "gst-launch-1.0 -v udpsrc port=%d caps=\'application/x-rtp, media=(string)audio, clock-rate=(int)%d, channels=(int)%d\' ! rtpjitterbuffer latency=%d ! rtppcmadepay ! alawdec ! audioresample ! audioconvert ! alsasink device=\'hw:0,2\'"
-#define RTP_TO_CMD "gst-launch-1.0 -v alsasrc device=\'hw:0,6\' ! audioconvert ! audioresample ! alawenc ! rtppcmapay ! %s udpsink host=%s %s auto-multicast=true port=%d"
-#define RTP_VLAN_INFO_FORMAT "multicast-iface=\"%s\""
-#define RTP_SSRC_INFO_FORMAT " rtpmux name=mux ssrc=%u !"
+#include "lynq_module_socket.h"
#define USER_LOG_TAG "LYNQ_CALL"
-typedef struct
-{
- char ip[MAX_IP_LENGTH];
- int port;
- int ssrc_mode;
- unsigned int ssrc;
- char vlan_info[MAX_VLAN_INFO_LENGTH];
-}lynq_rtp_server_info;
-
-typedef struct
-{
- int port;
- int clockrate;
- int latency;
- int channels;
-}lynq_rtp_client_info;
-
-static lynq_rtp_client_info g_rtp_client_info;
-static lynq_rtp_server_info g_rtp_server_info;
-
-static pthread_t g_rtp_thread[RTP_MODE_MAX];
-static bool g_rtp_thread_valid[RTP_MODE_MAX];
-
-void lynq_init_rtp()
-{
- memset(&g_rtp_client_info,0,sizeof(g_rtp_client_info));
- memset(&g_rtp_server_info,0,sizeof(g_rtp_server_info));
-
-
- lynq_set_rtp_param(8000,1,400);
-
- for(int i=0;i<RTP_MODE_MAX;i++)
- {
- lynq_set_rtp_port(i,6666);
- g_rtp_thread_valid[i] = 0;
- }
-
- LYDBGLOG("lynq init rtp success!!!");
- return;
-}
-
-/*Audio Path setting begin*/
-/*sub function*/
-void lynq_set_rtp_mixer_ctrl(int enable_rtp)
-{
- char cmd[256];
- LYINFLOG("set_rtp_mixer_ctrl %d", enable_rtp);
- if(enable_rtp)
- {
- sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on\" %d", 0);
- system(cmd);
- sprintf(cmd, "amixer -D mtk_phonecall cset name=\"M2M_Speech_on\" %d", 1);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH1 DL2_CH1\" %d", 1);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH2 DL2_CH2\" %d", 1);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"UL2_CH1 PCM_2_CAP_CH1\" %d", 1);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"UL2_CH2 PCM_2_CAP_CH1\" %d", 1);
- system(cmd);
- }
- else
- {
- sprintf(cmd, "amixer -D mtk_phonecall cset name=\"M2M_Speech_on\" %d", 0);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH1 DL2_CH1\" %d", 0);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"PCM_2_PB_CH2 DL2_CH2\" %d", 0);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"UL2_CH1 PCM_2_CAP_CH1\" %d", 0);
- system(cmd);
- sprintf(cmd, "amixer -c0 cset name=\"UL2_CH2 PCM_2_CAP_CH1\" %d", 0);
- system(cmd);
- sprintf(cmd, "amixer -D mtk_phonecall cset name=\"Speech_on\" %d", 1);
- system(cmd);
- }
-}
-
-void* lynq_start_rtp_cmd(void *arg)
-{
- int* rtp_mode= (int*) arg;
- char cmd[384];
- char vlan_para_string[sizeof(RTP_VLAN_INFO_FORMAT)+MAX_VLAN_INFO_LENGTH-2/*sizeof "%s"*/]={0};
- char ssrc_para_string[sizeof(RTP_SSRC_INFO_FORMAT)+MAX_SSRC_INFO_LENGTH-2/*sizeof "%u"*/]={0};
- LYINFLOG("lynq_start_rtp_cmd: rtp_mode is %d",(*rtp_mode));
- if ((*rtp_mode) == RTP_CLIENT)
- {
- sprintf(cmd,RTP_FROM_CMD, \
- g_rtp_client_info.port,g_rtp_client_info.clockrate,g_rtp_client_info.channels, \
- g_rtp_client_info.latency);
- // LYINFLOG("start from rtp play: cmd is %s",cmd);
- system(cmd);
- }
- else if ((*rtp_mode) == RTP_SERVER)
- {
- if(strlen(g_rtp_server_info.vlan_info)>0)
- {
- sprintf(vlan_para_string,RTP_VLAN_INFO_FORMAT,g_rtp_server_info.vlan_info);
- }
-
- if(g_rtp_server_info.ssrc_mode == Rtp_Ssrc_specific)
- {
- sprintf(ssrc_para_string,RTP_SSRC_INFO_FORMAT,g_rtp_server_info.ssrc);
- }
- sprintf(cmd,RTP_TO_CMD, \
- ssrc_para_string, g_rtp_server_info.ip,vlan_para_string,g_rtp_server_info.port);
-
- LYINFLOG("start to rtp play: cmd is %s",cmd);
- system(cmd);
- }
- return NULL;
-}
-
-int lynq_start_rtp_thread(int rtp_mode)
-{
- int ret;
- pthread_attr_t attr;
- static int start_mode[RTP_MODE_MAX]={0,1};
-
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- ret = pthread_create(&(g_rtp_thread[rtp_mode]),&attr,lynq_start_rtp_cmd,&(start_mode[rtp_mode]));
- if(ret != 0)
- {
- g_rtp_thread_valid[rtp_mode]=0;
- LYERRLOG("rtp create %d pthread error, ret is %d",rtp_mode, ret);
- return ret;
- }
- g_rtp_thread_valid[rtp_mode]=1;
- return RESULT_OK;
-}
-
/*set*/
int lynq_set_voice_audio_mode(const LYNQ_Audio_Mode audio_mode)
{
- int ret;
- int i;
-
- if(audio_mode==AUDIO_MODE_RTP)
+ if(g_module_init_flag != MODULE_RUNNING)
{
- lynq_set_rtp_mixer_ctrl(1);
- for(i=0;i<RTP_MODE_MAX;i++)
- {
- if(!g_rtp_thread_valid[i])
- {
- if(lynq_start_rtp_thread(i)!= 0)
- {
- LYERRLOG("start rtp %d fail",i);
- break;
- }
- else
- {
- LYINFLOG("start rtp %d suc",i);
- }
- }
- else
- {
- LYERRLOG("rtp %d needn't start",i);
- }
- }
- if(i!= RTP_MODE_MAX)
- {
- LYERRLOG("start rtp whole fail");
- lynq_set_voice_audio_mode(AUDIO_MODE_CODEC);
- return RESULT_ERROR;
- }
- LYINFLOG("start rtp whole suc");
- return RESULT_OK;
+ LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
+ return LYNQ_E_CONFLICT;
}
- else if(audio_mode==AUDIO_MODE_CODEC)
+ if(audio_mode < AUDIO_MODE_CODEC)
{
- for(i=0;i<RTP_MODE_MAX;i++)
- {
- if(g_rtp_thread_valid[i])
- {
- ret = pthread_cancel(g_rtp_thread[i]);
- LYINFLOG("pthread cancel rtp %d ret = %d",i,ret);
- ret = pthread_join(g_rtp_thread[i],NULL);
- LYINFLOG("pthread join rtp %d ret = %d",i,ret);
- g_rtp_thread_valid[i] = 0;
- }
- else
- {
- LYINFLOG("rtp %d needn't stop",i);
- }
- }
- lynq_set_rtp_mixer_ctrl(0);
- LYINFLOG("stop rtp suc");
- }
- return RESULT_OK;
-}
-int lynq_set_remote_rtp_ip(const char* ip, const int ip_length)
-{
- if (NULL == ip)
- {
- LYERRLOG("ip is NULL!!!");
return LYNQ_E_PARAMETER_ANONALY;
}
- if ((ip_length < strlen(ip)+1) || (ip_length > MAX_IP_LENGTH))
- {
- LYERRLOG("incoming ip length error %d", ip_length);
- return LYNQ_E_PARAMETER_ANONALY;
- }
- bzero(g_rtp_server_info.ip,MAX_IP_LENGTH);
- strcpy(g_rtp_server_info.ip,ip);
-
- LYINFLOG("lynq_set_remote_rtp_ip suc: ip is %s, length is %d", ip,ip_length);
-
- return RESULT_OK;
-}
-int lynq_set_vlan_info(const char* vlan_info, const int vlan_info_length)
-{
- if (NULL == vlan_info)
+ Parcel* p=NULL;
+ int ret=lynq_send_common_request(p,g_wait_time,LYNQ_REQUEST_SET_VOICE_AUDIO_MODE,1,"%d",audio_mode);
+ if(ret==RESULT_OK)
{
- LYERRLOG("vlan_info is NULL!!!");
- return LYNQ_E_PARAMETER_ANONALY;
+ delete p;
}
-
- if ((vlan_info_length < strlen(vlan_info)+1) || (vlan_info_length > MAX_VLAN_INFO_LENGTH))
- {
- LYERRLOG("incoming vlan_info error, vlan info length %d", vlan_info_length);
- return LYNQ_E_PARAMETER_ANONALY;
- }
-
-
- bzero(g_rtp_server_info.vlan_info,MAX_VLAN_INFO_LENGTH);
- strcpy(g_rtp_server_info.vlan_info,vlan_info);
-
- LYINFLOG("lynq_set_vlan_info suc: vlan is %s, length is %d", vlan_info,vlan_info_length);
-
- return RESULT_OK;
-}
-int lynq_set_rtp_port(const LYNQ_Rtp_Mode rtp_mode, const int port)
-{
- if (port < 0)
- {
- LYERRLOG("invalid port number %d", port);
- return LYNQ_E_PARAMETER_ANONALY;
- }
- if (rtp_mode == 0)
- {
- g_rtp_client_info.port = port;
- }
- else if (rtp_mode == 1)
- {
- g_rtp_server_info.port = port;
- }
- LYINFLOG("lynq_set_rtp_port suc: LYNQ_Rtp_Mode is %d, port is %d", rtp_mode, port);
- return RESULT_OK;
-}
-int lynq_set_rtp_param(const int clock_rate,const int channels,const int latency) //only for client mode
-{
- g_rtp_client_info.clockrate = clock_rate;
- g_rtp_client_info.channels = channels;
- g_rtp_client_info.latency = latency;
- LYINFLOG("lynq_set_rtp_param suc: clockrate is %d, channels is %d, latency is %d", clock_rate, channels, latency);
- return RESULT_OK;
-}
-int lynq_set_call_rtp_ssrc(const LYNQ_Rtp_Ssrc_Mode ssrc_mode,const unsigned int ssrc)
-{
- if(ssrc_mode < Rtp_Ssrc_random || ssrc_mode > Rtp_Ssrc_specific)
- {
- return LYNQ_E_PARAMETER_ANONALY;
- }
- g_rtp_server_info.ssrc_mode = ssrc_mode;
- g_rtp_server_info.ssrc = ssrc ;
- LYINFLOG("%s suc: param is %d %d", __func__, ssrc_mode, ssrc);
- return RESULT_OK;
+ return ret;
}
/*get*/
-LYNQ_Audio_Mode lynq_get_voice_audio_mode()
+int lynq_get_voice_audio_mode(LYNQ_Audio_Mode* voice_audio_mode)
{
- if(g_rtp_thread_valid[0])
+ if(g_module_init_flag != MODULE_RUNNING)
{
- return AUDIO_MODE_RTP;
+ LYERRLOG("%s module state %d error",__func__,g_module_init_flag);
+ return LYNQ_E_CONFLICT;
}
- else
+
+ if(voice_audio_mode==NULL)
{
- return AUDIO_MODE_CODEC;
- }
-}
-int lynq_get_remote_rtp_ip(char* ip, const int ip_length)
-{
- if(ip==NULL)
- {
- LYERRLOG("ip is NULL");
+ LYERRLOG("parameter is NULL");
return LYNQ_E_PARAMETER_ANONALY;
}
- if(ip_length < strlen(g_rtp_server_info.ip)+1)
- {
- LYERRLOG("ip length %d is shorter than saved ip length %d",ip_length,strlen(g_rtp_server_info.ip)+1);
- return LYNQ_E_PARAMETER_ANONALY;
- }
-
- bzero(ip,ip_length);
- strcpy(ip,g_rtp_server_info.ip);
-
- return RESULT_OK;
-}
-int lynq_get_vlan_info(char* vlan_info, const int vlan_info_length)
-{
- if(vlan_info==NULL)
- {
- LYERRLOG("vlan info is NULL");
- return LYNQ_E_PARAMETER_ANONALY;
- }
+ int local_mode;
- if(vlan_info_length < strlen(g_rtp_server_info.vlan_info)+1)
- {
- LYERRLOG("vlan info length %d is shorter than saved vlan info length %d",vlan_info_length,strlen(g_rtp_server_info.vlan_info)+1);
- return LYNQ_E_PARAMETER_ANONALY;
- }
-
- bzero(vlan_info,vlan_info_length);
- strcpy(vlan_info,g_rtp_server_info.vlan_info);
-
- return RESULT_OK;
-}
-int lynq_get_rtp_port(const LYNQ_Rtp_Mode rtp_mode, int* port)
-{
- if(port==NULL)
- {
- return LYNQ_E_PARAMETER_ANONALY;
- }
- if (rtp_mode == 0)
- {
- *port = g_rtp_client_info.port;
- }
- else if (rtp_mode == 1)
- {
- *port = g_rtp_server_info.port;
- }
- return RESULT_OK;
-}
-int lynq_get_rtp_param(int* clock_rate, int* channels, int* latency)//only for client mode
-{
- if(clock_rate == NULL || channels ==NULL || latency ==NULL)
- {
- LYERRLOG("input parameter is NULL");
- return LYNQ_E_PARAMETER_ANONALY;
- }
+ int ret=lynq_get_common_request(LYNQ_REQUEST_GET_VOICE_AUDIO_MODE,&local_mode);
- *clock_rate = g_rtp_client_info.clockrate;
- *channels = g_rtp_client_info.channels ;
- *latency = g_rtp_client_info.latency;
-
- return RESULT_OK;
-}
-int lynq_get_call_rtp_ssrc(int* ssrc_mode, unsigned int* ssrc)
-{
- if(ssrc_mode == NULL || ssrc ==NULL)
- {
- LYERRLOG("input parameter is NULL");
- return LYNQ_E_PARAMETER_ANONALY;
- }
-
- *ssrc_mode = g_rtp_server_info.ssrc_mode;
- *ssrc = g_rtp_server_info.ssrc ;
-
- return RESULT_OK;
+ *voice_audio_mode = (LYNQ_Audio_Mode) local_mode;
+ return ret;
}
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_module_common.h b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_module_common.h
index 590971a..47b7eab 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_module_common.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_module_common.h
@@ -30,6 +30,8 @@
#define LYNQ_REQUEST_OOS_DEEP_SLEEP_RECOVER_TIMER_INTERVAL (LYNQ_REQUEST_VENDOR_BASE +13)
#define LYNQ_REQUEST_CHANGE_SCREEN_STATE (LYNQ_REQUEST_VENDOR_BASE + 14)/*jb.qi add for two sim suspend 2022/9/19*/
#define LYNQ_REQUEST_CHANGE_RADIO (LYNQ_REQUEST_VENDOR_BASE + 15)
+#define LYNQ_REQUEST_SET_VOICE_AUDIO_MODE (LYNQ_REQUEST_VENDOR_BASE + 28)
+#define LYNQ_REQUEST_GET_VOICE_AUDIO_MODE (LYNQ_REQUEST_VENDOR_BASE + 21)
/*the same with lynq_interface.h end*/
typedef enum{
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/include/lynq-qser-voice.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/include/lynq-qser-voice.h
index 8de497a..1c4c586 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/include/lynq-qser-voice.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/include/lynq-qser-voice.h
@@ -58,6 +58,13 @@
void *contextPtr
);
+typedef enum
+{
+ E_QSER_VOICE_AUDIO_MODE_CODEC = 0, /**< Voice call audio mode codec*/
+ E_QSER_VOICE_AUDIO_MODE_RTP = 1, /**< Voice call audio mode rtp. */
+}E_QSER_VOICE_CALL_AUDIO_MODE_T;
+
+
/* Init voice module and return h_voice, this should be called before any other APIs */
int qser_voice_call_client_init(voice_client_handle_type *ph_voice);
@@ -96,6 +103,11 @@
int qser_voice_set_dtmf(const char callnum);
+int qser_voice_set_audio_mode(const E_QSER_VOICE_CALL_AUDIO_MODE_T audio_mode);
+
+int qser_voice_get_audio_mode(E_QSER_VOICE_CALL_AUDIO_MODE_T* audio_mode);
+
+
/*
Usage 1 (register callback and wait for new call in, then answer):
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp
index 657d8c0..537272a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp
@@ -258,6 +258,18 @@
}
+int qser_voice_set_audio_mode(const E_QSER_VOICE_CALL_AUDIO_MODE_T audio_mode)
+{
+ return lynq_set_voice_audio_mode((LYNQ_Audio_Mode) audio_mode);
+}
+
+int qser_voice_get_audio_mode(E_QSER_VOICE_CALL_AUDIO_MODE_T* audio_mode)
+{
+ return lynq_get_voice_audio_mode((LYNQ_Audio_Mode*) audio_mode );
+}
+
+
+
#ifdef ECALL_SUPPORT
int qser_voice_fast_ecall(voice_client_handle_type* h_voice,
int *call_id,