Commit 21151ba9 authored by Olivier Crête's avatar Olivier Crête
Browse files

basertppayload: Accept maxptime from caps

https://bugzilla.gnome.org/show_bug.cgi?id=606050
parent 8fb183c7
......@@ -46,6 +46,9 @@ struct _GstBaseRTPPayloadPrivate
gboolean ssrc_random;
guint16 next_seqnum;
gboolean perfect_rtptime;
gint64 prop_max_ptime;
gint64 caps_max_ptime;
};
/* BaseRTPPayload signals and args */
......@@ -281,6 +284,9 @@ gst_basertppayload_init (GstBaseRTPPayload * basertppayload, gpointer g_class)
basertppayload->encoding_name = NULL;
basertppayload->clock_rate = 0;
basertppayload->priv->caps_max_ptime = DEFAULT_MAX_PTIME;
basertppayload->priv->prop_max_ptime = DEFAULT_MAX_PTIME;
}
static void
......@@ -469,6 +475,21 @@ copy_fixed (GQuark field_id, const GValue * value, GstStructure * dest)
return TRUE;
}
static void
update_max_ptime (GstBaseRTPPayload * basertppayload)
{
if (basertppayload->priv->caps_max_ptime != -1 &&
basertppayload->priv->prop_max_ptime != -1)
basertppayload->max_ptime = MIN (basertppayload->priv->caps_max_ptime,
basertppayload->priv->prop_max_ptime);
else if (basertppayload->priv->caps_max_ptime != -1)
basertppayload->max_ptime = basertppayload->priv->caps_max_ptime;
else if (basertppayload->priv->prop_max_ptime != -1)
basertppayload->max_ptime = basertppayload->priv->prop_max_ptime;
else
basertppayload->max_ptime = DEFAULT_MAX_PTIME;
}
/**
* gst_basertppayload_set_outcaps:
* @payload: a #GstBaseRTPPayload
......@@ -508,6 +529,8 @@ gst_basertppayload_set_outcaps (GstBaseRTPPayload * payload, gchar * fieldname,
GST_DEBUG_OBJECT (payload, "custom added: %" GST_PTR_FORMAT, srccaps);
}
payload->priv->caps_max_ptime = DEFAULT_MAX_PTIME;
/* the peer caps can override some of the defaults */
peercaps = gst_pad_peer_get_caps (payload->srcpad);
if (peercaps == NULL) {
......@@ -524,6 +547,7 @@ gst_basertppayload_set_outcaps (GstBaseRTPPayload * payload, gchar * fieldname,
GstStructure *s, *d;
const GValue *value;
gint pt;
guint max_ptime;
/* peer provides caps we can use to fixate, intersect. This always returns a
* writable caps. */
......@@ -537,6 +561,9 @@ gst_basertppayload_set_outcaps (GstBaseRTPPayload * payload, gchar * fieldname,
/* get first structure */
s = gst_caps_get_structure (temp, 0);
if (gst_structure_get_uint (s, "maxptime", &max_ptime))
payload->priv->caps_max_ptime = max_ptime * GST_MSECOND;
if (gst_structure_get_int (s, "payload", &pt)) {
/* use peer pt */
GST_BASE_RTP_PAYLOAD_PT (payload) = pt;
......@@ -602,6 +629,8 @@ gst_basertppayload_set_outcaps (GstBaseRTPPayload * payload, gchar * fieldname,
GST_DEBUG_OBJECT (payload, "with peer caps: %" GST_PTR_FORMAT, srccaps);
}
update_max_ptime (payload);
res = gst_pad_set_caps (GST_BASE_RTP_PAYLOAD_SRCPAD (payload), srccaps);
gst_caps_unref (srccaps);
......@@ -858,7 +887,8 @@ gst_basertppayload_set_property (GObject * object, guint prop_id,
basertppayload->seqnum_offset, priv->seqnum_offset_random);
break;
case PROP_MAX_PTIME:
basertppayload->max_ptime = g_value_get_int64 (value);
basertppayload->priv->prop_max_ptime = g_value_get_int64 (value);
update_max_ptime (basertppayload);
break;
case PROP_MIN_PTIME:
basertppayload->min_ptime = g_value_get_int64 (value);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment