MMI_VIDEO_CALL_SUPPORT_JRTC
authorCCC <2393524978@qq.com>
Fri, 30 Jun 2023 03:41:22 +0000 (11:41 +0800)
committerCCC <2393524978@qq.com>
Fri, 30 Jun 2023 03:41:22 +0000 (11:41 +0800)
C55/C55_ZHMF_Q7/project_C55_ZHMF_Q7.mk
MS_Code/MS_MMI_Main/source/mmi_app/app/jrtc_video_call/c/mmi_jrtc_client.c
MS_Code/MS_MMI_Main/source/mmi_app/app/jrtc_video_call/c/mmi_video_call.c
MS_Code/MS_MMI_Main/source/mmi_app/app/jrtc_video_call/h/mmi_video_call.h

index b727fc4..d98fd93 100644 (file)
@@ -596,6 +596,10 @@ MMI_FALL_DOWN_SOS_WINDOW_TIPS_SUPPORT = TRUE
 #   FALSE:Disable this feature.
 
 
+MMI_VIDEO_CALL_SUPPORT_JRTC = TRUE
+#jrtc video call
+
+
 
 #INCAR_ALIPAY_SUPPORT = TRUE
 # 
@@ -606,12 +610,12 @@ MMI_BAR_CODE_SUPPORT = TRUE
 endif
 
 
-MMI_MEREG_VIDEO_CALL_SUPPORT = TRUE
-MMI_VIDEO_CHAT_WIN_BACKGROUND_BLACK = TRUE
+#MMI_MEREG_VIDEO_CALL_SUPPORT = TRUE
+#MMI_VIDEO_CHAT_WIN_BACKGROUND_BLACK = TRUE
 # 
 
 ########HERO START######################################################
-HERO_ENGINE_SUPPORT=TRUE # Æ½Ì¨×ܺê
+#HERO_ENGINE_SUPPORT = TRUE # Æ½Ì¨×ܺê
 
 ifeq ($(strip $(HERO_ENGINE_SUPPORT)),TRUE)
 HERO_ENGINE_SUPPORT_CLIENT_INFO=TRUE  #Ö§³Ö¿Í»§×Ô¶¨Ò弯³ÉÉÌ+»úÐ͵ÄÅäÖúê
index 064adc4..a0fe228 100644 (file)
@@ -11,7 +11,6 @@
 
 // for network
 #include <socket_api.h>
-#include <stdint.h>
 
 #include "mn_type.h"
 #include "mmk_type.h"
 
 typedef enum jrtc_state video_call_jrtc_state_e;
 typedef enum jrtc_error video_call_jrtc_error_e;
-typedef struct jrtc_image_t  video_call_jrtc_image_t;
+typedef struct jrtc_image_t video_call_jrtc_image_t;
 
 typedef struct 
 {
-    void * state_task;
+       void * state_timer_ptr;
     video_call_jrtc_image_t video_frame;
     video_call_jrtc_image_t camera_frame;
     void * jrtc_ptr;
-    TIMER_ID closed_timer_id;
-    uint8_t closing;
+    uint8 closed_timer_id;
+    uint8 closing;
 } video_call_jrtc_t;
 
 
-extern voip_phone_call_params_t voipcall_params;
+extern MMI_VIDEO_CALL_PARAMS_T s_video_call_params;
 static video_call_jrtc_t s_video_call_jrtc = {0};
 
 
-static uint8_t voip_jrtc_get_image(void * preview_buf);
-
-
 void mmi_video_call_jrtc_config_init(void)
 {
        char appkey[24+1] = "dc1db81c19d1da4f5fb4a197";
@@ -63,30 +59,190 @@ void mmi_video_call_jrtc_config_init(void)
        jrtc_config(appkey, uid, key, tokens);
 }
 
