From 86a4c1c6b0fb20f0700b7497508206c90844579c Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 12 Apr 2007 08:21:28 +0000 Subject: [PATCH] gst/rtsp/gstrtpdec.*: Make backward compat with rtpbin by adding the request-pt-map signals. Original commit message from CVS: * gst/rtsp/gstrtpdec.c: (gst_rtp_dec_marshal_BOXED__UINT_UINT), (gst_rtp_dec_class_init), (gst_rtp_dec_chain_rtp): * gst/rtsp/gstrtpdec.h: Make backward compat with rtpbin by adding the request-pt-map signals. * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_create_stream), (new_session_pad), (request_pt_map), (gst_rtspsrc_stream_configure_transport), (gst_rtspsrc_stream_configure_caps), (gst_rtspsrc_activate_streams): * gst/rtsp/gstrtspsrc.h: Implement request-pt-map signals instead of setting caps on the buffers for the session manager. --- ChangeLog | 16 +++++++++ gst/rtsp/gstrtpdec.c | 81 ++++++++++++++++++++++++++++++++++++++++++- gst/rtsp/gstrtpdec.h | 3 ++ gst/rtsp/gstrtspsrc.c | 38 +++++++++++++++++--- gst/rtsp/gstrtspsrc.h | 1 + 5 files changed, 134 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1543ad079e..3ae6face28 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2007-04-12 Wim Taymans + + * gst/rtsp/gstrtpdec.c: (gst_rtp_dec_marshal_BOXED__UINT_UINT), + (gst_rtp_dec_class_init), (gst_rtp_dec_chain_rtp): + * gst/rtsp/gstrtpdec.h: + Make backward compat with rtpbin by adding the request-pt-map signals. + + * gst/rtsp/gstrtspsrc.c: (gst_rtspsrc_create_stream), + (new_session_pad), (request_pt_map), + (gst_rtspsrc_stream_configure_transport), + (gst_rtspsrc_stream_configure_caps), + (gst_rtspsrc_activate_streams): + * gst/rtsp/gstrtspsrc.h: + Implement request-pt-map signals instead of setting caps on the buffers + for the session manager. + 2007-04-11 Wim Taymans * gst/udp/gstudp.c: (plugin_init): diff --git a/gst/rtsp/gstrtpdec.c b/gst/rtsp/gstrtpdec.c index ed119a5d75..8ee03502e1 100644 --- a/gst/rtsp/gstrtpdec.c +++ b/gst/rtsp/gstrtpdec.c @@ -76,6 +76,7 @@ GST_ELEMENT_DETAILS ("RTP Decoder", /* GstRTPDec signals and args */ enum { + SIGNAL_REQUEST_PT_MAP, LAST_SIGNAL }; @@ -189,7 +190,7 @@ free_session (GstRTPDecSession * session) g_free (session); } -/*static guint gst_rtp_dec_signals[LAST_SIGNAL] = { 0 };*/ +static guint gst_rtp_dec_signals[LAST_SIGNAL] = { 0 }; GST_BOILERPLATE (GstRTPDec, gst_rtp_dec, GstElement, GST_TYPE_ELEMENT); @@ -212,6 +213,44 @@ gst_rtp_dec_base_init (gpointer klass) gst_element_class_set_details (element_class, &rtpdec_details); } +/* BOXED:UINT,UINT */ +#define g_marshal_value_peek_uint(v) g_value_get_uint (v) + +void +gst_rtp_dec_marshal_BOXED__UINT_UINT (GClosure * closure, + GValue * return_value, + guint n_param_values, + const GValue * param_values, + gpointer invocation_hint, gpointer marshal_data) +{ + typedef gpointer (*GMarshalFunc_BOXED__UINT_UINT) (gpointer data1, + guint arg_1, guint arg_2, gpointer data2); + register GMarshalFunc_BOXED__UINT_UINT callback; + register GCClosure *cc = (GCClosure *) closure; + register gpointer data1, data2; + gpointer v_return; + + g_return_if_fail (return_value != NULL); + g_return_if_fail (n_param_values == 3); + + if (G_CCLOSURE_SWAP_DATA (closure)) { + data1 = closure->data; + data2 = g_value_peek_pointer (param_values + 0); + } else { + data1 = g_value_peek_pointer (param_values + 0); + data2 = closure->data; + } + callback = + (GMarshalFunc_BOXED__UINT_UINT) (marshal_data ? marshal_data : cc-> + callback); + + v_return = callback (data1, + g_marshal_value_peek_uint (param_values + 1), + g_marshal_value_peek_uint (param_values + 2), data2); + + g_value_take_boxed (return_value, v_return); +} + static void gst_rtp_dec_class_init (GstRTPDecClass * g_class) { @@ -227,6 +266,20 @@ gst_rtp_dec_class_init (GstRTPDecClass * g_class) gobject_class->set_property = gst_rtp_dec_set_property; gobject_class->get_property = gst_rtp_dec_get_property; + /** + * GstRTPDec::request-pt-map: + * @rtpdec: the object which received the signal + * @session: the session + * @pt: the pt + * + * Request the payload type as #GstCaps for @pt in @session. + */ + gst_rtp_dec_signals[SIGNAL_REQUEST_PT_MAP] = + g_signal_new ("request-pt-map", G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRTPDecClass, request_pt_map), + NULL, NULL, gst_rtp_dec_marshal_BOXED__UINT_UINT, GST_TYPE_CAPS, 2, + G_TYPE_UINT, G_TYPE_UINT); + gstelement_class->provide_clock = GST_DEBUG_FUNCPTR (gst_rtp_dec_provide_clock); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_dec_change_state); @@ -308,17 +361,41 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer) GstPadTemplate *templ; GstElementClass *klass; gchar *name; + GstCaps *caps; + GValue ret = { 0 }; + GValue args[3] = { {0} + , {0} + , {0} + }; GST_DEBUG_OBJECT (rtpdec, "creating stream"); session->ssrc = ssrc; session->pt = pt; + /* get pt map */ + g_value_init (&args[0], GST_TYPE_ELEMENT); + g_value_set_object (&args[0], rtpdec); + g_value_init (&args[1], G_TYPE_UINT); + g_value_set_uint (&args[1], session->id); + g_value_init (&args[2], G_TYPE_UINT); + g_value_set_uint (&args[2], pt); + + g_value_init (&ret, GST_TYPE_CAPS); + g_value_set_boxed (&ret, NULL); + + g_signal_emitv (args, gst_rtp_dec_signals[SIGNAL_REQUEST_PT_MAP], 0, &ret); + + caps = (GstCaps *) g_value_get_boxed (&ret); + name = g_strdup_printf ("recv_rtp_src_%d_%u_%d", session->id, ssrc, pt); klass = GST_ELEMENT_GET_CLASS (rtpdec); templ = gst_element_class_get_pad_template (klass, "recv_rtp_src_%d_%d_%d"); session->recv_rtp_src = gst_pad_new_from_template (templ, name); g_free (name); + + gst_pad_set_caps (session->recv_rtp_src, caps); + gst_pad_set_element_private (session->recv_rtp_src, session); gst_pad_set_query_function (session->recv_rtp_src, gst_rtp_dec_query_src); gst_pad_set_active (session->recv_rtp_src, TRUE); @@ -327,6 +404,8 @@ gst_rtp_dec_chain_rtp (GstPad * pad, GstBuffer * buffer) session->active = TRUE; } + gst_buffer_set_caps (buffer, GST_PAD_CAPS (session->recv_rtp_src)); + res = gst_pad_push (session->recv_rtp_src, buffer); return res; diff --git a/gst/rtsp/gstrtpdec.h b/gst/rtsp/gstrtpdec.h index 9c8e936511..1c9f42ebd4 100644 --- a/gst/rtsp/gstrtpdec.h +++ b/gst/rtsp/gstrtpdec.h @@ -66,6 +66,9 @@ struct _GstRTPDec { struct _GstRTPDecClass { GstElementClass parent_class; + + /* get the caps for pt */ + GstCaps* (*request_pt_map) (GstRTPDec *rtpdec, guint session, guint pt); }; GType gst_rtp_dec_get_type(void); diff --git a/gst/rtsp/gstrtspsrc.c b/gst/rtsp/gstrtspsrc.c index f5513bbb07..0685adb0f2 100644 --- a/gst/rtsp/gstrtspsrc.c +++ b/gst/rtsp/gstrtspsrc.c @@ -519,6 +519,8 @@ gst_rtspsrc_create_stream (GstRTSPSrc * src, SDPMessage * sdp, gint idx) src->streams = g_list_append (src->streams, stream); return stream; + + /* ERRORS */ } static void @@ -1061,6 +1063,7 @@ new_session_pad (GstElement * session, GstPad * pad, GstRTSPSrc * src) if (!stream->added) goto done; } + GST_DEBUG_OBJECT (src, "We added all streams"); /* when we get here, all stream are added and we can fire the no-more-pads * signal. */ gst_element_no_more_pads (GST_ELEMENT_CAST (src)); @@ -1077,6 +1080,30 @@ unknown_stream: } } +static GstCaps * +request_pt_map (GstElement * sess, guint session, guint pt, GstRTSPSrc * src) +{ + GstRTSPStream *stream; + GList *lstream; + + lstream = g_list_find_custom (src->streams, GINT_TO_POINTER (session), + (GCompareFunc) find_stream_by_id); + if (!lstream) + goto unknown_stream; + + stream = (GstRTSPStream *) lstream->data; + + GST_DEBUG_OBJECT (src, "getting pt map for pt %d in session %d", pt, session); + + return stream->caps; + +unknown_stream: + { + GST_DEBUG_OBJECT (src, "unknown stream %d", session); + return NULL; + } +} + /* sets up all elements needed for streaming over the specified transport. * Does not yet expose the element pads, this will be done when there is actuall * dataflow detected, which might never happen when UDP is blocked in a @@ -1288,10 +1315,13 @@ use_no_manager: } if (src->session && !src->session_sig_id) { - GST_DEBUG_OBJECT (src, "connect to pad-added on session manager"); + GST_DEBUG_OBJECT (src, "connect to signals on session manager"); src->session_sig_id = g_signal_connect (src->session, "pad-added", (GCallback) new_session_pad, src); + src->session_ptmap_id = + g_signal_connect (src->session, "request-pt-map", + (GCallback) request_pt_map, src); } if (outpad) { @@ -1347,10 +1377,10 @@ gst_rtspsrc_stream_configure_caps (GstRTSPStream * stream) { /* configure the caps on the UDP source and the channelpad */ if (stream->udpsrc[0]) { - g_object_set (G_OBJECT (stream->udpsrc[0]), "caps", stream->caps, NULL); + //g_object_set (G_OBJECT (stream->udpsrc[0]), "caps", stream->caps, NULL); } if (stream->channelpad[0]) { - gst_pad_set_caps (stream->channelpad[0], stream->caps); + //gst_pad_set_caps (stream->channelpad[0], stream->caps); } return TRUE; } @@ -1380,7 +1410,7 @@ gst_rtspsrc_activate_streams (GstRTSPSrc * src) gst_pad_set_active (stream->srcpad, TRUE); /* add the pad */ if (!stream->added) { - gst_pad_set_caps (stream->srcpad, stream->caps); + //gst_pad_set_caps (stream->srcpad, stream->caps); gst_element_add_pad (GST_ELEMENT_CAST (src), stream->srcpad); stream->added = TRUE; } diff --git a/gst/rtsp/gstrtspsrc.h b/gst/rtsp/gstrtspsrc.h index d628dffcbc..19cf7f1c2a 100644 --- a/gst/rtsp/gstrtspsrc.h +++ b/gst/rtsp/gstrtspsrc.h @@ -149,6 +149,7 @@ struct _GstRTSPSrc { /* session management */ GstElement *session; gulong session_sig_id; + gulong session_ptmap_id; RTSPConnection *connection;