*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
*/
/**
- * SECTION:element-gstrtpbin
- * @see_also: gstrtpjitterbuffer, gstrtpsession, gstrtpptdemux, gstrtpssrcdemux
+ * SECTION:element-rtpbin
+ * @see_also: rtpjitterbuffer, rtpsession, rtpptdemux, rtpssrcdemux
*
* RTP bin combines the functions of #GstRtpSession, #GstRtpSsrcDemux,
* #GstRtpJitterBuffer and #GstRtpPtDemux in one element. It allows for multiple
* the packets are released from the jitterbuffer, they will be forwarded to a
* #GstRtpPtDemux element. The #GstRtpPtDemux element will demux the packets based
* on the payload type and will create a unique pad recv_rtp_src_\%u_\%u_\%u on
- * gstrtpbin with the session number, SSRC and payload type respectively as the pad
+ * rtpbin with the session number, SSRC and payload type respectively as the pad
* name.
*
* To also use #GstRtpBin as an RTCP receiver, request a recv_rtcp_sink_\%u pad. The
* mapping. One can clear the cached values with the #GstRtpSession::clear-pt-map
* signal.
*
- * Access to the internal statistics of gstrtpbin is provided with the
+ * Access to the internal statistics of rtpbin is provided with the
* get-internal-session property. This action signal gives access to the
* RTPSession object which further provides action signals to retrieve the
* internal source and other sources.
*
+ * #GstRtpBin also has signals (#GstRtpBin::request-rtp-encoder,
+ * #GstRtpBin::request-rtp-decoder, #GstRtpBin::request-rtcp-encoder and
+ * #GstRtpBin::request-rtp-decoder) to dynamically request for RTP and RTCP encoders
+ * and decoders in order to support SRTP. The encoders must provide the pads
+ * rtp_sink_\%d and rtp_src_\%d for RTP and rtcp_sink_\%d and rtcp_src_\%d for
+ * RTCP. The session number will be used in the pad name. The decoders must provide
+ * rtp_sink and rtp_src for RTP and rtcp_sink and rtcp_src for RTCP. The decoders will
+ * be placed before the #GstRtpSession element, thus they must support SSRC demuxing
+ * internally.
+ *
* <refsect2>
* <title>Example pipelines</title>
* |[
* gst-launch-1.0 udpsrc port=5000 caps="application/x-rtp, ..." ! .recv_rtp_sink_0 \
- * gstrtpbin ! rtptheoradepay ! theoradec ! xvimagesink
- * ]| Receive RTP data from port 5000 and send to the session 0 in gstrtpbin.
+ * rtpbin ! rtptheoradepay ! theoradec ! xvimagesink
+ * ]| Receive RTP data from port 5000 and send to the session 0 in rtpbin.
* |[
- * gst-launch-1.0 gstrtpbin name=rtpbin \
+ * gst-launch-1.0 rtpbin name=rtpbin \
* v4l2src ! videoconvert ! ffenc_h263 ! rtph263ppay ! rtpbin.send_rtp_sink_0 \
* rtpbin.send_rtp_src_0 ! udpsink port=5000 \
* rtpbin.send_rtcp_src_0 ! udpsink port=5001 sync=false async=false \
* as soon as possible and do not participate in preroll, sync=false and
* async=false is configured on udpsink
* |[
- * gst-launch-1.0 -v gstrtpbin name=rtpbin \
+ * gst-launch-1.0 -v rtpbin name=rtpbin \
* udpsrc caps="application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H263-1998" \
* port=5000 ! rtpbin.recv_rtp_sink_0 \
* rtpbin. ! rtph263pdepay ! ffdec_h263 ! xvimagesink \
#include <gst/rtp/gstrtpbuffer.h>
#include <gst/rtp/gstrtcpbuffer.h>
-#include "gstrtpbin-marshal.h"
#include "gstrtpbin.h"
#include "rtpsession.h"
#include "gstrtpsession.h"
/* sink pads */
static GstStaticPadTemplate rtpbin_recv_rtp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtp_sink_%u",
+ GST_STATIC_PAD_TEMPLATE ("recv_rtp_sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
- GST_STATIC_CAPS ("application/x-rtp")
+ GST_STATIC_CAPS ("application/x-rtp;application/x-srtp")
);
static GstStaticPadTemplate rtpbin_recv_rtcp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("recv_rtcp_sink_%u",
+ GST_STATIC_PAD_TEMPLATE ("recv_rtcp_sink_%u",
GST_PAD_SINK,
GST_PAD_REQUEST,
- GST_STATIC_CAPS ("application/x-rtcp")
+ GST_STATIC_CAPS ("application/x-rtcp;application/x-srtcp")
);
static GstStaticPadTemplate rtpbin_send_rtp_sink_template =
);
static GstStaticPadTemplate rtpbin_send_rtcp_src_template =
-GST_STATIC_PAD_TEMPLATE ("send_rtcp_src_%u",
+ GST_STATIC_PAD_TEMPLATE ("send_rtcp_src_%u",
GST_PAD_SRC,
GST_PAD_REQUEST,
- GST_STATIC_CAPS ("application/x-rtcp")
+ GST_STATIC_CAPS ("application/x-rtcp;application/x-srtcp")
);
static GstStaticPadTemplate rtpbin_send_rtp_src_template =
-GST_STATIC_PAD_TEMPLATE ("send_rtp_src_%u",
+ GST_STATIC_PAD_TEMPLATE ("send_rtp_src_%u",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
- GST_STATIC_CAPS ("application/x-rtp")
+ GST_STATIC_CAPS ("application/x-rtp;application/x-srtp")
);
#define GST_RTP_BIN_GET_PRIVATE(obj) \
/* UNIX (ntp) time of last SR sync used */
guint64 last_unix;
+
+ /* list of extra elements */
+ GList *elements;
};
/* signals and args */
SIGNAL_ON_TIMEOUT,
SIGNAL_ON_SENDER_TIMEOUT,
SIGNAL_ON_NPT_STOP,
+
+ SIGNAL_REQUEST_RTP_ENCODER,
+ SIGNAL_REQUEST_RTP_DECODER,
+ SIGNAL_REQUEST_RTCP_ENCODER,
+ SIGNAL_REQUEST_RTCP_DECODER,
+
+ SIGNAL_NEW_JITTERBUFFER,
+
LAST_SIGNAL
};
#define DEFAULT_USE_PIPELINE_CLOCK FALSE
#define DEFAULT_RTCP_SYNC GST_RTP_BIN_RTCP_SYNC_ALWAYS
#define DEFAULT_RTCP_SYNC_INTERVAL 0
+#define DEFAULT_DO_SYNC_EVENT FALSE
+#define DEFAULT_DO_RETRANSMISSION FALSE
enum
{
PROP_AUTOREMOVE,
PROP_BUFFER_MODE,
PROP_USE_PIPELINE_CLOCK,
+ PROP_DO_SYNC_EVENT,
+ PROP_DO_RETRANSMISSION,
PROP_LAST
};
static void remove_send_rtp (GstRtpBin * rtpbin, GstRtpBinSession * session);
static void remove_rtcp (GstRtpBin * rtpbin, GstRtpBinSession * session);
static void free_client (GstRtpBinClient * client, GstRtpBin * bin);
-static void free_stream (GstRtpBinStream * stream);
+static void free_stream (GstRtpBinStream * stream, GstRtpBin * bin);
/* Manages the RTP stream for one SSRC.
*
/* list of GstRtpBinStream */
GSList *streams;
+ /* list of encoders */
+ GSList *encoders;
+
+ /* list of decoders */
+ GSList *decoders;
+
/* mapping of payload type to caps */
GHashTable *ptmap;
GstRtpBinSession * session)
{
GstRtpBinStream *stream = NULL;
+ GstRtpBin *rtpbin;
+
+ rtpbin = session->bin;
+
+ GST_RTP_BIN_LOCK (rtpbin);
GST_RTP_SESSION_LOCK (session);
if ((stream = find_stream_by_ssrc (session, ssrc)))
GST_RTP_SESSION_UNLOCK (session);
if (stream)
- free_stream (stream);
+ free_stream (stream, rtpbin);
+
+ GST_RTP_BIN_UNLOCK (rtpbin);
}
/* create a session with the given id. Must be called with RTP_BIN_LOCK */
/* ERRORS */
no_session:
{
- g_warning ("rtpbin: could not create gstrtpsession element");
+ g_warning ("rtpbin: could not create rtpsession element");
return NULL;
}
no_demux:
{
gst_object_unref (session);
- g_warning ("rtpbin: could not create gstrtpssrcdemux element");
+ g_warning ("rtpbin: could not create rtpssrcdemux element");
return NULL;
}
}
+static gboolean
+bin_manage_element (GstRtpBin * bin, GstElement * element)
+{
+ GstRtpBinPrivate *priv = bin->priv;
+
+ if (g_list_find (priv->elements, element)) {
+ GST_DEBUG_OBJECT (bin, "requested element %p already in bin", element);
+ } else {
+ GST_DEBUG_OBJECT (bin, "adding requested element %p", element);
+ if (!gst_bin_add (GST_BIN_CAST (bin), element))
+ goto add_failed;
+ if (!gst_element_sync_state_with_parent (element))
+ GST_WARNING_OBJECT (bin, "unable to sync element state with rtpbin");
+ }
+ /* we add the element multiple times, each we need an equal number of
+ * removes to really remove the element from the bin */
+ priv->elements = g_list_prepend (priv->elements, element);
+
+ return TRUE;
+
+ /* ERRORS */
+add_failed:
+ {
+ GST_WARNING_OBJECT (bin, "unable to add element");
+ return FALSE;
+ }
+}
+
+static void
+remove_bin_element (GstElement * element, GstRtpBin * bin)
+{
+ GstRtpBinPrivate *priv = bin->priv;
+ GList *find;
+
+ find = g_list_find (priv->elements, element);
+ if (find) {
+ priv->elements = g_list_delete_link (priv->elements, find);
+
+ if (!g_list_find (priv->elements, element))
+ gst_bin_remove (GST_BIN_CAST (bin), element);
+ else
+ gst_object_unref (element);
+ }
+}
+
/* called with RTP_BIN_LOCK */
static void
free_session (GstRtpBinSession * sess, GstRtpBin * bin)
{
- GSList *client_walk;
-
GST_DEBUG_OBJECT (bin, "freeing session %p", sess);
gst_element_set_locked_state (sess->demux, TRUE);
gst_bin_remove (GST_BIN_CAST (bin), sess->session);
gst_bin_remove (GST_BIN_CAST (bin), sess->demux);
- /* remove any references in bin->clients to the streams in sess->streams */
- client_walk = bin->clients;
- while (client_walk) {
- GSList *client_node = client_walk;
- GstRtpBinClient *client = (GstRtpBinClient *) client_node->data;
- GSList *stream_walk = client->streams;
-
- while (stream_walk) {
- GSList *stream_node = stream_walk;
- GstRtpBinStream *stream = (GstRtpBinStream *) stream_node->data;
- GSList *inner_walk;
-
- stream_walk = g_slist_next (stream_walk);
-
- for (inner_walk = sess->streams; inner_walk;
- inner_walk = g_slist_next (inner_walk)) {
- if ((GstRtpBinStream *) inner_walk->data == stream) {
- client->streams = g_slist_delete_link (client->streams, stream_node);
- --client->nstreams;
- break;
- }
- }
- }
- client_walk = g_slist_next (client_walk);
+ g_slist_foreach (sess->encoders, (GFunc) remove_bin_element, bin);
+ g_slist_free (sess->encoders);
- g_assert ((client->streams && client->nstreams > 0) || (!client->streams
- && client->streams == 0));
- if (client->nstreams == 0) {
- free_client (client, bin);
- bin->clients = g_slist_delete_link (bin->clients, client_node);
- }
- }
+ g_slist_foreach (sess->decoders, (GFunc) remove_bin_element, bin);
+ g_slist_free (sess->decoders);
- g_slist_foreach (sess->streams, (GFunc) free_stream, NULL);
+ g_slist_foreach (sess->streams, (GFunc) free_stream, bin);
g_slist_free (sess->streams);
g_mutex_clear (&sess->lock);
return internal_session;
}
+static GstElement *
+gst_rtp_bin_request_encoder (GstRtpBin * bin, guint session_id)
+{
+ GST_DEBUG_OBJECT (bin, "return NULL encoder");
+ return NULL;
+}
+
+static GstElement *
+gst_rtp_bin_request_decoder (GstRtpBin * bin, guint session_id)
+{
+ GST_DEBUG_OBJECT (bin, "return NULL decoder");
+ return NULL;
+}
+
static void
gst_rtp_bin_propagate_property_to_jitterbuffer (GstRtpBin * bin,
const gchar * name, const GValue * value)
stream->ssrc, ts_offset);
}
+static void
+gst_rtp_bin_send_sync_event (GstRtpBinStream * stream)
+{
+ if (stream->bin->send_sync_event) {
+ GstEvent *event;
+ GstPad *srcpad;
+
+ GST_DEBUG_OBJECT (stream->bin,
+ "sending GstRTCPSRReceived event downstream");
+
+ event = gst_event_new_custom (GST_EVENT_CUSTOM_DOWNSTREAM,
+ gst_structure_new_empty ("GstRTCPSRReceived"));
+
+ srcpad = gst_element_get_static_pad (stream->buffer, "src");
+ gst_pad_push_event (srcpad, event);
+ gst_object_unref (srcpad);
+ }
+}
+
/* associate a stream to the given CNAME. This will make sure all streams for
* that CNAME are synchronized together.
* Must be called with GST_RTP_BIN_LOCK */
stream_set_ts_offset (bin, ostream, ts_offset, TRUE);
}
}
+ gst_rtp_bin_send_sync_event (stream);
+
return;
}
if (!(demux = gst_element_factory_make ("rtpptdemux", NULL)))
goto no_demux;
-
stream = g_new0 (GstRtpBinStream, 1);
stream->ssrc = ssrc;
stream->bin = rtpbin;
g_object_set (buffer, "drop-on-latency", rtpbin->drop_on_latency, NULL);
g_object_set (buffer, "do-lost", rtpbin->do_lost, NULL);
g_object_set (buffer, "mode", rtpbin->buffer_mode, NULL);
+ g_object_set (buffer, "do-retransmission", rtpbin->do_retransmission, NULL);
+
+ g_signal_emit (rtpbin, gst_rtp_bin_signals[SIGNAL_NEW_JITTERBUFFER], 0,
+ buffer, session->id, ssrc);
if (!rtpbin->ignore_pt)
gst_bin_add (GST_BIN_CAST (rtpbin), demux);
/* link stuff */
if (demux)
- gst_element_link (buffer, demux);
+ gst_element_link_pads_full (buffer, "src", demux, "sink",
+ GST_PAD_LINK_CHECK_NOTHING);
if (rtpbin->buffering) {
guint64 last_out;
/* ERRORS */
no_jitterbuffer:
{
- g_warning ("rtpbin: could not create gstrtpjitterbuffer element");
+ g_warning ("rtpbin: could not create rtpjitterbuffer element");
return NULL;
}
no_demux:
{
gst_object_unref (buffer);
- g_warning ("rtpbin: could not create gstrtpptdemux element");
+ g_warning ("rtpbin: could not create rtpptdemux element");
return NULL;
}
}
+/* called with RTP_BIN_LOCK */
static void
-free_stream (GstRtpBinStream * stream)
+free_stream (GstRtpBinStream * stream, GstRtpBin * bin)
{
- GstRtpBinSession *session;
+ GSList *clients, *next_client;
- session = stream->session;
+ GST_DEBUG_OBJECT (bin, "freeing stream %p", stream);
if (stream->demux) {
g_signal_handler_disconnect (stream->demux, stream->demux_newpad_sig);
if (stream->demux)
g_signal_handler_disconnect (stream->demux, stream->demux_padremoved_sig);
- gst_bin_remove (GST_BIN_CAST (session->bin), stream->buffer);
+ gst_bin_remove (GST_BIN_CAST (bin), stream->buffer);
if (stream->demux)
- gst_bin_remove (GST_BIN_CAST (session->bin), stream->demux);
+ gst_bin_remove (GST_BIN_CAST (bin), stream->demux);
+
+ for (clients = bin->clients; clients; clients = next_client) {
+ GstRtpBinClient *client = (GstRtpBinClient *) clients->data;
+ GSList *streams, *next_stream;
+ next_client = g_slist_next (clients);
+
+ for (streams = client->streams; streams; streams = next_stream) {
+ GstRtpBinStream *ostream = (GstRtpBinStream *) streams->data;
+
+ next_stream = g_slist_next (streams);
+
+ if (ostream == stream) {
+ client->streams = g_slist_delete_link (client->streams, streams);
+ /* If this was the last stream belonging to this client,
+ * clean up the client. */
+ if (--client->nstreams == 0) {
+ bin->clients = g_slist_delete_link (bin->clients, clients);
+ free_client (client, bin);
+ break;
+ }
+ }
+ }
+ }
g_free (stream);
}
#define gst_rtp_bin_parent_class parent_class
G_DEFINE_TYPE (GstRtpBin, gst_rtp_bin, GST_TYPE_BIN);
+static gboolean
+_gst_element_accumulator (GSignalInvocationHint * ihint,
+ GValue * return_accu, const GValue * handler_return, gpointer dummy)
+{
+ GstElement *element;
+
+ element = g_value_get_object (handler_return);
+ GST_DEBUG ("got element %" GST_PTR_FORMAT, element);
+
+ if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
+ g_value_set_object (return_accu, element);
+
+ /* stop emission if we have an element */
+ return (element == NULL);
+}
+
static void
gst_rtp_bin_class_init (GstRtpBinClass * klass)
{
gst_rtp_bin_signals[SIGNAL_REQUEST_PT_MAP] =
g_signal_new ("request-pt-map", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, request_pt_map),
- NULL, NULL, gst_rtp_bin_marshal_BOXED__UINT_UINT, GST_TYPE_CAPS, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, GST_TYPE_CAPS, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::payload-type-change:
* @pt: the pt
*
* Signal that the current payload type changed to @pt in @session.
- *
- * Since: 0.10.17
*/
gst_rtp_bin_signals[SIGNAL_PAYLOAD_TYPE_CHANGE] =
g_signal_new ("payload-type-change", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, payload_type_change),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::clear-pt-map:
gst_rtp_bin_signals[SIGNAL_GET_INTERNAL_SESSION] =
g_signal_new ("get-internal-session", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (GstRtpBinClass,
- get_internal_session), NULL, NULL, gst_rtp_bin_marshal_OBJECT__UINT,
+ get_internal_session), NULL, NULL, g_cclosure_marshal_generic,
RTP_TYPE_SESSION, 1, G_TYPE_UINT);
/**
gst_rtp_bin_signals[SIGNAL_ON_NEW_SSRC] =
g_signal_new ("on-new-ssrc", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_new_ssrc),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-ssrc-collision:
* @rtpbin: the object which received the signal
gst_rtp_bin_signals[SIGNAL_ON_SSRC_COLLISION] =
g_signal_new ("on-ssrc-collision", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_ssrc_collision),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-ssrc-validated:
* @rtpbin: the object which received the signal
gst_rtp_bin_signals[SIGNAL_ON_SSRC_VALIDATED] =
g_signal_new ("on-ssrc-validated", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_ssrc_validated),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-ssrc-active:
* @rtpbin: the object which received the signal
gst_rtp_bin_signals[SIGNAL_ON_SSRC_ACTIVE] =
g_signal_new ("on-ssrc-active", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_ssrc_active),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-ssrc-sdes:
* @rtpbin: the object which received the signal
gst_rtp_bin_signals[SIGNAL_ON_SSRC_SDES] =
g_signal_new ("on-ssrc-sdes", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_ssrc_sdes),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-bye-ssrc:
gst_rtp_bin_signals[SIGNAL_ON_BYE_SSRC] =
g_signal_new ("on-bye-ssrc", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_bye_ssrc),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-bye-timeout:
* @rtpbin: the object which received the signal
gst_rtp_bin_signals[SIGNAL_ON_BYE_TIMEOUT] =
g_signal_new ("on-bye-timeout", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_bye_timeout),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-timeout:
* @rtpbin: the object which received the signal
gst_rtp_bin_signals[SIGNAL_ON_TIMEOUT] =
g_signal_new ("on-timeout", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_timeout),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-sender-timeout:
* @rtpbin: the object which received the signal
gst_rtp_bin_signals[SIGNAL_ON_SENDER_TIMEOUT] =
g_signal_new ("on-sender-timeout", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_sender_timeout),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
/**
* GstRtpBin::on-npt-stop:
gst_rtp_bin_signals[SIGNAL_ON_NPT_STOP] =
g_signal_new ("on-npt-stop", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass, on_npt_stop),
- NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
- G_TYPE_UINT, G_TYPE_UINT);
+ NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 2, G_TYPE_UINT,
+ G_TYPE_UINT);
+
+ /**
+ * GstRtpBin::request-rtp-encoder:
+ * @rtpbin: the object which received the signal
+ * @session: the session
+ *
+ * Request an RTP encoder element for the given @session. The encoder
+ * element will be added to the bin if not previously added.
+ *
+ * If no handler is connected, no encoder will be used.
+ *
+ * Since: 1.4
+ */
+ gst_rtp_bin_signals[SIGNAL_REQUEST_RTP_ENCODER] =
+ g_signal_new ("request-rtp-encoder", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass,
+ request_rtp_encoder), _gst_element_accumulator, NULL,
+ g_cclosure_marshal_generic, GST_TYPE_ELEMENT, 1, G_TYPE_UINT);
+
+ /**
+ * GstRtpBin::request-rtp-decoder:
+ * @rtpbin: the object which received the signal
+ * @session: the session
+ *
+ * Request an RTP decoder element for the given @session. The decoder
+ * element will be added to the bin if not previously added.
+ *
+ * If no handler is connected, no encoder will be used.
+ *
+ * Since: 1.4
+ */
+ gst_rtp_bin_signals[SIGNAL_REQUEST_RTP_DECODER] =
+ g_signal_new ("request-rtp-decoder", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass,
+ request_rtp_decoder), _gst_element_accumulator, NULL,
+ g_cclosure_marshal_generic, GST_TYPE_ELEMENT, 1, G_TYPE_UINT);
+
+ /**
+ * GstRtpBin::request-rtcp-encoder:
+ * @rtpbin: the object which received the signal
+ * @session: the session
+ *
+ * Request an RTCP encoder element for the given @session. The encoder
+ * element will be added to the bin if not previously added.
+ *
+ * If no handler is connected, no encoder will be used.
+ *
+ * Since: 1.4
+ */
+ gst_rtp_bin_signals[SIGNAL_REQUEST_RTCP_ENCODER] =
+ g_signal_new ("request-rtcp-encoder", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass,
+ request_rtcp_encoder), _gst_element_accumulator, NULL,
+ g_cclosure_marshal_generic, GST_TYPE_ELEMENT, 1, G_TYPE_UINT);
+
+ /**
+ * GstRtpBin::request-rtcp-decoder:
+ * @rtpbin: the object which received the signal
+ * @session: the session
+ *
+ * Request an RTCP decoder element for the given @session. The decoder
+ * element will be added to the bin if not previously added.
+ *
+ * If no handler is connected, no encoder will be used.
+ *
+ * Since: 1.4
+ */
+ gst_rtp_bin_signals[SIGNAL_REQUEST_RTCP_DECODER] =
+ g_signal_new ("request-rtcp-decoder", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass,
+ request_rtcp_decoder), _gst_element_accumulator, NULL,
+ g_cclosure_marshal_generic, GST_TYPE_ELEMENT, 1, G_TYPE_UINT);
+
+ /**
+ * GstRtpBin::new-jitterbuffer:
+ * @rtpbin: the object which received the signal
+ * @jitterbuffer: the new jitterbuffer
+ * @session: the session
+ * @ssrc: the SSRC
+ *
+ * Notify that a new @jitterbuffer was created for @session and @ssrc.
+ * This signal can, for example, be used to configure @jitterbuffer.
+ *
+ * Since: 1.4
+ */
+ gst_rtp_bin_signals[SIGNAL_NEW_JITTERBUFFER] =
+ g_signal_new ("new-jitterbuffer", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRtpBinClass,
+ new_jitterbuffer), NULL, NULL, g_cclosure_marshal_generic,
+ G_TYPE_NONE, 3, GST_TYPE_ELEMENT, G_TYPE_UINT, G_TYPE_UINT);
g_object_class_install_property (gobject_class, PROP_SDES,
g_param_spec_boxed ("sdes", "SDES",
DEFAULT_USE_PIPELINE_CLOCK,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
- * GstRtpBin::buffer-mode:
+ * GstRtpBin:buffer-mode:
*
* Control the buffering and timestamping mode used by the jitterbuffer.
- *
- * Since: 0.10.17
*/
g_object_class_install_property (gobject_class, PROP_BUFFER_MODE,
g_param_spec_enum ("buffer-mode", "Buffer Mode",
"Control the buffering algorithm in use", RTP_TYPE_JITTER_BUFFER_MODE,
DEFAULT_BUFFER_MODE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
- * GstRtpBin::ntp-sync:
+ * GstRtpBin:ntp-sync:
*
- * Synchronize received streams to the NTP clock. When the NTP clock is shared
- * between the receivers and the senders (such as when using ntpd) this option
- * can be used to synchronize receivers on multiple machines.
- *
- * Since: 0.10.21
+ * Set the NTP time from the sender reports as the running-time on the
+ * buffers. When both the sender and receiver have sychronized
+ * running-time, i.e. when the clock and base-time is shared
+ * between the receivers and the and the senders, this option can be
+ * used to synchronize receivers on multiple machines.
*/
g_object_class_install_property (gobject_class, PROP_NTP_SYNC,
g_param_spec_boolean ("ntp-sync", "Sync on NTP clock",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
- * GstRtpBin::rtcp-sync:
+ * GstRtpBin:rtcp-sync:
*
* If not synchronizing (directly) to the NTP clock, determines how to sync
* the various streams.
- *
- * Since: 0.10.31
*/
g_object_class_install_property (gobject_class, PROP_RTCP_SYNC,
g_param_spec_enum ("rtcp-sync", "RTCP Sync",
DEFAULT_RTCP_SYNC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
/**
- * GstRtpBin::rtcp-sync-interval:
+ * GstRtpBin:rtcp-sync-interval:
*
* Determines how often to sync streams using RTCP data.
- *
- * Since: 0.10.31
*/
g_object_class_install_property (gobject_class, PROP_RTCP_SYNC_INTERVAL,
g_param_spec_uint ("rtcp-sync-interval", "RTCP Sync Interval",
0, G_MAXUINT, DEFAULT_RTCP_SYNC_INTERVAL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_DO_SYNC_EVENT,
+ g_param_spec_boolean ("do-sync-event", "Do Sync Event",
+ "Send event downstream when a stream is synchronized to the sender",
+ DEFAULT_DO_SYNC_EVENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
+ g_object_class_install_property (gobject_class, PROP_DO_RETRANSMISSION,
+ g_param_spec_boolean ("do-retransmission", "Do retransmission",
+ "Send an event downstream to request packet retransmission",
+ DEFAULT_DO_RETRANSMISSION,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_bin_change_state);
gstelement_class->request_new_pad =
GST_DEBUG_FUNCPTR (gst_rtp_bin_request_new_pad);
klass->reset_sync = GST_DEBUG_FUNCPTR (gst_rtp_bin_reset_sync);
klass->get_internal_session =
GST_DEBUG_FUNCPTR (gst_rtp_bin_get_internal_session);
+ klass->request_rtp_encoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_encoder);
+ klass->request_rtp_decoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_decoder);
+ klass->request_rtcp_encoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_encoder);
+ klass->request_rtcp_decoder = GST_DEBUG_FUNCPTR (gst_rtp_bin_request_decoder);
GST_DEBUG_CATEGORY_INIT (gst_rtp_bin_debug, "rtpbin", 0, "RTP bin");
}
rtpbin->priv->autoremove = DEFAULT_AUTOREMOVE;
rtpbin->buffer_mode = DEFAULT_BUFFER_MODE;
rtpbin->use_pipeline_clock = DEFAULT_USE_PIPELINE_CLOCK;
+ rtpbin->send_sync_event = DEFAULT_DO_SYNC_EVENT;
+ rtpbin->do_retransmission = DEFAULT_DO_RETRANSMISSION;
/* some default SDES entries */
cname = g_strdup_printf ("user%u@host-%x", g_random_int (), g_random_int ());
g_slist_foreach (rtpbin->sessions, (GFunc) free_session, rtpbin);
g_slist_free (rtpbin->sessions);
rtpbin->sessions = NULL;
- GST_DEBUG_OBJECT (object, "freeing clients");
- g_slist_foreach (rtpbin->clients, (GFunc) free_client, rtpbin);
- g_slist_free (rtpbin->clients);
- rtpbin->clients = NULL;
GST_RTP_BIN_UNLOCK (rtpbin);
G_OBJECT_CLASS (parent_class)->dispose (object);
GST_RTP_BIN_UNLOCK (rtpbin);
}
break;
+ case PROP_DO_SYNC_EVENT:
+ rtpbin->send_sync_event = g_value_get_boolean (value);
+ break;
case PROP_BUFFER_MODE:
GST_RTP_BIN_LOCK (rtpbin);
rtpbin->buffer_mode = g_value_get_enum (value);
/* propagate the property down to the jitterbuffer */
gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin, "mode", value);
break;
+ case PROP_DO_RETRANSMISSION:
+ GST_RTP_BIN_LOCK (rtpbin);
+ rtpbin->do_retransmission = g_value_get_boolean (value);
+ GST_RTP_BIN_UNLOCK (rtpbin);
+ gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin,
+ "do-retransmission", value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
case PROP_USE_PIPELINE_CLOCK:
g_value_set_boolean (value, rtpbin->use_pipeline_clock);
break;
+ case PROP_DO_SYNC_EVENT:
+ g_value_set_boolean (value, rtpbin->send_sync_event);
+ break;
+ case PROP_DO_RETRANSMISSION:
+ GST_RTP_BIN_LOCK (rtpbin);
+ g_value_set_boolean (value, rtpbin->do_retransmission);
+ GST_RTP_BIN_UNLOCK (rtpbin);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
return res;
}
+static GstElement *
+session_request_encoder (GstRtpBinSession * session, guint signal)
+{
+ GstElement *encoder = NULL;
+ GstRtpBin *bin = session->bin;
+
+ g_signal_emit (bin, gst_rtp_bin_signals[signal], 0, session->id, &encoder);
+
+ if (encoder) {
+ if (!bin_manage_element (bin, encoder))
+ goto manage_failed;
+ session->encoders = g_slist_prepend (session->encoders, encoder);
+ }
+ return encoder;
+
+ /* ERRORS */
+manage_failed:
+ {
+ GST_WARNING_OBJECT (bin, "unable to manage encoder");
+ gst_object_unref (encoder);
+ return NULL;
+ }
+}
+
+static GstElement *
+session_request_decoder (GstRtpBinSession * session, guint signal)
+{
+ GstElement *decoder = NULL;
+ GstRtpBin *bin = session->bin;
+
+ g_signal_emit (bin, gst_rtp_bin_signals[signal], 0, session->id, &decoder);
+
+ if (decoder) {
+ if (!bin_manage_element (bin, decoder))
+ goto manage_failed;
+ session->decoders = g_slist_prepend (session->decoders, decoder);
+ }
+ return decoder;
+
+ /* ERRORS */
+manage_failed:
+ {
+ GST_WARNING_OBJECT (bin, "unable to manage decoder");
+ gst_object_unref (decoder);
+ return NULL;
+ }
+}
+
/* a new pad (SSRC) was created in @session. This signal is emited from the
* payload demuxer. */
static void
srcpad = gst_element_get_static_pad (element, padname);
g_free (padname);
sinkpad = gst_element_get_static_pad (stream->buffer, "sink");
- gst_pad_link (srcpad, sinkpad);
+ gst_pad_link_full (srcpad, sinkpad, GST_PAD_LINK_CHECK_NOTHING);
gst_object_unref (sinkpad);
gst_object_unref (srcpad);
srcpad = gst_element_get_static_pad (element, padname);
g_free (padname);
sinkpad = gst_element_get_request_pad (stream->buffer, "sink_rtcp");
- gst_pad_link (srcpad, sinkpad);
+ gst_pad_link_full (srcpad, sinkpad, GST_PAD_LINK_CHECK_NOTHING);
gst_object_unref (sinkpad);
gst_object_unref (srcpad);
stream->demux_ptchange_sig = g_signal_connect (stream->demux,
"payload-type-change", (GCallback) payload_type_change, session);
} else {
- /* add gstrtpjitterbuffer src pad to pads */
+ /* add rtpjitterbuffer src pad to pads */
GstElementClass *klass;
GstPadTemplate *templ;
gchar *padname;
static GstPad *
create_recv_rtp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
{
- GstPad *sinkdpad;
guint sessid;
+ GstElement *decoder;
+ GstPad *sinkdpad, *decsink;
GstRtpBinSession *session;
- GstPadLinkReturn lres;
/* first get the session number */
if (name == NULL || sscanf (name, "recv_rtp_sink_%u", &sessid) != 1)
g_signal_connect (session->recv_rtp_sink, "notify::caps",
(GCallback) caps_changed, session);
+ GST_DEBUG_OBJECT (rtpbin, "requesting RTP decoder");
+ decoder = session_request_decoder (session, SIGNAL_REQUEST_RTP_DECODER);
+ if (decoder) {
+ GstPad *decsrc;
+ GstPadLinkReturn ret;
+
+ GST_DEBUG_OBJECT (rtpbin, "linking RTP decoder");
+ decsink = gst_element_get_static_pad (decoder, "rtp_sink");
+ decsrc = gst_element_get_static_pad (decoder, "rtp_src");
+
+ if (decsink == NULL)
+ goto dec_sink_failed;
+
+ if (decsrc == NULL)
+ goto dec_src_failed;
+
+ ret = gst_pad_link (decsrc, session->recv_rtp_sink);
+ gst_object_unref (decsrc);
+
+ if (ret != GST_PAD_LINK_OK)
+ goto dec_link_failed;
+ } else {
+ GST_DEBUG_OBJECT (rtpbin, "no RTP decoder given");
+ decsink = gst_object_ref (session->recv_rtp_sink);
+ }
+
GST_DEBUG_OBJECT (rtpbin, "getting RTP src pad");
/* get srcpad, link to SSRCDemux */
session->recv_rtp_src =
gst_element_get_static_pad (session->session, "recv_rtp_src");
if (session->recv_rtp_src == NULL)
- goto pad_failed;
+ goto src_pad_failed;
GST_DEBUG_OBJECT (rtpbin, "getting demuxer RTP sink pad");
sinkdpad = gst_element_get_static_pad (session->demux, "sink");
GST_DEBUG_OBJECT (rtpbin, "linking demuxer RTP sink pad");
- lres = gst_pad_link (session->recv_rtp_src, sinkdpad);
+ gst_pad_link_full (session->recv_rtp_src, sinkdpad,
+ GST_PAD_LINK_CHECK_NOTHING);
gst_object_unref (sinkdpad);
- if (lres != GST_PAD_LINK_OK)
- goto link_failed;
/* connect to the new-ssrc-pad signal of the SSRC demuxer */
session->demux_newpad_sig = g_signal_connect (session->demux,
GST_DEBUG_OBJECT (rtpbin, "ghosting session sink pad");
session->recv_rtp_sink_ghost =
- gst_ghost_pad_new_from_template (name, session->recv_rtp_sink, templ);
+ gst_ghost_pad_new_from_template (name, decsink, templ);
+ gst_object_unref (decsink);
gst_pad_set_active (session->recv_rtp_sink_ghost, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpbin), session->recv_rtp_sink_ghost);
}
pad_failed:
{
- g_warning ("rtpbin: failed to get session pad");
+ g_warning ("rtpbin: failed to get session rtp_sink pad");
return NULL;
}
-link_failed:
+dec_sink_failed:
{
- g_warning ("rtpbin: failed to link pads");
+ g_warning ("rtpbin: failed to get decoder sink pad for session %d", sessid);
+ return NULL;
+ }
+dec_src_failed:
+ {
+ g_warning ("rtpbin: failed to get decoder src pad for session %d", sessid);
+ gst_object_unref (decsink);
+ return NULL;
+ }
+dec_link_failed:
+ {
+ g_warning ("rtpbin: failed to link rtp decoder for session %d", sessid);
+ gst_object_unref (decsink);
+ return NULL;
+ }
+src_pad_failed:
+ {
+ g_warning ("rtpbin: failed to get session rtp_src pad");
+ gst_object_unref (decsink);
return NULL;
}
}
const gchar * name)
{
guint sessid;
+ GstElement *decoder;
GstRtpBinSession *session;
- GstPad *sinkdpad;
- GstPadLinkReturn lres;
+ GstPad *sinkdpad, *decsink;
/* first get the session number */
if (name == NULL || sscanf (name, "recv_rtcp_sink_%u", &sessid) != 1)
if (session->recv_rtcp_sink == NULL)
goto pad_failed;
+ GST_DEBUG_OBJECT (rtpbin, "getting RTCP decoder");
+ decoder = session_request_decoder (session, SIGNAL_REQUEST_RTCP_DECODER);
+ if (decoder) {
+ GstPad *decsrc;
+ GstPadLinkReturn ret;
+
+ GST_DEBUG_OBJECT (rtpbin, "linking RTCP decoder");
+ decsink = gst_element_get_static_pad (decoder, "rtcp_sink");
+ decsrc = gst_element_get_static_pad (decoder, "rtcp_src");
+
+ if (decsink == NULL)
+ goto dec_sink_failed;
+
+ if (decsrc == NULL)
+ goto dec_src_failed;
+
+ ret = gst_pad_link (decsrc, session->recv_rtcp_sink);
+ gst_object_unref (decsrc);
+
+ if (ret != GST_PAD_LINK_OK)
+ goto dec_link_failed;
+ } else {
+ GST_DEBUG_OBJECT (rtpbin, "no RTCP decoder given");
+ decsink = gst_object_ref (session->recv_rtcp_sink);
+ }
+
/* get srcpad, link to SSRCDemux */
GST_DEBUG_OBJECT (rtpbin, "getting sync src pad");
session->sync_src = gst_element_get_static_pad (session->session, "sync_src");
if (session->sync_src == NULL)
- goto pad_failed;
+ goto src_pad_failed;
GST_DEBUG_OBJECT (rtpbin, "getting demuxer RTCP sink pad");
sinkdpad = gst_element_get_static_pad (session->demux, "rtcp_sink");
- lres = gst_pad_link (session->sync_src, sinkdpad);
+ gst_pad_link_full (session->sync_src, sinkdpad, GST_PAD_LINK_CHECK_NOTHING);
gst_object_unref (sinkdpad);
- if (lres != GST_PAD_LINK_OK)
- goto link_failed;
session->recv_rtcp_sink_ghost =
- gst_ghost_pad_new_from_template (name, session->recv_rtcp_sink, templ);
+ gst_ghost_pad_new_from_template (name, decsink, templ);
+ gst_object_unref (decsink);
gst_pad_set_active (session->recv_rtcp_sink_ghost, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpbin),
session->recv_rtcp_sink_ghost);
}
pad_failed:
{
- g_warning ("rtpbin: failed to get session pad");
+ g_warning ("rtpbin: failed to get session rtcp_sink pad");
return NULL;
}
-link_failed:
+dec_sink_failed:
{
- g_warning ("rtpbin: failed to link pads");
+ g_warning ("rtpbin: failed to get decoder sink pad for session %d", sessid);
+ return NULL;
+ }
+dec_src_failed:
+ {
+ g_warning ("rtpbin: failed to get decoder src pad for session %d", sessid);
+ gst_object_unref (decsink);
+ return NULL;
+ }
+dec_link_failed:
+ {
+ g_warning ("rtpbin: failed to link rtcp decoder for session %d", sessid);
+ gst_object_unref (decsink);
+ return NULL;
+ }
+src_pad_failed:
+ {
+ g_warning ("rtpbin: failed to get session sync_src pad");
+ gst_object_unref (decsink);
return NULL;
}
}
{
gchar *gname;
guint sessid;
+ GstPad *encsrc;
+ GstElement *encoder;
GstRtpBinSession *session;
GstElementClass *klass;
if (session->send_rtp_src == NULL)
goto no_srcpad;
+ GST_DEBUG_OBJECT (rtpbin, "getting RTP encoder");
+ encoder = session_request_encoder (session, SIGNAL_REQUEST_RTP_ENCODER);
+ if (encoder) {
+ gchar *ename;
+ GstPad *encsink;
+ GstPadLinkReturn ret;
+
+ GST_DEBUG_OBJECT (rtpbin, "linking RTP encoder");
+ ename = g_strdup_printf ("rtp_sink_%d", sessid);
+ encsink = gst_element_get_static_pad (encoder, ename);
+ g_free (ename);
+ ename = g_strdup_printf ("rtp_src_%d", sessid);
+ encsrc = gst_element_get_static_pad (encoder, ename);
+ g_free (ename);
+
+ if (encsrc == NULL)
+ goto enc_src_failed;
+
+ if (encsink == NULL)
+ goto enc_sink_failed;
+
+ ret = gst_pad_link (session->send_rtp_src, encsink);
+ gst_object_unref (encsink);
+
+ if (ret != GST_PAD_LINK_OK)
+ goto enc_link_failed;
+ } else {
+ GST_DEBUG_OBJECT (rtpbin, "no RTP encoder given");
+ encsrc = gst_object_ref (session->send_rtp_src);
+ }
+
/* ghost the new source pad */
klass = GST_ELEMENT_GET_CLASS (rtpbin);
gname = g_strdup_printf ("send_rtp_src_%u", sessid);
templ = gst_element_class_get_pad_template (klass, "send_rtp_src_%u");
session->send_rtp_src_ghost =
- gst_ghost_pad_new_from_template (gname, session->send_rtp_src, templ);
+ gst_ghost_pad_new_from_template (gname, encsrc, templ);
+ gst_object_unref (encsrc);
gst_pad_set_active (session->send_rtp_src_ghost, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpbin), session->send_rtp_src_ghost);
g_free (gname);
g_warning ("rtpbin: failed to get rtp source pad for session %d", sessid);
return NULL;
}
+enc_src_failed:
+ {
+ g_warning ("rtpbin: failed to get encoder src pad for session %d", sessid);
+ return NULL;
+ }
+enc_sink_failed:
+ {
+ g_warning ("rtpbin: failed to get encoder sink pad for session %d", sessid);
+ gst_object_unref (encsrc);
+ return NULL;
+ }
+enc_link_failed:
+ {
+ g_warning ("rtpbin: failed to link rtp encoder for session %d", sessid);
+ gst_object_unref (encsrc);
+ return NULL;
+ }
}
static void
create_rtcp (GstRtpBin * rtpbin, GstPadTemplate * templ, const gchar * name)
{
guint sessid;
+ GstPad *encsrc;
+ GstElement *encoder;
GstRtpBinSession *session;
/* first get the session number */
if (session->send_rtcp_src == NULL)
goto pad_failed;
+ GST_DEBUG_OBJECT (rtpbin, "getting RTCP encoder");
+ encoder = session_request_encoder (session, SIGNAL_REQUEST_RTCP_ENCODER);
+ if (encoder) {
+ gchar *ename;
+ GstPad *encsink;
+ GstPadLinkReturn ret;
+
+ GST_DEBUG_OBJECT (rtpbin, "linking RTCP encoder");
+ ename = g_strdup_printf ("rtcp_sink_%d", sessid);
+ encsink = gst_element_get_static_pad (encoder, ename);
+ g_free (ename);
+ ename = g_strdup_printf ("rtcp_src_%d", sessid);
+ encsrc = gst_element_get_static_pad (encoder, ename);
+ g_free (ename);
+
+ if (encsrc == NULL)
+ goto enc_src_failed;
+
+ if (encsink == NULL)
+ goto enc_sink_failed;
+
+ ret = gst_pad_link (session->send_rtcp_src, encsink);
+ gst_object_unref (encsink);
+
+ if (ret != GST_PAD_LINK_OK)
+ goto enc_link_failed;
+ } else {
+ GST_DEBUG_OBJECT (rtpbin, "no RTCP encoder given");
+ encsrc = gst_object_ref (session->send_rtcp_src);
+ }
+
session->send_rtcp_src_ghost =
- gst_ghost_pad_new_from_template (name, session->send_rtcp_src, templ);
+ gst_ghost_pad_new_from_template (name, encsrc, templ);
+ gst_object_unref (encsrc);
gst_pad_set_active (session->send_rtcp_src_ghost, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpbin), session->send_rtcp_src_ghost);
g_warning ("rtpbin: failed to get rtcp pad for session %d", sessid);
return NULL;
}
+enc_src_failed:
+ {
+ g_warning ("rtpbin: failed to get encoder src pad for session %d", sessid);
+ return NULL;
+ }
+enc_sink_failed:
+ {
+ g_warning ("rtpbin: failed to get encoder sink pad for session %d", sessid);
+ gst_object_unref (encsrc);
+ return NULL;
+ }
+enc_link_failed:
+ {
+ g_warning ("rtpbin: failed to link rtcp encoder for session %d", sessid);
+ gst_object_unref (encsrc);
+ return NULL;
+ }
}
static void