Add new statistics type for 'outbound-rtp' 86/272686/3
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 22 Mar 2022 12:29:09 +0000 (21:29 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 25 Mar 2022 01:29:11 +0000 (10:29 +0900)
New statistics type is added as below.
 - WEBRTC_STATS_TYPE_OUTBOUND_RTP

Property enums are added as below for this type
 - WEBRTC_STATS_PROP_BYTES_SENT
 - WEBRTC_STATS_PROP_PACKETS_SENT

[Version] 0.3.72
[Issue Type] API

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

index 1c00f8cfea0c7d6dda2055f43255a017f5d78507..ae3ed1abe28eb424a3c35559d40e2c8f0ab8ca6a 100644 (file)
@@ -280,6 +280,7 @@ typedef enum {
 typedef enum {
        WEBRTC_STATS_TYPE_CODEC                = 0x0001,   /**< Codec */
        WEBRTC_STATS_TYPE_INBOUND_RTP          = 0x0002,   /**< Inbound RTP */
+       WEBRTC_STATS_TYPE_OUTBOUND_RTP         = 0x0004    /**< Outbound RTP */
 } webrtc_stats_type_e;
 
 /**
@@ -289,7 +290,8 @@ typedef enum {
  */
 #define WEBRTC_STATS_TYPE_ALL \
        WEBRTC_STATS_TYPE_CODEC | \
-       WEBRTC_STATS_TYPE_INBOUND_RTP
+       WEBRTC_STATS_TYPE_INBOUND_RTP | \
+       WEBRTC_STATS_TYPE_OUTBOUND_RTP
 
 /**
  * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC stats.
@@ -331,6 +333,22 @@ typedef enum {
  */
 #define WEBRTC_STATS_INBOUND_RTP_STREAM    0x00000F00
 
+/**
+ * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC sent RTP stream stats.
+ * @since_tizen 7.0
+ * @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
+
+/**
+ * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC outbound RTP stream stats.
+ * @since_tizen 7.0
+ * @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
+
 /**
  * @brief Enumeration for WebRTC statistics property.
  * @since_tizen 7.0
@@ -351,12 +369,14 @@ typedef enum {
        WEBRTC_STATS_PROP_PACKETS_LOST       = WEBRTC_STATS_RECEIVED_RTP_STREAM | 0x02, /**< Packets lost */
        WEBRTC_STATS_PROP_PACKETS_DISCARDED  = WEBRTC_STATS_RECEIVED_RTP_STREAM | 0x03, /**< Packets discarded */
        WEBRTC_STATS_PROP_JITTER             = WEBRTC_STATS_RECEIVED_RTP_STREAM | 0x05, /**< Jitter */
-       WEBRTC_STATS_PROP_REMOTE_ID          = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x01, /**< Remote id */
-       WEBRTC_STATS_PROP_BYTES_RECEIVED     = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x02, /**< Bytes received */
-       WEBRTC_STATS_PROP_PACKETS_DUPLICATED = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x03, /**< Packets duplicated */
-       WEBRTC_STATS_PROP_FIR_COUNT          = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x04, /**< FIR packets */
-       WEBRTC_STATS_PROP_PLI_COUNT          = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x05, /**< PLI packets */
-       WEBRTC_STATS_PROP_NACK_COUNT         = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x06, /**< NACK packets */
+       WEBRTC_STATS_PROP_BYTES_RECEIVED     = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x01, /**< Bytes received */
+       WEBRTC_STATS_PROP_PACKETS_DUPLICATED = WEBRTC_STATS_INBOUND_RTP_STREAM | 0x02, /**< Packets duplicated */
+       WEBRTC_STATS_PROP_BYTES_SENT         = WEBRTC_STATS_SENT_RTP_STREAM | 0x01, /**< Bytes sent */
+       WEBRTC_STATS_PROP_PACKETS_SENT       = WEBRTC_STATS_SENT_RTP_STREAM | 0x02, /**< Packets sent */
+       WEBRTC_STATS_PROP_REMOTE_ID          = WEBRTC_STATS_INBOUND_RTP_STREAM | WEBRTC_STATS_OUTBOUND_RTP_STREAM | 0x01, /**< Remote id */
+       WEBRTC_STATS_PROP_FIR_COUNT          = WEBRTC_STATS_INBOUND_RTP_STREAM | WEBRTC_STATS_OUTBOUND_RTP_STREAM | 0x02, /**< FIR packets */
+       WEBRTC_STATS_PROP_PLI_COUNT          = WEBRTC_STATS_INBOUND_RTP_STREAM | WEBRTC_STATS_OUTBOUND_RTP_STREAM | 0x03, /**< PLI packets */
+       WEBRTC_STATS_PROP_NACK_COUNT         = WEBRTC_STATS_INBOUND_RTP_STREAM | WEBRTC_STATS_OUTBOUND_RTP_STREAM | 0x04, /**< NACK packets */
 } webrtc_stats_prop_e;
 
 /**
index 113ec52dd5beafd6c9a0342d8c1c2d1e48818eae..6e0a4034aba1fb826e4d494009376c3dd7c3f51a 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-webrtc
 Summary:    A WebRTC library in Tizen Native API
-Version:    0.3.71
+Version:    0.3.72
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
index a8f2498e0e4ab2dae9e76b3029ba71a853dd393e..7b92da18b5cb856422d52573f18f84e7165ab115 100644 (file)
@@ -129,8 +129,8 @@ static stats_field_s __stats_inbound_rtp_stream_fields[] = {
  *  "bytes-sent"          G_TYPE_UINT64               number of packets sent (only for local outbound)
  */
 static stats_field_s __stats_sent_rtp_stream_fields[] = {
-       { "packets-sent", WEBRTC_STATS_PROP_NOT_EXPORTED, 0 },
-       { "bytes-sent", WEBRTC_STATS_PROP_NOT_EXPORTED, 0 },
+       { "packets-sent", WEBRTC_STATS_PROP_PACKETS_SENT, 0 },
+       { "bytes-sent", WEBRTC_STATS_PROP_BYTES_SENT, 0 },
        { NULL, 0, 0 }
 };
 
@@ -139,9 +139,15 @@ static stats_field_s __stats_sent_rtp_stream_fields[] = {
  * RTCOutboundRTPStreamStats supported fields (https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*)
  *
  *  "remote-id"           G_TYPE_STRING               identifier for the associated RTCRemoteInboundRTPSTreamStats
+ *  "fir-count"           G_TYPE_UINT                 FIR packets received by the sender
+ *  "pli-count"           G_TYPE_UINT                 PLI packets received by the sender
+ *  "nack-count"          G_TYPE_UINT                 NACK packets received by the sender
  */
 static stats_field_s __stats_outbound_rtp_stream_fields[] = {
-       { "remote-id", WEBRTC_STATS_PROP_NOT_EXPORTED, 0 },
+       { "remote-id", WEBRTC_STATS_PROP_REMOTE_ID, 0 },
+       { "fir-count", WEBRTC_STATS_PROP_FIR_COUNT, 0 },
+       { "pli-count", WEBRTC_STATS_PROP_PLI_COUNT, 0 },
+       { "nack-count", WEBRTC_STATS_PROP_NACK_COUNT, 0 },
        { NULL, 0, 0 }
 };
 
@@ -473,7 +479,7 @@ static void __stats_inbound_rtp_invoke_callback(const GstStructure *s, webrtc_st
 
 static void __stats_outbound_rtp_invoke_callback(const GstStructure *s, webrtc_stats_type_e type, stats_field_s **fields_list, promise_userdata_s *user_data)
 {
-       stats_userdata_s stats_userdata = { .p_userdata = user_data, .type = type, .fields_list = fields_list };
+       stats_userdata_s stats_userdata = { .p_userdata = user_data, .type = type, .fields_list = fields_list, .export = true };
        GstStructure *rtpsource_stats;
 
        RET_IF(user_data == NULL, "user_data is NULL");
@@ -482,6 +488,7 @@ static void __stats_outbound_rtp_invoke_callback(const GstStructure *s, webrtc_s
 
        gst_structure_foreach(s, __stats_field_foreach_cb, &stats_userdata);
 
+       stats_userdata.export = false; /* to skip invoking callback stats below */
        gst_structure_get(s, "gst-rtpsource-stats", GST_TYPE_STRUCTURE, &rtpsource_stats, NULL);
        LOG_DEBUG("gst-rtpsource-stats ---> ");
        gst_structure_foreach(rtpsource_stats, __stats_field_foreach_cb, &stats_userdata);
@@ -614,7 +621,6 @@ typedef struct {
 } parse_stats_s;
 
 /* Definitions below are not exported types due to the incompletion. */
-#define WEBRTC_STATS_TYPE_OUTBOUND_RTP         0x0004   /**< Outbound RTP */
 #define WEBRTC_STATS_TYPE_REMOTE_INBOUND_RTP   0x0008   /**< Remote Inbound RTP */
 #define WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP  0x000F   /**< Remote Outbound RTP */
 #define WEBRTC_STATS_TYPE_PEER_CONNECTION      0x0010   /**< Peer Connection */