[Feature][T106][VOICE] add  get current call state api

Only Configure: Yes
Affected branch: master
Affected module: voice
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I962b84c718031abe491c088bd6a266e20a13a1a0
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp
index e9730f1..4f4273c 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-voice-demo/files/lynq-qser-voice-demo.cpp
@@ -33,6 +33,7 @@
     {10,  "qser_voice_get_audio_mode"},

     {11,  "qser_voice_set_mic_volume"},

     {12,  "qser_voice_get_mic_volume"},

+    {13,  "qser_voice_get_current_state"},

     {-1,    NULL}

 };

 

@@ -60,7 +61,7 @@
 

 int (*qser_voice_set_mic_volume)(const int volume);

 int (*qser_voice_get_mic_volume)(int *volume);

-

+int (*qser_voice_get_current_state)(const int call_id, int *voice_state);

 

 #ifdef ECALL_SUPPORT

 int (*qser_voice_set_test_num)(voice_client_handle_type*       h_voice,E_QSER_VOICE_ECALL_SET_TYPE_T type, const char *test_num, int test_num_length);

@@ -271,6 +272,12 @@
             return -1;

     }

     

+    qser_voice_get_current_state = (int (*)(const int,int* ))dlsym(dlHandle_call,"qser_voice_get_current_state");

+    if(qser_voice_get_current_state == NULL)

+    {

+            printf("qser_voice_get_current_state not defined or exported in %s\n", lynqLibPath_Call);

+            return -1;

+    }

     

     ret = qser_voice_call_client_init(&h_voice);

     if(ret != 0 )

@@ -456,6 +463,17 @@
                 printf("ret is %d,get volume is %d\n",ret,volume);

                 break;

             }

+	    case 13:

+            {

+                int call_id = -1;

+                printf("Please input call id \n");

+                scanf("%d",&call_id);

+                int voice_state = -1;

+                int ret = -1;

+                ret = qser_voice_get_current_state(call_id,&voice_state);

+                printf("qser_get_current_call_state ret is %d,voice state is %d",ret,voice_state);

+                break;

+            }

             default:

                 print_help();

                 break;

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 c7fa8b0..51d9b33 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
@@ -111,7 +111,7 @@
 
 int qser_voice_get_mic_volume(int *volume);
 
-
+int qser_voice_get_current_state(const int call_id,int *voice_state);
 
 /*
 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 e2232ec..39a271b 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
@@ -285,6 +285,66 @@
 }
 
 
+int qser_voice_get_current_state(const int call_id,int *voice_state)
+{
+    int ret = -1;
+    int call_state = -1;
+    int toa = -1;
+    int direction = -1;
+    char addr[64] = {0};
+
+
+    if(voice_state == NULL)
+    {
+        LYERRLOG("Invalid input pointer. call_id or voice_state is NULL");
+        return RESULT_ERROR;
+    }
+
+    if(call_id <= 0)
+    {
+        LYERRLOG(" Invalid call id  %d",call_id);
+        return RESULT_ERROR;
+    }
+
+    ret = lynq_get_current_call_state(&call_id,&call_state,&toa,&direction,addr);
+    if(ret != 0)
+    {
+        LYERRLOG("qser_get_current_call_state ret is %d",ret);
+        return RESULT_ERROR;
+    }
+
+    if (call_state == LYNQ_CALL_ACTIVE)
+    {
+        *voice_state = E_QSER_VOICE_CALL_STATE_ACTIVE;
+    }
+    else if(call_state == LYNQ_CALL_HOLDING)
+    {
+        *voice_state = E_QSER_VOICE_CALL_STATE_HOLDING;
+    }
+    else if(call_state == LYNQ_CALL_DIALING)
+    {
+        *voice_state = E_QSER_VOICE_CALL_STATE_DIALING;
+    }
+    else if(call_state == LYNQ_CALL_ALERTING)
+    {
+        *voice_state = E_QSER_VOICE_CALL_STATE_ALERTING;
+    }
+    else if(call_state == LYNQ_CALL_INCOMING)
+    {
+        *voice_state = E_QSER_VOICE_CALL_STATE_INCOMING;
+    }
+    else if(call_state == LYNQ_CALL_WAITING)
+    {
+        *voice_state = E_QSER_VOICE_CALL_STATE_WAITING;
+    }
+    else if(call_state == LYNQ_CALL_END)
+    {
+        *voice_state = E_QSER_VOICE_CALL_STATE_END;
+    }
+
+    return ret;
+}
+
 
 #ifdef ECALL_SUPPORT
 int qser_voice_fast_ecall(voice_client_handle_type*       h_voice,