+static void mmi_video_call_jrtc_pdp_msg_cb(MMIPDP_CNF_INFO_T *msg_ptr)
+{
+       if(PNULL == msg_ptr)
+       {
+               return;
+       }
+       
+       SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: \n", __FUNCTION__, __LINE__);               
+       
+       switch(msg_ptr->msg_id) 
+       {
+               case MMIPDP_ACTIVE_CNF:
+                        if (MMIPDP_RESULT_SUCC == msg_ptr->result)
+                        {
+                                _jrtc_net_id = msg_ptr->nsapi;
+                                SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: _jrtc_net_id=%d\n", __FUNCTION__, __LINE__, _jrtc_net_id);          
+                        } 
+                        else
+                        {
+                                MMIAPIPDP_Deactive(msg_ptr->app_handler);
+                        }
+                        break;
+                       
+               case MMIPDP_DEACTIVE_CNF:
+                       SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: \n", __FUNCTION__, __LINE__);               
+                        _jrtc_net_id = 0;
+                        break;
+                       
+               case MMIPDP_DEACTIVE_IND:
+                       SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: \n", __FUNCTION__, __LINE__);               
+                        _jrtc_net_id = 0;
+                        break;
+                       
+               default:
+                        break;
+       }
+}
+
+static BOOLEAN mmi_video_call_jrtc_PDPActive(void)
+{
+       MN_DUAL_SYS_E dual_sys = MN_DUAL_SYS_1;
+    uint8 setting_index = 0;
+       uint8  linkset_num = 0;
+       MMIPDP_ACTIVE_INFO_T active_info = {0};
+       MMICONNECTION_LINKSETTING_DETAIL_T* linksetting = PNULL;
+       
+       if (FALSE == MMIAPIPHONE_GetDataServiceSIM(&dual_sys))
+    {
+               SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: \n", __FUNCTION__, __LINE__);               
+        return FALSE;
+    }
+
+    setting_index = MMIAPICONNECTION_GetDefaultAPN(dual_sys);
+    linkset_num = MMIAPICONNECTION_GetLinkSettingNum(dual_sys);
+       
+       SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: %d,%d\n", __FUNCTION__, __LINE__, setting_index,linkset_num);
+    if(0 < linkset_num)
+       {
+               linksetting = MMIAPICONNECTION_GetLinkSettingItemByIndex(dual_sys, setting_index);
+               if(PNULL != linksetting && 0 != linksetting->apn_len)
+               {
+                       active_info.dual_sys = dual_sys;
+                       active_info.auth_type = linksetting->auth_type;
+                       active_info.priority = 3;
+                       active_info.app_handler = MMI_MODULE_CAMERA; // MMIAUT_GetModuleID();
+                       active_info.handle_msg_callback = mmi_video_call_jrtc_pdp_msg_cb;
+                       active_info.apn_ptr = linksetting->apn;
+                       active_info.user_name_ptr = linksetting->username;
+                       active_info.psw_ptr = linksetting->password;
+                       active_info.ps_service_rat = MN_UNSPECIFIED;
+                       active_info.ps_service_type = BROWSER_E;
+                       active_info.storage = MN_GPRS_STORAGE_ALL;
+                       active_info.ps_interface = MMIPDP_INTERFACE_GPRS;
+                       #ifdef IPVERSION_SUPPORT_V4_V6
+                       active_info.ip_type = linksetting->ip_type;
+                       #endif
+
+                       if(MMIAPIPDP_Active(&active_info))
+                       {
+                               return TRUE;
+                       }
+               }
+       }
+       
+       SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: error\n", __FUNCTION__, __LINE__);
+       
+    return FALSE;
+}
+
+
 static void mmi_video_call_jrtc_clean_up(void)
 {
        SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: \n", __FUNCTION__, __LINE__);
 
-    if(NULL != s_video_call_jrtc.state_task) 
+    if(NULL != s_video_call_jrtc.state_timer_ptr) 
        {
                SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: \n", __FUNCTION__, __LINE__);
                
-        lv_task_del(s_video_call_jrtc.state_task);
+               SCI_DeleteTimer(s_video_call_jrtc.state_timer_ptr);
+               s_video_call_jrtc.state_timer_ptr = NULL;
     }
 
-    Hal_Mem_Set(&voip_jrtc, 0, sizeof(video_call_jrtc_t));
+       if(0 != s_video_call_jrtc.closed_timer_id)
+       {
+               MMK_StopTimer(s_video_call_jrtc.closed_timer_id);
+               s_video_call_jrtc.closed_timer_id = 0;
+       }
+
+    memset(&s_video_call_jrtc, 0x0, sizeof(video_call_jrtc_t));
+       
+       if ((MMI_VIDEO_CALL_STATE_ACTIVE == s_video_call_params.state) && (MMI_VIDEO_CALL_TYPE_VIDEO == s_video_call_params.calltype))
+       {
+               //lcd
+       }
 }
 
-static void mmi_video_call_jrtc_timeout_cb(void * para)
+static void mmi_video_call_jrtc_timeout_cb(void)
 {
        SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: \n", __FUNCTION__, __LINE__);
 
     mmi_video_call_jrtc_clean_up();
 }
 
