webrtc_test: Add menu to set/get RTP packet drop probability 05/268205/6
authorSangchul Lee <sc11.lee@samsung.com>
Fri, 17 Dec 2021 04:43:28 +0000 (13:43 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Thu, 23 Dec 2021 03:49:31 +0000 (12:49 +0900)
sdp. Set RTP packet drop probability
gdp. Get RTP packet drop probability

[Version] 0.3.29
[Issue Type] New feature

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

index a4bdd979a2fce164dd0ae6d31a4b9618ee6f9231..a4e4faa002f2b50f69f319ff6ef231182c2169fc 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.28
+Version:    0.3.29
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index 413ae4b209c06c18122d0f6531d3f71233abc150..d9a49f716d385dc43961e051f469dcdc98e9a701 100644 (file)
@@ -91,6 +91,8 @@ enum {
        CURRENT_STATUS_SET_ICE_TRANSPORT_POLICY,
        CURRENT_STATUS_SET_LOCAL_DESCRIPTION,
        CURRENT_STATUS_SET_REMOTE_DESCRIPTION,
+       CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY,
+       CURRENT_STATUS_GET_RTP_PACKET_DROP_PROBABILITY,
        CURRENT_STATUS_SETTING_SIGNALING_SERVER,
        CURRENT_STATUS_SETTING_PROXY,
        CURRENT_STATUS_REQUEST_SESSION,
@@ -1431,6 +1433,27 @@ static void _webrtc_get_ice_transport_policy(int index)
        g_print("webrtc_get_ice_transport_policy() success, policy[%d]\n", policy);
 }
 
+static void _webrtc_set_rtp_packet_drop_probability(bool sender, float probability)
+{
+       int ret = WEBRTC_ERROR_NONE;
+
+       ret = webrtc_set_rtp_packet_drop_probability(g_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);
+}
+
+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_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);
+}
+
 static char * __get_channel_label(webrtc_data_channel_h channel)
 {
        int ret = WEBRTC_ERROR_NONE;
@@ -4021,6 +4044,12 @@ void _interpret_main_menu(char *cmd)
                } else if (strncmp(cmd, "gtp", 3) == 0) {
                        _webrtc_get_ice_transport_policy(0);
 
+               } else if (strncmp(cmd, "sdp", 3) == 0) {
+                       g_menu_state = CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY;
+
+               } else if (strncmp(cmd, "gdp", 3) == 0) {
+                       g_menu_state = CURRENT_STATUS_GET_RTP_PACKET_DROP_PROBABILITY;
+
                } else if (strncmp(cmd, "ssc", 3) == 0) {
                        g_menu_state = CURRENT_STATUS_CREATE_PRIVATE_SIGNALING_SERVER;
 
@@ -4146,6 +4175,8 @@ void display_sub_basic()
        g_print("ual. Unset audio loopback\n");
        g_print("vl. Set video loopback\t");
        g_print("uvl. Unset video loopback\n");
+       g_print("sdp. *Set RTP packet drop probability\t");
+       g_print("gdp. *Get RTP packet drop probability\n");
        g_print("------------------------------------- Data Channel --------------------------------------\n");
        g_print("cd. Create data channel\t");
        g_print("dd. Destroy data channel\n");
@@ -4363,6 +4394,16 @@ static void displaymenu()
        } else if (g_menu_state == CURRENT_STATUS_SET_LOCAL_DESCRIPTION) {
                g_print("*** input type of local description.(1:offer, 2:answer)\n");
 
+       } else if (g_menu_state == CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY) {
+               if (g_cnt == 0)
+                       g_print("*** input side.(1:sender, 2:receiver)\n");
+               else if (g_cnt == 1)
+                       g_print("*** input drop probability.(0 ~ 1.0)\n");
+
+       } else if (g_menu_state == CURRENT_STATUS_GET_RTP_PACKET_DROP_PROBABILITY) {
+               if (g_cnt == 0)
+                       g_print("*** input side.(1:sender, 2:receiver)\n");
+
        } else if (g_menu_state == CURRENT_STATUS_SETTING_SIGNALING_SERVER) {
                g_print("*** input signaling server URL.\n");
 
@@ -4717,6 +4758,41 @@ static void interpret(char *cmd)
                reset_menu_state();
                break;
        }
+       case CURRENT_STATUS_SET_RTP_PACKET_DROP_PROBABILITY: {
+               static bool sender;
+               switch (g_cnt) {
+               case 0:
+                       value = atoi(cmd);
+                       if (value != 1 && value != 2) {
+                               g_print("invalid value[%d]\n", value);
+                               reset_menu_state();
+                               break;
+                       }
+                       sender = (value == 1);
+                       g_cnt++;
+                       break;
+               case 1: {
+                       float fvalue = strtof(cmd, NULL);
+                       _webrtc_set_rtp_packet_drop_probability(sender, fvalue);
+                       sender = false;
+                       g_cnt = 0;
+                       reset_menu_state();
+                       break;
+               }
+               }
+               break;
+       }
+       case CURRENT_STATUS_GET_RTP_PACKET_DROP_PROBABILITY: {
+               value = atoi(cmd);
+               if (value != 1 && value != 2) {
+                       g_print("invalid value[%d]\n", value);
+                       reset_menu_state();
+                       break;
+               }
+               _webrtc_get_rtp_packet_drop_probability((value == 1));
+               reset_menu_state();
+               break;
+       }
        case CURRENT_STATUS_SETTING_SIGNALING_SERVER: {
                _setting_uri(g_signaling_server.url, cmd);
                reset_menu_state();