webrtc_stats: Fix invalid bitwise value of stats type 07/274007/2
authorSangchul Lee <sc11.lee@samsung.com>
Wed, 20 Apr 2022 03:51:03 +0000 (12:51 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 20 Apr 2022 04:03:42 +0000 (13:03 +0900)
Type selection is added to the test case for
webrtc_foreach_stats().

[Version] 0.3.90
[Issue Type] Bug fix

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

index aeece6b47891466e1e3f6abed11cb58859a2f3a1..9863fc341ccd6ef4746b07873279c956198a5941 100644 (file)
@@ -282,7 +282,7 @@ typedef enum {
        WEBRTC_STATS_TYPE_INBOUND_RTP          = 0x0002,   /**< Inbound RTP */
        WEBRTC_STATS_TYPE_OUTBOUND_RTP         = 0x0004,   /**< Outbound RTP */
        WEBRTC_STATS_TYPE_REMOTE_INBOUND_RTP   = 0x0008,   /**< Remote inbound RTP */
-       WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP  = 0x000F    /**< Remote outbound RTP */
+       WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP  = 0x0010    /**< Remote outbound RTP */
 } webrtc_stats_type_e;
 
 /**
@@ -335,7 +335,7 @@ typedef enum {
  * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcinboundrtpstreamstats.
  * @see webrtc_stats_prop_e
  */
-#define WEBRTC_STATS_INBOUND_RTP_STREAM    0x00000F00
+#define WEBRTC_STATS_INBOUND_RTP_STREAM    0x00001000
 
 /**
  * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC sent RTP stream stats.
@@ -343,7 +343,7 @@ typedef enum {
  * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcsentrtpstreamstats.
  * @see webrtc_stats_prop_e
  */
-#define WEBRTC_STATS_SENT_RTP_STREAM    0x00001000
+#define WEBRTC_STATS_SENT_RTP_STREAM    0x00002000
 
 /**
  * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC outbound RTP stream stats.
@@ -351,7 +351,7 @@ typedef enum {
  * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcoutboundrtpstreamstats.
  * @see webrtc_stats_prop_e
  */
-#define WEBRTC_STATS_OUTBOUND_RTP_STREAM    0x00002000
+#define WEBRTC_STATS_OUTBOUND_RTP_STREAM    0x00004000
 
 /**
  * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC remote inbound RTP stream stats.
@@ -359,7 +359,7 @@ typedef enum {
  * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteinboundrtpstreamstats.
  * @see webrtc_stats_prop_e
  */
-#define WEBRTC_STATS_REMOTE_INBOUND_RTP_STREAM    0x00004000
+#define WEBRTC_STATS_REMOTE_INBOUND_RTP_STREAM    0x00008000
 
 /**
  * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC remote outbound RTP stream stats.
@@ -367,7 +367,7 @@ typedef enum {
  * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats.
  * @see webrtc_stats_prop_e
  */
-#define WEBRTC_STATS_REMOTE_OUTBOUND_RTP_STREAM    0x00008000
+#define WEBRTC_STATS_REMOTE_OUTBOUND_RTP_STREAM    0x00010000
 
 /**
  * @brief Enumeration for WebRTC statistics property.
index 807992ce67ce157a7831581d5307f9cc90db41a3..7f4db4306dc2acef0c17ddc873be52deb1e735e6 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.89
+Version:    0.3.90
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index b81501d13c3266b3c3199ce8f827a4f81cbb8511..90b33248be9468a414c6baabd55e79380887e731 100644 (file)
@@ -625,11 +625,11 @@ typedef struct {
 #define WEBRTC_STATS_TYPE_CSRC                 0x0020   /**< CSRC */
 #define WEBRTC_STATS_TYPE_DATA_CHANNEL         0x0040   /**< Data Channel */
 #define WEBRTC_STATS_TYPE_STREAM               0x0080   /**< Stream */
-#define WEBRTC_STATS_TYPE_TRANSPORT            0x00F0   /**< Transport */
-#define WEBRTC_STATS_TYPE_CANDIDATE_PAIR       0x0100   /**< Candidate Pair */
-#define WEBRTC_STATS_TYPE_LOCAL_CANDIDATE      0x0200   /**< Local Candidate */
-#define WEBRTC_STATS_TYPE_REMOTE_CANDIDATE     0x0400   /**< Remote Candidate */
-#define WEBRTC_STATS_TYPE_CERTIFICATE          0x0800   /**< Certificate */
+#define WEBRTC_STATS_TYPE_TRANSPORT            0x0100   /**< Transport */
+#define WEBRTC_STATS_TYPE_CANDIDATE_PAIR       0x0200   /**< Candidate Pair */
+#define WEBRTC_STATS_TYPE_LOCAL_CANDIDATE      0x0400   /**< Local Candidate */
+#define WEBRTC_STATS_TYPE_REMOTE_CANDIDATE     0x0800   /**< Remote Candidate */
+#define WEBRTC_STATS_TYPE_CERTIFICATE          0x1000   /**< Certificate */
 
 /* Refer to GstWebRTCStatsType of webrtc_fwd.h */
 static parse_stats_s parse_stats[] = {
index 9854ed1b2ae3cd06c14f39ddc629f1b51500d77d..3925df83543a003be4f29f28dd9fb52183b3786a 100644 (file)
@@ -65,7 +65,8 @@ do { \
 #define TEST_MENU_WEBRTC_MEDIA_SOURCE   0x00002000
 #define TEST_MENU_WEBRTC_MEDIA_RENDER   0x00004000
 #define TEST_MENU_WEBRTC_DATA_CHANNEL   0x00008000
-#define TEST_MENU_APP_SIGNALING         0x00010000
+#define TEST_MENU_WEBRTC_STATS          0x00010000
+#define TEST_MENU_APP_SIGNALING         0x00020000
 
 enum {
        CURRENT_STATUS_MAINMENU,
@@ -116,6 +117,8 @@ enum {
        CURRENT_STATUS_DATA_CHANNEL_SEND_STRING_AS_BYTES = TEST_MENU_WEBRTC_DATA_CHANNEL | 0x02,
        CURRENT_STATUS_DATA_CHANNEL_SEND_FILE = TEST_MENU_WEBRTC_DATA_CHANNEL | 0x03,
        CURRENT_STATUS_DATA_CHANNEL_SET_BUFFERED_AMOUNT_LOW_CB = TEST_MENU_WEBRTC_DATA_CHANNEL | 0x04,
+       /* webrtc stats */
+       CURRENT_STATUS_FOREACH_STATS = TEST_MENU_WEBRTC_STATS | 0x01,
        /* app. setting & signaling */
        CURRENT_STATUS_SETTING_SIGNALING_SERVER = TEST_MENU_APP_SIGNALING | 0x01,
        CURRENT_STATUS_SETTING_PROXY = TEST_MENU_APP_SIGNALING | 0x02,
@@ -1882,11 +1885,30 @@ static bool __stats_cb(webrtc_stats_type_e type, const webrtc_stats_prop_info_s
        return true;
 }
 
-static void _webrtc_foreach_stats(int index)
+static void _webrtc_foreach_stats(int index, int selected)
 {
        int ret = WEBRTC_ERROR_NONE;
+       int type_mask;
 
-       ret = webrtc_foreach_stats(g_conns[index].webrtc, WEBRTC_STATS_TYPE_ALL, __stats_cb, NULL);
+       switch (selected) {
+       case 1: /* all */
+               type_mask = WEBRTC_STATS_TYPE_ALL;
+               break;
+       case 2: /* codec */
+               type_mask = WEBRTC_STATS_TYPE_CODEC;
+               break;
+       case 3: /* inbound-rtp + remote-outbound-rtp */
+               type_mask = WEBRTC_STATS_TYPE_INBOUND_RTP | WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP;
+               break;
+       case 4: /* outbound-rtp + remote-inbound-rtp */
+               type_mask = WEBRTC_STATS_TYPE_OUTBOUND_RTP | WEBRTC_STATS_TYPE_REMOTE_INBOUND_RTP;
+               break;
+       default:
+               g_printerr("invalid selected value[%d]\n", selected);
+               return;
+       }
+
+       ret = webrtc_foreach_stats(g_conns[index].webrtc, type_mask, __stats_cb, NULL);
        if (ret != WEBRTC_ERROR_NONE)
                g_print("failed to webrtc_foreach_stats(), index[%d]\n", index);
        else
@@ -4472,7 +4494,7 @@ static void change_menu_state_3(char *cmd)
                _webrtc_data_channel_unset_buffered_amount_low_cb(0);
 
        } else if (strncmp(cmd, "sts", 3) == 0) {
-               _webrtc_foreach_stats(0);
+               g_menu_state = CURRENT_STATUS_FOREACH_STATS;
 
        } else {
                g_print("%s() > unknown menu[%s]\n", __FUNCTION__, cmd);
@@ -4869,6 +4891,16 @@ static void display_menu_webrtc_data_channel(void)
        }
 }
 
+static void display_menu_webrtc_stats(void)
+{
+       switch (g_menu_state) {
+       case CURRENT_STATUS_FOREACH_STATS:
+               if (g_cnt == 0)
+                       g_print("*** input stats type.(1:all, 2:codec, 3:inbound-rtp/remote-outbound-rtp, 4:outbound-rtp/remote-inbound-rtp)\n");
+               break;
+       }
+}
+
 static void display_menu_app_signaling(void)
 {
        switch (g_menu_state) {
@@ -4920,6 +4952,9 @@ static void displaymenu(void)
                } else if (g_menu_state & TEST_MENU_WEBRTC_DATA_CHANNEL) {
                        display_menu_webrtc_data_channel();
 
+               } else if (g_menu_state & TEST_MENU_WEBRTC_STATS) {
+                       display_menu_webrtc_stats();
+
                } else if (g_menu_state & TEST_MENU_APP_SIGNALING) {
                        display_menu_app_signaling();
 
@@ -5431,6 +5466,17 @@ static void test_webrtc_data_channel(char *cmd)
        }
 }
 
+static void test_webrtc_stats(char *cmd)
+{
+       switch (g_menu_state) {
+       case CURRENT_STATUS_FOREACH_STATS: {
+               _webrtc_foreach_stats(0, atoi(cmd));
+               reset_menu_state();
+               break;
+       }
+       }
+}
+
 static void app_setting_and_signaling(char *cmd)
 {
        int value;
@@ -5541,6 +5587,9 @@ static void interpret(char *cmd)
                else if (g_menu_state & TEST_MENU_WEBRTC_DATA_CHANNEL)
                        test_webrtc_data_channel(cmd);
 
+               else if (g_menu_state & TEST_MENU_WEBRTC_STATS)
+                       test_webrtc_stats(cmd);
+
                else if (g_menu_state & TEST_MENU_APP_SIGNALING)
                        app_setting_and_signaling(cmd);
        }