-static void mmi_video_call_jrtc_on_state(lv_task_t * task)
+static void lcd_show(video_call_jrtc_image_t * image)
 {
-    static int8_t oldstate = -1;
+       const unsigned width = image->width, height = image->height;
+       uint8 *yuv_addr = image->data;
+       LCD_INFO_T lcd_info;
+       uint16 *dest_ptr;
+       uint32 i;
+       BLOCKCFG_T cfg;
+       
+       LCD_DisableAllBlock(MAIN_LCD_ID);
+       LCD_EnterSleep(MAIN_LCD_ID, FALSE);
+       GPIO_SetLcdBackLight(TRUE);
+       
+       cfg.end_x = 240-1;
+       cfg.start_x = cfg.end_x + 1 - width;
+       cfg.start_y = 0;
+       cfg.end_y = cfg.start_y + height - 1;
+       switch(image->format)
+       {
+               case 0://I420
+                       cfg.resolution = LCD_RESOLUTION_YUV420;
+                       cfg.width = width;
+                       break;
+                       
+               case 2://UYVY
+                       cfg.resolution = LCD_RESOLUTION_YUV422;
+                       cfg.width = width * 2;
+                       break;
+                       
+               default:
+                       return;
+       }
+       cfg.colorkey_en = FALSE;
+       cfg.alpha_sel = 1;
+       cfg.alpha = 0xFF;
+       cfg.priority = 0;
+       cfg.type = 1; //0:OSD; 1:image
+       cfg.rotation = 0;
+       
+       if (LCD_RESOLUTION_YUV420 == cfg.resolution)
+       {
+               LCD_SetBlockBuffer(MAIN_LCD_ID, 0, (uint32*)yuv_addr);
+               LCD_SetUVBuffer(MAIN_LCD_ID, 0, (uint32*)(yuv_addr + width * height));//YUV420p
+       }
+       else if (LCD_RESOLUTION_YUV422 == cfg.resolution)
+       { 
+               //LCD_SetBlockBuffer(0, 0, yuv_addr->yaddr);//UYVY
+               LCD_SetBlockBuffer(0, 0, yuv_addr);//UYVY
+       }
+
+       SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: resolution=%d\n", __FUNCTION__, __LINE__, cfg.resolution);
+       
+       LCD_SetImageLayerSourceSize(MAIN_LCD_ID, width, height);
+       LCD_ConfigBlock(0, 0, cfg);
+       LCD_EnableBlock(0, 0);
+       LCD_InvalidateRect(0, cfg.start_x, cfg.start_y, cfg.end_x, cfg.end_y);
+}
+
+static void mmi_video_call_jrtc_on_state(uint32 in)
+{
+    static int8 oldstate = -1;
     video_call_jrtc_state_e state = jrtc_state(s_video_call_jrtc.jrtc_ptr);
 
     if(state != oldstate) 
@@ -97,7 +253,7 @@ static void mmi_video_call_jrtc_on_state(lv_task_t * task)
     switch(state) 
        {
            case JRTC_CLOSED:
-               if((NULL != s_video_call_jrtc.jrtc_ptr) && (NULL == s_video_call_jrtc.closed_timer_id)) 
+               if((NULL != s_video_call_jrtc.jrtc_ptr) && (0 == s_video_call_jrtc.closed_timer_id)) 
                        {
                        video_call_jrtc_error_e err = jrtc_error(s_video_call_jrtc.jrtc_ptr);
                                
@@ -109,12 +265,7 @@ static void mmi_video_call_jrtc_on_state(lv_task_t * task)
                        s_video_call_jrtc.closing = 1;
                    }
 
-                   s_video_call_jrtc.closed_timer_id = Hal_Timer_Start(100, mmi_video_call_jrtc_timeout_cb, NULL, 0);
-               }
-
-               if(MMI_VOIP_CALL_STATE_NULL != voipcall_params.state) 
-                       {
-                   watch_voip_call_response_no_carrier(0, 1);
+                   s_video_call_jrtc.closed_timer_id = MMK_CreateTimerCallback(100, mmi_video_call_jrtc_timeout_cb, PNULL, FALSE);
                }
                break;
 
@@ -131,19 +282,20 @@ static void mmi_video_call_jrtc_on_state(lv_task_t * task)
                break;
 
            case JRTC_TALKING:
-               if(MMI_VOIP_CALL_STATE_ACTIVE != voipcall_params.state) 
+               if(MMI_VIDEO_CALL_STATE_ACTIVE != s_video_call_params.state) 
                        {
-                   watch_voip_call_response_connect(0);
+                   mmi_video_call_connect();
                }
 
-               /* Get image */
-               if (MMI_VIDEO_CALL_TYPE_VIDEO == voipcall_params.voip_call_type) 
+               if (MMI_VIDEO_CALL_TYPE_VIDEO == s_video_call_params.calltype) 
                        {
-                   void *buf = voip_phone_get_video_buffer();
-                   if(voip_jrtc_get_image(buf)) 
+                               video_call_jrtc_image_t * img = &(s_video_call_jrtc.video_frame);
+                               
+                               if (img->get != img->put) 
                                {
-                       lv_canvas_set_buffer(voip_phone_get_ext()->canvas, buf, canvas_width, canvas_heigh, LV_IMG_CF_TRUE_COLOR);
-                   }
+                                       lcd_show(img); // display
+                                       img->get = img->put; // reset
+                               }
                }
                break;
 
@@ -154,28 +306,29 @@ static void mmi_video_call_jrtc_on_state(lv_task_t * task)
     oldstate = state;
 }
 
-
-static int8_t mmi_video_call_jrtc_open(const char* roomid, MMI_VIDEO_CALL_TYPE_E calltype)
+static int8 mmi_video_call_jrtc_open(const char* roomid, MMI_VIDEO_CALL_TYPE_E calltype)
 {
        SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: %s,%d\n", __FUNCTION__, __LINE__, roomid, calltype);
 
-    Hal_Mem_Set(&voip_jrtc, 0, sizeof(video_call_jrtc_t));
-       
-    if (MMI_VIDEO_CALL_TYPE_VIDEO == calltype) 
-       {
-        s_video_call_jrtc.rxframe.width  = s_video_call_jrtc.txframe.width  = 176; // 240; // 176;
-        s_video_call_jrtc.rxframe.height = s_video_call_jrtc.txframe.height = 144; // 320; // 144;
-        s_video_call_jrtc.rxframe.fps    = s_video_call_jrtc.txframe.fps    = 8; // 10;
-        s_video_call_jrtc.rxframe.kbps   = s_video_call_jrtc.txframe.kbps   = 120; // 240;
-
-               mci_videocall_camera_set_sensor(1); // 0:rear camera; 1:front camera
-               
-        s_video_call_jrtc.jrtc_ptr= jrtc_open(roomid, 0, &s_video_call_jrtc.rxframe, &s_video_call_jrtc.txframe);
-    } 
-       else 
+    memset(&s_video_call_jrtc, 0x0, sizeof(video_call_jrtc_t));
+       if(TRUE == mmi_video_call_jrtc_PDPActive())
        {
-        s_video_call_jrtc.jrtc_ptr= jrtc_open(roomid, 0, NULL, NULL);
-    }
+           if (MMI_VIDEO_CALL_TYPE_VIDEO == calltype) 
+               {
+               s_video_call_jrtc.video_frame.width  = s_video_call_jrtc.camera_frame.width  = 176; // 240; // 176;
+               s_video_call_jrtc.video_frame.height = s_video_call_jrtc.camera_frame.height = 144; // 320; // 144;
+               s_video_call_jrtc.video_frame.fps    = s_video_call_jrtc.camera_frame.fps    = 8; // 10;
+               s_video_call_jrtc.video_frame.kbps   = s_video_call_jrtc.camera_frame.kbps   = 120; // 240;
+
+                       //mci_videocall_camera_set_sensor(1); // 0:rear camera; 1:front camera
+                       
+               s_video_call_jrtc.jrtc_ptr = jrtc_open(roomid, 0, &s_video_call_jrtc.video_frame, &s_video_call_jrtc.camera_frame);
+           } 
+               else 
+               {
+               s_video_call_jrtc.jrtc_ptr = jrtc_open(roomid, 0, NULL, NULL);
+           }
+       }
 
     if (!s_video_call_jrtc.jrtc_ptr) 
        {
@@ -185,7 +338,9 @@ static int8_t mmi_video_call_jrtc_open(const char* roomid, MMI_VIDEO_CALL_TYPE_E
     }
     jrtc_activate(s_video_call_jrtc.jrtc_ptr, JRTC_AUDIO|JRTC_CAMERA);
 
-    s_video_call_jrtc.state_task = lv_task_create(mmi_video_call_jrtc_on_state, VIDEO_RENDER_PERIOD, LV_TASK_PRIO_HIGH, NULL);
+    s_video_call_jrtc.state_timer_ptr = SCI_CreatePeriodTimer("render", mmi_video_call_jrtc_on_state, 0, 40, 0);
+       SCI_ActiveTimer(s_video_call_jrtc.state_timer_ptr);
+
     return 0;
 }
 
