webrtc_test: Add support for program execution option 61/276761/6
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 24 Jun 2022 05:44:15 +0000 (14:44 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Tue, 28 Jun 2022 07:54:52 +0000 (16:54 +0900)
proxy setting is moved to the execution option from menu item.

webrtc_test [OPTION]
 -p, --proxy           proxy URL to use (e.g. http://123.123.123.123:8080)
 -h, --help            help

[Version] 0.3.137
[Issue Type] Improvement

Change-Id: I438c0d79a5715562901112199318e8ea2c518fd9
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 f61a93e23b7b6895d65e67a87b1b2384418bea81..2fe08f27ab4c5938b3a7af1e1770a225036e8bdd 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.136
+Version:    0.3.137
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 5b8afc4a9dec13546326b9d192b0f2cfa4e38eb8..739f63f3756c57be50152a6862077a8b41d64f97 100644 (file)
@@ -21,6 +21,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
+#include <getopt.h>
 
 #ifdef PACKAGE
 #undef PACKAGE
@@ -5162,11 +5163,6 @@ static void app_setting_and_signaling(char *cmd)
                reset_menu_state();
                break;
        }
-       case CURRENT_STATUS_SETTING_PROXY: {
-               _setting_uri(g_ad.proxy, cmd);
-               reset_menu_state();
-               break;
-       }
        case CURRENT_STATUS_CONNECT_SIGNALING_SERVER: {
                _connect_signaling_server();
                reset_menu_state();
@@ -5321,15 +5317,48 @@ static gboolean input_watch_cb(GIOChannel *channel, GIOCondition condition, gpoi
        return TRUE;
 }
 
+static void print_usage()
+{
+       printf("Usage : ");
+       printf("webrtc_test [option]\n\n"
+                  "  -p, --proxy           proxy URL to use (e.g. http://123.123.123.123:8080)\n"
+                  "  -h, --help            help\n");
+}
+
 int main(int argc, char *argv[])
 {
        GIOChannel *stdin_channel = g_io_channel_unix_new(0);
        g_io_channel_set_flags(stdin_channel, G_IO_FLAG_NONBLOCK, NULL);
        g_io_add_watch(stdin_channel, G_IO_IN, input_watch_cb, NULL);
 
-       displaymenu();
        memset(&g_ad, 0x0, sizeof(appdata_s));
        ops.data = &g_ad;
 
+       while (1) {
+               int opt;
+               int opt_idx = 0;
+
+               static struct option long_options[] = {
+                       { "proxy", required_argument, 0, 'p' },
+                       { "help", no_argument, 0, 'h' },
+                       { 0, 0, 0, 0 }
+               };
+
+               if ((opt = getopt_long(argc, argv, "p:h", long_options, &opt_idx)) == -1)
+                       break;
+
+               switch (opt) {
+               case 'p':
+                       strncpy(g_ad.proxy, optarg, sizeof(g_ad.proxy) - 1);
+                       break;
+               case 'h':
+               default:
+                       print_usage();
+                       return 0;
+               }
+       }
+
+       displaymenu();
+
        return appcore_efl_main(PACKAGE, &argc, &argv, &ops);
 }
index f4f9c102951040a63faeb04b778e61039f582352..25e95001b913bd2f8ce0f520d027316450b76c26 100644 (file)
@@ -102,7 +102,6 @@ menu_info_s g_menu_infos[] = {
        /* app. setting & signaling */
        { "ss", CURRENT_STATUS_SETTING_SIGNALING_SERVER, true },
        { "cs", CURRENT_STATUS_CONNECT_SIGNALING_SERVER, false },
-       { "px", CURRENT_STATUS_SETTING_PROXY, true },
        { "rs", CURRENT_STATUS_REQUEST_SESSION, true },
        { "rj", CURRENT_STATUS_REQUEST_JOIN_ROOM, true },
        { "sd", CURRENT_STATUS_SEND_LOCAL_DESCRIPTION, true },
@@ -250,7 +249,6 @@ void display_menu_main(void)
        g_print("sts. Get stats\n");
        g_print("------------------------------- App. Setting & Signaling --------------------------------\n");
        display_setting_status();
-       g_print("px. Set proxy URL\n");
        g_print("ss. Set signaling server URL\n");
        g_print("cs. Connect to the signaling server\n");
        g_print("rs. Request session of remote peer id\n");
@@ -525,9 +523,6 @@ void display_menu_app_signaling(void)
        case CURRENT_STATUS_SETTING_SIGNALING_SERVER:
                g_print("*** input signaling server URL.\n");
                break;
-       case CURRENT_STATUS_SETTING_PROXY:
-               g_print("*** input proxy URL.\n");
-               break;
        case CURRENT_STATUS_REQUEST_SESSION:
                g_print("*** input remote peer id.\n");
                break;
index 44bfd56a3785c392836c78a975f0e1fc9d57e891..f1ba03a017bfbdeefd6c9a0ccfe1bf2e5ccf2316 100644 (file)
@@ -138,16 +138,15 @@ enum {
        /* app. setting & signaling */
        CURRENT_STATUS_SETTING_SIGNALING_SERVER = TEST_MENU_APP_SIGNALING | 0x01,
        CURRENT_STATUS_CONNECT_SIGNALING_SERVER = TEST_MENU_APP_SIGNALING | 0x02,
-       CURRENT_STATUS_SETTING_PROXY = TEST_MENU_APP_SIGNALING | 0x03,
-       CURRENT_STATUS_REQUEST_SESSION = TEST_MENU_APP_SIGNALING | 0x04,
-       CURRENT_STATUS_REQUEST_JOIN_ROOM = TEST_MENU_APP_SIGNALING | 0x05,
-       CURRENT_STATUS_SEND_LOCAL_DESCRIPTION = TEST_MENU_APP_SIGNALING | 0x06,
-       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_CREATE = TEST_MENU_APP_SIGNALING | 0x07,
-       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_DESTROY = TEST_MENU_APP_SIGNALING | 0x08,
-       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_START = TEST_MENU_APP_SIGNALING | 0x09,
-       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_STOP = TEST_MENU_APP_SIGNALING | 0x0A,
-       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_CONNECT = TEST_MENU_APP_SIGNALING | 0x0B,
-       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_DISCONNECT = TEST_MENU_APP_SIGNALING | 0x0C,
+       CURRENT_STATUS_REQUEST_SESSION = TEST_MENU_APP_SIGNALING | 0x03,
+       CURRENT_STATUS_REQUEST_JOIN_ROOM = TEST_MENU_APP_SIGNALING | 0x04,
+       CURRENT_STATUS_SEND_LOCAL_DESCRIPTION = TEST_MENU_APP_SIGNALING | 0x05,
+       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_CREATE = TEST_MENU_APP_SIGNALING | 0x06,
+       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_DESTROY = TEST_MENU_APP_SIGNALING | 0x07,
+       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_START = TEST_MENU_APP_SIGNALING | 0x08,
+       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_STOP = TEST_MENU_APP_SIGNALING | 0x09,
+       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_CONNECT = TEST_MENU_APP_SIGNALING | 0x0A,
+       CURRENT_STATUS_PRIVATE_SIGNALING_SERVER_DISCONNECT = TEST_MENU_APP_SIGNALING | 0x0B,
 };
 
 enum {