mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-19 20:46:22 +00:00
gstrtpsession: Split getting the caps into its own function
This commit is contained in:
parent
8e1c9b5b33
commit
8e73da10b3
1 changed files with 36 additions and 23 deletions
|
@ -1184,28 +1184,19 @@ gst_rtp_session_cache_caps (GstRtpSession * rtpsession, GstCaps * caps)
|
||||||
gst_caps_ref (caps));
|
gst_caps_ref (caps));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* called when the session manager needs the clock rate */
|
static GstCaps *
|
||||||
static gint
|
gst_rtp_session_get_caps_for_pt (GstRtpSession * rtpsession, guint payload)
|
||||||
gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload,
|
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
gint ipayload, result = -1;
|
GstCaps *caps = NULL;
|
||||||
GstRtpSession *rtpsession;
|
|
||||||
GstRtpSessionPrivate *priv;
|
|
||||||
GValue ret = { 0 };
|
|
||||||
GValue args[2] = { {0}, {0} };
|
GValue args[2] = { {0}, {0} };
|
||||||
GstCaps *caps;
|
GValue ret = { 0 };
|
||||||
const GstStructure *s;
|
|
||||||
|
|
||||||
rtpsession = GST_RTP_SESSION_CAST (user_data);
|
|
||||||
priv = rtpsession->priv;
|
|
||||||
|
|
||||||
GST_RTP_SESSION_LOCK (rtpsession);
|
GST_RTP_SESSION_LOCK (rtpsession);
|
||||||
ipayload = payload; /* make compiler happy */
|
caps = g_hash_table_lookup (rtpsession->priv->ptmap,
|
||||||
caps = g_hash_table_lookup (priv->ptmap, GINT_TO_POINTER (ipayload));
|
GINT_TO_POINTER (payload));
|
||||||
if (caps) {
|
if (caps) {
|
||||||
gst_caps_ref (caps);
|
gst_caps_ref (caps);
|
||||||
goto found;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* not found in the cache, try to get it with a signal */
|
/* not found in the cache, try to get it with a signal */
|
||||||
|
@ -1229,7 +1220,35 @@ gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload,
|
||||||
|
|
||||||
gst_rtp_session_cache_caps (rtpsession, caps);
|
gst_rtp_session_cache_caps (rtpsession, caps);
|
||||||
|
|
||||||
found:
|
done:
|
||||||
|
GST_RTP_SESSION_UNLOCK (rtpsession);
|
||||||
|
|
||||||
|
return caps;
|
||||||
|
|
||||||
|
no_caps:
|
||||||
|
{
|
||||||
|
GST_DEBUG_OBJECT (rtpsession, "could not get caps");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* called when the session manager needs the clock rate */
|
||||||
|
static gint
|
||||||
|
gst_rtp_session_clock_rate (RTPSession * sess, guint8 payload,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
gint result = -1;
|
||||||
|
GstRtpSession *rtpsession;
|
||||||
|
GstCaps *caps;
|
||||||
|
const GstStructure *s;
|
||||||
|
|
||||||
|
rtpsession = GST_RTP_SESSION_CAST (user_data);
|
||||||
|
|
||||||
|
caps = gst_rtp_session_get_caps_for_pt (rtpsession, payload);
|
||||||
|
|
||||||
|
if (!caps)
|
||||||
|
goto done;
|
||||||
|
|
||||||
s = gst_caps_get_structure (caps, 0);
|
s = gst_caps_get_structure (caps, 0);
|
||||||
if (!gst_structure_get_int (s, "clock-rate", &result))
|
if (!gst_structure_get_int (s, "clock-rate", &result))
|
||||||
goto no_clock_rate;
|
goto no_clock_rate;
|
||||||
|
@ -1239,16 +1258,10 @@ found:
|
||||||
GST_DEBUG_OBJECT (rtpsession, "parsed clock-rate %d", result);
|
GST_DEBUG_OBJECT (rtpsession, "parsed clock-rate %d", result);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
GST_RTP_SESSION_UNLOCK (rtpsession);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
no_caps:
|
|
||||||
{
|
|
||||||
GST_DEBUG_OBJECT (rtpsession, "could not get caps");
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
no_clock_rate:
|
no_clock_rate:
|
||||||
{
|
{
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
|
|
Loading…
Reference in a new issue