@@ -197,10 +352,11 @@ int8 mmi_video_call_dial(char * number, MMI_VIDEO_CALL_TYPE_E calltype)
         ret = mmi_video_call_jrtc_open(number, calltype);
 
        SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: %s,%d,%d\n", __FUNCTION__, __LINE__, number, calltype, ret);
+       
     return ret;
 }
 
-void mmi_video_call_hangup(BOOL bye)
+void mmi_video_call_hangup(BOOLEAN bye)
 {
        SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: %p,%d\n", __FUNCTION__, __LINE__, s_video_call_jrtc.jrtc_ptr, bye);
 
@@ -213,70 +369,21 @@ void mmi_video_call_hangup(BOOL bye)
     } 
        else
        {
-        watch_voip_call_response_no_carrier(0, 0);
+        //watch_voip_call_response_no_carrier(0, 0);
     }
 }
 
-int8_t mmi_video_call_answer_req(void)
+int8 mmi_video_call_answer(void)
 {
-    int8_t ret = -1;
+    int8 ret = -1;
 
        SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: %p\n", __FUNCTION__, __LINE__, s_video_call_jrtc.jrtc_ptr);
+       
     if (NULL == s_video_call_jrtc.jrtc_ptr)
-        ret = mmi_video_call_jrtc_open(voipcall_params.number, voipcall_params.voip_call_type);
+        ret = mmi_video_call_jrtc_open(s_video_call_params.number, s_video_call_params.calltype);
 
     return ret;
 }
-
-void mmi_video_call_reject_req(BOOL bye)
-{
-       SCI_TRACE_LOW("[@CHENG_VIDEO_CALL][%s][%d]: %p,%d\n", __FUNCTION__, __LINE__, s_video_call_jrtc.jrtc_ptr, bye);
-
-    if (NULL != s_video_call_jrtc.jrtc_ptr) 
-       {
-        video_call_jrtc_error_e err = (TRUE == bye) ? JRTC_EBYE : JRTC_EAUDIOCALL;
-
-        jrtc_close(s_video_call_jrtc.jrtc_ptr, err);
-        s_video_call_jrtc.closing = 1;
-    } 
-       else 
-       {
-        watch_voip_call_response_no_carrier(0, 0);
-    }
-}
-
-
-//extern unsigned yuv420_scale(int src_width, int src_height, int dst_width, int dst_height,     unsigned char *src_buf, unsigned char *dst_buf, unsigned char semi);
-//extern unsigned rgb565_scale(int32_t src_width, int32_t src_height, int32_t dst_width, int32_t dst_height, uint8_t *src_buf, uint8_t *dst_buf);
-//extern void yuv420_2_rgb565(int width, int height, const unsigned char *src, unsigned short *dst, unsigned semi);
-
-static uint8_t voip_jrtc_get_image(void * preview_buf)
-{
-    uint8_t ret = 0;
-    lv_voip_phone_obj_ext_t * ext = voip_phone_get_ext();
-    LV_ASSERT_MEM(ext);
-
-    video_call_jrtc_image_t * frame = NULL;
-    if(ext->local_remote_switch_flag == VOIP_REMOTE_SWITCH_REMOTE)
-        frame = &s_video_call_jrtc.rxframe;
-    else
-        frame = &s_video_call_jrtc.txframe;
-
-    if (frame->put != frame->get) {
-#if (ENABLE_VIDEO_SCALE == 0)
-        yuv420_2_rgb565(frame->width, frame->height, frame->data, preview_buf, frame->format);
-#else
-        Hal_Yuv420_Render(frame->width, frame->height, canvas_width, canvas_heigh, frame->data, preview_buf, frame->format);
-#endif
-
-        frame->get = frame->put;
-        ret = 1;
-        voip_fps_check(frame->fps);
-    }
-
-    return ret;
-}
-
 #endif
 
 
index a1fa639..843781f 100644 (file)
@@ -3,12 +3,10 @@
 
 #ifdef MMI_VIDEO_CALL_SUPPORT_JRTC
 
+#if 0
 #include <string.h>
 #include <os_api.h>
 
-#include "video_call_demo.h"
-#include "agora_video_call.h"
-
 
 // for network
 #include <socket_api.h>
@@ -414,48 +412,6 @@ int video_call_stop(void)
 
 
 
