From: Sangchul Lee Date: Wed, 20 Apr 2022 03:51:03 +0000 (+0900) Subject: webrtc_stats: Fix invalid bitwise value of stats type X-Git-Tag: submit/tizen/20220426.020921~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eaccdf48d932e95e211beb01ec66f72b918d5a89;p=platform%2Fcore%2Fapi%2Fwebrtc.git webrtc_stats: Fix invalid bitwise value of stats type 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 --- diff --git a/include/webrtc.h b/include/webrtc.h index aeece6b4..9863fc34 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -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. diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 807992ce..7f4db430 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.89 +Version: 0.3.90 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc_stats.c b/src/webrtc_stats.c index b81501d1..90b33248 100644 --- a/src/webrtc_stats.c +++ b/src/webrtc_stats.c @@ -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[] = { diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 9854ed1b..3925df83 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -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); }