Add webrtcbin test menu 54/235154/5
authorHyunil <hyunil46.park@samsung.com>
Tue, 2 Jun 2020 08:07:01 +0000 (17:07 +0900)
committerHyunil <hyunil46.park@samsung.com>
Wed, 3 Jun 2020 04:38:12 +0000 (13:38 +0900)
[Version] 0.1.50
[Issue Type] New feature

Change-Id: I3ce67e4c875461c6421cf9aa0454af04a7ff698d
Signed-off-by: Hyunil <hyunil46.park@samsung.com>
packaging/capi-media-streamer.spec
test/media_streamer_test.c

index c315509..d8412f1 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-streamer
 Summary:    A Media Streamer API
-Version:    0.1.49
+Version:    0.1.50
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 14e68b3..4691731 100644 (file)
@@ -38,12 +38,15 @@ typedef enum {
        MENU_STATE_AUTOPLUG_PLAYING_MENU,
        MENU_STATE_STATIC_LINK_PLAYING_MENU,
        MENU_STATE_VIDEO_TEST_MENU,
+       MENU_STATE_WEBRTC_MENU,
        MENU_STATE_PRESET_MENU,
        MENU_STATE_ADAPTIVE_MENU,
 } menu_state_e;
 
 typedef enum {
        SUBMENU_STATE_UNKNOWN,
+       SUBMENU_STATE_GETTING_PEER_ID,
+       SUBMENU_STATE_GETTING_PROXY_ADDR,
        SUBMENU_STATE_GETTING_IP,
        SUBMENU_STATE_GETTING_SEEK_POS,
        SUBMENU_STATE_GETTING_FILE_URI,
@@ -53,6 +56,7 @@ typedef enum {
        SUBMENU_STATE_AUTOPLUG_PLAYING_SCENARIO,
        SUBMENU_STATE_STATIC_LINK_PLAYING_SCENARIO,
        SUBMENU_STATE_VIDEO_TEST_SCENARIO,
+       SUBMENU_STATE_WEBRTC_SCENARIO,
        SUBMENU_STATE_FORMAT,
        SUBMENU_STATE_ADAPTIVE_SCENARIO,
 } submenu_state_e;
@@ -93,16 +97,17 @@ typedef enum {
        SCENARIO_MODE_FILE_PLAY_MP3_AUDIO,
        SCENARIO_MODE_FILE_PLAY_MP4_VIDEO,
        SCENARIO_MODE_VIDEOTESTSRC_VIDEOSINK,
-       SCENARIO_MODE_VIDEOTESTSRC_CAPSFILTER_VIDEOSINK
+       SCENARIO_MODE_VIDEOTESTSRC_CAPSFILTER_VIDEOSINK,
+       SCENARIO_MODE_WEBRTC_SENDRECV_VIDEO_AUDIO,
 } scenario_mode_e;
 
 #define PACKAGE "media_streamer_test"
 
-#define MAX_STRING_LEN    2048
-#define DEFAULT_IP_ADDR   "127.0.0.1"
+#define MAX_STRING_LEN     2048
+#define DEFAULT_IP_ADDR    "127.0.0.1"
 #define DEFAULT_SEEK_POS   0
-#define MSEC_MULTIPLIER   1000
-#define MAX_NODES_COUNT   50
+#define MSEC_MULTIPLIER    1000
+#define MAX_NODES_COUNT    50
 
 #define VIDEO_PORT 5000
 #define AUDIO_PORT 6000
@@ -131,8 +136,10 @@ int g_node_counter = 0;
 #define APPEND_NODE(x) {g_nodes[g_node_counter++] = x; }
 
 gchar *g_broadcast_address = NULL;
+gchar *g_proxy_address = NULL;
 int g_seek_pos = 0;
 int g_time = 0;
+int g_peer_id = 0;
 gchar *g_uri = NULL;
 gchar *g_sub_uri = NULL;
 
@@ -145,7 +152,9 @@ gboolean use_tbm = FALSE;
 gboolean g_autoplug_mode = FALSE;
 gboolean g_video_is_on = FALSE;
 gboolean g_audio_is_on = FALSE;
+gboolean g_use_proxy = FALSE;
 
+media_format_h vfmt_vp8 = NULL;
 media_format_h vfmt_i420 = NULL;
 media_format_h vfmt_encoded = NULL;
 media_format_h vfmt_h264 = NULL;
@@ -353,6 +362,15 @@ static void create_formats(void)
        media_format_set_video_avg_bps(vfmt_encoded, VIDEO_AVG_BPS);
        media_format_set_video_max_bps(vfmt_encoded, VIDEO_MAX_BPS);
 
+       media_format_create(&vfmt_vp8);
+       if (media_format_set_video_mime(vfmt_vp8, MEDIA_FORMAT_VP8) != MEDIA_FORMAT_ERROR_NONE)
+               g_print("media_format_set_video_mime failed!");
+
+       media_format_set_video_width(vfmt_vp8, VIDEO_WIDTH);
+       media_format_set_video_height(vfmt_vp8, VIDEO_HIGHT);
+       media_format_set_video_avg_bps(vfmt_vp8, VIDEO_AVG_BPS);
+       media_format_set_video_max_bps(vfmt_vp8, VIDEO_MAX_BPS);
+
        /* Define encoded video format for adaptive stream */
        media_format_create(&vfmt_h264);
        if (media_format_set_video_mime(vfmt_h264, MEDIA_FORMAT_H264_SP) != MEDIA_FORMAT_ERROR_NONE)
@@ -614,6 +632,11 @@ static void _create_videotestsrc_capsfilter_videosink(void)
        media_streamer_node_link(videoconverter, "src", video_sink, "sink");
 }
 