-
-#include "sci_types.h"
-#include "mmi_common.h"
-#include "mmi_font.h"
-#include "mmiset_nv.h"
-#include "mmi_id.h"
-#include "mmiset_id.h"
-#include "window_parse.h"
-#include "mmidisplay_data.h"
-#include "mereg_videocall.h"
-#include "mmiset_text.h"
-#include "gps_at6558r_ref.h"
-#include "mmi_protocol_customer_api.h"
-#include "mmi_protocol_main_api.h"
-#include "mmipub.h"
-#include "Mmicc_text.h"
-
-
-#include "videochatservice.h"
-
-/**---------------------------------------------------------------------------*
- **                         Compiler Flag                                     *
- **---------------------------------------------------------------------------*/
-#ifdef   __cplusplus
-    extern   "C" 
-    {
-#endif
-
-
-static MEREG_LOCAL_USER_ID_STRUCT_T s_userId = {0};
-
-static VC_CONTACTS_DATA_T s_video_call_contact_info = {0};
-static uint8 s_video_call_contact_index = 0;
-static uint8 s_video_call_win_status = 0; // 0-contact list menu; 1-call button select
-static MMI_VIDEO_CALL_PARAMS_T s_video_call_params = {0};
-
-
-
-
-
-
-
 PUBLIC void MMIAPI_InitMeregUserId(void)
 {
    MN_RETURN_RESULT_E  return_value = MN_RETURN_FAILURE;
@@ -586,11 +542,73 @@ PUBLIC void MMIAPI_StopVideoCallRing(void)
        }
 }
 
