webrtc_test: Remove global variables 33/275633/8 accepted/tizen/unified/20220607.134909 submit/tizen/20220607.060007
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 27 May 2022 11:12:07 +0000 (20:12 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 2 Jun 2022 13:07:36 +0000 (22:07 +0900)
Some global variables are put inside to app data structure.
get_appdata() is added.

[Version] 0.3.116
[Issue Type] Refactoring

Change-Id: I12ee6a29a5ae8a1b4b1ee1db9c8ca885eef3b56a
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/capi-media-webrtc.spec
test/webrtc_test.c
test/webrtc_test_menu.c
test/webrtc_test_priv.h

index dbd24a5d9503132803e4471e169ea2d2c1907305..381bef0430914a7401b406bd90c9a2048a72a7c5 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.115
+Version:    0.3.116
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index acd96f0686eae5a0834c5eb3d52a788f457b4782..8edb50d7bf312fde202ad23e07b96f1641e5b70c 100644 (file)
@@ -70,18 +70,7 @@ static const char *g_webrtc_stats_type_str[] = {
        [WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP] = "remote-outbound-rtp",
 };
 
-int g_menu_status;
-int g_cnt;
-gchar g_proxy[MAX_STRING_LEN];
-appdata_s g_ad;
-connection_s g_conns[MAX_CONNECTION_LEN];
-signaling_server_s g_signaling_server;
-static webrtc_signaling_server_h g_inner_signaling_server;
-
-/* for video display */
-static Evas_Object *g_win_id;
-static Evas_Object *g_eo_mine;
-static Evas_Object *g_text_eo_mine;
+static appdata_s g_ad;
 
 #if defined(__DEBUG_VALIDATE_MEDIA_PACKET_SOURCE__) || defined(__DEBUG_VALIDATE_ENCODED_FRAME_CB__)
 GstBuffer *__alloc_buffer_from_packet(media_packet_h packet);
@@ -94,6 +83,11 @@ static GstElement* __build_appsrc_vp8_render_pipeline(GstElement **appsrc);
 static GstElement* __build_appsrc_opus_render_pipeline(GstElement **appsrc);
 #endif
 
+appdata_s *get_appdata(void)
+{
+       return &g_ad;
+}
+
 static void win_del(void *data, Evas_Object *obj, void *event)
 {
        elm_exit();
@@ -205,7 +199,7 @@ static int app_create(void *data)
        if (win == NULL)
                return -1;
        ad->win = win;
-       g_win_id = win;
+       ad->win_id = win;
        create_render_rect_and_bg(ad->win);
 
        /* Create evas image object for EVAS surface.
@@ -215,7 +209,7 @@ static int app_create(void *data)
         * |    eo (remote1)    |    eo (remote2)    | *
         * |____________________|____________________| */
        for (i = 0; i < MAX_CONNECTION_LEN + 1; i++) {
-               eo = (i == 0) ? &g_eo_mine : &g_conns[i - 1].render.eo;
+               eo = (i == 0) ? &g_ad.eo_mine : &g_ad.conns[i - 1].render.eo;
                *eo = create_image_object(ad->win);
                if (!*eo) {
                        g_print("failed to create evas image object\n");
@@ -288,24 +282,24 @@ static int app_terminate(void *data)
        int i;
 
        for (i = 0; i < MAX_CONNECTION_LEN; i++) {
-               if (g_conns[i].render.eo) {
-                       evas_object_del(g_conns[i].render.eo);
-                       g_conns[i].render.eo = NULL;
+               if (g_ad.conns[i].render.eo) {
+                       evas_object_del(g_ad.conns[i].render.eo);
+                       g_ad.conns[i].render.eo = NULL;
                }
-               if (g_conns[i].render.text_eo) {
-                       evas_object_del(g_conns[i].render.text_eo);
-                       g_conns[i].render.text_eo = NULL;
+               if (g_ad.conns[i].render.text_eo) {
+                       evas_object_del(g_ad.conns[i].render.text_eo);
+                       g_ad.conns[i].render.text_eo = NULL;
                }
        }
 
-       if (g_eo_mine) {
-               evas_object_del(g_eo_mine);
-               g_eo_mine = NULL;
+       if (g_ad.eo_mine) {
+               evas_object_del(g_ad.eo_mine);
+               g_ad.eo_mine = NULL;
        }
 
-       if (g_win_id) {
-               evas_object_del(g_win_id);
-               g_win_id = NULL;
+       if (ad->win_id) {
+               evas_object_del(ad->win_id);
+               ad->win_id = NULL;
        }
 
        ad->win = NULL;
@@ -339,7 +333,7 @@ static void __release_packet_source(int conn_idx, unsigned int source_idx)
        if (source_idx >= MAX_MEDIA_PACKET_SOURCE_LEN)
                return;
 
-       media_packet_source_s *packet_source = &g_conns[conn_idx].packet_sources[source_idx];
+       media_packet_source_s *packet_source = &g_ad.conns[conn_idx].packet_sources[source_idx];
 
        packet_source->source_id = 0;
        if (packet_source->format) {
@@ -375,13 +369,13 @@ static void _webrtc_create(int index)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       RET_IF(g_conns[index].webrtc, "already created");
+       RET_IF(g_ad.conns[index].webrtc, "already created");
 
-       ret = webrtc_create(&g_conns[index].webrtc);
+       ret = webrtc_create(&g_ad.conns[index].webrtc);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       g_conns[index].index = index;
-       g_print("webrtc[%p, index:%d] is created\n", g_conns[index].webrtc, index);
+       g_ad.conns[index].index = index;
+       g_print("webrtc[%p, index:%d] is created\n", g_ad.conns[index].webrtc, index);
 }
 
 static void _webrtc_destroy(int index)
@@ -389,63 +383,63 @@ static void _webrtc_destroy(int index)
        int ret = WEBRTC_ERROR_NONE;
        int i;
 
-       RET_IF(!g_conns[index].webrtc, "webrtc is NULL");
+       RET_IF(!g_ad.conns[index].webrtc, "webrtc is NULL");
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i]) {
-                       webrtc_destroy_data_channel(g_conns[index].channels[i]);
-                       g_conns[index].channels[i] = NULL;
+               if (g_ad.conns[index].channels[i]) {
+                       webrtc_destroy_data_channel(g_ad.conns[index].channels[i]);
+                       g_ad.conns[index].channels[i] = NULL;
                }
-               g_conns[index].recv_channels[i] = NULL;
+               g_ad.conns[index].recv_channels[i] = NULL;
        }
 
-       ret = webrtc_destroy(g_conns[index].webrtc);
+       ret = webrtc_destroy(g_ad.conns[index].webrtc);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       g_print("webrtc[%p, index:%d] is destroyed\n", g_conns[index].webrtc, index);
+       g_print("webrtc[%p, index:%d] is destroyed\n", g_ad.conns[index].webrtc, index);
 
-       g_conns[index].webrtc = NULL;
-       if (g_conns[index].offer) {
-               free(g_conns[index].offer);
-               g_conns[index].offer = NULL;
+       g_ad.conns[index].webrtc = NULL;
+       if (g_ad.conns[index].offer) {
+               free(g_ad.conns[index].offer);
+               g_ad.conns[index].offer = NULL;
        }
-       if (g_conns[index].answer) {
-               free(g_conns[index].answer);
-               g_conns[index].answer = NULL;
+       if (g_ad.conns[index].answer) {
+               free(g_ad.conns[index].answer);
+               g_ad.conns[index].answer = NULL;
        }
-       if (g_conns[index].remote_desc) {
-               free(g_conns[index].remote_desc);
-               g_conns[index].remote_desc = NULL;
+       if (g_ad.conns[index].remote_desc) {
+               free(g_ad.conns[index].remote_desc);
+               g_ad.conns[index].remote_desc = NULL;
        }
-       g_list_free_full(g_conns[index].ice_candidates, free);
-       g_conns[index].ice_candidates = NULL;
+       g_list_free_full(g_ad.conns[index].ice_candidates, free);
+       g_ad.conns[index].ice_candidates = NULL;
 
-       g_conns[index].channel_index = 0;
+       g_ad.conns[index].channel_index = 0;
 
        for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++)
                __release_packet_source(index, i);
 
-       if (g_conns[index].source.stream_info) {
-               sound_manager_destroy_stream_information(g_conns[index].source.stream_info);
-               g_conns[index].source.stream_info = NULL;
+       if (g_ad.conns[index].source.stream_info) {
+               sound_manager_destroy_stream_information(g_ad.conns[index].source.stream_info);
+               g_ad.conns[index].source.stream_info = NULL;
        }
 
-       if (g_conns[index].render.stream_info) {
-               sound_manager_destroy_stream_information(g_conns[index].render.stream_info);
-               g_conns[index].render.stream_info = NULL;
+       if (g_ad.conns[index].render.stream_info) {
+               sound_manager_destroy_stream_information(g_ad.conns[index].render.stream_info);
+               g_ad.conns[index].render.stream_info = NULL;
        }
 
-       g_conns[index].render.loopback_track_id = 0;
+       g_ad.conns[index].render.loopback_track_id = 0;
 
 #ifndef TIZEN_TV
-       if (g_conns[index].encoded_audio_frame_cb_is_set)
-               g_conns[index].encoded_audio_frame_cb_is_set = false;
+       if (g_ad.conns[index].encoded_audio_frame_cb_is_set)
+               g_ad.conns[index].encoded_audio_frame_cb_is_set = false;
 
-       if (g_conns[index].encoded_video_frame_cb_is_set)
-               g_conns[index].encoded_video_frame_cb_is_set = false;
+       if (g_ad.conns[index].encoded_video_frame_cb_is_set)
+               g_ad.conns[index].encoded_video_frame_cb_is_set = false;
 
-       if (g_conns[index].render.espp) {
-               g_conns[index].render.espp = NULL;
+       if (g_ad.conns[index].render.espp) {
+               g_ad.conns[index].render.espp = NULL;
                g_print("espp close & destroy\n");
        }
 #endif
@@ -455,23 +449,23 @@ static void _webrtc_start(int index)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       RET_IF(!g_conns[index].webrtc, "webrtc is NULL");
+       RET_IF(!g_ad.conns[index].webrtc, "webrtc is NULL");
 
-       ret = webrtc_start(g_conns[index].webrtc);
+       ret = webrtc_start(g_ad.conns[index].webrtc);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_start() success\n");
 #ifndef TIZEN_TV
-       if (g_conns[index].encoded_audio_frame_cb_is_set ||
-               g_conns[index].encoded_video_frame_cb_is_set) {
-               if (!g_conns[index].render.espp)
+       if (g_ad.conns[index].encoded_audio_frame_cb_is_set ||
+               g_ad.conns[index].encoded_video_frame_cb_is_set) {
+               if (!g_ad.conns[index].render.espp)
                        g_print("espp create & open\n");
        }
 
-       if (g_conns[index].encoded_audio_frame_cb_is_set)
+       if (g_ad.conns[index].encoded_audio_frame_cb_is_set)
                g_print("espp set audio stream info\n");
 
-       if (g_conns[index].encoded_video_frame_cb_is_set)
+       if (g_ad.conns[index].encoded_video_frame_cb_is_set)
                g_print("espp set video stream info\n");
 #endif
 }
@@ -481,40 +475,40 @@ static void _webrtc_stop(int index)
        int ret = WEBRTC_ERROR_NONE;
        int i;
 
-       RET_IF(!g_conns[index].webrtc, "webrtc is NULL");
+       RET_IF(!g_ad.conns[index].webrtc, "webrtc is NULL");
 
-       ret = webrtc_stop(g_conns[index].webrtc);
+       ret = webrtc_stop(g_ad.conns[index].webrtc);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_stop() success\n");
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].recv_channels[i] != NULL)
-                       g_conns[index].recv_channels[i] = NULL;
+               if (g_ad.conns[index].recv_channels[i] != NULL)
+                       g_ad.conns[index].recv_channels[i] = NULL;
        }
 
 #ifdef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
-       if (g_conns[index].video_render_pipeline) {
-               if (gst_element_set_state(g_conns[index].video_render_pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE)
+       if (g_ad.conns[index].video_render_pipeline) {
+               if (gst_element_set_state(g_ad.conns[index].video_render_pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE)
                        g_printerr("failed to set state to NULL\n");
-               gst_object_unref(g_conns[index].video_render_pipeline);
-               g_conns[index].video_render_pipeline = NULL;
-               g_conns[index].appsrc_for_video = NULL;
+               gst_object_unref(g_ad.conns[index].video_render_pipeline);
+               g_ad.conns[index].video_render_pipeline = NULL;
+               g_ad.conns[index].appsrc_for_video = NULL;
                g_print("video render pipeline is released\n");
        }
-       if (g_conns[index].audio_render_pipeline) {
-               if (gst_element_set_state(g_conns[index].audio_render_pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE)
+       if (g_ad.conns[index].audio_render_pipeline) {
+               if (gst_element_set_state(g_ad.conns[index].audio_render_pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE)
                        g_printerr("failed to set state to NULL\n");
-               gst_object_unref(g_conns[index].audio_render_pipeline);
-               g_conns[index].audio_render_pipeline = NULL;
-               g_conns[index].appsrc_for_audio = NULL;
+               gst_object_unref(g_ad.conns[index].audio_render_pipeline);
+               g_ad.conns[index].audio_render_pipeline = NULL;
+               g_ad.conns[index].appsrc_for_audio = NULL;
                g_print("audio render pipeline is released\n");
        }
 #endif
 #ifndef TIZEN_TV
-       if (g_conns[index].encoded_audio_frame_cb_is_set ||
-               g_conns[index].encoded_video_frame_cb_is_set) {
-               if (g_conns[index].render.espp) {
-                       g_conns[index].render.espp = NULL;
+       if (g_ad.conns[index].encoded_audio_frame_cb_is_set ||
+               g_ad.conns[index].encoded_video_frame_cb_is_set) {
+               if (g_ad.conns[index].render.espp) {
+                       g_ad.conns[index].render.espp = NULL;
                        g_print("espp destroy\n");
                }
        }
@@ -526,7 +520,7 @@ static void _webrtc_get_state(int index)
        int ret = WEBRTC_ERROR_NONE;
        webrtc_state_e state;
 
-       ret = webrtc_get_state(g_conns[index].webrtc, &state);
+       ret = webrtc_get_state(g_ad.conns[index].webrtc, &state);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("state: [%s]\n", g_webrtc_state_str[state]);
@@ -537,7 +531,7 @@ static int _get_empty_packet_sources_index(int index)
        int i;
 
        for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++) {
-               if (g_conns[index].packet_sources[i].source_id == 0)
+               if (g_ad.conns[index].packet_sources[i].source_id == 0)
                        return i;
        }
 
@@ -553,7 +547,7 @@ static int _find_packet_sources_index(int index, unsigned int source_id)
                return -1;
 
        for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++) {
-               if (g_conns[index].packet_sources[i].source_id == source_id)
+               if (g_ad.conns[index].packet_sources[i].source_id == source_id)
                        return i;
        }
 
@@ -700,17 +694,17 @@ static void _webrtc_add_media_source(int index, int type, unsigned int *source_i
                        i = _get_empty_packet_sources_index(index);
                        RET_IF(i == -1, "media packet source can be added up to %d", MAX_MEDIA_PACKET_SOURCE_LEN);
                }
-               ret = webrtc_add_media_source(g_conns[index].webrtc, type, &_source_id);
+               ret = webrtc_add_media_source(g_ad.conns[index].webrtc, type, &_source_id);
                RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
                if (type == WEBRTC_MEDIA_SOURCE_TYPE_MEDIA_PACKET) {
-                       g_conns[index].packet_sources[i].source_id = _source_id;
-                       g_mutex_init(&g_conns[index].packet_sources[i].mutex);
-                       g_cond_init(&g_conns[index].packet_sources[i].cond);
+                       g_ad.conns[index].packet_sources[i].source_id = _source_id;
+                       g_mutex_init(&g_ad.conns[index].packet_sources[i].mutex);
+                       g_cond_init(&g_ad.conns[index].packet_sources[i].cond);
                }
                break;
        case WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_AUDIO ... WEBRTC_MEDIA_SOURCE_TYPE_CUSTOM_VIDEO:
-               ret = webrtc_add_media_source_internal(g_conns[index].webrtc, type, &_source_id);
+               ret = webrtc_add_media_source_internal(g_ad.conns[index].webrtc, type, &_source_id);
                RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
                break;
        default:
@@ -728,18 +722,18 @@ static void _webrtc_add_mic_source(int index, bool aec, unsigned int *source_id)
        int ret = WEBRTC_ERROR_NONE;
        unsigned int _source_id = 0;
 
-       ret = webrtc_add_media_source(g_conns[index].webrtc, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &_source_id);
+       ret = webrtc_add_media_source(g_ad.conns[index].webrtc, WEBRTC_MEDIA_SOURCE_TYPE_MIC, &_source_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       if (g_conns[index].source.stream_info) {
-               sound_manager_destroy_stream_information(g_conns[index].source.stream_info);
-               g_conns[index].source.stream_info = NULL;
+       if (g_ad.conns[index].source.stream_info) {
+               sound_manager_destroy_stream_information(g_ad.conns[index].source.stream_info);
+               g_ad.conns[index].source.stream_info = NULL;
        }
 
-       if (__get_mic_sound_stream_info(aec, &g_conns[index].source.stream_info) < 0) {
+       if (__get_mic_sound_stream_info(aec, &g_ad.conns[index].source.stream_info) < 0) {
                g_printerr("failed to __get_mic_sound_stream_info()\n");
        } else {
-               ret = webrtc_mic_source_set_sound_stream_info(g_conns[index].webrtc, _source_id, g_conns[index].source.stream_info);
+               ret = webrtc_mic_source_set_sound_stream_info(g_ad.conns[index].webrtc, _source_id, g_ad.conns[index].source.stream_info);
                if (ret != WEBRTC_ERROR_NONE)
                        g_printerr("failed to webrtc_mic_source_set_sound_stream_info(), ret[0x%x]\n", ret);
        }
@@ -754,7 +748,7 @@ static void _webrtc_remove_media_source(int index, unsigned int source_id)
        int ret = WEBRTC_ERROR_NONE;
        int i;
 
-       ret = webrtc_remove_media_source(g_conns[index].webrtc, source_id);
+       ret = webrtc_remove_media_source(g_ad.conns[index].webrtc, source_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_remove_media_source() success, source_id[%u]\n", source_id);
@@ -767,7 +761,7 @@ static void _webrtc_media_source_set_pause(int index, unsigned int source_id, un
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_source_set_pause(g_conns[index].webrtc, source_id, media_type, pause);
+       ret = webrtc_media_source_set_pause(g_ad.conns[index].webrtc, source_id, media_type, pause);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_pause() success, source_id[%u], media_type[%s], pause[%d]\n",
@@ -779,7 +773,7 @@ static void _webrtc_media_source_get_pause(int index, unsigned int source_id, un
        int ret = WEBRTC_ERROR_NONE;
        bool paused = false;
 
-       ret = webrtc_media_source_get_pause(g_conns[index].webrtc, source_id, media_type, &paused);
+       ret = webrtc_media_source_get_pause(g_ad.conns[index].webrtc, source_id, media_type, &paused);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_get_pause() success, source_id[%u], media_type[%s], paused[%d]\n",
@@ -790,7 +784,7 @@ static void _webrtc_media_source_set_video_resolution(int index, unsigned int so
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_source_set_video_resolution(g_conns[index].webrtc, source_id, width, height);
+       ret = webrtc_media_source_set_video_resolution(g_ad.conns[index].webrtc, source_id, width, height);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_video_resolution() success, source_id[%u], [%dx%d]\n", source_id, width, height);
@@ -802,7 +796,7 @@ static void _webrtc_media_source_get_video_resolution(int index, unsigned int so
        int width;
        int height;
 
-       ret = webrtc_media_source_get_video_resolution(g_conns[index].webrtc, source_id, &width, &height);
+       ret = webrtc_media_source_get_video_resolution(g_ad.conns[index].webrtc, source_id, &width, &height);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_get_video_resolution() success, source_id[%u], [%dx%d]\n", source_id, width, height);
@@ -812,7 +806,7 @@ static void _webrtc_media_source_set_video_framerate(int index, unsigned int sou
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_source_set_video_framerate(g_conns[index].webrtc, source_id, framerate);
+       ret = webrtc_media_source_set_video_framerate(g_ad.conns[index].webrtc, source_id, framerate);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_video_framerate() success, source_id[%u], framerate[%d]\n", source_id, framerate);
@@ -823,7 +817,7 @@ static void _webrtc_media_source_get_video_framerate(int index, unsigned int sou
        int ret = WEBRTC_ERROR_NONE;
        int framerate;
 
-       ret = webrtc_media_source_get_video_framerate(g_conns[index].webrtc, source_id, &framerate);
+       ret = webrtc_media_source_get_video_framerate(g_ad.conns[index].webrtc, source_id, &framerate);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_get_video_framerate() success, source_id[%u], framerate[%d]\n", source_id, framerate);
@@ -913,7 +907,7 @@ static void _webrtc_media_packet_source_set_format(int index, unsigned int sourc
        if (__create_formats(type, &format) == -1)
                return;
 
-       ret = webrtc_media_packet_source_set_format(g_conns[index].webrtc, source_id, format);
+       ret = webrtc_media_packet_source_set_format(g_ad.conns[index].webrtc, source_id, format);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_media_format() success, source_id[%u], format[%p]\n", source_id, format);
@@ -921,10 +915,10 @@ static void _webrtc_media_packet_source_set_format(int index, unsigned int sourc
        i = _find_packet_sources_index(index, source_id);
        RET_IF(i == -1, "could not find media packet source id[%u]", source_id);
 
-       if (g_conns[index].packet_sources[i].format)
-               media_format_unref(g_conns[index].packet_sources[i].format);
-       g_conns[index].packet_sources[i].format = format;
-       g_conns[index].packet_sources[i].webrtc = g_conns[index].webrtc;
+       if (g_ad.conns[index].packet_sources[i].format)
+               media_format_unref(g_ad.conns[index].packet_sources[i].format);
+       g_ad.conns[index].packet_sources[i].format = format;
+       g_ad.conns[index].packet_sources[i].webrtc = g_ad.conns[index].webrtc;
 }
 
 static void _webrtc_media_source_get_transceiver_direction(int index, unsigned int source_id, webrtc_media_type_e media_type)
@@ -932,7 +926,7 @@ static void _webrtc_media_source_get_transceiver_direction(int index, unsigned i
        int ret = WEBRTC_ERROR_NONE;
        webrtc_transceiver_direction_e direction;
 
-       ret = webrtc_media_source_get_transceiver_direction(g_conns[index].webrtc, source_id, media_type, &direction);
+       ret = webrtc_media_source_get_transceiver_direction(g_ad.conns[index].webrtc, source_id, media_type, &direction);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_get_transceiver_direction() success, source_id[%u], media_type[%s], direction[%s]\n",
@@ -943,7 +937,7 @@ static void _webrtc_media_source_set_transceiver_direction(int index, unsigned i
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_source_set_transceiver_direction(g_conns[index].webrtc, source_id, media_type, direction);
+       ret = webrtc_media_source_set_transceiver_direction(g_ad.conns[index].webrtc, source_id, media_type, direction);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_transceiver_direction() success, source_id[%u], media_type[%s], direction[%s]\n",
@@ -952,7 +946,7 @@ static void _webrtc_media_source_set_transceiver_direction(int index, unsigned i
 
 static void _webrtc_set_display_type(int index, int type)
 {
-       g_conns[index].render.display_type = type;
+       g_ad.conns[index].render.display_type = type;
 
        g_print("display type[%d] is set, it'll be applied when starting rendering video.\n", type);
 }
@@ -961,7 +955,7 @@ static void _webrtc_set_display_mode(int index, unsigned int track_id, unsigned
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_set_display_mode(g_conns[index].webrtc, track_id, mode);
+       ret = webrtc_set_display_mode(g_ad.conns[index].webrtc, track_id, mode);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_display_mode() success, track_id[%u], mode[%u]\n", track_id, mode);
@@ -972,7 +966,7 @@ static void _webrtc_get_display_mode(int index, unsigned int track_id)
        int ret = WEBRTC_ERROR_NONE;
        webrtc_display_mode_e mode;
 
-       ret = webrtc_get_display_mode(g_conns[index].webrtc, track_id, &mode);
+       ret = webrtc_get_display_mode(g_ad.conns[index].webrtc, track_id, &mode);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_get_display_mode() success, track_id[%u], mode[%u]\n", track_id, mode);
@@ -982,7 +976,7 @@ static void _webrtc_set_display_visible(int index, unsigned int track_id, int vi
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_set_display_visible(g_conns[index].webrtc, track_id, (bool)visible);
+       ret = webrtc_set_display_visible(g_ad.conns[index].webrtc, track_id, (bool)visible);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_display_visible() success, track_id[%u], visible[%u]\n", track_id, visible);
@@ -993,7 +987,7 @@ static void _webrtc_get_display_visible(int index, unsigned int track_id)
        int ret = WEBRTC_ERROR_NONE;
        bool visible;
 
-       ret = webrtc_get_display_visible(g_conns[index].webrtc, track_id, &visible);
+       ret = webrtc_get_display_visible(g_ad.conns[index].webrtc, track_id, &visible);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_get_display_visible() success, track_id[%u], visible[%u]\n", track_id, visible);
@@ -1004,12 +998,12 @@ static void _webrtc_media_source_set_audio_loopback(int index, unsigned int sour
        int ret = WEBRTC_ERROR_NONE;
        unsigned int track_id;
 
-       if (!g_conns[index].render.stream_info) {
-               ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &g_conns[index].render.stream_info);
+       if (!g_ad.conns[index].render.stream_info) {
+               ret = sound_manager_create_stream_information(SOUND_STREAM_TYPE_MEDIA, NULL, NULL, &g_ad.conns[index].render.stream_info);
                RET_IF(ret != SOUND_MANAGER_ERROR_NONE, "failed to sound_manager_create_stream_information(), ret[0x%x]", ret);
        }
 
-       ret = webrtc_media_source_set_audio_loopback(g_conns[index].webrtc, source_id, g_conns[index].render.stream_info, &track_id);
+       ret = webrtc_media_source_set_audio_loopback(g_ad.conns[index].webrtc, source_id, g_ad.conns[index].render.stream_info, &track_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_audio_loopback() success, source_id[%u] track_id[%u]\n", source_id, track_id);
@@ -1019,7 +1013,7 @@ static void _webrtc_media_source_unset_audio_loopback(int index, unsigned int so
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_source_unset_audio_loopback(g_conns[index].webrtc, source_id);
+       ret = webrtc_media_source_unset_audio_loopback(g_ad.conns[index].webrtc, source_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_unset_audio_loopback() success, source_id[%u]\n", source_id);
@@ -1030,21 +1024,21 @@ static void _webrtc_media_source_set_video_loopback(int index, unsigned int sour
        int ret = WEBRTC_ERROR_NONE;
        unsigned int track_id;
 
-       ret = webrtc_media_source_set_video_loopback(g_conns[index].webrtc, source_id, WEBRTC_DISPLAY_TYPE_EVAS, g_eo_mine, &track_id);
+       ret = webrtc_media_source_set_video_loopback(g_ad.conns[index].webrtc, source_id, WEBRTC_DISPLAY_TYPE_EVAS, g_ad.eo_mine, &track_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_video_loopback() success, source_id[%u] track_id[%u]\n", source_id, track_id);
-       g_conns[index].render.loopback_track_id = track_id;
+       g_ad.conns[index].render.loopback_track_id = track_id;
 }
 
 static void _webrtc_media_source_unset_video_loopback(int index, unsigned int source_id)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_source_unset_video_loopback(g_conns[index].webrtc, source_id);
+       ret = webrtc_media_source_unset_video_loopback(g_ad.conns[index].webrtc, source_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       evas_object_hide(g_eo_mine);
+       evas_object_hide(g_ad.eo_mine);
 
        g_print("webrtc_media_source_unset_video_loopback() success, source_id[%u]\n", source_id);
 }
@@ -1073,31 +1067,31 @@ static void _webrtc_data_channel_send_string(const char *string, bool send_as_by
        int ret;
        int i, j;
        gchar *string_with_peer_id;
-       string_with_peer_id = g_strdup_printf("[%d] %s", g_signaling_server.local_peer_id, string);
+       string_with_peer_id = g_strdup_printf("[%d] %s", g_ad.signaling_server.local_peer_id, string);
 
        for (i = 0; i < MAX_CONNECTION_LEN; i++) {
-               if (!g_conns[i].webrtc)
+               if (!g_ad.conns[i].webrtc)
                        continue;
                for (j = 0; j < MAX_CHANNEL_LEN; j++) {
-                       if (!g_conns[i].channels[j])
+                       if (!g_ad.conns[i].channels[j])
                                continue;
-                       g_print("[%d] data_channel[%p], index[%d]: ", i, g_conns[i].channels[j], j);
+                       g_print("[%d] data_channel[%p], index[%d]: ", i, g_ad.conns[i].channels[j], j);
                        if (send_as_bytes) {
-                               ret = webrtc_data_channel_send_bytes(g_conns[i].channels[j], string_with_peer_id, strlen(string_with_peer_id));
+                               ret = webrtc_data_channel_send_bytes(g_ad.conns[i].channels[j], string_with_peer_id, strlen(string_with_peer_id));
                                if (ret != WEBRTC_ERROR_NONE)
                                        g_print("failed to webrtc_data_channel_send_bytes(), string[%s]\n", string_with_peer_id);
                                else
                                        g_print("webrtc_data_channel_send_bytes() success, string[%s]\n", string_with_peer_id);
                        } else {
-                               ret = webrtc_data_channel_send_string(g_conns[i].channels[j], string_with_peer_id);
+                               ret = webrtc_data_channel_send_string(g_ad.conns[i].channels[j], string_with_peer_id);
                                if (ret != WEBRTC_ERROR_NONE)
                                        g_print("failed to webrtc_data_channel_send_string(), string[%s]\n", string_with_peer_id);
                                else
                                        g_print("webrtc_data_channel_send_string() success, string[%s]\n", string_with_peer_id);
                        }
                }
-               if (g_conns[i].render.loopback_track_id > 0)
-                       __render_text_message(&g_text_eo_mine, 0, string_with_peer_id);
+               if (g_ad.conns[i].render.loopback_track_id > 0)
+                       __render_text_message(&g_ad.text_eo_mine, 0, string_with_peer_id);
        }
 
        g_free(string_with_peer_id);
@@ -1118,9 +1112,9 @@ static void _webrtc_data_channel_send_file(int index, const char *file_path)
        unsigned int buffered_amount;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i] == NULL)
+               if (g_ad.conns[index].channels[i] == NULL)
                        continue;
-               g_print("data_channel[%p], index[%d]: ", g_conns[index].channels[i], i);
+               g_print("data_channel[%p], index[%d]: ", g_ad.conns[index].channels[i], i);
 
                fd = open(file_path, O_RDONLY);
                if (fd == -1) {
@@ -1138,13 +1132,13 @@ static void _webrtc_data_channel_send_file(int index, const char *file_path)
                expected_size = g_strdup_printf("expected size:%llu", (unsigned long long)st.st_size);
                expected_name = g_strdup_printf("expected name:%s", basename((char *)file_path));
 
-               ret = webrtc_data_channel_send_string(g_conns[index].channels[i], expected_size);
+               ret = webrtc_data_channel_send_string(g_ad.conns[index].channels[i], expected_size);
                if (ret != WEBRTC_ERROR_NONE)
                        g_print("failed to webrtc_data_channel_send_string(), string[%s]\n", expected_size);
                else
                        g_print("webrtc_data_channel_send_string() success, string[%s]\n", expected_size);
 
-               ret = webrtc_data_channel_send_string(g_conns[index].channels[i], expected_name);
+               ret = webrtc_data_channel_send_string(g_ad.conns[index].channels[i], expected_name);
                if (ret != WEBRTC_ERROR_NONE)
                        g_print("failed to webrtc_data_channel_send_string(), string[%s]\n", expected_name);
                else
@@ -1158,11 +1152,11 @@ static void _webrtc_data_channel_send_file(int index, const char *file_path)
                        sum_size += read_size;
                        g_print("%s : [%llu / %llu]bytes is read.", file_path, sum_size, (unsigned long long)st.st_size);
 
-                       ret = webrtc_data_channel_send_bytes(g_conns[index].channels[i], buffer, (unsigned int)read_size);
+                       ret = webrtc_data_channel_send_bytes(g_ad.conns[index].channels[i], buffer, (unsigned int)read_size);
                        if (ret != WEBRTC_ERROR_NONE)
                                g_print("failed to webrtc_data_channel_send_bytes(), file_path[%s], size[%zd]\n", file_path, read_size);
 
-                       ret = webrtc_data_channel_get_buffered_amount(g_conns[index].channels[i], &buffered_amount);
+                       ret = webrtc_data_channel_get_buffered_amount(g_ad.conns[index].channels[i], &buffered_amount);
                        if (ret != WEBRTC_ERROR_NONE)
                                g_print("failed to webrtc_data_channel_get_buffered_amount()\n");
                        if (buffered_amount > 0)
@@ -1176,7 +1170,7 @@ static void _webrtc_data_channel_send_file(int index, const char *file_path)
 
 static void _webrtc_media_source_set_mute(int index, unsigned int source_id, webrtc_media_type_e media_type, bool mute)
 {
-       int ret = webrtc_media_source_set_mute(g_conns[index].webrtc, source_id, media_type, mute);
+       int ret = webrtc_media_source_set_mute(g_ad.conns[index].webrtc, source_id, media_type, mute);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_set_mute() success, source_id[%d], media_type[%s], mute[%d]\n",
@@ -1186,7 +1180,7 @@ static void _webrtc_media_source_set_mute(int index, unsigned int source_id, web
 static void _webrtc_media_source_get_mute(int index, unsigned int source_id, webrtc_media_type_e media_type)
 {
        bool muted = false;
-       int ret = webrtc_media_source_get_mute(g_conns[index].webrtc, source_id, media_type, &muted);
+       int ret = webrtc_media_source_get_mute(g_ad.conns[index].webrtc, source_id, media_type, &muted);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_source_get_mute() success, source_id[%d], media_type[%s], muted[%d]\n",
@@ -1197,7 +1191,7 @@ static void _webrtc_screen_source_set_crop(int index, unsigned int source_id, in
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_screen_source_set_crop(g_conns[index].webrtc, source_id, x, y, w, h, is_vertical, width, height);
+       ret = webrtc_screen_source_set_crop(g_ad.conns[index].webrtc, source_id, x, y, w, h, is_vertical, width, height);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_screen_source_set_crop(), source_id[%d], ret[0x%x]\n", source_id, ret);
 
@@ -1208,7 +1202,7 @@ static void _webrtc_screen_source_unset_crop(int index, unsigned int source_id)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_screen_source_unset_crop(g_conns[index].webrtc, source_id);
+       ret = webrtc_screen_source_unset_crop(g_ad.conns[index].webrtc, source_id);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_screen_source_unset_crop(), source_id[%d], ret[0x%x]\n", source_id, ret);
 }
@@ -1336,7 +1330,7 @@ static void _webrtc_set_stun_server(int index, char *uri)
        if (!uri)
                return;
 
-       ret = webrtc_set_stun_server(g_conns[index].webrtc, uri);
+       ret = webrtc_set_stun_server(g_ad.conns[index].webrtc, uri);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_stun_server() success, uri[%s]\n", uri);
@@ -1347,7 +1341,7 @@ static void _webrtc_get_stun_server(int index)
        int ret = WEBRTC_ERROR_NONE;
        char *stun_server;
 
-       ret = webrtc_get_stun_server(g_conns[index].webrtc, &stun_server);
+       ret = webrtc_get_stun_server(g_ad.conns[index].webrtc, &stun_server);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("STUN server[%s]", stun_server);
@@ -1361,7 +1355,7 @@ static void _webrtc_add_turn_server(int index, char *uri)
        if (!uri)
                return;
 
-       ret = webrtc_add_turn_server(g_conns[index].webrtc, uri);
+       ret = webrtc_add_turn_server(g_ad.conns[index].webrtc, uri);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_add_turn_server() success, uri[%s]\n", uri);
@@ -1377,7 +1371,7 @@ static void _webrtc_get_turn_servers(int index)
 {
        int ret = 0;
 
-       ret = webrtc_foreach_turn_server(g_conns[index].webrtc, foreach_turn_server, NULL);
+       ret = webrtc_foreach_turn_server(g_ad.conns[index].webrtc, foreach_turn_server, NULL);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_foreach_turn_server() success\n");
@@ -1387,7 +1381,7 @@ static void _webrtc_set_bundle_policy(int index, int policy)
 {
        int ret = 0;
 
-       ret = webrtc_set_bundle_policy(g_conns[index].webrtc, policy);
+       ret = webrtc_set_bundle_policy(g_ad.conns[index].webrtc, policy);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_bundle_policy() success\n");
@@ -1398,7 +1392,7 @@ static void _webrtc_get_bundle_policy(int index)
        int ret = 0;
        webrtc_bundle_policy_e policy;
 
-       ret = webrtc_get_bundle_policy(g_conns[index].webrtc, &policy);
+       ret = webrtc_get_bundle_policy(g_ad.conns[index].webrtc, &policy);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_get_bundle_policy() success, policy[%d]\n", policy);
@@ -1408,7 +1402,7 @@ static void _webrtc_set_ice_transport_policy(int index, int policy)
 {
        int ret = 0;
 
-       ret = webrtc_set_ice_transport_policy(g_conns[index].webrtc, policy);
+       ret = webrtc_set_ice_transport_policy(g_ad.conns[index].webrtc, policy);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_ice_transport_policy() success\n");
@@ -1419,7 +1413,7 @@ static void _webrtc_get_ice_transport_policy(int index)
        int ret = 0;
        webrtc_ice_transport_policy_e policy;
 
-       ret = webrtc_get_ice_transport_policy(g_conns[index].webrtc, &policy);
+       ret = webrtc_get_ice_transport_policy(g_ad.conns[index].webrtc, &policy);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_get_ice_transport_policy() success, policy[%d]\n", policy);
@@ -1429,7 +1423,7 @@ static void _webrtc_set_rtp_packet_drop_probability(bool sender, float probabili
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_set_rtp_packet_drop_probability(g_conns[0].webrtc, sender, probability);
+       ret = webrtc_set_rtp_packet_drop_probability(g_ad.conns[0].webrtc, sender, probability);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_rtp_packet_drop_probability() success, sender[%u] probability[%f]\n", sender, probability);
@@ -1440,7 +1434,7 @@ static void _webrtc_get_rtp_packet_drop_probability(bool sender)
        int ret = WEBRTC_ERROR_NONE;
        float probability;
 
-       ret = webrtc_get_rtp_packet_drop_probability(g_conns[0].webrtc, sender, &probability);
+       ret = webrtc_get_rtp_packet_drop_probability(g_ad.conns[0].webrtc, sender, &probability);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("_webrtc_get_rtp_packet_drop_probability() success, sender[%u] probability[%f]\n", sender, probability);
@@ -1667,10 +1661,10 @@ static void _webrtc_data_channel_set_buffered_amount_low_cb(int index, unsigned
        int i;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i] == NULL)
+               if (g_ad.conns[index].channels[i] == NULL)
                        continue;
 
-               ret = webrtc_data_channel_set_buffered_amount_low_cb(g_conns[index].channels[i], threshold, __data_channel_buffered_amount_low_cb, &g_conns[index]);
+               ret = webrtc_data_channel_set_buffered_amount_low_cb(g_ad.conns[index].channels[i], threshold, __data_channel_buffered_amount_low_cb, &g_ad.conns[index]);
                if (ret != WEBRTC_ERROR_NONE)
                        g_print("failed to webrtc_data_channel_set_buffered_amount_low_cb(), index[%d]\n", i);
                else
@@ -1685,10 +1679,10 @@ static void _webrtc_data_channel_get_buffered_amount_low_threshold(int index)
        unsigned int threshold;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i] == NULL)
+               if (g_ad.conns[index].channels[i] == NULL)
                        continue;
 
-               ret = webrtc_data_channel_get_buffered_amount_low_threshold(g_conns[index].channels[i], &threshold);
+               ret = webrtc_data_channel_get_buffered_amount_low_threshold(g_ad.conns[index].channels[i], &threshold);
                if (ret != WEBRTC_ERROR_NONE)
                        g_print("failed to webrtc_data_channel_get_buffered_amount_low_threshold(), index[%d]\n", i);
                else
@@ -1702,10 +1696,10 @@ static void _webrtc_data_channel_unset_buffered_amount_low_cb(int index)
        int i;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i] == NULL)
+               if (g_ad.conns[index].channels[i] == NULL)
                        continue;
 
-               ret = webrtc_data_channel_unset_buffered_amount_low_cb(g_conns[index].channels[i]);
+               ret = webrtc_data_channel_unset_buffered_amount_low_cb(g_ad.conns[index].channels[i]);
                if (ret != WEBRTC_ERROR_NONE)
                        g_print("failed to webrtc_data_channel_unset_buffered_amount_low_cb(), index[%d]\n", i);
                else
@@ -1720,10 +1714,10 @@ static void _webrtc_data_channel_get_buffered_amount(int index)
        unsigned int buffered_amount;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i] == NULL)
+               if (g_ad.conns[index].channels[i] == NULL)
                        continue;
 
-               ret = webrtc_data_channel_get_buffered_amount(g_conns[index].channels[i], &buffered_amount);
+               ret = webrtc_data_channel_get_buffered_amount(g_ad.conns[index].channels[i], &buffered_amount);
                if (ret != WEBRTC_ERROR_NONE)
                        g_print("failed to webrtc_data_channel_get_buffered_amount(), index[%d]\n", i);
                else
@@ -1805,7 +1799,7 @@ static void _webrtc_foreach_stats(int index, int selected)
                return;
        }
 
-       ret = webrtc_foreach_stats(g_conns[index].webrtc, type_mask, __stats_cb, NULL);
+       ret = webrtc_foreach_stats(g_ad.conns[index].webrtc, type_mask, __stats_cb, NULL);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_foreach_stats(), index[%d]\n", index);
        else
@@ -1827,7 +1821,7 @@ static void _websocket_connection_send_text_for_room(connection_s *conn, int rem
        RET_IF(!message, "message is NULL");
 
        message_for_room = g_strdup_printf ("ROOM_PEER_MSG %d %s", remote_peer_id, message);
-       soup_websocket_connection_send_text(g_signaling_server.ws_conn, message_for_room);
+       soup_websocket_connection_send_text(g_ad.signaling_server.ws_conn, message_for_room);
        g_free(message_for_room);
 }
 
@@ -1870,22 +1864,22 @@ static void __signaling_message_cb(webrtc_signaling_message_type_e type, const c
 
        if (type == SIGNALING_MESSAGE_TYPE_CONNECTED) {
                g_print("\n[from SERVER > CONNECTED %s]\n", message);
-               g_signaling_server.is_connected = true;
-               g_signaling_server.server_status = SERVER_STATUS_CONNECTED;
-               g_signaling_server.local_peer_id = atoi(message);
+               g_ad.signaling_server.is_connected = true;
+               g_ad.signaling_server.server_status = SERVER_STATUS_CONNECTED;
+               g_ad.signaling_server.local_peer_id = atoi(message);
 
        } else if (type == SIGNALING_MESSAGE_TYPE_DISCONNECTED) {
                g_print("\n[from SERVER > DISCONNECTED %s]\n", message);
-               g_signaling_server.is_connected = false;
-               g_signaling_server.server_status = SERVER_STATUS_DISCONNECTED;
+               g_ad.signaling_server.is_connected = false;
+               g_ad.signaling_server.server_status = SERVER_STATUS_DISCONNECTED;
 
        } else if (type == SIGNALING_MESSAGE_TYPE_SESSION_ESTABLISHED) {
                g_print("\n[from SERVER > SESSION_ESTABLISHED with %s]\n", message);
-               g_signaling_server.server_status = SERVER_STATUS_SESSION_ESTABLISHED;
+               g_ad.signaling_server.server_status = SERVER_STATUS_SESSION_ESTABLISHED;
 
        } else if (type == SIGNALING_MESSAGE_TYPE_SESSION_CLOSED) {
                g_print("\n[from SERVER > SESSION_CLOSED with %s]\n", message);
-               g_signaling_server.server_status = SERVER_STATUS_SESSION_CLOSED;
+               g_ad.signaling_server.server_status = SERVER_STATUS_SESSION_CLOSED;
 
        } else if (type == SIGNALING_MESSAGE_TYPE_SDP) {
                g_print("\n[from SERVER > SDP]\n%s\n", message);
@@ -1903,18 +1897,18 @@ static void _webrtc_signaling_connect(const char *ip, int port)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       if (strlen(g_signaling_server.url) > 0) {
-               g_printerr("server[%s] is already set by 'ss'\n", g_signaling_server.url);
+       if (strlen(g_ad.signaling_server.url) > 0) {
+               g_printerr("server[%s] is already set by 'ss'\n", g_ad.signaling_server.url);
                return;
        }
 
-       ret = webrtc_signaling_connect(ip, port, __signaling_message_cb, &g_conns[0], &g_signaling_server.signaling_client);
+       ret = webrtc_signaling_connect(ip, port, __signaling_message_cb, &g_ad.conns[0], &g_ad.signaling_server.signaling_client);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       if (g_signaling_server.private_ip)
-               free(g_signaling_server.private_ip);
-       g_signaling_server.private_ip = strdup(ip);
-       g_signaling_server.port = port;
+       if (g_ad.signaling_server.private_ip)
+               free(g_ad.signaling_server.private_ip);
+       g_ad.signaling_server.private_ip = strdup(ip);
+       g_ad.signaling_server.port = port;
 
        g_print("webrtc_signaling_connect() success\n");
 }
@@ -1923,7 +1917,7 @@ static void _webrtc_signaling_disconnect(void)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_signaling_disconnect(g_signaling_server.signaling_client);
+       ret = webrtc_signaling_disconnect(g_ad.signaling_server.signaling_client);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_signaling_disconnect() success\n");
@@ -1933,7 +1927,7 @@ static void _webrtc_signaling_request_session(int peer_id)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_signaling_request_session(g_signaling_server.signaling_client, peer_id);
+       ret = webrtc_signaling_request_session(g_ad.signaling_server.signaling_client, peer_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_signaling_request_session() success\n");
@@ -1944,9 +1938,9 @@ static void _webrtc_signaling_send_message(const char *message)
        int ret = WEBRTC_ERROR_NONE;
 
        RET_IF(!message, "message is NULL");
-       RET_IF(!g_signaling_server.signaling_client, "signaling_client is NULL");
+       RET_IF(!g_ad.signaling_server.signaling_client, "signaling_client is NULL");
 
-       ret = webrtc_signaling_send_message(g_signaling_server.signaling_client, message);
+       ret = webrtc_signaling_send_message(g_ad.signaling_server.signaling_client, message);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_signaling_send_message() success\n");
@@ -1960,12 +1954,12 @@ static void __ice_candidate_cb(webrtc_h webrtc, const char *candidate, void *use
        RET_IF(!conn, "conn is NULL");
 
        g_print("\n[to SERVER > ICE]\n%s\n", candidate);
-       if (g_signaling_server.ws_conn) {
+       if (g_ad.signaling_server.ws_conn) {
                if (conn->is_for_room)
                        _websocket_connection_send_text_for_room(conn, conn->remote_peer_id, candidate);
                else
-                       soup_websocket_connection_send_text(g_signaling_server.ws_conn, candidate);
-       } else if (g_signaling_server.signaling_client && g_signaling_server.is_connected) {
+                       soup_websocket_connection_send_text(g_ad.signaling_server.ws_conn, candidate);
+       } else if (g_ad.signaling_server.signaling_client && g_ad.signaling_server.is_connected) {
                _webrtc_signaling_send_message(candidate);
        }
 }
@@ -2015,25 +2009,25 @@ static void __ice_connection_state_change_cb(webrtc_h webrtc, webrtc_ice_connect
 
 static void _webrtc_set_all_negotiation_state_change_cbs(int index)
 {
-       int ret = webrtc_set_peer_connection_state_change_cb(g_conns[index].webrtc, __peer_connection_state_change_cb, &g_conns[index]);
+       int ret = webrtc_set_peer_connection_state_change_cb(g_ad.conns[index].webrtc, __peer_connection_state_change_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_peer_connection_state_change_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_peer_connection_state_change_cb() success\n");
 
-       ret = webrtc_set_signaling_state_change_cb(g_conns[index].webrtc, __signaling_state_change_cb, &g_conns[index]);
+       ret = webrtc_set_signaling_state_change_cb(g_ad.conns[index].webrtc, __signaling_state_change_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_signaling_state_change_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_signaling_state_change_cb() success\n");
 
-       ret = webrtc_set_ice_gathering_state_change_cb(g_conns[index].webrtc, __ice_gathering_state_change_cb, &g_conns[index]);
+       ret = webrtc_set_ice_gathering_state_change_cb(g_ad.conns[index].webrtc, __ice_gathering_state_change_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_ice_gathering_state_change_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_ice_gathering_state_change_cb() success\n");
 
-       ret = webrtc_set_ice_connection_state_change_cb(g_conns[index].webrtc, __ice_connection_state_change_cb, &g_conns[index]);
+       ret = webrtc_set_ice_connection_state_change_cb(g_ad.conns[index].webrtc, __ice_connection_state_change_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_ice_connection_state_change_cb(), ret[0x%x]\n", ret);
        else
@@ -2042,25 +2036,25 @@ static void _webrtc_set_all_negotiation_state_change_cbs(int index)
 
 static void _webrtc_unset_all_negotiation_state_change_cbs(int index)
 {
-       int ret = webrtc_unset_peer_connection_state_change_cb(g_conns[index].webrtc);
+       int ret = webrtc_unset_peer_connection_state_change_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_peer_connection_state_change_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_peer_connection_state_change_cb() success\n");
 
-       ret = webrtc_unset_signaling_state_change_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_signaling_state_change_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_signaling_state_change_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_signaling_state_change_cb() success\n");
 
-       ret = webrtc_unset_ice_gathering_state_change_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_ice_gathering_state_change_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_ice_gathering_state_change_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_ice_gathering_state_change_cb() success\n");
 
-       ret = webrtc_unset_ice_connection_state_change_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_ice_connection_state_change_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_ice_connection_state_change_cb(), ret[0x%x]\n", ret);
        else
@@ -2075,19 +2069,19 @@ static void _webrtc_get_all_negotiation_states(int index)
        webrtc_ice_gathering_state_e ice_gathering_state = WEBRTC_ICE_GATHERING_STATE_NEW;
        webrtc_ice_connection_state_e ice_conn_state = WEBRTC_ICE_CONNECTION_STATE_NEW;
 
-       ret = webrtc_get_peer_connection_state(g_conns[index].webrtc, &peer_conn_state);
+       ret = webrtc_get_peer_connection_state(g_ad.conns[index].webrtc, &peer_conn_state);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_get_peer_connection_state()\n");
 
-       ret = webrtc_get_signaling_state(g_conns[index].webrtc, &signaling_state);
+       ret = webrtc_get_signaling_state(g_ad.conns[index].webrtc, &signaling_state);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_get_signaling_state()\n");
 
-       ret = webrtc_get_ice_gathering_state(g_conns[index].webrtc, &ice_gathering_state);
+       ret = webrtc_get_ice_gathering_state(g_ad.conns[index].webrtc, &ice_gathering_state);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_get_ice_gathering_state()\n");
 
-       ret = webrtc_get_ice_connection_state(g_conns[index].webrtc, &ice_conn_state);
+       ret = webrtc_get_ice_connection_state(g_ad.conns[index].webrtc, &ice_conn_state);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_get_ice_connection_state()\n");
 
@@ -2122,8 +2116,8 @@ static void __track_added_cb(webrtc_h webrtc, webrtc_media_type_e type, unsigned
        if (type == WEBRTC_MEDIA_TYPE_VIDEO) {
 #ifndef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
                if (conn->render.display_type == WEBRTC_DISPLAY_TYPE_OVERLAY) {
-                       g_print("Video track is added, set display - overlay, object[%p]\n", g_win_id);
-                       webrtc_set_display(webrtc, id, WEBRTC_DISPLAY_TYPE_OVERLAY, g_win_id);
+                       g_print("Video track is added, set display - overlay, object[%p]\n", g_ad.win_id);
+                       webrtc_set_display(webrtc, id, WEBRTC_DISPLAY_TYPE_OVERLAY, g_ad.win_id);
 
                } else if (conn->render.display_type == WEBRTC_DISPLAY_TYPE_EVAS) {
                        g_print("Video track is added, set display - evas object[%p]\n", conn->render.eo);
@@ -2166,39 +2160,39 @@ static void __track_added_cb(webrtc_h webrtc, webrtc_media_type_e type, unsigned
 static void _webrtc_set_all_basic_cbs(int index)
 {
        /* COMMON */
-       int ret = webrtc_set_error_cb(g_conns[index].webrtc, __error_cb, g_conns[index].webrtc);
+       int ret = webrtc_set_error_cb(g_ad.conns[index].webrtc, __error_cb, g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_error_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_error_cb() success\n");
 
-       ret = webrtc_set_state_changed_cb(g_conns[index].webrtc, __state_changed_cb, &g_conns[index]);
+       ret = webrtc_set_state_changed_cb(g_ad.conns[index].webrtc, __state_changed_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_state_changed_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_state_changed_cb() success\n");
 
-       ret = webrtc_set_negotiation_needed_cb(g_conns[index].webrtc, __negotiation_needed_cb, g_conns[index].webrtc);
+       ret = webrtc_set_negotiation_needed_cb(g_ad.conns[index].webrtc, __negotiation_needed_cb, g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_negotiation_needed_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_negotiation_needed_cb() success\n");
 
-       ret = webrtc_set_ice_candidate_cb(g_conns[index].webrtc, __ice_candidate_cb, &g_conns[index]);
+       ret = webrtc_set_ice_candidate_cb(g_ad.conns[index].webrtc, __ice_candidate_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_ice_candidate_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_ice_candidate_cb() success\n");
 
        /* MEDIA RENDER */
-       ret = webrtc_set_track_added_cb(g_conns[index].webrtc, __track_added_cb, &g_conns[index]);
+       ret = webrtc_set_track_added_cb(g_ad.conns[index].webrtc, __track_added_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_track_added_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_set_track_added_cb() success\n");
 
        /* DATA CHANNEL */
-       ret = webrtc_set_data_channel_cb(g_conns[index].webrtc, __data_channel_cb, &g_conns[index]);
+       ret = webrtc_set_data_channel_cb(g_ad.conns[index].webrtc, __data_channel_cb, &g_ad.conns[index]);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_set_data_channel_cb(), ret[0x%x]\n", ret);
        else
@@ -2208,39 +2202,39 @@ static void _webrtc_set_all_basic_cbs(int index)
 static void _webrtc_unset_all_basic_cbs(int index)
 {
        /* COMMON */
-       int ret = webrtc_unset_error_cb(g_conns[index].webrtc);
+       int ret = webrtc_unset_error_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_error_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_error_cb() success\n");
 
-       ret = webrtc_unset_state_changed_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_state_changed_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_state_changed_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_state_changed_cb() success\n");
 
-       ret = webrtc_unset_negotiation_needed_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_negotiation_needed_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_negotiation_needed_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_negotiation_needed_cb() success\n");
 
-       ret = webrtc_unset_ice_candidate_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_ice_candidate_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_ice_candidate_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_ice_candidate_cb() success\n");
 
        /* MEDIA RENDER */
-       ret = webrtc_unset_track_added_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_track_added_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_track_added_cb(), ret[0x%x]\n", ret);
        else
                g_print("webrtc_unset_track_added_cb() success\n");
 
        /* DATA CHANNEL */
-       ret = webrtc_unset_data_channel_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_data_channel_cb(g_ad.conns[index].webrtc);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_unset_data_channel_cb(), ret[0x%x]\n", ret);
        else
@@ -2349,15 +2343,15 @@ static void _webrtc_set_encoded_audio_frame_cb(int index)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_set_encoded_audio_frame_cb(g_conns[index].webrtc, __encoded_frame_cb, &g_conns[index]);
+       ret = webrtc_set_encoded_audio_frame_cb(g_ad.conns[index].webrtc, __encoded_frame_cb, &g_ad.conns[index]);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_encoded_audio_frame_cb() success\n");
 #ifndef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
 #ifndef TIZEN_TV
-       if (!g_conns[index].encoded_audio_frame_cb_is_set) {
-               g_conns[index].encoded_audio_frame_cb_is_set = true;
-               if (!g_conns[index].render.espp)
+       if (!g_ad.conns[index].encoded_audio_frame_cb_is_set) {
+               g_ad.conns[index].encoded_audio_frame_cb_is_set = true;
+               if (!g_ad.conns[index].render.espp)
                        g_print("espp create & open\n");
 
                g_print("espp set audio stream info\n");
@@ -2370,14 +2364,14 @@ static void _webrtc_unset_encoded_audio_frame_cb(int index)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_unset_encoded_audio_frame_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_encoded_audio_frame_cb(g_ad.conns[index].webrtc);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_unset_encoded_audio_frame_cb() success\n");
 #ifndef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
 #ifndef TIZEN_TV
-       if (g_conns[index].encoded_audio_frame_cb_is_set) {
-               g_conns[index].encoded_audio_frame_cb_is_set = false;
+       if (g_ad.conns[index].encoded_audio_frame_cb_is_set) {
+               g_ad.conns[index].encoded_audio_frame_cb_is_set = false;
                g_print("espp close & destroy\n");
        }
 #endif
@@ -2388,16 +2382,16 @@ static void _webrtc_set_encoded_video_frame_cb(int index)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_set_encoded_video_frame_cb(g_conns[index].webrtc, __encoded_frame_cb, &g_conns[index]);
+       ret = webrtc_set_encoded_video_frame_cb(g_ad.conns[index].webrtc, __encoded_frame_cb, &g_ad.conns[index]);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_set_encoded_video_frame_cb() success\n");
 
 #ifndef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
 #ifndef TIZEN_TV
-       if (!g_conns[index].encoded_video_frame_cb_is_set) {
-               g_conns[index].encoded_video_frame_cb_is_set = true;
-               if (!g_conns[index].render.espp) {
+       if (!g_ad.conns[index].encoded_video_frame_cb_is_set) {
+               g_ad.conns[index].encoded_video_frame_cb_is_set = true;
+               if (!g_ad.conns[index].render.espp) {
                        g_print("espp create & open\n");
                }
                g_print("espp set video stream info\n");
@@ -2410,15 +2404,15 @@ static void _webrtc_unset_encoded_video_frame_cb(int index)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_unset_encoded_video_frame_cb(g_conns[index].webrtc);
+       ret = webrtc_unset_encoded_video_frame_cb(g_ad.conns[index].webrtc);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_unset_encoded_video_frame_cb() success\n");
 
 #ifndef __DEBUG_VALIDATE_ENCODED_FRAME_CB__
 #ifndef TIZEN_TV
-       if (g_conns[index].encoded_video_frame_cb_is_set) {
-               g_conns[index].encoded_video_frame_cb_is_set = false;
+       if (g_ad.conns[index].encoded_video_frame_cb_is_set) {
+               g_ad.conns[index].encoded_video_frame_cb_is_set = false;
                g_print("espp close & destroy\n");
        }
 #endif
@@ -2452,7 +2446,7 @@ static void _webrtc_media_packet_source_set_buffer_state_changed_cb(int index, u
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_packet_source_set_buffer_state_changed_cb(g_conns[index].webrtc, source_id, __media_packet_source_buffer_state_changed_cb, &g_conns[index]);
+       ret = webrtc_media_packet_source_set_buffer_state_changed_cb(g_ad.conns[index].webrtc, source_id, __media_packet_source_buffer_state_changed_cb, &g_ad.conns[index]);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_packet_source_set_buffer_state_changed_cb() success\n");
@@ -2462,7 +2456,7 @@ static void _webrtc_media_packet_source_unset_buffer_state_changed_cb(int index,
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_media_packet_source_unset_buffer_state_changed_cb(g_conns[index].webrtc, source_id);
+       ret = webrtc_media_packet_source_unset_buffer_state_changed_cb(g_ad.conns[index].webrtc, source_id);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_media_packet_source_unset_buffer_state_changed_cb() success\n");
@@ -2476,8 +2470,8 @@ static void _webrtc_set_all_cbs(int index)
        _webrtc_set_all_negotiation_state_change_cbs(index);
 
        for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++) {
-               if (g_conns[index].packet_sources[i].source_id > 0)
-                       _webrtc_media_packet_source_set_buffer_state_changed_cb(0, g_conns[index].packet_sources[i].source_id);
+               if (g_ad.conns[index].packet_sources[i].source_id > 0)
+                       _webrtc_media_packet_source_set_buffer_state_changed_cb(0, g_ad.conns[index].packet_sources[i].source_id);
        }
 }
 
@@ -2489,8 +2483,8 @@ static void _webrtc_unset_all_cbs(int index)
        _webrtc_unset_all_negotiation_state_change_cbs(index);
 
        for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++) {
-               if (g_conns[index].packet_sources[i].source_id > 0)
-                       _webrtc_media_packet_source_unset_buffer_state_changed_cb(0, g_conns[index].packet_sources[i].source_id);
+               if (g_ad.conns[index].packet_sources[i].source_id > 0)
+                       _webrtc_media_packet_source_unset_buffer_state_changed_cb(0, g_ad.conns[index].packet_sources[i].source_id);
        }
 }
 
@@ -2499,21 +2493,21 @@ static void _webrtc_create_data_channel(int index)
        int ret = WEBRTC_ERROR_NONE;
        gchar *label;
 
-       RET_IF(g_conns[index].channel_index == MAX_CHANNEL_LEN, "%d channels are already created, skip it", MAX_CHANNEL_LEN);
+       RET_IF(g_ad.conns[index].channel_index == MAX_CHANNEL_LEN, "%d channels are already created, skip it", MAX_CHANNEL_LEN);
 
-       label = g_strdup_printf("data_channel_%d_%d", index, g_conns[index].channel_index);
+       label = g_strdup_printf("data_channel_%d_%d", index, g_ad.conns[index].channel_index);
 
-       ret = webrtc_create_data_channel(g_conns[index].webrtc, label, NULL, &g_conns[index].channels[g_conns[index].channel_index]);
+       ret = webrtc_create_data_channel(g_ad.conns[index].webrtc, label, NULL, &g_ad.conns[index].channels[g_ad.conns[index].channel_index]);
        if (ret != WEBRTC_ERROR_NONE) {
                g_print("failed to webrtc_create_data_channel()\n");
        } else {
                g_print("webrtc_create_data_channel() success, channel[%p], index[%d]\n",
-                       g_conns[index].channels[g_conns[index].channel_index], g_conns[index].channel_index);
-               webrtc_data_channel_set_open_cb(g_conns[index].channels[g_conns[index].channel_index], __data_channel_open_cb, &g_conns[index]);
-               webrtc_data_channel_set_message_cb(g_conns[index].channels[g_conns[index].channel_index], __data_channel_message_cb, &g_conns[index]);
-               webrtc_data_channel_set_error_cb(g_conns[index].channels[g_conns[index].channel_index], __data_channel_error_cb, &g_conns[index]);
-               webrtc_data_channel_set_close_cb(g_conns[index].channels[g_conns[index].channel_index], __data_channel_close_cb, &g_conns[index]);
-               g_conns[index].channel_index++;
+                       g_ad.conns[index].channels[g_ad.conns[index].channel_index], g_ad.conns[index].channel_index);
+               webrtc_data_channel_set_open_cb(g_ad.conns[index].channels[g_ad.conns[index].channel_index], __data_channel_open_cb, &g_ad.conns[index]);
+               webrtc_data_channel_set_message_cb(g_ad.conns[index].channels[g_ad.conns[index].channel_index], __data_channel_message_cb, &g_ad.conns[index]);
+               webrtc_data_channel_set_error_cb(g_ad.conns[index].channels[g_ad.conns[index].channel_index], __data_channel_error_cb, &g_ad.conns[index]);
+               webrtc_data_channel_set_close_cb(g_ad.conns[index].channels[g_ad.conns[index].channel_index], __data_channel_close_cb, &g_ad.conns[index]);
+               g_ad.conns[index].channel_index++;
        }
 
        g_free(label);
@@ -2525,20 +2519,20 @@ static void _webrtc_destroy_data_channel(int index)
        int i;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i] == NULL)
+               if (g_ad.conns[index].channels[i] == NULL)
                        continue;
-               ret = webrtc_destroy_data_channel(g_conns[index].channels[i]);
+               ret = webrtc_destroy_data_channel(g_ad.conns[index].channels[i]);
                if (ret != WEBRTC_ERROR_NONE) {
                        g_print("failed to _webrtc_destroy_data_channel(), index[%d]\n", i);
                } else {
                        g_print("_webrtc_destroy_data_channel() success, send channel index[%d]\n", i);
-                       g_conns[index].channels[i] = NULL;
+                       g_ad.conns[index].channels[i] = NULL;
                }
        }
-       g_conns[index].channel_index = 0;
+       g_ad.conns[index].channel_index = 0;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++)
-               g_conns[index].recv_channels[i] = NULL;
+               g_ad.conns[index].recv_channels[i] = NULL;
 }
 
 static void _webrtc_data_channel_get_label(int index)
@@ -2547,10 +2541,10 @@ static void _webrtc_data_channel_get_label(int index)
        char *label = NULL;
 
        for (i = 0; i < MAX_CHANNEL_LEN; i++) {
-               if (g_conns[index].channels[i] == NULL)
+               if (g_ad.conns[index].channels[i] == NULL)
                        continue;
 
-               label = __get_channel_label(g_conns[index].channels[i]);
+               label = __get_channel_label(g_ad.conns[index].channels[i]);
                if (!label)
                        continue;
 
@@ -2568,7 +2562,7 @@ static void _setting_uri(gchar *dest_arr, char *uri)
        if (!uri)
                return;
 
-       if (g_signaling_server.signaling_client) {
+       if (g_ad.signaling_server.signaling_client) {
                g_printerr("already set by 'scc'\n");
                return;
        }
@@ -2584,14 +2578,14 @@ static void _setting_uri(gchar *dest_arr, char *uri)
 
 static void _request_session(int remote_peer_id)
 {
-       if (!g_signaling_server.ws_conn && !g_signaling_server.is_connected) {
-               g_printerr("server[%s] is not connected\n", g_signaling_server.url);
+       if (!g_ad.signaling_server.ws_conn && !g_ad.signaling_server.is_connected) {
+               g_printerr("server[%s] is not connected\n", g_ad.signaling_server.url);
                return;
        }
 
-       if (g_signaling_server.ws_conn) {
+       if (g_ad.signaling_server.ws_conn) {
                gchar *msg;
-               if (soup_websocket_connection_get_state(g_signaling_server.ws_conn) != SOUP_WEBSOCKET_STATE_OPEN) {
+               if (soup_websocket_connection_get_state(g_ad.signaling_server.ws_conn) != SOUP_WEBSOCKET_STATE_OPEN) {
                        g_printerr("websocket is not opened\n");
                        return;
                }
@@ -2599,7 +2593,7 @@ static void _request_session(int remote_peer_id)
                msg = g_strdup_printf("SESSION %d", remote_peer_id);
 
                g_print("\n[to SERVER > %s]\n", msg);
-               soup_websocket_connection_send_text(g_signaling_server.ws_conn, msg);
+               soup_websocket_connection_send_text(g_ad.signaling_server.ws_conn, msg);
                g_free(msg);
 
        } else {
@@ -2613,14 +2607,14 @@ static void _request_join_room(char *room_name)
 
        RET_IF(!room_name, "room_name is NULL");
 
-       if (!g_signaling_server.ws_conn && !g_signaling_server.is_connected) {
-               g_printerr("server[%s] is not connected\n", g_signaling_server.url);
+       if (!g_ad.signaling_server.ws_conn && !g_ad.signaling_server.is_connected) {
+               g_printerr("server[%s] is not connected\n", g_ad.signaling_server.url);
                return;
        }
 
-       RET_IF(!g_signaling_server.ws_conn, "ws_conn is NULL");
+       RET_IF(!g_ad.signaling_server.ws_conn, "ws_conn is NULL");
 
-       if (soup_websocket_connection_get_state(g_signaling_server.ws_conn) != SOUP_WEBSOCKET_STATE_OPEN) {
+       if (soup_websocket_connection_get_state(g_ad.signaling_server.ws_conn) != SOUP_WEBSOCKET_STATE_OPEN) {
                g_printerr("websocket is not opened\n");
                return;
        }
@@ -2628,7 +2622,7 @@ static void _request_join_room(char *room_name)
        msg = g_strdup_printf("ROOM %s", room_name);
 
        g_print("\n[to SERVER > %s]\n", msg);
-       soup_websocket_connection_send_text(g_signaling_server.ws_conn, msg);
+       soup_websocket_connection_send_text(g_ad.signaling_server.ws_conn, msg);
        g_free(msg);
 }
 
@@ -2636,17 +2630,17 @@ static void _send_local_description(bool is_offer)
 {
        char *desc;
 
-       if (!g_signaling_server.ws_conn && !g_signaling_server.is_connected) {
-               g_printerr("server[%s] is not connected\n", g_signaling_server.url);
+       if (!g_ad.signaling_server.ws_conn && !g_ad.signaling_server.is_connected) {
+               g_printerr("server[%s] is not connected\n", g_ad.signaling_server.url);
                return;
        }
 
-       desc = is_offer ? g_conns[0].offer : g_conns[0].answer;
+       desc = is_offer ? g_ad.conns[0].offer : g_ad.conns[0].answer;
 
        g_print("\n[to SERVER > local description]\n%s\n", desc);
 
-       if (g_signaling_server.ws_conn)
-               soup_websocket_connection_send_text(g_signaling_server.ws_conn, desc);
+       if (g_ad.signaling_server.ws_conn)
+               soup_websocket_connection_send_text(g_ad.signaling_server.ws_conn, desc);
        else
                _webrtc_signaling_send_message(desc);
 }
@@ -3644,21 +3638,21 @@ static void _start_pushing_packet(int index, int source_id)
        int i = _find_packet_sources_index(index, source_id);
        RET_IF(i == -1, "could not find media packet source id[%u]", source_id);
 
-       RET_IF(!g_conns[index].packet_sources[i].format, "please call webrtc_media_packet_source_set_format() first, press 'f'");
+       RET_IF(!g_ad.conns[index].packet_sources[i].format, "please call webrtc_media_packet_source_set_format() first, press 'f'");
 
-       if (!g_conns[index].packet_sources[i].src_pipeline) {
-               g_conns[index].packet_sources[i].src_pipeline = __make_src_pipeline(&g_conns[index].packet_sources[i]);
-               RET_IF(!g_conns[index].packet_sources[i].src_pipeline, "src_pipeline is NULL");
+       if (!g_ad.conns[index].packet_sources[i].src_pipeline) {
+               g_ad.conns[index].packet_sources[i].src_pipeline = __make_src_pipeline(&g_ad.conns[index].packet_sources[i]);
+               RET_IF(!g_ad.conns[index].packet_sources[i].src_pipeline, "src_pipeline is NULL");
        }
 
-       state_change_ret = gst_element_set_state(g_conns[index].packet_sources[i].src_pipeline, GST_STATE_PLAYING);
+       state_change_ret = gst_element_set_state(g_ad.conns[index].packet_sources[i].src_pipeline, GST_STATE_PLAYING);
 #ifdef __DEBUG_VALIDATE_MEDIA_PACKET_SOURCE__
-       if (g_conns[index].packet_sources[i].render_pipeline)
-               state_change_ret = gst_element_set_state(g_conns[index].packet_sources[i].render_pipeline, GST_STATE_PLAYING);
+       if (g_ad.conns[index].packet_sources[i].render_pipeline)
+               state_change_ret = gst_element_set_state(g_ad.conns[index].packet_sources[i].render_pipeline, GST_STATE_PLAYING);
 #endif
        RET_IF(state_change_ret == GST_STATE_CHANGE_FAILURE, "failed to set state to PLAYING");
 
-       g_conns[index].packet_sources[i].is_stop_requested = false;
+       g_ad.conns[index].packet_sources[i].is_stop_requested = false;
 
        g_print("_start_pushing_packet()\n");
 }
@@ -3668,17 +3662,17 @@ static void _stop_pushing_packet(int index, int source_id)
        int i = _find_packet_sources_index(index, source_id);
        RET_IF(i == -1, "could not find media packet source id[%u]", source_id);
 
-       RET_IF(!g_conns[index].packet_sources[i].src_pipeline, "already stopped for pushing packet");
+       RET_IF(!g_ad.conns[index].packet_sources[i].src_pipeline, "already stopped for pushing packet");
 
-       if (g_conns[index].packet_sources[i].is_overflowed)
-               g_cond_signal(&g_conns[index].packet_sources[i].cond);
+       if (g_ad.conns[index].packet_sources[i].is_overflowed)
+               g_cond_signal(&g_ad.conns[index].packet_sources[i].cond);
 
-       g_conns[index].packet_sources[i].is_stop_requested = true;
+       g_ad.conns[index].packet_sources[i].is_stop_requested = true;
 
-       gst_element_set_state(g_conns[index].packet_sources[i].src_pipeline, GST_STATE_PAUSED);
+       gst_element_set_state(g_ad.conns[index].packet_sources[i].src_pipeline, GST_STATE_PAUSED);
 #ifdef __DEBUG_VALIDATE_MEDIA_PACKET_SOURCE__
-       if (g_conns[index].packet_sources[i].render_pipeline)
-               gst_element_set_state(g_conns[index].packet_sources[i].render_pipeline, GST_STATE_PAUSED);
+       if (g_ad.conns[index].packet_sources[i].render_pipeline)
+               gst_element_set_state(g_ad.conns[index].packet_sources[i].render_pipeline, GST_STATE_PAUSED);
 #endif
 
        g_print("_stop_pushing_packet()\n");
@@ -3688,7 +3682,7 @@ static void _set_media_path(int index, unsigned int source_id, const char *path)
 {
        int ret = 0;
 
-       ret = webrtc_file_source_set_path(g_conns[index].webrtc, source_id, path);
+       ret = webrtc_file_source_set_path(g_ad.conns[index].webrtc, source_id, path);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_file_source_set_path(), source_id[%d], ret[0x%x]\n", source_id, ret);
        else
@@ -3699,7 +3693,7 @@ static void _webrtc_file_source_set_looping(int index, unsigned int source_id, b
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_file_source_set_looping(g_conns[index].webrtc, source_id, looping);
+       ret = webrtc_file_source_set_looping(g_ad.conns[index].webrtc, source_id, looping);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_file_source_set_looping() success, source_id[%u] looping_state[%u]\n", source_id, looping);
@@ -3710,7 +3704,7 @@ static void _webrtc_file_source_get_looping(int index, unsigned int source_id)
        int ret = WEBRTC_ERROR_NONE;
        bool looping_state;
 
-       ret = webrtc_file_source_get_looping(g_conns[index].webrtc, source_id, &looping_state);
+       ret = webrtc_file_source_get_looping(g_ad.conns[index].webrtc, source_id, &looping_state);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_file_source_get_looping() success, source_id[%u] looping_state[%u]\n", source_id, looping_state);
@@ -3756,21 +3750,21 @@ static void __auto_configure_add_peer(gchar *peer_id, bool is_offer)
        for (i = 0; i < MAX_CONNECTION_LEN; i++) {
                unsigned int source_id = 0;
 
-               if (g_conns[i].webrtc)
+               if (g_ad.conns[i].webrtc)
                        continue;
 
-               g_conns[i].remote_peer_id = atoi((const char *)peer_id);
-               g_conns[i].is_for_room = true;
-               g_conns[i].is_offer = is_offer;
+               g_ad.conns[i].remote_peer_id = atoi((const char *)peer_id);
+               g_ad.conns[i].is_for_room = true;
+               g_ad.conns[i].is_offer = is_offer;
                if (i > 0) /* follow the source type of the first one */
-                       g_conns[i].room_source_type = g_conns[0].room_source_type;
+                       g_ad.conns[i].room_source_type = g_ad.conns[0].room_source_type;
 
                _webrtc_create(i);
                _webrtc_set_all_basic_cbs(i);
                _webrtc_set_all_negotiation_state_change_cbs(i);
                _webrtc_create_data_channel(i);
 
-               switch (g_conns[i].room_source_type) {
+               switch (g_ad.conns[i].room_source_type) {
                case 1:
                        _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_AUDIOTEST, NULL);
                        _webrtc_add_media_source(i, WEBRTC_MEDIA_SOURCE_TYPE_VIDEOTEST, &source_id);
@@ -3808,12 +3802,12 @@ static connection_s *__get_conn_from_peer_id(gchar *peer_id, int *index)
        }
 
        for (i = 0; i < MAX_CONNECTION_LEN; i++) {
-               if (g_conns[i].remote_peer_id <= 0)
+               if (g_ad.conns[i].remote_peer_id <= 0)
                        continue;
-               if (g_conns[i].remote_peer_id == atoi((const char *)peer_id)) {
+               if (g_ad.conns[i].remote_peer_id == atoi((const char *)peer_id)) {
                        if (index)
                                *index = i;
-                       return &g_conns[i];
+                       return &g_ad.conns[i];
                }
        }
 
@@ -3921,7 +3915,7 @@ static void __handle_room_related_message(const gchar *text)
 
        if (g_str_has_prefix(text, "ROOM_OK")) {
                g_print("\n[from SERVER > %s]\n", text);
-               g_signaling_server.server_status = SERVER_STATUS_ROOM_ESTABLISHED;
+               g_ad.signaling_server.server_status = SERVER_STATUS_ROOM_ESTABLISHED;
 
                /* parse text, get the previous peers in the room and negotiate to each other */
                if (strlen(text) > strlen("ROOM_OK")) {
@@ -3957,7 +3951,7 @@ static void __handle_room_related_message(const gchar *text)
 
        } else {
                g_print("\n[from SERVER > %s]\n", text);
-               g_signaling_server.server_status = SERVER_STATUS_ERROR_FOUND;
+               g_ad.signaling_server.server_status = SERVER_STATUS_ERROR_FOUND;
        }
 }
 
@@ -3970,7 +3964,7 @@ static void __websocket_message_cb(SoupWebsocketConnection *ws_conn, SoupWebsock
 
        RET_IF(!conn, "conn is NULL");
        RET_IF(!ws_conn, "ws_conn is NULL");
-       RET_IF(g_signaling_server.ws_conn != ws_conn, "not matched ws_conn[%p, %p]", g_signaling_server.ws_conn, ws_conn);
+       RET_IF(g_ad.signaling_server.ws_conn != ws_conn, "not matched ws_conn[%p, %p]", g_ad.signaling_server.ws_conn, ws_conn);
        RET_IF(type != SOUP_WEBSOCKET_DATA_TEXT, "invalid data type(%d)", type);
 
        data = g_bytes_get_data(message, &size);
@@ -3978,18 +3972,18 @@ static void __websocket_message_cb(SoupWebsocketConnection *ws_conn, SoupWebsock
 
        /* NOTE: Logics below can be different in each server */
        if (g_strcmp0(text, "HELLO") == 0) {
-               g_print("\n[from SERVER > %s] registered done, local_peer_id[%d]\n", text, g_signaling_server.local_peer_id);
+               g_print("\n[from SERVER > %s] registered done, local_peer_id[%d]\n", text, g_ad.signaling_server.local_peer_id);
 
        } else if (g_strcmp0(text, "SESSION_OK") == 0) {
                g_print("\n[from SERVER > %s]\n", text);
-               g_signaling_server.server_status = SERVER_STATUS_SESSION_ESTABLISHED;
+               g_ad.signaling_server.server_status = SERVER_STATUS_SESSION_ESTABLISHED;
 
        } else if (g_str_has_prefix(text, "ROOM_")) {
                __handle_room_related_message(text);
 
        } else if (g_str_has_prefix(text, "ERROR")) {
                g_print("\n[from SERVER > %s]\n", text);
-               g_signaling_server.server_status = SERVER_STATUS_ERROR_FOUND;
+               g_ad.signaling_server.server_status = SERVER_STATUS_ERROR_FOUND;
 
        } else {
                __handle_json_structured_message(conn, text);
@@ -4043,15 +4037,15 @@ static void __websocket_connected_cb(SoupSession *session, GAsyncResult *res, vo
                g_error_free(error);
                return;
        }
-       g_print("\n[%s] is connected, conn[%p]\n", g_signaling_server.url, conn);
+       g_print("\n[%s] is connected, conn[%p]\n", g_ad.signaling_server.url, conn);
 
-       g_signaling_server.ws_conn = ws_conn;
-       g_signaling_server.server_status = SERVER_STATUS_CONNECTED;
+       g_ad.signaling_server.ws_conn = ws_conn;
+       g_ad.signaling_server.server_status = SERVER_STATUS_CONNECTED;
 
-       g_signal_connect(ws_conn, "closed", G_CALLBACK(__websocket_closed_cb), &g_signaling_server);
+       g_signal_connect(ws_conn, "closed", G_CALLBACK(__websocket_closed_cb), &g_ad.signaling_server);
        g_signal_connect(ws_conn, "message", G_CALLBACK(__websocket_message_cb), conn);
 
-       g_signaling_server.local_peer_id = __send_greeting_to_register(ws_conn);
+       g_ad.signaling_server.local_peer_id = __send_greeting_to_register(ws_conn);
 }
 
 static void _connect_signaling_server(void)
@@ -4061,14 +4055,14 @@ static void _connect_signaling_server(void)
        SoupURI *proxy_uri;
        const char *https_aliases[] = {"wss", NULL};
 
-       RET_IF(g_signaling_server.signaling_client, "already set by 'scc'");
+       RET_IF(g_ad.signaling_server.signaling_client, "already set by 'scc'");
 
-       if (strlen(g_proxy) == 0) {
+       if (strlen(g_ad.proxy) == 0) {
                session = soup_session_new_with_options(SOUP_SESSION_SSL_STRICT, TRUE,
                        SOUP_SESSION_HTTPS_ALIASES, https_aliases, NULL);
        } else {
-               g_print("use proxy [%s]\n", g_proxy);
-               proxy_uri = soup_uri_new(g_proxy);
+               g_print("use proxy [%s]\n", g_ad.proxy);
+               proxy_uri = soup_uri_new(g_ad.proxy);
                session = soup_session_new_with_options(SOUP_SESSION_SSL_STRICT, TRUE,
                        SOUP_SESSION_SSL_USE_SYSTEM_CA_FILE, TRUE,
                        SOUP_SESSION_PROXY_URI, proxy_uri,
@@ -4077,29 +4071,29 @@ static void _connect_signaling_server(void)
                        soup_uri_free(proxy_uri);
        }
 
-       message = soup_message_new(SOUP_METHOD_GET, g_signaling_server.url);
+       message = soup_message_new(SOUP_METHOD_GET, g_ad.signaling_server.url);
 
-       g_print("connecting to signaling server[%s]...\n", g_signaling_server.url);
+       g_print("connecting to signaling server[%s]...\n", g_ad.signaling_server.url);
 
        soup_session_websocket_connect_async(session, message, NULL, NULL, NULL,
-               (GAsyncReadyCallback) __websocket_connected_cb, &g_conns[0]);
+               (GAsyncReadyCallback) __websocket_connected_cb, &g_ad.conns[0]);
 }
 
 static void _webrtc_signaling_server_create(int port)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_signaling_server_create(port, &g_inner_signaling_server);
+       ret = webrtc_signaling_server_create(port, &(g_ad.inner_signaling_server));
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       g_print("webrtc_signaling_server_create() success, port[%d] g_inner_signaling_server[%p]\n", port, g_inner_signaling_server);
+       g_print("webrtc_signaling_server_create() success, port[%d] g_inner_signaling_server[%p]\n", port, g_ad.inner_signaling_server);
 }
 
 static void _webrtc_signaling_server_destroy(void)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_signaling_server_destroy(g_inner_signaling_server);
+       ret = webrtc_signaling_server_destroy(g_ad.inner_signaling_server);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_signaling_server_destroy() success\n");
@@ -4109,7 +4103,7 @@ static void _webrtc_signaling_server_start(void)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_signaling_server_start(g_inner_signaling_server);
+       ret = webrtc_signaling_server_start(g_ad.inner_signaling_server);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_signaling_server_start() success\n");
@@ -4119,7 +4113,7 @@ static void _webrtc_signaling_server_stop(void)
 {
        int ret = WEBRTC_ERROR_NONE;
 
-       ret = webrtc_signaling_server_stop(g_inner_signaling_server);
+       ret = webrtc_signaling_server_stop(g_ad.inner_signaling_server);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
        g_print("webrtc_signaling_server_stop() success\n");
@@ -4129,14 +4123,14 @@ void quit_program(void)
 {
        int i;
        for (i = 0; i < MAX_CONNECTION_LEN; i++) {
-               if (g_conns[i].webrtc != NULL) {
+               if (g_ad.conns[i].webrtc != NULL) {
                        _webrtc_stop(i);
                        _webrtc_destroy(i);
                }
        }
 
        g_print("quit program\n");
-       g_menu_status = CURRENT_STATUS_TERMINATE;
+       g_ad.menu_status = CURRENT_STATUS_TERMINATE;
 
        elm_exit();
 }
@@ -4157,7 +4151,7 @@ static bool interpret_main_menu_cmd(char *cmd)
                menu_info_s *menu_info = g_hash_table_lookup(g_ad.menu_items, cmd);
                if (!menu_info)
                        break;
-               g_menu_status = menu_info->status;
+               g_ad.menu_status = menu_info->status;
                return menu_info->key_input_needed;
        }
        default:
@@ -4178,7 +4172,7 @@ static void test_webrtc_common(char *cmd)
 {
        int value;
 
-       switch (g_menu_status) {
+       switch (g_ad.menu_status) {
        case CURRENT_STATUS_CREATE:
                _webrtc_create(0);
                reset_menu_state();
@@ -4244,22 +4238,22 @@ static void test_webrtc_common(char *cmd)
        }
        case CURRENT_STATUS_CREATE_OFFER:
        case CURRENT_STATUS_CREATE_OFFER_ASYNC: {
-               _webrtc_create_offer(&g_conns[0], g_menu_status == CURRENT_STATUS_CREATE_OFFER ? false : true);
+               _webrtc_create_offer(&g_ad.conns[0], g_ad.menu_status == CURRENT_STATUS_CREATE_OFFER ? false : true);
                reset_menu_state();
                break;
        }
        case CURRENT_STATUS_CREATE_ANSWER:
        case CURRENT_STATUS_CREATE_ANSWER_ASYNC: {
-               _webrtc_create_answer(&g_conns[0], g_menu_status == CURRENT_STATUS_CREATE_ANSWER ? false: true);
+               _webrtc_create_answer(&g_ad.conns[0], g_ad.menu_status == CURRENT_STATUS_CREATE_ANSWER ? false: true);
                reset_menu_state();
                break;
        }
        case CURRENT_STATUS_SET_LOCAL_DESCRIPTION: {
                value = atoi(cmd);
                if (value == 1)
-                       _webrtc_set_local_description(&g_conns[0], true);
+                       _webrtc_set_local_description(&g_ad.conns[0], true);
                else if (value == 2)
-                       _webrtc_set_local_description(&g_conns[0], false);
+                       _webrtc_set_local_description(&g_ad.conns[0], false);
                else
                        g_print("invalid value[%d]\n", value);
 
@@ -4267,12 +4261,12 @@ static void test_webrtc_common(char *cmd)
                break;
        }
        case CURRENT_STATUS_SET_REMOTE_DESCRIPTION: {
-               _webrtc_set_remote_description(&g_conns[0]);
+               _webrtc_set_remote_description(&g_ad.conns[0]);
                reset_menu_state();
                break;
        }
        case CURRENT_STATUS_ADD_ICE_CANDIDATE: {
-               _webrtc_add_ice_candidate(&g_conns[0], NULL);
+               _webrtc_add_ice_candidate(&g_ad.conns[0], NULL);
                reset_menu_state();
                break;
        }
@@ -4293,7 +4287,7 @@ static void test_webrtc_common(char *cmd)
        }
        case CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY: {
                static bool sender;
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        value = atoi(cmd);
                        if (value != 1 && value != 2) {
@@ -4302,13 +4296,13 @@ static void test_webrtc_common(char *cmd)
                                break;
                        }
                        sender = (value == 1);
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1: {
                        float fvalue = strtof(cmd, NULL);
                        _webrtc_set_rtp_packet_drop_probability(sender, fvalue);
                        sender = false;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4333,14 +4327,14 @@ static void test_webrtc_media_source(char *cmd)
 {
        int value;
 
-       switch (g_menu_status) {
+       switch (g_ad.menu_status) {
        case CURRENT_STATUS_ADD_MEDIA_SOURCE: {
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        if (value == 3) { /* mic source */
-                               g_cnt++;
+                               g_ad.input_count++;
                        } else {
                                _webrtc_add_media_source(0, value - 1, NULL);
                                reset_menu_state();
@@ -4348,7 +4342,7 @@ static void test_webrtc_media_source(char *cmd)
                        break;
                case 1:
                        _webrtc_add_mic_source(0, !(value == 0), NULL);
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4367,23 +4361,23 @@ static void test_webrtc_media_source(char *cmd)
                int new_state;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        media_type = value - 1;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 2:
                        new_state = value;
-                       if (g_menu_status == CURRENT_STATUS_MEDIA_SOURCE_SET_PAUSE)
+                       if (g_ad.menu_status == CURRENT_STATUS_MEDIA_SOURCE_SET_PAUSE)
                                _webrtc_media_source_set_pause(0, id, media_type, new_state);
                        else
                                _webrtc_media_source_set_mute(0, id, media_type, new_state);
                        id = media_type = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4394,18 +4388,18 @@ static void test_webrtc_media_source(char *cmd)
                static unsigned int id;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
-                       if (g_menu_status == CURRENT_STATUS_MEDIA_SOURCE_GET_PAUSE)
+                       if (g_ad.menu_status == CURRENT_STATUS_MEDIA_SOURCE_GET_PAUSE)
                                _webrtc_media_source_get_pause(0, id, value - 1);
                        else
                                _webrtc_media_source_get_mute(0, id, value - 1);
                        id = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4417,20 +4411,20 @@ static void test_webrtc_media_source(char *cmd)
                static int height;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        width = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 2:
                        height =  value;
                        _webrtc_media_source_set_video_resolution(0, id, width, height);
                        id = width = height = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4447,16 +4441,16 @@ static void test_webrtc_media_source(char *cmd)
                static int framerate;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        framerate = value;
                        _webrtc_media_source_set_video_framerate(0, id, framerate);
                        id = framerate = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4472,15 +4466,15 @@ static void test_webrtc_media_source(char *cmd)
                static unsigned int id;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        _set_media_path(0, id, cmd);
                        id = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4489,15 +4483,15 @@ static void test_webrtc_media_source(char *cmd)
        case CURRENT_STATUS_FILE_SOURCE_SET_LOOPING: {
                static unsigned int id;
                value = atoi(cmd);
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        _webrtc_file_source_set_looping(0, id, value);
                        id = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4525,15 +4519,15 @@ static void test_webrtc_media_source(char *cmd)
                static unsigned int id;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        _webrtc_media_packet_source_set_format(0, id, value);
                        id = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4545,20 +4539,20 @@ static void test_webrtc_media_source(char *cmd)
                static unsigned int direction;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        media_type = value - 1;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 2:
                        direction =  value - 1;
                        _webrtc_media_source_set_transceiver_direction(0, id, media_type, direction);
                        id = media_type = direction = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4569,16 +4563,16 @@ static void test_webrtc_media_source(char *cmd)
                static unsigned int media_type;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        media_type = value - 1;
                        _webrtc_media_source_get_transceiver_direction(0, id, media_type);
                        id = media_type = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4602,33 +4596,33 @@ static void test_webrtc_media_source(char *cmd)
                static int is_vertical;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        x = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 2:
                        y = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 3:
                        w = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 4:
                        h = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 5:
                        is_vertical = value;
                        int width, height;
                        _webrtc_screen_source_set_crop(0, id, x, y, w, h, is_vertical, &width, &height);
                        x = y = w = h = is_vertical = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4647,7 +4641,7 @@ static void test_webrtc_media_render(char *cmd)
 {
        int value;
 
-       switch (g_menu_status) {
+       switch (g_ad.menu_status) {
        case CURRENT_STATUS_SET_DISPLAY_TYPE: {
                value = atoi(cmd);
                _webrtc_set_display_type(0, value - 1);
@@ -4658,15 +4652,15 @@ static void test_webrtc_media_render(char *cmd)
                static unsigned int id;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        _webrtc_set_display_mode(0, id, value - 1);
                        id = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4682,15 +4676,15 @@ static void test_webrtc_media_render(char *cmd)
                static unsigned int id;
                value = atoi(cmd);
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        id = value;
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        _webrtc_set_display_visible(0, id, value);
                        id = 0;
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4751,7 +4745,7 @@ static void test_webrtc_media_render(char *cmd)
 
 static void test_webrtc_data_channel(char *cmd)
 {
-       switch (g_menu_status) {
+       switch (g_ad.menu_status) {
        case CURRENT_STATUS_DATA_CHANNEL_CREATE: {
                _webrtc_create_data_channel(0);
                reset_menu_state();
@@ -4807,7 +4801,7 @@ static void test_webrtc_data_channel(char *cmd)
 
 static void test_webrtc_stats(char *cmd)
 {
-       switch (g_menu_status) {
+       switch (g_ad.menu_status) {
        case CURRENT_STATUS_FOREACH_STATS: {
                _webrtc_foreach_stats(0, atoi(cmd));
                reset_menu_state();
@@ -4820,14 +4814,14 @@ static void app_setting_and_signaling(char *cmd)
 {
        int value;
 
-       switch (g_menu_status) {
+       switch (g_ad.menu_status) {
        case CURRENT_STATUS_SETTING_SIGNALING_SERVER: {
-               _setting_uri(g_signaling_server.url, cmd);
+               _setting_uri(g_ad.signaling_server.url, cmd);
                reset_menu_state();
                break;
        }
        case CURRENT_STATUS_SETTING_PROXY: {
-               _setting_uri(g_proxy, cmd);
+               _setting_uri(g_ad.proxy, cmd);
                reset_menu_state();
                break;
        }
@@ -4843,7 +4837,7 @@ static void app_setting_and_signaling(char *cmd)
                break;
        }
        case CURRENT_STATUS_REQUEST_JOIN_ROOM: {
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        value = atoi(cmd);
                        if (value <= 0 || value > 3) {
@@ -4851,12 +4845,12 @@ static void app_setting_and_signaling(char *cmd)
                                reset_menu_state();
                                break;
                        }
-                       g_conns[0].room_source_type = value;
-                       g_cnt++;
+                       g_ad.conns[0].room_source_type = value;
+                       g_ad.input_count++;
                        break;
                case 1:
                        _request_join_room(cmd);
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        reset_menu_state();
                        break;
                }
@@ -4898,21 +4892,21 @@ static void app_setting_and_signaling(char *cmd)
        case CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_CONNECT: {
                static char *ip = NULL;
 
-               if (strlen(g_signaling_server.url) > 0) {
-                       g_printerr("server[%s] is already set by 'ss'\n", g_signaling_server.url);
+               if (strlen(g_ad.signaling_server.url) > 0) {
+                       g_printerr("server[%s] is already set by 'ss'\n", g_ad.signaling_server.url);
                        reset_menu_state();
                        break;
                }
 
-               switch (g_cnt) {
+               switch (g_ad.input_count) {
                case 0:
                        ip = strdup(cmd);
-                       g_cnt++;
+                       g_ad.input_count++;
                        break;
                case 1:
                        value = atoi(cmd);
                        _webrtc_signaling_connect(ip, value);
-                       g_cnt = 0;
+                       g_ad.input_count = 0;
                        if (ip) {
                                free(ip);
                                ip = NULL;
@@ -4935,34 +4929,34 @@ static void interpret(char *cmd)
        if (!cmd)
                return;
 
-       if (g_menu_status == CURRENT_STATUS_MAINMENU) {
+       if (g_ad.menu_status == CURRENT_STATUS_MAINMENU) {
                if (interpret_main_menu_cmd(cmd))
                        goto out;
        }
 
-       if (g_menu_status & TEST_MENU_WEBRTC_COMMON)
+       if (g_ad.menu_status & TEST_MENU_WEBRTC_COMMON)
                test_webrtc_common(cmd);
 
-       else if (g_menu_status & TEST_MENU_WEBRTC_MEDIA_SOURCE)
+       else if (g_ad.menu_status & TEST_MENU_WEBRTC_MEDIA_SOURCE)
                test_webrtc_media_source(cmd);
 
-       else if (g_menu_status & TEST_MENU_WEBRTC_MEDIA_RENDER)
+       else if (g_ad.menu_status & TEST_MENU_WEBRTC_MEDIA_RENDER)
                test_webrtc_media_render(cmd);
 
-       else if (g_menu_status & TEST_MENU_WEBRTC_DATA_CHANNEL)
+       else if (g_ad.menu_status & TEST_MENU_WEBRTC_DATA_CHANNEL)
                test_webrtc_data_channel(cmd);
 
-       else if (g_menu_status & TEST_MENU_WEBRTC_STATS)
+       else if (g_ad.menu_status & TEST_MENU_WEBRTC_STATS)
                test_webrtc_stats(cmd);
 
-       else if (g_menu_status & TEST_MENU_APP_SIGNALING)
+       else if (g_ad.menu_status & TEST_MENU_APP_SIGNALING)
                app_setting_and_signaling(cmd);
 
-       else if (g_menu_status == CURRENT_STATUS_QUIT)
+       else if (g_ad.menu_status == CURRENT_STATUS_QUIT)
                quit_program();
 
 out:
-       if (g_menu_status != CURRENT_STATUS_TERMINATE)
+       if (g_ad.menu_status != CURRENT_STATUS_TERMINATE)
                g_timeout_add(100, timeout_menu_display_cb, 0);
 }
 
index cb60ab58b1380602aa81763ccc8afa879ae73a4c..e346a82dc694fbc48a88db1368baa36e5ff4e121 100644 (file)
@@ -118,19 +118,19 @@ void display_handle_status(int index)
        webrtc_state_e state;
        char *stun_server = NULL;
 
-       if (g_conns[index].webrtc == NULL)
+       if (get_appdata()->conns[index].webrtc == NULL)
                return;
 
-       ret = webrtc_get_state(g_conns[index].webrtc, &state);
+       ret = webrtc_get_state(get_appdata()->conns[index].webrtc, &state);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       ret = webrtc_get_stun_server(g_conns[index].webrtc, &stun_server);
+       ret = webrtc_get_stun_server(get_appdata()->conns[index].webrtc, &stun_server);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       ret = webrtc_foreach_turn_server(g_conns[index].webrtc, foreach_turn_server, NULL);
+       ret = webrtc_foreach_turn_server(get_appdata()->conns[index].webrtc, foreach_turn_server, NULL);
        RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret);
 
-       g_print("  webrtc[%p]", g_conns[index].webrtc);
+       g_print("  webrtc[%p]", get_appdata()->conns[index].webrtc);
        g_print("  state[%s]", g_webrtc_state_str[state]);
        if (stun_server) {
                g_print("  STUN server[%s]", stun_server);
@@ -142,22 +142,22 @@ void display_handle_status(int index)
 
 void display_setting_status(void)
 {
-       int len_proxy = strlen(g_proxy);
-       int len_server = strlen(g_signaling_server.url);
+       int len_proxy = strlen(get_appdata()->proxy);
+       int len_server = strlen(get_appdata()->signaling_server.url);
        int i;
 
        if (len_proxy > 0)
-               g_print("  proxy[%s]", g_proxy);
+               g_print("  proxy[%s]\n", get_appdata()->proxy);
        if (len_server > 0)
-               g_print("  server[%s][%s]\n", g_signaling_server.url, g_server_status_str[g_signaling_server.server_status]);
-       if (g_signaling_server.private_ip && g_signaling_server.port > 0)
-               g_print("  server[%s:%d][%s]\n", g_signaling_server.private_ip, g_signaling_server.port, g_server_status_str[g_signaling_server.server_status]);
-       if (g_signaling_server.local_peer_id > 0)
-               g_print("  local peer id : %d\n", g_signaling_server.local_peer_id);
+               g_print("  server[%s][%s]\n", get_appdata()->signaling_server.url, g_server_status_str[get_appdata()->signaling_server.server_status]);
+       if (get_appdata()->signaling_server.private_ip && get_appdata()->signaling_server.port > 0)
+               g_print("  server[%s:%d][%s]\n", get_appdata()->signaling_server.private_ip, get_appdata()->signaling_server.port, g_server_status_str[get_appdata()->signaling_server.server_status]);
+       if (get_appdata()->signaling_server.local_peer_id > 0)
+               g_print("  local peer id : %d\n", get_appdata()->signaling_server.local_peer_id);
        for (i = 0; i < MAX_CONNECTION_LEN; i++) {
-               if (g_conns[i].remote_peer_id == 0)
+               if (get_appdata()->conns[i].remote_peer_id == 0)
                        continue;
-               g_print("  [%d] remote peer id : %d\n", i, g_conns[i].remote_peer_id);
+               g_print("  [%d] remote peer id : %d\n", i, get_appdata()->conns[i].remote_peer_id);
        }
        g_print("-----------------------------------------------------------------------------------------\n");
 }
@@ -263,7 +263,7 @@ void display_menu_main(void)
 
 void display_menu_webrtc_common(void)
 {
-       switch (g_menu_status) {
+       switch (get_appdata()->menu_status) {
        case CURRENT_STATUS_SET_STUN_SERVER:
                g_print("*** input STUN server address.\n");
                break;
@@ -280,13 +280,13 @@ void display_menu_webrtc_common(void)
                g_print("*** input type of local description.(1:offer, 2:answer)\n");
                break;
        case CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input side.(1:sender, 2:receiver)\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input drop probability.(0 ~ 1.0)\n");
                break;
        case CURRENT_STATUS_GET_RTP_PACKET_DROP_PROBABILITY:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input side.(1:sender, 2:receiver)\n");
                break;
        }
@@ -295,92 +295,92 @@ void display_menu_webrtc_common(void)
 
 void display_menu_webrtc_media_source(void)
 {
-       switch (g_menu_status) {
+       switch (get_appdata()->menu_status) {
        case CURRENT_STATUS_ADD_MEDIA_SOURCE:
-        if (g_cnt == 0)
+        if (get_appdata()->input_count == 0)
                    g_print("*** input media source type.(1:audiotest, 2:videotest, 3:mic, 4:camera, 5:screen, 6:file, 7:media packet, 8:custom audio, 9:custom video)\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input value to enable AEC. (1:enable 0:disable)\n");
                break;
        case CURRENT_STATUS_REMOVE_MEDIA_SOURCE:
                g_print("*** input media source id to remove.\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_SET_PAUSE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media type.(1:audio 2:video)\n");
-               else if (g_cnt == 2)
+               else if (get_appdata()->input_count == 2)
                        g_print("*** input pause or play.(1:pause, 0:play)\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_GET_PAUSE :
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media type.(1:audio 2:video)\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_SET_MUTE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media type.(1:audio 2:video)\n");
-               else if (g_cnt == 2)
+               else if (get_appdata()->input_count == 2)
                        g_print("*** input mute mode.(1:mute 0:unmute)\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_GET_MUTE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media type.(1:audio 2:video)\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_RESOLUTION:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input width.\n");
-               else if (g_cnt == 2)
+               else if (get_appdata()->input_count == 2)
                        g_print("*** input height.\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_RESOLUTION:
                g_print("*** input source id.\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_FRAMERATE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input framerate.\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_FRAMERATE:
                g_print("*** input source id.\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_SET_TRANSCEIVER_DIRECTION:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media type.(1:audio 2:video)\n");
-               else if (g_cnt == 2)
+               else if (get_appdata()->input_count == 2)
                        g_print("*** input transceiver direction.(1:sendonly 2:recvonly 3:sendrecv)\n");
                break;
        case CURRENT_STATUS_MEDIA_SOURCE_GET_TRANSCEIVER_DIRECTION:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media type.(1:audio 2:video)\n");
                break;
        case CURRENT_STATUS_FILE_SOURCE_SET_PATH:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media path.\n");
                break;
        case CURRENT_STATUS_FILE_SOURCE_SET_LOOPING:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input looping state.(1:true 0:false)\n");
                break;
        case CURRENT_STATUS_FILE_SOURCE_GET_LOOPING:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
                break;
        case CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_BUFFER_STATE_CHANGED_CB:
@@ -390,9 +390,9 @@ void display_menu_webrtc_media_source(void)
                g_print("*** input media packet source id to unset buffer state changed callback.\n");
                break;
        case CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_FORMAT:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input media format.(1:I420 2:NV12 3:PCM_S16LE 4:H264)\n");
                break;
        case CURRENT_STATUS_START_PUSHING_PACKET_TO_MEDIA_PACKET_SOURCE:
@@ -402,21 +402,21 @@ void display_menu_webrtc_media_source(void)
                g_print("*** input media packet source id to stop pushing packet.\n");
                break;
        case CURRENT_STATUS_SET_CROP_SCREEN_SOURCE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input x.\n");
-               else if (g_cnt == 2)
+               else if (get_appdata()->input_count == 2)
                        g_print("*** input y.\n");
-               else if (g_cnt == 3)
+               else if (get_appdata()->input_count == 3)
                        g_print("*** input width.\n");
-               else if (g_cnt == 4)
+               else if (get_appdata()->input_count == 4)
                        g_print("*** input height.\n");
-               else if (g_cnt == 5)
+               else if (get_appdata()->input_count == 5)
                        g_print("*** input whether screen rotates (0: horizontal, 1: vertical).\n");
                break;
        case CURRENT_STATUS_UNSET_CROP_SCREEN_SOURCE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source id.\n");
                break;
        }
@@ -425,23 +425,23 @@ void display_menu_webrtc_media_source(void)
 
 void display_menu_webrtc_media_render(void)
 {
-       switch (g_menu_status) {
+       switch (get_appdata()->menu_status) {
        case CURRENT_STATUS_SET_DISPLAY_TYPE:
                g_print("*** input display type.(1:overlay 2:evas)\n");
                break;
        case CURRENT_STATUS_SET_DISPLAY_MODE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input track id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input display mode.(1:letter-box 2:origin size 3:full)\n");
                break;
        case CURRENT_STATUS_GET_DISPLAY_MODE:
                g_print("*** input track id.\n");
                break;
        case CURRENT_STATUS_SET_DISPLAY_VISIBLE:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input track id.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input display visible.(1:true 0:false)\n");
                break;
        case CURRENT_STATUS_GET_DISPLAY_VISIBLE:
@@ -465,7 +465,7 @@ void display_menu_webrtc_media_render(void)
 
 void display_menu_webrtc_data_channel(void)
 {
-       switch (g_menu_status) {
+       switch (get_appdata()->menu_status) {
        case CURRENT_STATUS_DATA_CHANNEL_SEND_STRING:
                g_print("*** input string to send.\n");
                break;
@@ -484,9 +484,9 @@ void display_menu_webrtc_data_channel(void)
 
 void display_menu_webrtc_stats(void)
 {
-       switch (g_menu_status) {
+       switch (get_appdata()->menu_status) {
        case CURRENT_STATUS_FOREACH_STATS:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input stats type.(1:all, 2:codec, 3:inbound-rtp/remote-outbound-rtp, 4:outbound-rtp/remote-inbound-rtp)\n");
                break;
        }
@@ -495,7 +495,7 @@ void display_menu_webrtc_stats(void)
 
 void display_menu_app_signaling(void)
 {
-       switch (g_menu_status) {
+       switch (get_appdata()->menu_status) {
        case CURRENT_STATUS_SETTING_SIGNALING_SERVER:
                g_print("*** input signaling server URL.\n");
                break;
@@ -506,9 +506,9 @@ void display_menu_app_signaling(void)
                g_print("*** input remote peer id.\n");
                break;
        case CURRENT_STATUS_REQUEST_JOIN_ROOM:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input source type.(1:audiotest/videotest 2:mic/camera 3:mic only)\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input room name to join.\n");
                break;
        case CURRENT_STATUS_SEND_LOCAL_DESCRIPTION:
@@ -518,9 +518,9 @@ void display_menu_app_signaling(void)
                g_print("*** input port.\n");
                break;
        case CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_CONNECT:
-               if (g_cnt == 0)
+               if (get_appdata()->input_count == 0)
                        g_print("*** input server ip.\n");
-               else if (g_cnt == 1)
+               else if (get_appdata()->input_count == 1)
                        g_print("*** input port.\n");
                break;
        }
@@ -529,30 +529,30 @@ void display_menu_app_signaling(void)
 
 void displaymenu(void)
 {
-       if (g_menu_status == CURRENT_STATUS_MAINMENU) {
+       if (get_appdata()->menu_status == CURRENT_STATUS_MAINMENU) {
                display_menu_main();
 
        } else {
-               if (g_menu_status & TEST_MENU_WEBRTC_COMMON) {
+               if (get_appdata()->menu_status & TEST_MENU_WEBRTC_COMMON) {
                        display_menu_webrtc_common();
 
-               } else if (g_menu_status & TEST_MENU_WEBRTC_MEDIA_SOURCE) {
+               } else if (get_appdata()->menu_status & TEST_MENU_WEBRTC_MEDIA_SOURCE) {
                        display_menu_webrtc_media_source();
 
-               } else if (g_menu_status & TEST_MENU_WEBRTC_MEDIA_RENDER) {
+               } else if (get_appdata()->menu_status & TEST_MENU_WEBRTC_MEDIA_RENDER) {
                        display_menu_webrtc_media_render();
 
-               } else if (g_menu_status & TEST_MENU_WEBRTC_DATA_CHANNEL) {
+               } else if (get_appdata()->menu_status & TEST_MENU_WEBRTC_DATA_CHANNEL) {
                        display_menu_webrtc_data_channel();
 
-               } else if (g_menu_status & TEST_MENU_WEBRTC_STATS) {
+               } else if (get_appdata()->menu_status & TEST_MENU_WEBRTC_STATS) {
                        display_menu_webrtc_stats();
 
-               } else if (g_menu_status & TEST_MENU_APP_SIGNALING) {
+               } else if (get_appdata()->menu_status & TEST_MENU_APP_SIGNALING) {
                        display_menu_app_signaling();
 
                } else {
-                       g_print("%s() > unknown menu status[0x%x]\n", __FUNCTION__, g_menu_status);
+                       g_print("%s() > unknown menu status[0x%x]\n", __FUNCTION__, get_appdata()->menu_status);
                        quit_program();
                }
        }
@@ -560,5 +560,5 @@ void displaymenu(void)
 
 void reset_menu_state(void)
 {
-       g_menu_status = CURRENT_STATUS_MAINMENU;
+       get_appdata()->menu_status = CURRENT_STATUS_MAINMENU;
 }
\ No newline at end of file
index 8ef90e461ab1ea49fee9308e2c1a2aad2cc7010d..941f37a3bd396c132c9b9a444341769772927ae6 100644 (file)
@@ -161,13 +161,6 @@ enum {
 #define MAX_CHANNEL_LEN 10
 #define MAX_MEDIA_PACKET_SOURCE_LEN 4
 
-typedef struct {
-       GHashTable *menu_items;
-       Evas_Object *win;
-       int win_width;
-       int win_height;
-} appdata_s;
-
 typedef struct {
        unsigned int source_id;
        media_format_h format;
@@ -262,16 +255,29 @@ typedef struct {
        bool key_input_needed;
 } menu_info_s;
 
+typedef struct {
+       GHashTable *menu_items;
+       int menu_status;
+       int input_count;
+
+       Evas_Object *win;
+       int win_width;
+       int win_height;
+       Evas_Object *win_id;
+       Evas_Object *eo_mine;
+       Evas_Object *text_eo_mine;
+
+       connection_s conns[MAX_CONNECTION_LEN];
+       signaling_server_s signaling_server;
+       webrtc_signaling_server_h inner_signaling_server;
+       gchar proxy[MAX_STRING_LEN];
+} appdata_s;
+
 extern menu_info_s g_menu_infos[];
 extern const char *g_server_status_str[];
 extern const char *g_webrtc_state_str[];
-extern int g_menu_status;
-extern int g_cnt;
-extern gchar g_proxy[];
-extern appdata_s g_ad;
-extern connection_s g_conns[];
-extern signaling_server_s g_signaling_server;
 
+appdata_s *get_appdata(void);
 void display_handle_status(int index);
 void display_setting_status(void);
 void display_menu_main(void);