webrtcbin: Implement getting stats for a specific pad
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1766>
This commit is contained in:
parent
23ea950351
commit
1c1661b54f
@ -5219,16 +5219,6 @@ _on_local_ice_candidate_cb (GstWebRTCICE * ice, guint session_id,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 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
|
struct get_stats
|
||||||
{
|
{
|
||||||
GstPad *pad;
|
GstPad *pad;
|
||||||
@ -5249,25 +5239,11 @@ _free_get_stats (struct get_stats *stats)
|
|||||||
static void
|
static void
|
||||||
_get_stats_task (GstWebRTCBin * webrtc, struct get_stats *stats)
|
_get_stats_task (GstWebRTCBin * webrtc, struct get_stats *stats)
|
||||||
{
|
{
|
||||||
GstStructure *s;
|
/* Our selector is the pad,
|
||||||
gpointer selector = NULL;
|
* https://www.w3.org/TR/webrtc/#dfn-stats-selection-algorithm
|
||||||
|
*/
|
||||||
gst_webrtc_bin_update_stats (webrtc);
|
gst_promise_reply (stats->promise, gst_webrtc_bin_create_stats (webrtc,
|
||||||
|
stats->pad));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -6461,10 +6437,6 @@ gst_webrtc_bin_finalize (GObject * object)
|
|||||||
gst_webrtc_session_description_free (webrtc->priv->last_generated_offer);
|
gst_webrtc_session_description_free (webrtc->priv->last_generated_offer);
|
||||||
webrtc->priv->last_generated_offer = NULL;
|
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 (ICE_GET_LOCK (webrtc));
|
||||||
g_mutex_clear (PC_GET_LOCK (webrtc));
|
g_mutex_clear (PC_GET_LOCK (webrtc));
|
||||||
g_cond_clear (PC_GET_COND (webrtc));
|
g_cond_clear (PC_GET_COND (webrtc));
|
||||||
|
@ -140,8 +140,6 @@ struct _GstWebRTCBinPrivate
|
|||||||
GstWebRTCSessionDescription *last_generated_offer;
|
GstWebRTCSessionDescription *last_generated_offer;
|
||||||
GstWebRTCSessionDescription *last_generated_answer;
|
GstWebRTCSessionDescription *last_generated_answer;
|
||||||
|
|
||||||
GstStructure *stats;
|
|
||||||
|
|
||||||
gboolean tos_attached;
|
gboolean tos_attached;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -768,8 +768,8 @@ out:
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
GstStructure *
|
||||||
gst_webrtc_bin_update_stats (GstWebRTCBin * webrtc)
|
gst_webrtc_bin_create_stats (GstWebRTCBin * webrtc, GstPad * pad)
|
||||||
{
|
{
|
||||||
GstStructure *s = gst_structure_new_empty ("application/x-webrtc-stats");
|
GstStructure *s = gst_structure_new_empty ("application/x-webrtc-stats");
|
||||||
double ts = monotonic_time_as_double_milliseconds ();
|
double ts = monotonic_time_as_double_milliseconds ();
|
||||||
@ -792,12 +792,13 @@ gst_webrtc_bin_update_stats (GstWebRTCBin * webrtc)
|
|||||||
gst_structure_free (pc_stats);
|
gst_structure_free (pc_stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_element_foreach_pad (GST_ELEMENT (webrtc),
|
if (pad)
|
||||||
(GstElementForeachPadFunc) _get_stats_from_pad, s);
|
_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");
|
gst_structure_remove_field (s, "timestamp");
|
||||||
|
|
||||||
if (webrtc->priv->stats)
|
return s;
|
||||||
gst_structure_free (webrtc->priv->stats);
|
|
||||||
webrtc->priv->stats = s;
|
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,8 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
void gst_webrtc_bin_update_stats (GstWebRTCBin * webrtc);
|
GstStructure * gst_webrtc_bin_create_stats (GstWebRTCBin * webrtc,
|
||||||
|
GstPad * pad);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user