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;
/**
* @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.
* @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.
* @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.
* @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.
* @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.
#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[] = {
#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,
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,
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
_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);
}
}
+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) {
} 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();
}
}
+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;
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);
}