}
}
-/* https://www.w3.org/TR/webrtc/#dfn-stats-selection-algorithm */
-static GstStructure *
-_get_stats_from_selector (GstWebRTCBin * webrtc, gpointer selector)
-{
- if (selector)
- GST_FIXME_OBJECT (webrtc, "Implement stats selection");
-
- return gst_structure_copy (webrtc->priv->stats);
-}
-
struct get_stats
{
GstPad *pad;
static void
_get_stats_task (GstWebRTCBin * webrtc, struct get_stats *stats)
{
- GstStructure *s;
- gpointer selector = NULL;
-
- gst_webrtc_bin_update_stats (webrtc);
-
- if (stats->pad) {
- GstWebRTCBinPad *wpad = GST_WEBRTC_BIN_PAD (stats->pad);
-
- if (wpad->trans) {
- if (GST_PAD_DIRECTION (wpad) == GST_PAD_SRC) {
- selector = wpad->trans->receiver;
- } else {
- selector = wpad->trans->sender;
- }
- }
- }
-
- s = _get_stats_from_selector (webrtc, selector);
- gst_promise_reply (stats->promise, s);
+ /* Our selector is the pad,
+ * https://www.w3.org/TR/webrtc/#dfn-stats-selection-algorithm
+ */
+ gst_promise_reply (stats->promise, gst_webrtc_bin_create_stats (webrtc,
+ stats->pad));
}
static void
gst_webrtc_session_description_free (webrtc->priv->last_generated_offer);
webrtc->priv->last_generated_offer = NULL;
- if (webrtc->priv->stats)
- gst_structure_free (webrtc->priv->stats);
- webrtc->priv->stats = NULL;
-
g_mutex_clear (ICE_GET_LOCK (webrtc));
g_mutex_clear (PC_GET_LOCK (webrtc));
g_cond_clear (PC_GET_COND (webrtc));
return TRUE;
}
-void
-gst_webrtc_bin_update_stats (GstWebRTCBin * webrtc)
+GstStructure *
+gst_webrtc_bin_create_stats (GstWebRTCBin * webrtc, GstPad * pad)
{
GstStructure *s = gst_structure_new_empty ("application/x-webrtc-stats");
double ts = monotonic_time_as_double_milliseconds ();
gst_structure_free (pc_stats);
}
- gst_element_foreach_pad (GST_ELEMENT (webrtc),
- (GstElementForeachPadFunc) _get_stats_from_pad, s);
+ if (pad)
+ _get_stats_from_pad (webrtc, pad, s);
+ else
+ gst_element_foreach_pad (GST_ELEMENT (webrtc),
+ (GstElementForeachPadFunc) _get_stats_from_pad, s);
gst_structure_remove_field (s, "timestamp");
- if (webrtc->priv->stats)
- gst_structure_free (webrtc->priv->stats);
- webrtc->priv->stats = s;
+ return s;
}