webrtc: Fix to have valid values of RTCPeerConnectionStats 71/273471/1
authorSangchul Lee <sc11.lee@samsung.com>
Tue, 5 Apr 2022 11:46:50 +0000 (20:46 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Wed, 6 Apr 2022 06:23:37 +0000 (15:23 +0900)
Valid values corresponding to 'dataChannelsOpened' and 'dataChannelsClosed'
of https://w3c.github.io/webrtc-stats/#pcstats-dict* can now be obtained.

[Version] 1.20.0-13
[Issue Type] Improvement

Change-Id: Ib67095ceab32fe1e24c50722eecabca5158c1811
Signed-off-by: Sangchul Lee <sc11.lee@samsung.com>
packaging/gstreamer.spec
subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c
subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.h
subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c
subprojects/gst-plugins-bad/ext/webrtc/webrtcdatachannel.c

index 468dfe0..abe2efd 100644 (file)
@@ -59,7 +59,7 @@
 
 Name:           %{_name}
 Version:        1.20.0
-Release:        12
+Release:        13
 Summary:        Streaming-Media Framework Runtime
 License:        LGPL-2.0+
 Group:          Multimedia/Framework
index d172e97..30d624c 100644 (file)
@@ -2364,6 +2364,10 @@ _on_data_channel_ready_state (WebRTCDataChannel * channel,
 
   g_object_get (channel, "ready-state", &ready_state, NULL);
 
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+  GST_TRACE_OBJECT (webrtc,
+      "%" GST_PTR_FORMAT " ready-state %u", channel, ready_state);
+#endif
   if (ready_state == GST_WEBRTC_DATA_CHANNEL_STATE_OPEN) {
     gboolean found;
 
@@ -2376,6 +2380,9 @@ _on_data_channel_ready_state (WebRTCDataChannel * channel,
     }
 
     g_ptr_array_add (webrtc->priv->data_channels, gst_object_ref (channel));
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+    webrtc->priv->data_channels_opened++;
+#endif
     DC_UNLOCK (webrtc);
 
     gst_webrtc_bin_update_sctp_priority (webrtc);
@@ -2384,8 +2391,17 @@ _on_data_channel_ready_state (WebRTCDataChannel * channel,
         channel);
   } else if (ready_state == GST_WEBRTC_DATA_CHANNEL_STATE_CLOSED) {
     gboolean found;
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+    int i;
+#endif
 
     DC_LOCK (webrtc);
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+    for (i = 0; i < webrtc->priv->data_channels->len; i++)
+      if (g_ptr_array_index (webrtc->priv->data_channels, i) == channel)
+        webrtc->priv->data_channels_closed++;
+
+#endif
     found = g_ptr_array_remove (webrtc->priv->pending_data_channels, channel)
         || g_ptr_array_remove (webrtc->priv->data_channels, channel);
 
@@ -7937,6 +7953,15 @@ gst_webrtc_bin_class_init (GstWebRTCBinClass * klass)
    *  "remote-timestamp"    G_TYPE_DOUBLE               remote timestamp the statistics were sent by the remote
    *
    */
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+  /**
+   * RTCPeerConnectionStats supported fields (https://w3c.github.io/webrtc-stats/#pcstats-dict*)
+   *
+   *  "data-channels-opened"  G_TYPE_UINT               number of unique data channels that have entered the 'open' state
+   *  "data-channels-closed"  G_TYPE_UINT               number of unique data channels that have left the 'open' state
+   *
+   */
+#endif
   gst_webrtc_bin_signals[GET_STATS_SIGNAL] =
       g_signal_new_class_handler ("get-stats",
       G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
index 447ab60..a775263 100644 (file)
@@ -106,6 +106,10 @@ struct _GstWebRTCBinPrivate
   /* list of data channels we've received a sctp stream for but no data
    * channel protocol for */
   GPtrArray *pending_data_channels;
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+  guint data_channels_opened;
+  guint data_channels_closed;
+#endif
   /* dc_lock protects data_channels and pending_data_channels */
   /* lock ordering is pc_lock first, then dc_lock */
   GMutex dc_lock;
index 04fc453..a0092b4 100644 (file)
@@ -75,10 +75,17 @@ _get_peer_connection_stats (GstWebRTCBin * webrtc)
 {
   GstStructure *s = gst_structure_new_empty ("unused");
 
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+  /* FIXME: 'data-channels-requested/accepted' should be updated */
+  gst_structure_set (s, "data-channels-opened", G_TYPE_UINT,
+      webrtc->priv->data_channels_opened, "data-channels-closed", G_TYPE_UINT,
+      webrtc->priv->data_channels_closed, NULL);
+#else
   /* FIXME: datachannel */
   gst_structure_set (s, "data-channels-opened", G_TYPE_UINT, 0,
       "data-channels-closed", G_TYPE_UINT, 0, "data-channels-requested",
       G_TYPE_UINT, 0, "data-channels-accepted", G_TYPE_UINT, 0, NULL);
+#endif
 
   return s;
 }
index 8b2110a..891e093 100644 (file)
@@ -712,6 +712,9 @@ webrtc_data_channel_start_negotiation (WebRTCDataChannel * channel)
   if (gst_app_src_push_buffer (GST_APP_SRC (channel->appsrc),
           buffer) == GST_FLOW_OK) {
     channel->opened = TRUE;
+#ifdef TIZEN_FEATURE_WEBRTC_MODIFICATION
+    channel->webrtcbin->priv->data_channels_opened++;
+#endif
     _channel_enqueue_task (channel, (ChannelTask) _emit_on_open, NULL, NULL);
   } else {
     GError *error = NULL;