From: Sangchul Lee Date: Fri, 3 Feb 2023 11:24:21 +0000 (+0900) Subject: Add new stats types X-Git-Tag: accepted/tizen/unified/20230322.080551~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F287745%2F8;p=platform%2Fcore%2Fapi%2Fwebrtc.git Add new stats types new enums are added as below. for webrtc_stats_type_e : WEBRTC_STATS_TYPE_CANDIDATE_PAIR : WEBRTC_STATS_TYPE_LOCAL_CANDIDATE : WEBRTC_STATS_TYPE_REMOTE_CANDIDATE for webrtc_stats_prop_e : WEBRTC_STATS_PROP_KIND : WEBRTC_STATS_PROP_ADDRESS : WEBRTC_STATS_PROP_PORT : WEBRTC_STATS_PROP_CANDIDATE_TYPE : WEBRTC_STATS_PROP_PRIORITY : WEBRTC_STATS_PROP_PROTOCOL : WEBRTC_STATS_PROP_RELAY_PROTOCOL : WEBRTC_STATS_PROP_URL : WEBRTC_STATS_PROP_LOCAL_CANDIDATE_ID : WEBRTC_STATS_PROP_REMOTE_CANDIDATE_ID Some enum values are changed. Some definitions are deprecated. [Version] 0.4.1 [Issue type] New feature Change-Id: I021af299a1b3ddb048f29a3888b5dc86d8191ab8 --- diff --git a/include/webrtc.h b/include/webrtc.h index cd971a24..44a46f5f 100644 --- a/include/webrtc.h +++ b/include/webrtc.h @@ -296,7 +296,10 @@ 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 = 0x0010 /**< Remote outbound RTP */ + WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP = 0x0010, /**< Remote outbound RTP */ + WEBRTC_STATS_TYPE_CANDIDATE_PAIR = 0x0020, /**< Candidate pair (Since 7.5) */ + WEBRTC_STATS_TYPE_LOCAL_CANDIDATE = 0x0040, /**< Local candidate (Since 7.5) */ + WEBRTC_STATS_TYPE_REMOTE_CANDIDATE = 0x0080, /**< Remote candidate (Since 7.5) */ } webrtc_stats_type_e; /** @@ -304,14 +307,10 @@ typedef enum { * @since_tizen 7.0 * @see webrtc_foreach_stats() */ -#define WEBRTC_STATS_TYPE_ALL \ - WEBRTC_STATS_TYPE_CODEC | \ - WEBRTC_STATS_TYPE_INBOUND_RTP | \ - WEBRTC_STATS_TYPE_OUTBOUND_RTP | \ - WEBRTC_STATS_TYPE_REMOTE_INBOUND_RTP | \ - WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP +#define WEBRTC_STATS_TYPE_ALL 0 /** + * @deprecated Deprecated since 7.5. * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC stats. * @since_tizen 7.0 * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcstats. @@ -320,6 +319,7 @@ typedef enum { #define WEBRTC_STATS_COMMON 0x00000100 /** + * @deprecated Deprecated since 7.5. * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC codec stats. * @since_tizen 7.0 * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtccodecstats. @@ -328,6 +328,7 @@ typedef enum { #define WEBRTC_STATS_CODEC 0x00000200 /** + * @deprecated Deprecated since 7.5. * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC RTP stream stats. * @since_tizen 7.0 * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcrtpstreamstats. @@ -336,6 +337,7 @@ typedef enum { #define WEBRTC_STATS_RTP_STREAM 0x00000400 /** + * @deprecated Deprecated since 7.5. * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC received RTP stream stats. * @since_tizen 7.0 * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcreceivedrtpstreamstats. @@ -344,6 +346,7 @@ typedef enum { #define WEBRTC_STATS_RECEIVED_RTP_STREAM 0x00000800 /** + * @deprecated Deprecated since 7.5. * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC inbound RTP stream stats. * @since_tizen 7.0 * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcinboundrtpstreamstats. @@ -352,6 +355,7 @@ typedef enum { #define WEBRTC_STATS_INBOUND_RTP_STREAM 0x00001000 /** + * @deprecated Deprecated since 7.5. * @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. @@ -360,6 +364,7 @@ typedef enum { #define WEBRTC_STATS_SENT_RTP_STREAM 0x00002000 /** + * @deprecated Deprecated since 7.5. * @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. @@ -368,6 +373,7 @@ typedef enum { #define WEBRTC_STATS_OUTBOUND_RTP_STREAM 0x00004000 /** + * @deprecated Deprecated since 7.5. * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC remote inbound RTP stream stats. * @since_tizen 7.0 * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteinboundrtpstreamstats. @@ -376,6 +382,7 @@ typedef enum { #define WEBRTC_STATS_REMOTE_INBOUND_RTP_STREAM 0x00008000 /** + * @deprecated Deprecated since 7.5. * @brief Definition for mask value used by #webrtc_stats_prop_e that represents properties of RTC remote outbound RTP stream stats. * @since_tizen 7.0 * @remarks It corresponds with the values described in https://www.w3.org/TR/webrtc-stats/#dom-rtcremoteoutboundrtpstreamstats. @@ -388,33 +395,43 @@ typedef enum { * @since_tizen 7.0 */ typedef enum { - WEBRTC_STATS_PROP_TIMESTAMP = WEBRTC_STATS_COMMON | 0x01, /**< Timestamp */ - WEBRTC_STATS_PROP_ID = WEBRTC_STATS_COMMON | 0x02, /**< Id */ - WEBRTC_STATS_PROP_PAYLOAD_TYPE = WEBRTC_STATS_CODEC | 0x01, /**< Payload type */ - WEBRTC_STATS_PROP_CLOCK_RATE = WEBRTC_STATS_CODEC | 0x02, /**< Clock rate */ - WEBRTC_STATS_PROP_CHANNELS = WEBRTC_STATS_CODEC | 0x03, /**< Channels */ - WEBRTC_STATS_PROP_MIME_TYPE = WEBRTC_STATS_CODEC | 0x04, /**< MIME type */ - WEBRTC_STATS_PROP_CODEC_TYPE = WEBRTC_STATS_CODEC | 0x05, /**< Codec type */ - WEBRTC_STATS_PROP_SDP_FMTP_LINE = WEBRTC_STATS_CODEC | 0x06, /**< SDP FMTP line */ - WEBRTC_STATS_PROP_SSRC = WEBRTC_STATS_RTP_STREAM | 0x01, /**< SSRC */ - WEBRTC_STATS_PROP_TRANSPORT_ID = WEBRTC_STATS_RTP_STREAM | 0x02, /**< Transport id */ - WEBRTC_STATS_PROP_CODEC_ID = WEBRTC_STATS_RTP_STREAM | 0x03, /**< Codec id */ - WEBRTC_STATS_PROP_PACKETS_RECEIVED = WEBRTC_STATS_RECEIVED_RTP_STREAM | 0x01, /**< Packets received */ - 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_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_ROUND_TRIP_TIME = WEBRTC_STATS_REMOTE_INBOUND_RTP_STREAM | 0x01, /**< Round trip time */ - WEBRTC_STATS_PROP_FRACTION_LOST = WEBRTC_STATS_REMOTE_INBOUND_RTP_STREAM | 0x02, /**< Fraction lost */ - WEBRTC_STATS_PROP_REMOTE_TIMESTAMP = WEBRTC_STATS_REMOTE_OUTBOUND_RTP_STREAM | 0x01, /**< Remote timestamp */ - WEBRTC_STATS_PROP_LOCAL_ID = WEBRTC_STATS_REMOTE_INBOUND_RTP_STREAM | WEBRTC_STATS_REMOTE_OUTBOUND_RTP_STREAM | 0x01, /**< Local id */ + WEBRTC_STATS_PROP_TIMESTAMP = 1, /**< Timestamp */ + WEBRTC_STATS_PROP_ID, /**< Id */ + WEBRTC_STATS_PROP_PAYLOAD_TYPE, /**< Payload type */ + WEBRTC_STATS_PROP_CLOCK_RATE, /**< Clock rate */ + WEBRTC_STATS_PROP_CHANNELS, /**< Channels */ + WEBRTC_STATS_PROP_MIME_TYPE, /**< MIME type */ + WEBRTC_STATS_PROP_CODEC_TYPE, /**< Codec type */ + WEBRTC_STATS_PROP_SDP_FMTP_LINE, /**< SDP FMTP line */ + WEBRTC_STATS_PROP_SSRC, /**< SSRC */ + WEBRTC_STATS_PROP_TRANSPORT_ID, /**< Transport id */ + WEBRTC_STATS_PROP_CODEC_ID, /**< Codec id */ + WEBRTC_STATS_PROP_PACKETS_RECEIVED, /**< Packets received */ + WEBRTC_STATS_PROP_PACKETS_LOST, /**< Packets lost */ + WEBRTC_STATS_PROP_PACKETS_DISCARDED, /**< Packets discarded */ + WEBRTC_STATS_PROP_JITTER, /**< Jitter */ + WEBRTC_STATS_PROP_BYTES_RECEIVED, /**< Bytes received */ + WEBRTC_STATS_PROP_PACKETS_DUPLICATED, /**< Packets duplicated */ + WEBRTC_STATS_PROP_BYTES_SENT, /**< Bytes sent */ + WEBRTC_STATS_PROP_PACKETS_SENT, /**< Packets sent */ + WEBRTC_STATS_PROP_REMOTE_ID, /**< Remote id */ + WEBRTC_STATS_PROP_FIR_COUNT, /**< FIR packets */ + WEBRTC_STATS_PROP_PLI_COUNT, /**< PLI packets */ + WEBRTC_STATS_PROP_NACK_COUNT, /**< NACK packets */ + WEBRTC_STATS_PROP_ROUND_TRIP_TIME, /**< Round trip time */ + WEBRTC_STATS_PROP_FRACTION_LOST, /**< Fraction lost */ + WEBRTC_STATS_PROP_REMOTE_TIMESTAMP, /**< Remote timestamp */ + WEBRTC_STATS_PROP_LOCAL_ID, /**< Local id */ + WEBRTC_STATS_PROP_KIND, /**< Kind (Since 7.5) */ + WEBRTC_STATS_PROP_ADDRESS, /**< Address of the candidate (Since 7.5) */ + WEBRTC_STATS_PROP_PORT, /**< Port number of the candidate (Since 7.5) */ + WEBRTC_STATS_PROP_CANDIDATE_TYPE, /**< Candidate type (Since 7.5) */ + WEBRTC_STATS_PROP_PRIORITY, /**< Priority (Since 7.5) */ + WEBRTC_STATS_PROP_PROTOCOL, /**< Protocol, 'udp' or 'tcp' (Since 7.5) */ + WEBRTC_STATS_PROP_RELAY_PROTOCOL, /**< Relay protocol (Since 7.5) */ + WEBRTC_STATS_PROP_URL, /**< URL (Since 7.5) */ + WEBRTC_STATS_PROP_LOCAL_CANDIDATE_ID, /**< Local candidate id associated with the candidate pair (Since 7.5) */ + WEBRTC_STATS_PROP_REMOTE_CANDIDATE_ID, /**< Remote candidate id associated with the candidate pair (Since 7.5) */ } webrtc_stats_prop_e; /** diff --git a/packaging/capi-media-webrtc.spec b/packaging/capi-media-webrtc.spec index 184ed368..c461f43d 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.289 +Version: 0.4.1 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/webrtc.c b/src/webrtc.c index f7b1ddd2..a8ea2d0b 100644 --- a/src/webrtc.c +++ b/src/webrtc.c @@ -2106,6 +2106,12 @@ int webrtc_foreach_stats(webrtc_h webrtc, int type_mask, webrtc_stats_cb callbac RET_VAL_IF(_webrtc->state != WEBRTC_STATE_PLAYING, WEBRTC_ERROR_INVALID_STATE, "the state should be PLAYING"); + if (type_mask == WEBRTC_STATS_TYPE_ALL) { + /* exported all types */ + type_mask = WEBRTC_STATS_TYPE_CODEC | WEBRTC_STATS_TYPE_INBOUND_RTP | WEBRTC_STATS_TYPE_OUTBOUND_RTP | + WEBRTC_STATS_TYPE_REMOTE_INBOUND_RTP | WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP | WEBRTC_STATS_TYPE_CANDIDATE_PAIR | + WEBRTC_STATS_TYPE_LOCAL_CANDIDATE | WEBRTC_STATS_TYPE_REMOTE_CANDIDATE; + } _webrtcbin_foreach_stats(_webrtc, type_mask, callback, user_data); LOG_INFO("webrtc[%p] type_mask[0x%x] callback[%p] user_data[%p]", webrtc, type_mask, callback, user_data); diff --git a/src/webrtc_stats.c b/src/webrtc_stats.c index a7c32a3e..0de066d7 100644 --- a/src/webrtc_stats.c +++ b/src/webrtc_stats.c @@ -78,11 +78,13 @@ static stats_field_s __stats_codec_fields[] = { * "ssrc" G_TYPE_STRING the rtp sequence src in use * "transport-id" G_TYPE_STRING identifier for the associated RTCTransportStats for this stream * "codec-id" G_TYPE_STRING identifier for the associated RTCCodecStats for this stream + * "kind" G_TYPE_STRING either "audio" or "video", depending on the associated transceiver (Since: GStreamer 1.22) */ static stats_field_s __stats_rtp_stream_fields[] = { { "ssrc", WEBRTC_STATS_PROP_SSRC, 0 }, { "transport-id", WEBRTC_STATS_PROP_TRANSPORT_ID, 0 }, { "codec-id", WEBRTC_STATS_PROP_CODEC_ID, 0 }, + { "kind", WEBRTC_STATS_PROP_KIND, 0 }, { NULL, 0, 0 } }; @@ -100,7 +102,7 @@ static stats_field_s __stats_received_rtp_stream_fields[] = { { "packets-received", WEBRTC_STATS_PROP_PACKETS_RECEIVED, 0 }, { "packets-lost", WEBRTC_STATS_PROP_PACKETS_LOST, 0 }, { "packets-discarded", WEBRTC_STATS_PROP_PACKETS_DISCARDED, 0 }, - { "packets-repaired", WEBRTC_STATS_PROP_NOT_EXPORTED, 0 }, /* It'll be exported after RTX verficiation */ + { "packets-repaired", WEBRTC_STATS_PROP_NOT_EXPORTED, 0 }, /* It'll be exported after RTX verification */ { "jitter", WEBRTC_STATS_PROP_JITTER, 0 }, { NULL, 0, 0 } }; @@ -206,6 +208,44 @@ static stats_field_s __stats_transport_fields[] = { { NULL, 0, 0 } }; +/* + * Description below is extracted from GstWebRTCBin::get-stats: + * RTCIceCandidateStats supported fields (https://www.w3.org/TR/webrtc-stats/#icecandidate-dict*) (Since: GStreamer 1.22) + * + * "transport-id" G_TYPE_STRING identifier for the associated RTCTransportStats for this stream + * "address" G_TYPE_STRING address of the candidate, allowing for IPv4, IPv6 and FQDNs + * "port" G_TYPE_UINT port number of the candidate + * "candidate-type" G_TYPE_STRING RTCIceCandidateType + * "priority" G_TYPE_UINT64 calculated as defined in RFC 5245 + * "protocol" G_TYPE_STRING Either "udp" or "tcp". Based on the "transport" defined in RFC 5245 + * "relay-protocol" G_TYPE_STRING protocol used by the endpoint to communicate with the TURN server. Only present for local candidates. Either "udp", "tcp" or "tls" + * "url" G_TYPE_STRING URL of the ICE server from which the candidate was obtained. Only present for local candidates + */ +static stats_field_s __stats_ice_candidate_fields[] = { + { "transport-id", WEBRTC_STATS_PROP_TRANSPORT_ID, 0 }, + { "address", WEBRTC_STATS_PROP_ADDRESS, 0 }, + { "port", WEBRTC_STATS_PROP_PORT, 0 }, + { "candidate-type", WEBRTC_STATS_PROP_CANDIDATE_TYPE, 0 }, + { "priority", WEBRTC_STATS_PROP_PRIORITY, 0 }, + { "protocol", WEBRTC_STATS_PROP_PROTOCOL, 0 }, + { "relay-protocol", WEBRTC_STATS_PROP_RELAY_PROTOCOL, 0 }, + { "url", WEBRTC_STATS_PROP_URL, 0 }, + { NULL, 0, 0 } +}; + +/* + * Description below is extracted from GstWebRTCBin::get-stats: + * RTCIceCandidatePairStats supported fields (https://www.w3.org/TR/webrtc-stats/#candidatepair-dict*) (Since: GStreamer 1.22) + * + * "local-candidate-id" G_TYPE_STRING unique identifier that is associated to the object that was inspected to produce the RTCIceCandidateStats for the local candidate associated with this candidate pair. + * "remote-candidate-id" G_TYPE_STRING unique identifier that is associated to the object that was inspected to produce the RTCIceCandidateStats for the remote candidate associated with this candidate pair. + */ +static stats_field_s __stats_ice_candidate_pair_fields[] = { + { "local-candidate-id", WEBRTC_STATS_PROP_LOCAL_CANDIDATE_ID, 0 }, + { "remote-candidate-id", WEBRTC_STATS_PROP_REMOTE_CANDIDATE_ID, 0 }, + { NULL, 0, 0 } +}; + static stats_field_s *__stats_all_fields_list[] = { __stats_common_fields, __stats_codec_fields, @@ -217,6 +257,8 @@ static stats_field_s *__stats_all_fields_list[] = { __stats_remote_inbound_rtp_stream_fields, __stats_remote_outbound_rtp_stream_fields, __stats_peer_connection_fields, + __stats_ice_candidate_fields, + __stats_ice_candidate_pair_fields, NULL }; @@ -270,6 +312,24 @@ static stats_field_s *__stats_transport_fields_list[] = { NULL }; +static stats_field_s *__stats_candidate_pair_fields_list[] = { + __stats_common_fields, + __stats_ice_candidate_pair_fields, + NULL +}; + +static stats_field_s *__stats_local_candidate_fields_list[] = { + __stats_common_fields, + __stats_ice_candidate_fields, + NULL +}; + +static stats_field_s *__stats_remote_candidate_fields_list[] = { + __stats_common_fields, + __stats_ice_candidate_fields, + NULL +}; + typedef struct _promise_userdata_s { webrtc_s *webrtc; int type_mask; @@ -671,35 +731,62 @@ static gboolean __stats_transport_invoke_callback(const GstStructure *s, webrtc_ static gboolean __stats_candidate_pair_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 }; + gboolean ret; + RET_VAL_IF(user_data == NULL, FALSE, "user_data is NULL"); LOG_DEBUG_ENTER(); - return gst_structure_foreach(s, __stats_field_foreach_cb, &stats_userdata); - /* not implemented */ + if (user_data->dump) + stats_userdata.sub_dump = json_object_new(); + + ret = gst_structure_foreach(s, __stats_field_foreach_cb, &stats_userdata); + + if (user_data->dump) + json_object_set_object_member(user_data->dump, "candidate-pair", stats_userdata.sub_dump); + + return ret; } static gboolean __stats_local_candidate_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 }; + gboolean ret; + RET_VAL_IF(user_data == NULL, FALSE, "user_data is NULL"); LOG_DEBUG_ENTER(); - return gst_structure_foreach(s, __stats_field_foreach_cb, &stats_userdata); - /* not implemented */ + if (user_data->dump) + stats_userdata.sub_dump = json_object_new(); + + ret = gst_structure_foreach(s, __stats_field_foreach_cb, &stats_userdata); + + if (user_data->dump) + json_object_set_object_member(user_data->dump, "local-candidate", stats_userdata.sub_dump); + + return ret; } static gboolean __stats_remote_candidate_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 }; + gboolean ret; + RET_VAL_IF(user_data == NULL, FALSE, "user_data is NULL"); LOG_DEBUG_ENTER(); - return gst_structure_foreach(s, __stats_field_foreach_cb, &stats_userdata); - /* not implemented */ + if (user_data->dump) + stats_userdata.sub_dump = json_object_new(); + + ret = gst_structure_foreach(s, __stats_field_foreach_cb, &stats_userdata); + + if (user_data->dump) + json_object_set_object_member(user_data->dump, "remote-candidate", stats_userdata.sub_dump); + + return ret; } static gboolean __stats_certificate_invoke_callback(const GstStructure *s, webrtc_stats_type_e type, stats_field_s **fields_list, promise_userdata_s *user_data) @@ -727,9 +814,6 @@ typedef struct { #define WEBRTC_STATS_TYPE_DATA_CHANNEL 0x0040 /**< Data Channel */ #define WEBRTC_STATS_TYPE_STREAM 0x0080 /**< Stream */ #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 */ @@ -755,11 +839,11 @@ static parse_stats_s parse_stats[] = { [GST_WEBRTC_STATS_TRANSPORT] = { __stats_transport_invoke_callback, WEBRTC_STATS_TYPE_TRANSPORT, __stats_transport_fields_list }, [GST_WEBRTC_STATS_CANDIDATE_PAIR] = { - __stats_candidate_pair_invoke_callback, WEBRTC_STATS_TYPE_CANDIDATE_PAIR, NULL }, + __stats_candidate_pair_invoke_callback, WEBRTC_STATS_TYPE_CANDIDATE_PAIR, __stats_candidate_pair_fields_list }, [GST_WEBRTC_STATS_LOCAL_CANDIDATE] = { - __stats_local_candidate_invoke_callback, WEBRTC_STATS_TYPE_LOCAL_CANDIDATE, NULL }, + __stats_local_candidate_invoke_callback, WEBRTC_STATS_TYPE_LOCAL_CANDIDATE, __stats_local_candidate_fields_list }, [GST_WEBRTC_STATS_REMOTE_CANDIDATE] = { - __stats_remote_candidate_invoke_callback, WEBRTC_STATS_TYPE_REMOTE_CANDIDATE, NULL }, + __stats_remote_candidate_invoke_callback, WEBRTC_STATS_TYPE_REMOTE_CANDIDATE, __stats_remote_candidate_fields_list }, [GST_WEBRTC_STATS_CERTIFICATE] = { __stats_certificate_invoke_callback, WEBRTC_STATS_TYPE_CERTIFICATE, NULL } }; diff --git a/test/webrtc_test.c b/test/webrtc_test.c index 754a6908..8fbb0cf9 100644 --- a/test/webrtc_test.c +++ b/test/webrtc_test.c @@ -72,6 +72,9 @@ static const char *g_webrtc_stats_type_str[] = { [WEBRTC_STATS_TYPE_OUTBOUND_RTP] = "outbound-rtp", [WEBRTC_STATS_TYPE_REMOTE_INBOUND_RTP] = "remote-inbound-rtp", [WEBRTC_STATS_TYPE_REMOTE_OUTBOUND_RTP] = "remote-outbound-rtp", + [WEBRTC_STATS_TYPE_CANDIDATE_PAIR] = "candidate-pair", + [WEBRTC_STATS_TYPE_LOCAL_CANDIDATE] = "local-candidate", + [WEBRTC_STATS_TYPE_REMOTE_CANDIDATE] = "remote-candidate", }; static appdata_s g_ad; @@ -1691,39 +1694,39 @@ static bool __stats_cb(webrtc_stats_type_e type, const webrtc_stats_prop_info_s switch (prop_info->type) { case WEBRTC_STATS_PROP_TYPE_BOOL: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21d], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21d], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_bool, user_data); break; case WEBRTC_STATS_PROP_TYPE_INT: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21d], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21d], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_int, user_data); break; case WEBRTC_STATS_PROP_TYPE_INT64: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21"PRId64"], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21"PRId64"], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_int64, user_data); break; case WEBRTC_STATS_PROP_TYPE_UINT: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21u], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21u], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_uint, user_data); break; case WEBRTC_STATS_PROP_TYPE_UINT64: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21"PRIu64"], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21"PRIu64"], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_uint64, user_data); break; case WEBRTC_STATS_PROP_TYPE_FLOAT: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21f], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21f], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_float, user_data); break; case WEBRTC_STATS_PROP_TYPE_DOUBLE: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21lf], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21lf], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_double, user_data); break; case WEBRTC_STATS_PROP_TYPE_STRING: - g_print(" prop[%23s, 0x%08x, type:%d, value:%21s], user_data[%p]\n", + g_print(" prop[%23s, %2d, type:%d, value:%21s], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, prop_info->v_string, user_data); break; default: - g_printerr("invalid prop_info->type, prop[%23s, 0x%08x, type:%d], user_data[%p]\n", + g_printerr("invalid prop_info->type, prop[%23s, %2d, type:%d], user_data[%p]\n", prop_info->name, prop_info->prop, prop_info->type, user_data); break; }