From: Sangchul Lee Date: Mon, 18 Apr 2022 09:13:45 +0000 (+0900) Subject: webrtc_test: Make sub functions to change menu state X-Git-Tag: submit/tizen/20220426.020921~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e49a6e8944a32183e96d518729d0877f50927f01;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_test: Make sub functions to change menu state [Version] 0.3.85 [Issue Type] Refactoring Change-Id: I91462e96aad3011aca9a9545cca5a08725e2c9f5 Signed-off-by: Sangchul Lee --- diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 3a73cfe7..c8548282 100644 --- a/packaging/capi-media-webrtc.spec +++ b/packaging/capi-media-webrtc.spec @@ -1,6 +1,6 @@ Name: capi-media-webrtc Summary: A WebRTC library in Tizen Native API -Version: 0.3.84 +Version: 0.3.85 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 5db19efb..9812da1c 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -4215,330 +4215,365 @@ void quit_program() elm_exit(); } -void _interpret_main_menu(char *cmd) +static void change_menu_state_1(char *cmd) { - int len = strlen(cmd); - if (len == 1) { - if (strncmp(cmd, "c", 1) == 0) { - _webrtc_create(0); + if (!cmd) + return; - } else if (strncmp(cmd, "a", 1) == 0) { - g_menu_state = CURRENT_STATUS_ADD_MEDIA_SOURCE; + if (strncmp(cmd, "c", 1) == 0) { + _webrtc_create(0); - } else if (strncmp(cmd, "r", 1) == 0) { - g_menu_state = CURRENT_STATUS_REMOVE_MEDIA_SOURCE; + } else if (strncmp(cmd, "a", 1) == 0) { + g_menu_state = CURRENT_STATUS_ADD_MEDIA_SOURCE; - } else if (strncmp(cmd, "p", 1) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_PAUSE; + } else if (strncmp(cmd, "r", 1) == 0) { + g_menu_state = CURRENT_STATUS_REMOVE_MEDIA_SOURCE; - } else if (strncmp(cmd, "o", 1) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_PAUSE; + } else if (strncmp(cmd, "p", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_PAUSE; - } else if (strncmp(cmd, "v", 1) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_RESOLUTION; + } else if (strncmp(cmd, "o", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_PAUSE; - } else if (strncmp(cmd, "l", 1) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_RESOLUTION; + } else if (strncmp(cmd, "v", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_RESOLUTION; - } else if (strncmp(cmd, "f", 1) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_FRAMERATE; + } else if (strncmp(cmd, "l", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_RESOLUTION; - } else if (strncmp(cmd, "m", 1) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_FRAMERATE; + } else if (strncmp(cmd, "f", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_FRAMERATE; - } else if (strncmp(cmd, "s", 1) == 0) { - _webrtc_start(0); + } else if (strncmp(cmd, "m", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_FRAMERATE; - } else if (strncmp(cmd, "t", 1) == 0) { - _webrtc_stop(0); + } else if (strncmp(cmd, "s", 1) == 0) { + _webrtc_start(0); - } else if (strncmp(cmd, "d", 1) == 0) { - _webrtc_destroy(0); + } else if (strncmp(cmd, "t", 1) == 0) { + _webrtc_stop(0); - } else if (strncmp(cmd, "g", 1) == 0) { - _webrtc_get_state(0); + } else if (strncmp(cmd, "d", 1) == 0) { + _webrtc_destroy(0); - } else if (strncmp(cmd, "q", 1) == 0) { - quit_program(); + } else if (strncmp(cmd, "g", 1) == 0) { + _webrtc_get_state(0); - } else { - g_print("unknown menu \n"); - } + } else if (strncmp(cmd, "q", 1) == 0) { + quit_program(); - } else if (len == 2) { - if (strncmp(cmd, "sf", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_FORMAT; + } else { + g_print("%s() > unknown menu[%s]\n", __FUNCTION__, cmd); + } +} - } else if (strncmp(cmd, "td", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_TRANSCEIVER_DIRECTION; +static void change_menu_state_2(char *cmd) +{ + if (!cmd) + return; - } else if (strncmp(cmd, "gd", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_TRANSCEIVER_DIRECTION; + if (strncmp(cmd, "sf", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_FORMAT; - } else if (strncmp(cmd, "mu", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_MUTE; + } else if (strncmp(cmd, "td", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_TRANSCEIVER_DIRECTION; - } else if (strncmp(cmd, "mg", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_MUTE; + } else if (strncmp(cmd, "gd", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_TRANSCEIVER_DIRECTION; - } else if (strncmp(cmd, "dt", 2) == 0) { - g_menu_state = CURRENT_STATUS_SET_DISPLAY_TYPE; + } else if (strncmp(cmd, "mu", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_MUTE; - } else if (strncmp(cmd, "dm", 2) == 0) { - g_menu_state = CURRENT_STATUS_SET_DISPLAY_MODE; + } else if (strncmp(cmd, "mg", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_MUTE; - } else if (strncmp(cmd, "gm", 2) == 0) { - g_menu_state = CURRENT_STATUS_GET_DISPLAY_MODE; + } else if (strncmp(cmd, "dt", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_DISPLAY_TYPE; - } else if (strncmp(cmd, "dv", 2) == 0) { - g_menu_state = CURRENT_STATUS_SET_DISPLAY_VISIBLE; + } else if (strncmp(cmd, "dm", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_DISPLAY_MODE; - } else if (strncmp(cmd, "gv", 2) == 0) { - g_menu_state = CURRENT_STATUS_GET_DISPLAY_VISIBLE; + } else if (strncmp(cmd, "gm", 2) == 0) { + g_menu_state = CURRENT_STATUS_GET_DISPLAY_MODE; - } else if (strncmp(cmd, "al", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_AUDIO_LOOPBACK; + } else if (strncmp(cmd, "dv", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_DISPLAY_VISIBLE; - } else if (strncmp(cmd, "vl", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_LOOPBACK; + } else if (strncmp(cmd, "gv", 2) == 0) { + g_menu_state = CURRENT_STATUS_GET_DISPLAY_VISIBLE; - } else if (strncmp(cmd, "cd", 2) == 0) { - _webrtc_create_data_channel(0); + } else if (strncmp(cmd, "al", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_AUDIO_LOOPBACK; - } else if (strncmp(cmd, "dd", 2) == 0) { - _webrtc_destroy_data_channel(0); + } else if (strncmp(cmd, "vl", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_LOOPBACK; - } else if (strncmp(cmd, "dl", 2) == 0) { - _webrtc_data_channel_get_label(0); + } else if (strncmp(cmd, "cd", 2) == 0) { + _webrtc_create_data_channel(0); - } else if (strncmp(cmd, "sz", 2) == 0) { - _webrtc_set_data_channel_cb(0); + } else if (strncmp(cmd, "dd", 2) == 0) { + _webrtc_destroy_data_channel(0); - } else if (strncmp(cmd, "uz", 2) == 0) { - _webrtc_unset_data_channel_cb(0); + } else if (strncmp(cmd, "dl", 2) == 0) { + _webrtc_data_channel_get_label(0); - } else if (strncmp(cmd, "zs", 2) == 0) { - g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SEND_STRING; + } else if (strncmp(cmd, "sz", 2) == 0) { + _webrtc_set_data_channel_cb(0); - } else if (strncmp(cmd, "zb", 2) == 0) { - g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SEND_STRING_AS_BYTES; + } else if (strncmp(cmd, "uz", 2) == 0) { + _webrtc_unset_data_channel_cb(0); - } else if (strncmp(cmd, "zf", 2) == 0) { - g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SEND_FILE; + } else if (strncmp(cmd, "zs", 2) == 0) { + g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SEND_STRING; - } else if (strncmp(cmd, "ba", 2) == 0) { - _webrtc_data_channel_get_buffered_amount(0); + } else if (strncmp(cmd, "zb", 2) == 0) { + g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SEND_STRING_AS_BYTES; - } else if (strncmp(cmd, "se", 2) == 0) { - _webrtc_set_error_cb(0); + } else if (strncmp(cmd, "zf", 2) == 0) { + g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SEND_FILE; - } else if (strncmp(cmd, "ue", 2) == 0) { - _webrtc_unset_error_cb(0); + } else if (strncmp(cmd, "ba", 2) == 0) { + _webrtc_data_channel_get_buffered_amount(0); - } else if (strncmp(cmd, "sc", 2) == 0) { - _webrtc_set_state_changed_cb(0); + } else if (strncmp(cmd, "se", 2) == 0) { + _webrtc_set_error_cb(0); - } else if (strncmp(cmd, "us", 2) == 0) { - _webrtc_unset_state_changed_cb(0); + } else if (strncmp(cmd, "ue", 2) == 0) { + _webrtc_unset_error_cb(0); - } else if (strncmp(cmd, "sn", 2) == 0) { - _webrtc_set_negotiation_needed_cb(0); + } else if (strncmp(cmd, "sc", 2) == 0) { + _webrtc_set_state_changed_cb(0); - } else if (strncmp(cmd, "un", 2) == 0) { - _webrtc_unset_negotiation_needed_cb(0); + } else if (strncmp(cmd, "us", 2) == 0) { + _webrtc_unset_state_changed_cb(0); - } else if (strncmp(cmd, "si", 2) == 0) { - _webrtc_set_ice_candidate_cb(0); + } else if (strncmp(cmd, "sn", 2) == 0) { + _webrtc_set_negotiation_needed_cb(0); - } else if (strncmp(cmd, "ui", 2) == 0) { - _webrtc_unset_ice_candidate_cb(0); + } else if (strncmp(cmd, "un", 2) == 0) { + _webrtc_unset_negotiation_needed_cb(0); - } else if (strncmp(cmd, "sk", 2) == 0) { - _webrtc_set_track_added_cb(0); + } else if (strncmp(cmd, "si", 2) == 0) { + _webrtc_set_ice_candidate_cb(0); - } else if (strncmp(cmd, "uk", 2) == 0) { - _webrtc_unset_track_added_cb(0); + } else if (strncmp(cmd, "ui", 2) == 0) { + _webrtc_unset_ice_candidate_cb(0); - } else if (strncmp(cmd, "sa", 2) == 0) { - _webrtc_set_encoded_audio_frame_cb(0); + } else if (strncmp(cmd, "sk", 2) == 0) { + _webrtc_set_track_added_cb(0); - } else if (strncmp(cmd, "ua", 2) == 0) { - _webrtc_unset_encoded_audio_frame_cb(0); + } else if (strncmp(cmd, "uk", 2) == 0) { + _webrtc_unset_track_added_cb(0); - } else if (strncmp(cmd, "sv", 2) == 0) { - _webrtc_set_encoded_video_frame_cb(0); + } else if (strncmp(cmd, "sa", 2) == 0) { + _webrtc_set_encoded_audio_frame_cb(0); - } else if (strncmp(cmd, "uv", 2) == 0) { - _webrtc_unset_encoded_video_frame_cb(0); + } else if (strncmp(cmd, "ua", 2) == 0) { + _webrtc_unset_encoded_audio_frame_cb(0); - } else if (strncmp(cmd, "sm", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_BUFFER_STATE_CHANGED_CB; + } else if (strncmp(cmd, "sv", 2) == 0) { + _webrtc_set_encoded_video_frame_cb(0); - } else if (strncmp(cmd, "um", 2) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_PACKET_SOURCE_UNSET_BUFFER_STATE_CHANGED_CB; + } else if (strncmp(cmd, "uv", 2) == 0) { + _webrtc_unset_encoded_video_frame_cb(0); - } else if (strncmp(cmd, "co", 2) == 0) { - _webrtc_create_offer(&g_conns[0], false); + } else if (strncmp(cmd, "sm", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_BUFFER_STATE_CHANGED_CB; - } else if (strncmp(cmd, "ca", 2) == 0) { - _webrtc_create_answer(&g_conns[0], false); + } else if (strncmp(cmd, "um", 2) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_PACKET_SOURCE_UNSET_BUFFER_STATE_CHANGED_CB; - } else if (strncmp(cmd, "sl", 2) == 0) { - g_menu_state = CURRENT_STATUS_SET_LOCAL_DESCRIPTION; + } else if (strncmp(cmd, "co", 2) == 0) { + _webrtc_create_offer(&g_conns[0], false); - } else if (strncmp(cmd, "sr", 2) == 0) { - _webrtc_set_remote_description(&g_conns[0]); + } else if (strncmp(cmd, "ca", 2) == 0) { + _webrtc_create_answer(&g_conns[0], false); - } else if (strncmp(cmd, "st", 2) == 0) { - g_menu_state = CURRENT_STATUS_SET_STUN_SERVER; + } else if (strncmp(cmd, "sl", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_LOCAL_DESCRIPTION; - } else if (strncmp(cmd, "gt", 2) == 0) { - _webrtc_get_stun_server(0); + } else if (strncmp(cmd, "sr", 2) == 0) { + _webrtc_set_remote_description(&g_conns[0]); - } else if (strncmp(cmd, "su", 2) == 0) { - g_menu_state = CURRENT_STATUS_ADD_TURN_SERVER; + } else if (strncmp(cmd, "st", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_STUN_SERVER; - } else if (strncmp(cmd, "gu", 2) == 0) { - _webrtc_get_turn_servers(0); + } else if (strncmp(cmd, "gt", 2) == 0) { + _webrtc_get_stun_server(0); - } else if (strncmp(cmd, "ss", 2) == 0) { - g_menu_state = CURRENT_STATUS_SETTING_SIGNALING_SERVER; + } else if (strncmp(cmd, "su", 2) == 0) { + g_menu_state = CURRENT_STATUS_ADD_TURN_SERVER; - } else if (strncmp(cmd, "px", 2) == 0) { - g_menu_state = CURRENT_STATUS_SETTING_PROXY; + } else if (strncmp(cmd, "gu", 2) == 0) { + _webrtc_get_turn_servers(0); - } else if (strncmp(cmd, "cs", 2) == 0) { - _connect_signaling_server(); + } else if (strncmp(cmd, "ss", 2) == 0) { + g_menu_state = CURRENT_STATUS_SETTING_SIGNALING_SERVER; - } else if (strncmp(cmd, "rs", 2) == 0) { - g_menu_state = CURRENT_STATUS_REQUEST_SESSION; + } else if (strncmp(cmd, "px", 2) == 0) { + g_menu_state = CURRENT_STATUS_SETTING_PROXY; - } else if (strncmp(cmd, "rj", 2) == 0) { - g_menu_state = CURRENT_STATUS_REQUEST_JOIN_ROOM; + } else if (strncmp(cmd, "cs", 2) == 0) { + _connect_signaling_server(); - } else if (strncmp(cmd, "sd", 2) == 0) { - g_menu_state = CURRENT_STATUS_SEND_LOCAL_DESCRIPTION; + } else if (strncmp(cmd, "rs", 2) == 0) { + g_menu_state = CURRENT_STATUS_REQUEST_SESSION; - } else if (strncmp(cmd, "sp", 2) == 0) { - g_menu_state = CURRENT_STATUS_START_PUSHING_PACKET_TO_MEDIA_PACKET_SOURCE; + } else if (strncmp(cmd, "rj", 2) == 0) { + g_menu_state = CURRENT_STATUS_REQUEST_JOIN_ROOM; - } else if (strncmp(cmd, "tp", 2) == 0) { - g_menu_state = CURRENT_STATUS_STOP_PUSHING_PACKET_TO_MEDIA_PACKET_SOURCE; + } else if (strncmp(cmd, "sd", 2) == 0) { + g_menu_state = CURRENT_STATUS_SEND_LOCAL_DESCRIPTION; - } else if (strncmp(cmd, "pa", 2) == 0) { - g_menu_state = CURRENT_STATUS_SET_MEDIA_PATH_TO_MEDIA_FILE_SOURCE; + } else if (strncmp(cmd, "sp", 2) == 0) { + g_menu_state = CURRENT_STATUS_START_PUSHING_PACKET_TO_MEDIA_PACKET_SOURCE; - } else if (strncmp(cmd, "ac", 2) == 0) { - _webrtc_add_ice_candidate(&g_conns[0], NULL); + } else if (strncmp(cmd, "tp", 2) == 0) { + g_menu_state = CURRENT_STATUS_STOP_PUSHING_PACKET_TO_MEDIA_PACKET_SOURCE; - } else { - g_print("unknown menu \n"); - } + } else if (strncmp(cmd, "pa", 2) == 0) { + g_menu_state = CURRENT_STATUS_SET_MEDIA_PATH_TO_MEDIA_FILE_SOURCE; - } else if (len == 3) { - if (strncmp(cmd, "ual", 3) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_UNSET_AUDIO_LOOPBACK; + } else if (strncmp(cmd, "ac", 2) == 0) { + _webrtc_add_ice_candidate(&g_conns[0], NULL); - } else if (strncmp(cmd, "uvl", 3) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_UNSET_VIDEO_LOOPBACK; + } else { + g_print("%s() > unknown menu[%s]\n", __FUNCTION__, cmd); + } +} + +static void change_menu_state_3(char *cmd) +{ + if (!cmd) + return; - } else if (strncmp(cmd, "sac", 3) == 0) { - int i; + if (strncmp(cmd, "ual", 3) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_UNSET_AUDIO_LOOPBACK; - _webrtc_set_error_cb(0); - _webrtc_set_state_changed_cb(0); - _webrtc_set_negotiation_needed_cb(0); - _webrtc_set_ice_candidate_cb(0); - _webrtc_set_track_added_cb(0); - _webrtc_set_data_channel_cb(0); - _webrtc_set_all_negotiation_state_change_cbs(0); + } else if (strncmp(cmd, "uvl", 3) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_UNSET_VIDEO_LOOPBACK; - for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++) { - if (g_conns[0].packet_sources[i].source_id > 0) - _webrtc_media_packet_source_set_buffer_state_changed_cb(0, g_conns[0].packet_sources[i].source_id); - } + } else if (strncmp(cmd, "sac", 3) == 0) { + int i; - } else if (strncmp(cmd, "san", 3) == 0) { - _webrtc_set_all_negotiation_state_change_cbs(0); + _webrtc_set_error_cb(0); + _webrtc_set_state_changed_cb(0); + _webrtc_set_negotiation_needed_cb(0); + _webrtc_set_ice_candidate_cb(0); + _webrtc_set_track_added_cb(0); + _webrtc_set_data_channel_cb(0); + _webrtc_set_all_negotiation_state_change_cbs(0); - } else if (strncmp(cmd, "uan", 3) == 0) { - _webrtc_unset_all_negotiation_state_change_cbs(0); + for (i = 0; i < MAX_MEDIA_PACKET_SOURCE_LEN; i++) { + if (g_conns[0].packet_sources[i].source_id > 0) + _webrtc_media_packet_source_set_buffer_state_changed_cb(0, g_conns[0].packet_sources[i].source_id); + } - } else if (strncmp(cmd, "gan", 3) == 0) { - _webrtc_get_all_negotiation_states(0); + } else if (strncmp(cmd, "san", 3) == 0) { + _webrtc_set_all_negotiation_state_change_cbs(0); - } else if (strncmp(cmd, "coa", 3) == 0) { - _webrtc_create_offer(&g_conns[0], true); + } else if (strncmp(cmd, "uan", 3) == 0) { + _webrtc_unset_all_negotiation_state_change_cbs(0); - } else if (strncmp(cmd, "caa", 3) == 0) { - _webrtc_create_answer(&g_conns[0], true); + } else if (strncmp(cmd, "gan", 3) == 0) { + _webrtc_get_all_negotiation_states(0); - } else if (strncmp(cmd, "sbp", 3) == 0) { - g_menu_state = CURRENT_STATUS_SET_BUNDLE_POLICY; + } else if (strncmp(cmd, "coa", 3) == 0) { + _webrtc_create_offer(&g_conns[0], true); - } else if (strncmp(cmd, "gbp", 3) == 0) { - _webrtc_get_bundle_policy(0); + } else if (strncmp(cmd, "caa", 3) == 0) { + _webrtc_create_answer(&g_conns[0], true); - } else if (strncmp(cmd, "stp", 3) == 0) { - g_menu_state = CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY; + } else if (strncmp(cmd, "sbp", 3) == 0) { + g_menu_state = CURRENT_STATUS_SET_BUNDLE_POLICY; - } else if (strncmp(cmd, "gtp", 3) == 0) { - _webrtc_get_ice_transport_policy(0); + } else if (strncmp(cmd, "gbp", 3) == 0) { + _webrtc_get_bundle_policy(0); - } else if (strncmp(cmd, "sdp", 3) == 0) { - g_menu_state = CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY; + } else if (strncmp(cmd, "stp", 3) == 0) { + g_menu_state = CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY; - } else if (strncmp(cmd, "gdp", 3) == 0) { - g_menu_state = CURRENT_STATUS_GET_RTP_PACKET_DROP_PROBABILITY; + } else if (strncmp(cmd, "gtp", 3) == 0) { + _webrtc_get_ice_transport_policy(0); - } else if (strncmp(cmd, "ssc", 3) == 0) { - g_menu_state = CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER; + } else if (strncmp(cmd, "sdp", 3) == 0) { + g_menu_state = CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY; - } else if (strncmp(cmd, "ssd", 3) == 0) { - _webrtc_signaling_server_destroy(); + } else if (strncmp(cmd, "gdp", 3) == 0) { + g_menu_state = CURRENT_STATUS_GET_RTP_PACKET_DROP_PROBABILITY; - } else if (strncmp(cmd, "sss", 3) == 0) { - _webrtc_signaling_server_start(); + } else if (strncmp(cmd, "ssc", 3) == 0) { + g_menu_state = CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER; - } else if (strncmp(cmd, "sst", 3) == 0) { - _webrtc_signaling_server_stop(); + } else if (strncmp(cmd, "ssd", 3) == 0) { + _webrtc_signaling_server_destroy(); - } else if (strncmp(cmd, "scc", 3) == 0) { - g_menu_state = CURRENT_STATUS_CONNECT_TO_PRIVATE_SIGNALING_SERVER; + } else if (strncmp(cmd, "sss", 3) == 0) { + _webrtc_signaling_server_start(); - } else if (strncmp(cmd, "scd", 3) == 0) { - _webrtc_signaling_disconnect(); + } else if (strncmp(cmd, "sst", 3) == 0) { + _webrtc_signaling_server_stop(); - } else if (strncmp(cmd, "scs", 3) == 0) { - g_menu_state = CURRENT_STATUS_SET_CROP_SCREEN_SOURCE; + } else if (strncmp(cmd, "scc", 3) == 0) { + g_menu_state = CURRENT_STATUS_CONNECT_TO_PRIVATE_SIGNALING_SERVER; - } else if (strncmp(cmd, "ucs", 3) == 0) { - g_menu_state = CURRENT_STATUS_UNSET_CROP_SCREEN_SOURCE; + } else if (strncmp(cmd, "scd", 3) == 0) { + _webrtc_signaling_disconnect(); - } else if (strncmp(cmd, "sfl", 3) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_FILE_LOOPING; + } else if (strncmp(cmd, "scs", 3) == 0) { + g_menu_state = CURRENT_STATUS_SET_CROP_SCREEN_SOURCE; - } else if (strncmp(cmd, "gfl", 3) == 0) { - g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_FILE_LOOPING; + } else if (strncmp(cmd, "ucs", 3) == 0) { + g_menu_state = CURRENT_STATUS_UNSET_CROP_SCREEN_SOURCE; - } else if (strncmp(cmd, "sbc", 3) == 0) { - g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SET_BUFFERED_AMOUNT_LOW_CB; + } else if (strncmp(cmd, "sfl", 3) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_FILE_LOOPING; - } else if (strncmp(cmd, "gbt", 3) == 0) { - _webrtc_data_channel_get_buffered_amount_low_threshold(0); + } else if (strncmp(cmd, "gfl", 3) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_FILE_LOOPING; - } else if (strncmp(cmd, "ubc", 3) == 0) { - _webrtc_data_channel_unset_buffered_amount_low_cb(0); + } else if (strncmp(cmd, "sbc", 3) == 0) { + g_menu_state = CURRENT_STATUS_DATA_CHANNEL_SET_BUFFERED_AMOUNT_LOW_CB; - } else if (strncmp(cmd, "sts", 3) == 0) { - _webrtc_foreach_stats(0); + } else if (strncmp(cmd, "gbt", 3) == 0) { + _webrtc_data_channel_get_buffered_amount_low_threshold(0); - } else { - g_print("unknown menu \n"); - } + } else if (strncmp(cmd, "ubc", 3) == 0) { + _webrtc_data_channel_unset_buffered_amount_low_cb(0); + + } else if (strncmp(cmd, "sts", 3) == 0) { + _webrtc_foreach_stats(0); } else { - g_print("unknown menu \n"); + g_print("%s() > unknown menu[%s]\n", __FUNCTION__, cmd); + } +} + +static void interpret_main_menu_cmd(char *cmd) +{ + int len; + + if (!cmd) + return; + + len = strlen(cmd); + + switch (len) { + case 0: + /* '\0' case */ + break; + case 1: + change_menu_state_1(cmd); + break; + case 2: + change_menu_state_2(cmd); + break; + case 3: + change_menu_state_3(cmd); + break; + default: + g_print("%s() > unknown menu[%s]\n", __FUNCTION__, cmd); + break; } } @@ -4957,9 +4992,12 @@ static void interpret(char *cmd) { int value; + if (!cmd) + return; + switch (g_menu_state) { case CURRENT_STATUS_MAINMENU: - _interpret_main_menu(cmd); + interpret_main_menu_cmd(cmd); break; case CURRENT_STATUS_ADD_MEDIA_SOURCE: { value = atoi(cmd);