+#endif
+
+
+
+
+#include "sci_types.h"
+#include "mmi_common.h"
+#include "mmi_font.h"
+#include "mmi_id.h"
+#include "window_parse.h"
+#include "mmidisplay_data.h"
+#include "mmiset_text.h"
+#include "mmi_protocol_main_api.h"
+#include "mmipub.h"
+#include "Guibutton.h"
+#include "Mmicc_text.h"
+#include "mmi_video_call.h"
+
+
+
+/**---------------------------------------------------------------------------*
+ **                         Compiler Flag                                     *
+ **---------------------------------------------------------------------------*/
+#ifdef   __cplusplus
+    extern   "C" 
+    {
+#endif
+
+
+static VC_CONTACTS_DATA_T s_video_call_contact_info = {0};
+static uint8 s_video_call_contact_index = 0;
+static uint8 s_video_call_win_status = 0; // 0-contact list menu; 1-call button select
+MMI_VIDEO_CALL_PARAMS_T s_video_call_params = {0};
+
+
+void mmi_video_call_connect(void)
+{
+       s_video_call_params.state = MMI_VIDEO_CALL_STATE_ACTIVE;
+
+       if(0 != s_video_call_params.dial_timer_id)
+       {
+               MMK_StopTimer(s_video_call_params.dial_timer_id);
+               s_video_call_params.dial_timer_id = 0;
+       }
+
+       if(0 != s_video_call_params.incoming_timer_id)
+       {
+               MMK_StopTimer(s_video_call_params.incoming_timer_id);
+               s_video_call_params.incoming_timer_id = 0;
+       }
+
+
+}
+
+static MMI_RESULT_E mmi_video_call_answer_button_cb(void)
+{
 
 
+       return 0;
+}
 
+static MMI_RESULT_E mmi_video_call_reject_button_cb(void)
+{
 
 
+       return 0;
+}
 
 static MMI_RESULT_E mmi_video_call_hangup_button_cb(void)
 {
@@ -599,6 +617,148 @@ static MMI_RESULT_E mmi_video_call_hangup_button_cb(void)
        return 0;
 }
 
+static void mmi_video_call_incoming_win_display(MMI_WIN_ID_T win_id)
+{
+       GUI_LCD_DEV_INFO lcd_dev_info = {GUI_MAIN_LCD_ID, GUI_BLOCK_MAIN};
+       GUI_RECT_T full_rect = MMITHEME_GetFullScreenRect();
+       MMI_CTRL_ID_T button_ctrl0 = MMI_COMMON_BUTTON_0_CTRL_ID, button_ctrl1 = MMI_COMMON_BUTTON_1_CTRL_ID;
+       GUI_RECT_T button_ctrl0_rect = {30, MMI_MAINSCREEN_HEIGHT-30-64, 30+64, MMI_MAINSCREEN_HEIGHT-30};
+       GUI_RECT_T button_ctrl1_rect = {MMI_MAINSCREEN_WIDTH-30-64, MMI_MAINSCREEN_HEIGHT-30-64, MMI_MAINSCREEN_WIDTH-30, MMI_MAINSCREEN_HEIGHT-30};
+       MMI_CTRL_ID_T label_ctrl0 = MMI_COMMON_LABEL_0_CTRL_ID, label_ctrl1 = MMI_COMMON_LABEL_1_CTRL_ID;
+       GUI_RECT_T label_ctrl0_rect = {10, 10, MMI_MAINSCREEN_WIDTH-10, 10+30};
+       GUI_RECT_T label_ctrl1_rect = {10, 10, MMI_MAINSCREEN_WIDTH-10, 10+30};
+       GUI_BG_T ctrl_bg = {0};
+       GUI_FONT_ALL_T font_all = {SONG_FONT_26, MMI_WHITE_COLOR};
+       MMI_STRING_T display_text = {0};
+       wchar temp_wstr[32] = {0};
+       GUI_POINT_T image_point = {0};
+       MMI_IMAGE_ID_T image_id = IMAGE_NULL;
+       uint16 image_width = 0, image_height = 0;
+
+       //background
+       GUI_FillRect(&lcd_dev_info, full_rect, MMI_BLACK_COLOR);
+
+
+       //prompt
+       GUILABEL_SetRect( label_ctrl0, &label_ctrl0_rect, FALSE);
+       //GUILABEL_SetBg( label_ctrl0, &ctrl_bg);
+       MMI_GetLabelTextByLang(TXT_SUNDAY, &display_text);
+       GUILABEL_SetFont( label_ctrl0, font_all.font, font_all.color);
+       GUILABEL_SetText( label_ctrl0, &display_text, FALSE);
+       GUILABEL_SetVisible(label_ctrl0, TRUE, FALSE);
+
+
+       //image
+       image_id = IMAGE_VIDEO_CALL_CONTACT_PHOTO;
+       GUIRES_GetImgWidthHeight(&image_width,&image_height, image_id, win_id);
+       image_point.x = (MMI_MAINSCREEN_WIDTH - image_width) / 2;
+       image_point.y = label_ctrl0_rect.bottom + 10;
+       IMG_EnableTransparentColor(TRUE);
+       GUIRES_DisplayImg(&image_point, PNULL, PNULL, win_id, image_id, &lcd_dev_info);
+       IMG_EnableTransparentColor(FALSE);
+
+
+       //number
+       label_ctrl1_rect.top = image_point.y + image_height + 10;
+       label_ctrl1_rect.bottom = label_ctrl1_rect.top + 30;
+       GUILABEL_SetRect( label_ctrl1, &label_ctrl1_rect, FALSE);
+       //GUILABEL_SetBg( label_ctrl1, &ctrl_bg);
+       //MMI_GetLabelTextByLang(TXT_MONDAY, &display_text);
+       GUILABEL_SetFont( label_ctrl1, font_all.font, font_all.color);
+       if(NULL != s_video_call_params.name)
+       {
+               MMIAPICOM_Wstrcpy(temp_wstr, s_video_call_params.name);
+       }
+       else
+       {
+               MMIAPICOM_StrToWstr(s_video_call_params.number, temp_wstr);
+       }
+       display_text.wstr_ptr = temp_wstr;
+       display_text.wstr_len = MMIAPICOM_Wstrlen(temp_wstr);
+       GUILABEL_SetText( label_ctrl1, &display_text, FALSE);
+       GUILABEL_SetVisible(label_ctrl1, FALSE, FALSE);
+
+       
+       //reject button
+       GUIBUTTON_SetRect( button_ctrl0, &button_ctrl0_rect);
+       //GUIBUTTON_SetFont( button_ctrl0, &font_all);
+       
+       //MMI_GetLabelTextByLang(TXT_GO_TO_WORK, &display_text);
+       //ctrl_bg.bg_type = GUI_BG_COLOR;
+       //ctrl_bg.color = GUI_RGB8882RGB565(0X0ECC92); //GUI_RGB2RGB565(0x40, 0x40, 0x40);
+       //GUIBUTTON_SetBg(button_ctrl0, &ctrl_bg);
+       GUIBUTTON_SetGrayed(button_ctrl0, FALSE, &ctrl_bg, FALSE);
+       
+       GUIBUTTON_SetRunSheen(button_ctrl0, FALSE);
+       //GUIBUTTON_SetText( button_ctrl0, display_text.wstr_ptr, display_text.wstr_len);
+       GUIBUTTON_SetCallBackFunc(button_ctrl0, mmi_video_call_reject_button_cb);
+       GUIBUTTON_SetVisible(button_ctrl0, TRUE, FALSE);
+
+
+       //answer button 
+       GUIBUTTON_SetRect( button_ctrl1, &button_ctrl1_rect);
+       //GUIBUTTON_SetFont( button_ctrl1, &font_all);
+
+       //MMI_GetLabelTextByLang(TXT_INSPECT_CLOCK_IN, &display_text);
+       //ctrl_bg.bg_type = GUI_BG_COLOR;
+       //ctrl_bg.color = GUI_RGB8882RGB565(0X0ECC92); //GUI_RGB2RGB565(0x40, 0x40, 0x40);
+       //GUIBUTTON_SetBg(button_ctrl1, &ctrl_bg);
+       GUIBUTTON_SetGrayed(button_ctrl1, FALSE, &ctrl_bg, FALSE);
+
+       GUIBUTTON_SetRunSheen(button_ctrl1, FALSE);
+       //GUIBUTTON_SetText( button_ctrl1, display_text.wstr_ptr, display_text.wstr_len);
+       GUIBUTTON_SetCallBackFunc(button_ctrl1, mmi_video_call_answer_button_cb);
+       GUIBUTTON_SetVisible(button_ctrl1, TRUE, FALSE);
+}
+
+LOCAL MMI_RESULT_E HandleVideoCallIncomingWindow(MMI_WIN_ID_T win_id, MMI_MESSAGE_ID_E msg_id, DPARAM param)
+{      
+       MMI_RESULT_E result = MMI_RESULT_TRUE;
+       GUI_POINT_T dis_point = {0, 0};
+       
+       switch (msg_id) 
+       {
+               case MSG_OPEN_WINDOW:
+                       break;
+                       
+               case MSG_FULL_PAINT:
+                       mmi_video_call_incoming_win_display(win_id);
+                       break;  
+                       
+               case MSG_KEYDOWN_CANCEL:
+               case MSG_CTL_CANCEL:
+                       MMK_CloseWin(win_id);
+                       break;
+               
+               case MSG_CLOSE_WINDOW:
+                       break;
+                        
+               default:
+                       result = MMI_RESULT_FALSE;
+                       break;
+       }
+       
+       return result;
+}
+
+WINDOW_TABLE(MMI_VIDEO_CALL_INCOMING_WIN_TAB) =
+{
+       WIN_FUNC( (uint32)HandleVideoCallIncomingWindow),
+       WIN_ID( MMI_VIDEO_CALL_INCOMING_WIN_ID ),
+       WIN_HIDE_STATUS,
+       CREATE_LABEL_CTRL(GUILABEL_ALIGN_MIDDLE, MMI_COMMON_LABEL_0_CTRL_ID),
+       CREATE_LABEL_CTRL(GUILABEL_ALIGN_MIDDLE, MMI_COMMON_LABEL_1_CTRL_ID),
+       CREATE_BUTTON_CTRL(IMAGE_VIDEO_CALL_HANGUP_BUTTON, MMI_COMMON_BUTTON_0_CTRL_ID),
+       CREATE_BUTTON_CTRL(IMAGE_VIDEO_CALL_ANSWER_BUTTON, MMI_COMMON_BUTTON_1_CTRL_ID),
+       END_WIN
+};
+
+BOOLEAN mmi_video_call_incoming_win_enter(void)
+{
+    MMK_CreateWin((uint32*)MMI_VIDEO_CALL_INCOMING_WIN_TAB, PNULL);
+       return TRUE;
+}
+
 static void mmi_video_call_dialing_win_display(MMI_WIN_ID_T win_id, MMI_CTRL_ID_T ctrl_id)
 {
        GUI_LCD_DEV_INFO lcd_dev_info = {GUI_MAIN_LCD_ID, GUI_BLOCK_MAIN};
@@ -650,21 +810,12 @@ LOCAL MMI_RESULT_E HandleVideoCallDialingWindow(MMI_WIN_ID_T win_id, MMI_MESSAGE
                case MSG_FULL_PAINT:
                        mmi_video_call_dialing_win_display(win_id, ctrl_id);
                        break;  
-
-               case MSG_CTL_PENOK:
-           case MSG_CTL_MIDSK:
-           case MSG_APP_WEB:
-                       break;
                        
                case MSG_KEYDOWN_CANCEL:
                case MSG_CTL_CANCEL:
                        MMK_CloseWin(win_id);
                        break;
                
-               case MSG_KEYDOWN_OK:
-               case MSG_CTL_OK:
-                       break;          
-               
                case MSG_CLOSE_WINDOW:
                        break;
                         
@@ -681,13 +832,17 @@ WINDOW_TABLE(MMI_VIDEO_CALL_DIALING_WIN_TAB) =
        WIN_FUNC( (uint32)HandleVideoCallDialingWindow),
        WIN_ID( MMI_VIDEO_CALL_DIALING_WIN_ID ),
        WIN_HIDE_STATUS,
-       //WIN_TITLE(TXT_MAINMENU_VIDEO_CALL),
        CREATE_BUTTON_CTRL(IMAGE_VIDEO_CALL_HANGUP_BUTTON, MMI_COMMON_BUTTON_CTRL_ID),
        END_WIN
 };
 
+BOOLEAN mmi_video_call_dialing_win_enter(void)
+{
+    MMK_CreateWin((uint32*)MMI_VIDEO_CALL_DIALING_WIN_TAB, PNULL);
+       return TRUE;
+}
 
-static void mmi_win_init_video_call_main(MMI_WIN_ID_T   win_id, MMI_CTRL_ID_T ctrl_id)
+static void mmi_video_call_main_win_init(MMI_WIN_ID_T win_id, MMI_CTRL_ID_T ctrl_id, MMI_CTRL_ID_T button_ctrl0, MMI_CTRL_ID_T button_ctrl1)
 {
        s_video_call_contact_index = 0;
        s_video_call_win_status = 0;
@@ -695,12 +850,21 @@ static void mmi_win_init_video_call_main(MMI_WIN_ID_T      win_id, MMI_CTRL_ID_T ctr
        
     //get video call contact members from server
     km_FZD_net_action_MEMBERS();
+
+#ifndef __FOR_DEBUG__
+#define __FOR_DEBUG__
+#endif
+#ifdef __FOR_DEBUG__
+       s_video_call_contact_info.vc_contact_num = 2;
+       strcpy(s_video_call_contact_info.vc_data[0].vc_number, "jrtc001");
+       strcpy(s_video_call_contact_info.vc_data[1].vc_number, "jrtc002");
+#endif
 }
 
 static void mmi_win_display_video_call_contact_list(MMI_WIN_ID_T       win_id, MMI_CTRL_ID_T ctrl_id)
 {
        uint8 index = 0;
-       uint8 total_item = s_video_call_contact_info.vc_contact_num > MMIAPI_VC_CONTACT_MAX_NUM ? MMIAPI_VC_CONTACT_MAX_NUM : s_vc_contact_info.vc_contact_num;
+       uint8 total_item = s_video_call_contact_info.vc_contact_num > MMIAPI_VC_CONTACT_MAX_NUM ? MMIAPI_VC_CONTACT_MAX_NUM : s_video_call_contact_info.vc_contact_num;
 
        GUILIST_RemoveAllItems(ctrl_id);
        GUILIST_SetMaxItem( ctrl_id, total_item, FALSE ); //max item MMIAPI_VC_CONTACT_MAX_NUM = 50
@@ -759,11 +923,25 @@ static void mmi_video_call_dial_timeout_cb(void)
 
        memset(&s_video_call_params, 0x0, sizeof(s_video_call_params));
 
+       MMK_CloseWin(MMI_VIDEO_CALL_DIALING_WIN_ID);
 }
 
 static void mmi_video_call_button_call(MMI_VIDEO_CALL_TYPE_E calltype)
 {
        int dial_ret = -1;
+    MN_DUAL_SYS_E dual_sys = MN_DUAL_SYS_1;
+
+       if(0 == MNPHONE_GetAttState(dual_sys)) // or use (FALSE == MMIAPIPHONE_GetDataServiceSIM(&dual_sys))
+       {
+               MMIPUB_OpenAlertWarningWin(STR_SIM_SEARCH_FAIL);
+               return ;
+       }
+       
+    if(FALSE == MMIAPIPHONE_IsSimAvailable(dual_sys))
+       {
+        MMIPUB_OpenAlertWarningWin(STR_SIM_NOT_SIM_EXT01);
+           return ;
+       }
        
        if(0 != s_video_call_params.dial_timer_id)
                MMK_StopTimer(s_video_call_params.dial_timer_id);
@@ -777,7 +955,7 @@ static void mmi_video_call_button_call(MMI_VIDEO_CALL_TYPE_E calltype)
        s_video_call_params.calltype = calltype;
        s_video_call_params.is_mt = FALSE;
        strcpy(s_video_call_params.number, s_video_call_contact_info.vc_data[s_video_call_contact_index].vc_number);
-       MMIAPICOM_Wstrcpy(s_video_call_params.name, s_video_call_contact_info.vc_data[s_video_call_contact_index].vc_name)
+       MMIAPICOM_Wstrcpy(s_video_call_params.name, s_video_call_contact_info.vc_data[s_video_call_contact_index].vc_name);
        
        dial_ret = mmi_video_call_dial(s_video_call_params.number, calltype);
        if(0 == s_video_call_params.dial_timer_id)
@@ -787,9 +965,8 @@ static void mmi_video_call_button_call(MMI_VIDEO_CALL_TYPE_E calltype)
                s_video_call_params.dial_timer_id = MMK_CreateTimerCallback(time_out, mmi_video_call_dial_timeout_cb, PNULL, FALSE);
        }
        
-    MMK_CreateWin((uint32*)MMI_VIDEO_CALL_DIALING_WIN_TAB, PNULL);
-       
-       return 0;
+       mmi_video_call_dialing_win_enter();
+
 }
 
 static MMI_RESULT_E mmi_video_call_voice_button_cb(void)
@@ -845,7 +1022,7 @@ static void mmi_win_display_video_call_button(MMI_WIN_ID_T win_id, MMI_CTRL_ID_T
        //GUIBUTTON_SetVisible(button_ctrl1, FALSE, FALSE);
 }
 
-static void mmi_win_display_video_call_main(MMI_WIN_ID_T win_id, MMI_CTRL_ID_T ctrl_id, MMI_CTRL_ID_T button_ctrl0, MMI_CTRL_ID_T button_ctrl1)
+static void mmi_video_call_main_win_display(MMI_WIN_ID_T win_id, MMI_CTRL_ID_T ctrl_id, MMI_CTRL_ID_T button_ctrl0, MMI_CTRL_ID_T button_ctrl1)
 {
        GUI_LCD_DEV_INFO lcd_dev_info = {GUI_MAIN_LCD_ID, GUI_BLOCK_MAIN};
        GUI_RECT_T full_rect = MMITHEME_GetFullScreenRect();
@@ -877,17 +1054,16 @@ LOCAL MMI_RESULT_E HandleVideoCallMainWindow(MMI_WIN_ID_T win_id, MMI_MESSAGE_ID
        switch (msg_id) 
        {
                case MSG_OPEN_WINDOW:
-                       mmi_win_init_video_call_main(win_id, ctrl_id, button_ctrl0, button_ctrl1);
+                       mmi_video_call_main_win_init(win_id, ctrl_id, button_ctrl0, button_ctrl1);
                        break;
                        
                case MSG_FULL_PAINT:
-                       mmi_win_display_video_call_main(win_id, ctrl_id, button_ctrl0, button_ctrl1);
+                       mmi_video_call_main_win_display(win_id, ctrl_id, button_ctrl0, button_ctrl1);
                        break;  
 
                case MSG_CTL_PENOK:
            case MSG_CTL_MIDSK:
            case MSG_APP_WEB:
-                    //user make a call by press or long press green key
                        if(0 != GUILIST_GetTotalItemNum(ctrl_id)) // && (GUILIST_GetSelectedItemIndex(ctrl_id, PNULL, 0) == 0))
                        {
                                s_video_call_contact_index = GUILIST_GetCurItemIndex(ctrl_id);
@@ -908,7 +1084,7 @@ LOCAL MMI_RESULT_E HandleVideoCallMainWindow(MMI_WIN_ID_T win_id, MMI_MESSAGE_ID
                
                case MSG_CLOSE_WINDOW:
                        //stop hero server
-                       MMIHERO_VoiceChatServerExit();
+                       //MMIHERO_VoiceChatServerExit();
                        break;
                         
                default:
@@ -962,3 +1138,4 @@ PUBLIC BOOLEAN MMIAPI_EnterVideoCallMainWindow(void)
 
 #endif
 
+
index 76810da..e12fe2d 100644 (file)
@@ -4,6 +4,15 @@
 #ifndef __MMI_VIDEO_CALL_H__
 #define __MMI_VIDEO_CALL_H__
 
+#include "sci_types.h"
+#include "mmi_image.h"
+#include "mmi_common.h"
+#include "mmi_font.h"
+#include "mmidisplay_data.h"
+#include "guistring.h"
+#include "window_parse.h"
+
+
 #ifdef __cplusplus
 extern  "C"
 {