+static void _create_webrtc_sendrec_video_audio(void)
+{
+
+}
+
 static void _create_file_sub_playing(void)
 {
        media_streamer_node_h file_sub_src = NULL;
@@ -1122,6 +1145,11 @@ void reset_current_menu_state(void)
                g_broadcast_address = NULL;
        }
 
+       if (g_proxy_address != NULL) {
+               g_free(g_proxy_address);
+               g_proxy_address = NULL;
+       }
+
        if (g_uri != NULL) {
                g_free(g_uri);
                g_uri = NULL;
@@ -1147,6 +1175,26 @@ void quit(void)
        elm_exit();
 }
 
+static void display_getting_proxy_addr_menu(void)
+{
+       g_print("\n");
+       g_print("====================================================\n");
+       g_print("Please input your proxy address\n");
+       g_print("If you don't use proxy address, please input '0'\n");
+       g_print("0: skip\n");
+       g_print("----------------------------------------------------\n");
+}
+
+static void display_getting_peer_id_menu(void)
+{
+       g_print("\n");
+       g_print("====================================================\n");
+       g_print("If your are an offer, please input peer id\n");
+       g_print("If your are an answer, please input '0'\n");
+       g_print("0: skip\n");
+       g_print("----------------------------------------------------\n");
+}
+
 static void display_getting_ip_menu(void)
 {
        g_print("\n");
@@ -1209,7 +1257,7 @@ static void display_autoplug_playing_scenario_select_menu(void)
 {
        g_print("\n");
        g_print("====================================================\n");
-       g_print("   media streamer test: Playing(Autoplug) menu v0.3\n");
+       g_print("   media streamer test: Playing(Autoplug) menu\n");
        g_print("----------------------------------------------------\n");
        g_print("\n");
        g_print("Please select Playing Scenario mode\n");
@@ -1227,7 +1275,7 @@ static void display_static_link_playing_scenario_select_menu(void)
 {
        g_print("\n");
        g_print("====================================================\n");
-       g_print("   media streamer test: Playing(static link) menu v0.3\n");
+       g_print("   media streamer test: Playing(static link) menu\n");
        g_print("----------------------------------------------------\n");
        g_print("\n");
        g_print("Please select Playing Scenario mode\n");
@@ -1245,7 +1293,7 @@ static void display_adaptive_scenario_select_menu(void)
 {
        g_print("\n");
        g_print("====================================================\n");
-       g_print("   media streamer test: Adaptive menu v0.3\n");
+       g_print("   media streamer test: Adaptive menu\n");
        g_print("----------------------------------------------------\n");
        g_print("\n");
        g_print("Please select Adaptive Scenario mode\n");
@@ -1263,7 +1311,7 @@ static void display_video_test_scenario_select_menu(void)
 {
        g_print("\n");
        g_print("====================================================\n");
-       g_print("   media streamer test: Video test menu v0.3\n");
+       g_print("   media streamer test: Video test menu\n");
        g_print("----------------------------------------------------\n");
        g_print("\n");
        g_print("Please select Videotest Scenario mode\n");
@@ -1275,11 +1323,24 @@ static void display_video_test_scenario_select_menu(void)
        g_print("====================================================\n");
 }
 
+static void display_webrtc_scenario_select_menu(void)
+{
+       g_print("\n");
+       g_print("====================================================\n");
+       g_print("   media streamer test: WebRTC menu\n");
+       g_print("----------------------------------------------------\n");
+       g_print("Please select WebRTC Scenario mode\n");
+       g_print("1. sendrecv audio and video\n");
+       g_print("b. back \n");
+       g_print("----------------------------------------------------\n");
+       g_print("====================================================\n");
+}
+
 static void display_preset_menu(void)
 {
        g_print("\n");
        g_print("====================================================\n");
-       g_print("   media streamer test: Preset menu v0.3\n");
+       g_print("   media streamer test: Preset menu\n");
        g_print("----------------------------------------------------\n");
        g_print("1. create media streamer \n");
        g_print("2. set up current preset \n");
@@ -1299,7 +1360,7 @@ static void display_voip_menu(void)
 {
        g_print("\n");
        g_print("====================================================\n");
-       g_print("   media streamer test: VoIP menu v0.3\n");
+       g_print("   media streamer test: VoIP menu\n");
        g_print("----------------------------------------------------\n");
        g_print("1. one streamer VoIP 1 \n");
        g_print("2. one streamer VoIP 2 \n");
@@ -1316,7 +1377,7 @@ static void display_broadcast_menu(void)
 {
        g_print("\n");
        g_print("====================================================\n");
-       g_print("   media streamer test: Broadcast menu v0.3\n");
+       g_print("   media streamer test: Broadcast menu\n");
        g_print("----------------------------------------------------\n");
        g_print("1. Broadcast client \n");
        g_print("2. Broadcast streamer \n");
@@ -1329,7 +1390,7 @@ static void display_main_menu(void)
 {
        g_print("\n");
        g_print("===========================================================================\n");
-       g_print("   media streamer test: Main menu v0.3\n");
+       g_print("   media streamer test: Main menu\n");
        g_print("---------------------------------------------------------------------------\n");
        g_print("1. Broadcast \n");
        g_print("2. VOIP \n");
@@ -1337,6 +1398,7 @@ static void display_main_menu(void)
        g_print("4. Local Playing (link: static) \n");
        g_print("5. Adaptive \n");
        g_print("6. Video test \n");
+       g_print("7. WebRTC \n");
        g_print("t. Use TBM (select to test 3 and 4 with TBM, change ini to use H/W codec.)\n");
        g_print("q. quit \n");
        g_print("---------------------------------------------------------------------------\n");
@@ -1361,6 +1423,7 @@ static void display_menu(void)
                case MENU_STATE_PRESET_MENU:
                case MENU_STATE_ADAPTIVE_MENU:
                case MENU_STATE_VIDEO_TEST_MENU:
+               case MENU_STATE_WEBRTC_MENU:
                        display_preset_menu();
                        break;
                default:
@@ -1369,6 +1432,12 @@ static void display_menu(void)
                }
        } else {
                switch (g_sub_menu_state) {
+               case SUBMENU_STATE_GETTING_PEER_ID:
+                       display_getting_peer_id_menu();
+                       break;
+               case SUBMENU_STATE_GETTING_PROXY_ADDR:
+                       display_getting_proxy_addr_menu();
+                       break;
                case SUBMENU_STATE_GETTING_IP:
                        display_getting_ip_menu();
                        break;
@@ -1399,6 +1468,9 @@ static void display_menu(void)
                case SUBMENU_STATE_VIDEO_TEST_SCENARIO:
                        display_video_test_scenario_select_menu();
                        break;
+               case SUBMENU_STATE_WEBRTC_SCENARIO:
+                       display_webrtc_scenario_select_menu();
+                       break;
                default:
                        g_print("*** Unknown Submenu state.\n");
                        break;
@@ -1468,6 +1540,16 @@ static void run_preset(void)
        }
 }
 
+void run_webrtc_preset(void)
+{
+       if ((g_scenario_mode == SCENARIO_MODE_WEBRTC_SENDRECV_VIDEO_AUDIO)) {
+               create_formats();
+               _create_webrtc_sendrec_video_audio();
+       } else {
+               g_print("Invalid scenario menu preset was selected!");
+       }
+}
+
 void run_video_test_preset(void)
 {
        if ((g_scenario_mode == SCENARIO_MODE_VIDEOTESTSRC_VIDEOSINK)) {
@@ -1537,6 +1619,8 @@ void _interpret_main_menu(char *cmd)
                        g_menu_state = MENU_STATE_ADAPTIVE_MENU;
                else if (!strncmp(cmd, "6", len))
                        g_menu_state = MENU_STATE_VIDEO_TEST_MENU;
+               else if (!strncmp(cmd, "7", len))
+                       g_menu_state = MENU_STATE_WEBRTC_MENU;
                else if (!strncmp(cmd, "t", len)) {
                        use_tbm = TRUE;
                        g_menu_state = MENU_STATE_MAIN_MENU;
@@ -1696,6 +1780,19 @@ void _interpret_video_test_scenario_menu(char *cmd)
        g_sub_menu_state = SUBMENU_STATE_UNKNOWN;
 }
 
+void _interpret_webrtc_scenario_menu(char *cmd)
+{
+       int len = strlen(cmd);
+
+       if (len == 1) {
+               if (!strncmp(cmd, "1", len)) {
+                       g_scenario_mode = SCENARIO_MODE_WEBRTC_SENDRECV_VIDEO_AUDIO;
+                       g_printf("g_sub_menu_state (%d)\n", g_sub_menu_state);
+               }
+       }
+       g_sub_menu_state = SUBMENU_STATE_GETTING_PROXY_ADDR;
+}
+
 void _interpret_scenario_menu(char *cmd)
 {
        int len = strlen(cmd);
@@ -1756,6 +1853,44 @@ void _interpret_scenario_menu(char *cmd)
        }
 }
 
+void _interpret_getting_proxy_addr_menu(char *cmd)
+{
+       int min_len = strlen("0.0.0.0");
+       int cmd_len = strlen(cmd);
+       if (g_proxy_address != NULL)
+               g_free(g_proxy_address);
+
+       if (cmd_len == 1) {
+               if (cmd[0] == '0') {
+                       g_use_proxy = FALSE;
+               }
+       } else if (cmd_len > min_len) {
+               g_proxy_address = g_strdup(cmd);
+               g_print("User set proxy address set to [%s]\n", g_proxy_address);
+       } else {
+               g_print("Invalid value\n");
+       }
+       g_sub_menu_state = SUBMENU_STATE_GETTING_PEER_ID;
+}
+
+void _interpret_getting_peer_id_menu(char *cmd)
+{
+       if (strlen(cmd) ==1 && cmd[0] == 0) {
+               g_peer_id = 0;
+               g_print("WebRTC operates in answer mode.\n");
+       } else {
+               g_peer_id = strtol(cmd, NULL, 10);
+               if (g_peer_id < 0) {
+                       printf("Invalid ID\n");
+               }
+               g_print("Peer id set to [%d]\n", g_peer_id);
+               g_print("WebRTC operate in offer mode.\n");
+       }
+
+       run_webrtc_preset();
+       g_sub_menu_state = SUBMENU_STATE_UNKNOWN;
+}
+
 void _interpret_getting_ip_menu(char *cmd)
 {
        int min_len = strlen("0.0.0.0");
@@ -1892,6 +2027,8 @@ void _interpret_preset_menu(char *cmd)
                                g_sub_menu_state = SUBMENU_STATE_ADAPTIVE_SCENARIO;
                        else if (g_menu_state == MENU_STATE_VIDEO_TEST_MENU)
                                g_sub_menu_state = SUBMENU_STATE_VIDEO_TEST_SCENARIO;
+                       else if (g_menu_state == MENU_STATE_WEBRTC_MENU)
+                               g_sub_menu_state = SUBMENU_STATE_WEBRTC_SCENARIO;
                        else
                                g_sub_menu_state = SUBMENU_STATE_AUTOPLUG;
                } else if (!strncmp(cmd, "3", len)) {
@@ -1943,6 +2080,7 @@ static void interpret_cmd(char *cmd)
                case MENU_STATE_VIDEO_TEST_MENU:
                case MENU_STATE_PRESET_MENU:
                case MENU_STATE_ADAPTIVE_MENU:
+               case MENU_STATE_WEBRTC_MENU:
                        _interpret_preset_menu(cmd);
                        break;
                default:
@@ -1952,6 +2090,12 @@ static void interpret_cmd(char *cmd)
                }
        } else {
                switch (g_sub_menu_state) {
+               case SUBMENU_STATE_GETTING_PROXY_ADDR:
+                       _interpret_getting_proxy_addr_menu(cmd);
+                       break;
+               case SUBMENU_STATE_GETTING_PEER_ID:
+                       _interpret_getting_peer_id_menu(cmd);
+                       break;
                case SUBMENU_STATE_GETTING_IP:
                        _interpret_getting_ip_menu(cmd);
                        break;
@@ -1982,6 +2126,9 @@ static void interpret_cmd(char *cmd)
                case SUBMENU_STATE_VIDEO_TEST_SCENARIO:
                        _interpret_video_test_scenario_menu(cmd);
                        break;
+               case SUBMENU_STATE_WEBRTC_SCENARIO:
+                       _interpret_webrtc_scenario_menu(cmd);
+                       break;
                default:
                        g_print("*** Unknown Submenu state.\n");
                        break;