From 527af9f7f723418d4ad005a2ef88c6d2050837f5 Mon Sep 17 00:00:00 2001 From: Sangchul Lee Date: Fri, 14 Jan 2022 18:55:52 +0900 Subject: [PATCH] webrtc_test: Add test cases for bundle policy and video frame rate Menu items below are added. f. Set video framerate m. Get video framerate sbp. Set bundle policy gbp. Get bundle policy [Version] 0.3.46 [Issue Type] Add Change-Id: I9a147947a86e340726734e58b565f20d8c12cc69 Signed-off-by: Sangchul Lee --- packaging/capi-media-webrtc.spec | 2 +- test/webrtc_test.c | 105 +++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index af6b2af1..76faf892 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.45 +Version: 0.3.46 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 2bef9453..513e4490 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -71,6 +71,8 @@ enum { CURRENT_STATUS_MEDIA_SOURCE_GET_PAUSE, CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_RESOLUTION, CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_RESOLUTION, + CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_FRAMERATE, + CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_FRAMERATE, CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_BUFFER_STATE_CHANGED_CB, CURRENT_STATUS_MEDIA_PACKET_SOURCE_UNSET_BUFFER_STATE_CHANGED_CB, CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_FORMAT, @@ -89,6 +91,7 @@ enum { CURRENT_STATUS_DATA_CHANNEL_SET_BUFFERED_AMOUNT_LOW_CB, CURRENT_STATUS_SET_STUN_SERVER, CURRENT_STATUS_ADD_TURN_SERVER, + CURRENT_STATUS_SET_BUNDLE_POLICY, CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY, CURRENT_STATUS_SET_LOCAL_DESCRIPTION, CURRENT_STATUS_SET_REMOTE_DESCRIPTION, @@ -883,6 +886,27 @@ static void _webrtc_media_source_get_video_resolution(int index, unsigned int so g_print("webrtc_media_source_get_video_resolution() success, source_id[%u], [%dx%d]\n", source_id, width, height); } +static void _webrtc_media_source_set_video_framerate(int index, unsigned int source_id, int framerate) +{ + int ret = WEBRTC_ERROR_NONE; + + ret = webrtc_media_source_set_video_framerate(g_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); +} + +static void _webrtc_media_source_get_video_framerate(int index, unsigned int source_id) +{ + int ret = WEBRTC_ERROR_NONE; + int framerate; + + ret = webrtc_media_source_get_video_framerate(g_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); +} + #define VIDEO_WIDTH 320 #define VIDEO_HEIGHT 240 #define VIDEO_FRAME_RATE 30 @@ -1436,6 +1460,27 @@ static void _webrtc_get_turn_servers(int index) g_print("webrtc_foreach_turn_server() success\n"); } +static void _webrtc_set_bundle_policy(int index, int policy) +{ + int ret = 0; + + ret = webrtc_set_bundle_policy(g_conns[index].webrtc, policy); + RET_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret); + + g_print("webrtc_set_bundle_policy() success\n"); +} + +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_IF(ret != WEBRTC_ERROR_NONE, "ret[0x%x]", ret); + + g_print("webrtc_get_bundle_policy() success, policy[%d]\n", policy); +} + static void _webrtc_set_ice_transport_policy(int index, int policy) { int ret = 0; @@ -4137,6 +4182,12 @@ void _interpret_main_menu(char *cmd) } else if (strncmp(cmd, "l", 1) == 0) { g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_RESOLUTION; + } else if (strncmp(cmd, "f", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_FRAMERATE; + + } else if (strncmp(cmd, "m", 1) == 0) { + g_menu_state = CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_FRAMERATE; + } else if (strncmp(cmd, "s", 1) == 0) { _webrtc_start(0); @@ -4361,6 +4412,12 @@ void _interpret_main_menu(char *cmd) } else if (strncmp(cmd, "caa", 3) == 0) { _webrtc_create_answer(&g_conns[0], true); + } else if (strncmp(cmd, "sbp", 3) == 0) { + g_menu_state = CURRENT_STATUS_SET_BUNDLE_POLICY; + + } else if (strncmp(cmd, "gbp", 3) == 0) { + _webrtc_get_bundle_policy(0); + } else if (strncmp(cmd, "stp", 3) == 0) { g_menu_state = CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY; @@ -4490,6 +4547,8 @@ void display_sub_basic() g_print("mu. Mute media source\n"); g_print("v. Set video resolution\t"); g_print("l. Get video resolution\n"); + g_print("f. Set video framerate\t"); + g_print("m. Get video framerate\n"); g_print("td. Set transceiver direction\t"); g_print("gd. Get transceiver direction\n"); g_print("scs. *Set crop screen source\t"); @@ -4548,6 +4607,8 @@ void display_sub_basic() g_print("gt. Get STUN server\n"); g_print("su. Add TURN server\t"); g_print("gu. Get TURN servers\n"); + g_print("sbp. Set bundle policy\t"); + g_print("gbp. Get bundle policy\n"); g_print("stp. Set ICE transport policy\t"); g_print("gtp. Get ICE transport policy\n"); g_print("co. Create offer\t"); @@ -4614,6 +4675,15 @@ static void displaymenu() } else if (g_menu_state == CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_RESOLUTION) { g_print("*** input source id.\n"); + } else if (g_menu_state == CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_FRAMERATE) { + if (g_cnt == 0) + g_print("*** input source id.\n"); + else if (g_cnt == 1) + g_print("*** input framerate.\n"); + + } else if (g_menu_state == CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_FRAMERATE) { + g_print("*** input source id.\n"); + } else if (g_menu_state == CURRENT_STATUS_MEDIA_PACKET_SOURCE_SET_BUFFER_STATE_CHANGED_CB) { g_print("*** input media packet source id to set buffer state changed callback.\n"); @@ -4728,6 +4798,9 @@ static void displaymenu() } else if (g_menu_state == CURRENT_STATUS_ADD_TURN_SERVER) { g_print("*** input TURN server address.\n"); + } else if (g_menu_state == CURRENT_STATUS_SET_BUNDLE_POLICY) { + g_print("*** input bundle policy.(0:none, 1:max-bundle)\n"); + } else if (g_menu_state == CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY) { g_print("*** input ICE transport policy.(0:all, 1:relay)\n"); @@ -4896,6 +4969,32 @@ static void interpret(char *cmd) } break; } + case CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_FRAMERATE: { + value = atoi(cmd); + _webrtc_media_source_get_video_framerate(0, value); + reset_menu_state(); + break; + } + case CURRENT_STATUS_MEDIA_SOURCE_SET_VIDEO_FRAMERATE: { + static unsigned int id; + static int framerate; + value = atoi(cmd); + + switch (g_cnt) { + case 0: + id = value; + g_cnt++; + break; + case 1: + framerate = value; + _webrtc_media_source_set_video_framerate(0, id, framerate); + id = framerate = 0; + g_cnt = 0; + reset_menu_state(); + break; + } + break; + } case CURRENT_STATUS_MEDIA_SOURCE_GET_VIDEO_RESOLUTION: { value = atoi(cmd); _webrtc_media_source_get_video_resolution(0, value); @@ -5085,6 +5184,12 @@ static void interpret(char *cmd) reset_menu_state(); break; } + case CURRENT_STATUS_SET_BUNDLE_POLICY: { + value = atoi(cmd); + _webrtc_set_bundle_policy(0, value); + reset_menu_state(); + break; + } case CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY: { value = atoi(cmd); _webrtc_set_ice_transport_policy(0, value); -- 2.34.1