1 /* RTP muxer element for GStreamer
5 * Copyright (C) <2007> Nokia Corporation.
6 * Contact: Zeeshan Ali <zeeshan.ali@nokia.com>
7 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
8 * 2000,2005 Wim Taymans <wim@fluendo.com>
10 * This library is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Library General Public
12 * License as published by the Free Software Foundation; either
13 * version 2 of the License, or (at your option) any later version.
15 * This library is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Library General Public License for more details.
20 * You should have received a copy of the GNU Library General Public
21 * License along with this library; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 02111-1307, USA.
27 * SECTION:element-rtpmux
29 * The rtp muxer takes multiple RTP streams having the same clock-rate and
30 * muxes into a single stream with a single SSRC.
38 #include <gst/rtp/gstrtpbuffer.h>
41 #include "gstrtpmux.h"
43 GST_DEBUG_CATEGORY_STATIC (gst_rtp_mux_debug);
44 #define GST_CAT_DEFAULT gst_rtp_mux_debug
49 PROP_TIMESTAMP_OFFSET,
55 #define DEFAULT_TIMESTAMP_OFFSET -1
56 #define DEFAULT_SEQNUM_OFFSET -1
57 #define DEFAULT_SSRC -1
59 static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
62 GST_STATIC_CAPS ("application/x-rtp")
65 static GstStaticPadTemplate sink_factory = GST_STATIC_PAD_TEMPLATE ("sink_%d",
68 GST_STATIC_CAPS ("application/x-rtp")
71 static GstPad *gst_rtp_mux_request_new_pad (GstElement * element,
72 GstPadTemplate * templ, const gchar * name);
73 static void gst_rtp_mux_release_pad (GstElement * element, GstPad * pad);
74 static GstFlowReturn gst_rtp_mux_chain (GstPad * pad, GstBuffer * buffer);
75 static GstFlowReturn gst_rtp_mux_chain_list (GstPad * pad,
76 GstBufferList * bufferlist);
77 static gboolean gst_rtp_mux_setcaps (GstPad * pad, GstCaps * caps);
78 static GstCaps *gst_rtp_mux_getcaps (GstPad * pad);
79 static gboolean gst_rtp_mux_sink_event (GstPad * pad, GstEvent * event);
81 static GstStateChangeReturn gst_rtp_mux_change_state (GstElement *
82 element, GstStateChange transition);
84 static void gst_rtp_mux_set_property (GObject * object, guint prop_id,
85 const GValue * value, GParamSpec * pspec);
86 static void gst_rtp_mux_get_property (GObject * object, guint prop_id,
87 GValue * value, GParamSpec * pspec);
88 static void gst_rtp_mux_dispose (GObject * object);
90 GST_BOILERPLATE (GstRTPMux, gst_rtp_mux, GstElement, GST_TYPE_ELEMENT);
93 gst_rtp_mux_base_init (gpointer g_class)
95 GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
97 gst_element_class_add_pad_template (element_class,
98 gst_static_pad_template_get (&src_factory));
99 gst_element_class_add_pad_template (element_class,
100 gst_static_pad_template_get (&sink_factory));
102 gst_element_class_set_details_simple (element_class, "RTP muxer",
104 "multiplex N rtp streams into one", "Zeeshan Ali <first.last@nokia.com>");
108 gst_rtp_mux_class_init (GstRTPMuxClass * klass)
110 GObjectClass *gobject_class;
111 GstElementClass *gstelement_class;
113 gobject_class = (GObjectClass *) klass;
114 gstelement_class = (GstElementClass *) klass;
116 gobject_class->get_property = gst_rtp_mux_get_property;
117 gobject_class->set_property = gst_rtp_mux_set_property;
118 gobject_class->dispose = gst_rtp_mux_dispose;
120 g_object_class_install_property (G_OBJECT_CLASS (klass),
121 PROP_TIMESTAMP_OFFSET, g_param_spec_int ("timestamp-offset",
123 "Offset to add to all outgoing timestamps (-1 = random)", -1,
124 G_MAXINT, DEFAULT_TIMESTAMP_OFFSET, G_PARAM_READWRITE));
125 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM_OFFSET,
126 g_param_spec_int ("seqnum-offset", "Sequence number Offset",
127 "Offset to add to all outgoing seqnum (-1 = random)", -1, G_MAXINT,
128 DEFAULT_SEQNUM_OFFSET, G_PARAM_READWRITE));
129 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM,
130 g_param_spec_uint ("seqnum", "Sequence number",
131 "The RTP sequence number of the last processed packet",
132 0, G_MAXUINT, 0, G_PARAM_READABLE));
133 g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SSRC,
134 g_param_spec_uint ("ssrc", "SSRC",
135 "The SSRC of the packets (-1 == random)",
136 0, G_MAXUINT, DEFAULT_SSRC, G_PARAM_READWRITE));
138 gstelement_class->request_new_pad =
139 GST_DEBUG_FUNCPTR (gst_rtp_mux_request_new_pad);
140 gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_rtp_mux_release_pad);
141 gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_rtp_mux_change_state);
145 gst_rtp_mux_dispose (GObject * object)
150 for (item = GST_ELEMENT_PADS (object); item; item = g_list_next (item)) {
151 GstPad *pad = GST_PAD (item->data);
152 if (GST_PAD_IS_SINK (pad)) {
153 gst_element_release_request_pad (GST_ELEMENT (object), pad);
158 G_OBJECT_CLASS (parent_class)->dispose (object);
162 gst_rtp_mux_src_event (GstPad * pad, GstEvent * event)
167 gboolean result = FALSE;
168 gboolean done = FALSE;
170 rtp_mux = gst_pad_get_parent_element (pad);
171 g_return_val_if_fail (rtp_mux != NULL, FALSE);
173 iter = gst_element_iterate_sink_pads (rtp_mux);
176 switch (gst_iterator_next (iter, (gpointer) & sinkpad)) {
177 case GST_ITERATOR_OK:
178 gst_event_ref (event);
179 result |= gst_pad_push_event (sinkpad, event);
180 gst_object_unref (sinkpad);
182 case GST_ITERATOR_RESYNC:
183 gst_iterator_resync (iter);
186 case GST_ITERATOR_ERROR:
187 GST_WARNING_OBJECT (rtp_mux, "Error iterating sinkpads");
188 case GST_ITERATOR_DONE:
193 gst_iterator_free (iter);
194 gst_object_unref (rtp_mux);
195 gst_event_unref (event);
201 gst_rtp_mux_init (GstRTPMux * object, GstRTPMuxClass * g_class)
203 GstElementClass *klass = GST_ELEMENT_GET_CLASS (object);
206 gst_pad_new_from_template (gst_element_class_get_pad_template (klass,
208 gst_pad_set_event_function (object->srcpad,
209 GST_DEBUG_FUNCPTR (gst_rtp_mux_src_event));
210 gst_element_add_pad (GST_ELEMENT (object), object->srcpad);
212 object->ssrc = DEFAULT_SSRC;
213 object->ts_offset = DEFAULT_TIMESTAMP_OFFSET;
214 object->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
216 object->segment_pending = TRUE;
220 gst_rtp_mux_setup_sinkpad (GstRTPMux * rtp_mux, GstPad * sinkpad)
222 GstRTPMuxClass *klass;
223 GstRTPMuxPadPrivate *padpriv = g_slice_new0 (GstRTPMuxPadPrivate);
225 klass = GST_RTP_MUX_GET_CLASS (rtp_mux);
227 /* setup some pad functions */
228 gst_pad_set_setcaps_function (sinkpad, gst_rtp_mux_setcaps);
229 gst_pad_set_getcaps_function (sinkpad, gst_rtp_mux_getcaps);
230 gst_pad_set_chain_function (sinkpad, GST_DEBUG_FUNCPTR (gst_rtp_mux_chain));
231 gst_pad_set_chain_list_function (sinkpad,
232 GST_DEBUG_FUNCPTR (gst_rtp_mux_chain_list));
233 gst_pad_set_event_function (sinkpad,
234 GST_DEBUG_FUNCPTR (gst_rtp_mux_sink_event));
237 gst_segment_init (&padpriv->segment, GST_FORMAT_UNDEFINED);
239 gst_pad_set_element_private (sinkpad, padpriv);
241 gst_pad_set_active (sinkpad, TRUE);
242 gst_element_add_pad (GST_ELEMENT (rtp_mux), sinkpad);
246 gst_rtp_mux_request_new_pad (GstElement * element,
247 GstPadTemplate * templ, const gchar * req_name)
252 g_return_val_if_fail (templ != NULL, NULL);
253 g_return_val_if_fail (GST_IS_RTP_MUX (element), NULL);
255 rtp_mux = GST_RTP_MUX (element);
257 if (templ->direction != GST_PAD_SINK) {
258 GST_WARNING_OBJECT (rtp_mux, "request pad that is not a SINK pad");
262 newpad = gst_pad_new_from_template (templ, req_name);
264 gst_rtp_mux_setup_sinkpad (rtp_mux, newpad);
266 GST_WARNING_OBJECT (rtp_mux, "failed to create request pad");
272 gst_rtp_mux_release_pad (GstElement * element, GstPad * pad)
274 GstRTPMuxPadPrivate *padpriv;
276 GST_OBJECT_LOCK (element);
277 padpriv = gst_pad_get_element_private (pad);
278 gst_pad_set_element_private (pad, NULL);
279 GST_OBJECT_UNLOCK (element);
281 gst_element_remove_pad (element, pad);
284 gst_caps_replace (&padpriv->out_caps, NULL);
285 g_slice_free (GstRTPMuxPadPrivate, padpriv);
289 /* Put our own clock-base on the buffer */
291 gst_rtp_mux_readjust_rtp_timestamp_locked (GstRTPMux * rtp_mux,
292 GstRTPMuxPadPrivate * padpriv, GstBuffer * buffer)
295 guint32 sink_ts_base = 0;
297 if (padpriv && padpriv->have_clock_base)
298 sink_ts_base = padpriv->clock_base;
300 ts = gst_rtp_buffer_get_timestamp (buffer) - sink_ts_base + rtp_mux->ts_base;
301 GST_LOG_OBJECT (rtp_mux, "Re-adjusting RTP ts %u to %u",
302 gst_rtp_buffer_get_timestamp (buffer), ts);
303 gst_rtp_buffer_set_timestamp (buffer, ts);
307 process_buffer_locked (GstRTPMux * rtp_mux, GstRTPMuxPadPrivate * padpriv,
310 GstRTPMuxClass *klass = GST_RTP_MUX_GET_CLASS (rtp_mux);
312 if (klass->accept_buffer_locked)
313 if (!klass->accept_buffer_locked (rtp_mux, padpriv, buffer))
317 gst_rtp_buffer_set_seq (buffer, rtp_mux->seqnum);
319 gst_rtp_buffer_set_ssrc (buffer, rtp_mux->current_ssrc);
320 gst_rtp_mux_readjust_rtp_timestamp_locked (rtp_mux, padpriv, buffer);
321 GST_LOG_OBJECT (rtp_mux, "Pushing packet size %d, seq=%d, ts=%u",
322 GST_BUFFER_SIZE (buffer), rtp_mux->seqnum,
323 gst_rtp_buffer_get_timestamp (buffer));
326 gst_buffer_set_caps (buffer, padpriv->out_caps);
327 if (padpriv->segment.format == GST_FORMAT_TIME)
328 GST_BUFFER_TIMESTAMP (buffer) =
329 gst_segment_to_running_time (&padpriv->segment, GST_FORMAT_TIME,
330 GST_BUFFER_TIMESTAMP (buffer));
337 gst_rtp_mux_chain_list (GstPad * pad, GstBufferList * bufferlist)
341 GstBufferListIterator *it;
342 GstRTPMuxPadPrivate *padpriv;
343 GstEvent *newseg_event = NULL;
344 gboolean drop = TRUE;
346 rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
348 if (!gst_rtp_buffer_list_validate (bufferlist)) {
349 GST_ERROR_OBJECT (rtp_mux, "Invalid RTP buffer");
350 gst_object_unref (rtp_mux);
351 return GST_FLOW_ERROR;
354 GST_OBJECT_LOCK (rtp_mux);
356 padpriv = gst_pad_get_element_private (pad);
358 GST_OBJECT_UNLOCK (rtp_mux);
359 ret = GST_FLOW_NOT_LINKED;
360 gst_buffer_list_unref (bufferlist);
364 bufferlist = gst_buffer_list_make_writable (bufferlist);
365 it = gst_buffer_list_iterate (bufferlist);
366 while (gst_buffer_list_iterator_next_group (it)) {
369 rtpbuf = gst_buffer_list_iterator_next (it);
370 rtpbuf = gst_buffer_make_writable (rtpbuf);
372 drop = !process_buffer_locked (rtp_mux, padpriv, rtpbuf);
377 gst_buffer_list_iterator_take (it, rtpbuf);
379 gst_buffer_list_iterator_free (it);
381 if (!drop && rtp_mux->segment_pending) {
383 * We set the start at 0, because we re-timestamps to the running time
385 newseg_event = gst_event_new_new_segment_full (FALSE, 1.0, 1.0,
386 GST_FORMAT_TIME, 0, -1, 0);
388 rtp_mux->segment_pending = FALSE;
391 GST_OBJECT_UNLOCK (rtp_mux);
394 gst_pad_push_event (rtp_mux->srcpad, newseg_event);
397 gst_buffer_list_unref (bufferlist);
400 ret = gst_pad_push_list (rtp_mux->srcpad, bufferlist);
405 gst_object_unref (rtp_mux);
411 gst_rtp_mux_chain (GstPad * pad, GstBuffer * buffer)
415 GstRTPMuxPadPrivate *padpriv;
416 GstEvent *newseg_event = NULL;
419 rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
421 if (!gst_rtp_buffer_validate (buffer)) {
422 gst_buffer_unref (buffer);
423 GST_ERROR_OBJECT (rtp_mux, "Invalid RTP buffer");
424 gst_object_unref (rtp_mux);
425 return GST_FLOW_ERROR;
428 GST_OBJECT_LOCK (rtp_mux);
429 padpriv = gst_pad_get_element_private (pad);
432 GST_OBJECT_UNLOCK (rtp_mux);
433 ret = GST_FLOW_NOT_LINKED;
434 gst_buffer_unref (buffer);
438 buffer = gst_buffer_make_writable (buffer);
440 drop = !process_buffer_locked (rtp_mux, padpriv, buffer);
442 if (!drop && rtp_mux->segment_pending) {
444 * We set the start at 0, because we re-timestamps to the running time
446 newseg_event = gst_event_new_new_segment_full (FALSE, 1.0, 1.0,
447 GST_FORMAT_TIME, 0, -1, 0);
449 rtp_mux->segment_pending = FALSE;
451 GST_OBJECT_UNLOCK (rtp_mux);
454 gst_pad_push_event (rtp_mux->srcpad, newseg_event);
457 gst_buffer_unref (buffer);
460 ret = gst_pad_push (rtp_mux->srcpad, buffer);
465 gst_object_unref (rtp_mux);
470 gst_rtp_mux_setcaps (GstPad * pad, GstCaps * caps)
473 GstStructure *structure;
474 gboolean ret = FALSE;
475 GstRTPMuxPadPrivate *padpriv;
477 rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
479 structure = gst_caps_get_structure (caps, 0);
484 GST_OBJECT_LOCK (rtp_mux);
485 padpriv = gst_pad_get_element_private (pad);
487 gst_structure_get_uint (structure, "clock-base", &padpriv->clock_base)) {
488 padpriv->have_clock_base = TRUE;
490 GST_OBJECT_UNLOCK (rtp_mux);
492 caps = gst_caps_copy (caps);
494 gst_caps_set_simple (caps,
495 "clock-base", G_TYPE_UINT, rtp_mux->ts_base,
496 "seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base, NULL);
498 GST_DEBUG_OBJECT (rtp_mux,
499 "setting caps %" GST_PTR_FORMAT " on src pad..", caps);
500 ret = gst_pad_set_caps (rtp_mux->srcpad, caps);
502 if (rtp_mux->ssrc == -1) {
503 if (gst_structure_has_field_typed (structure, "ssrc", G_TYPE_UINT)) {
504 rtp_mux->current_ssrc = g_value_get_uint
505 (gst_structure_get_value (structure, "ssrc"));
510 GST_OBJECT_LOCK (rtp_mux);
511 padpriv = gst_pad_get_element_private (pad);
513 gst_caps_replace (&padpriv->out_caps, caps);
514 GST_OBJECT_UNLOCK (rtp_mux);
516 gst_caps_unref (caps);
519 gst_object_unref (rtp_mux);
525 clear_caps (GstCaps * caps, gboolean only_clock_rate)
529 /* Lets only match on the clock-rate */
530 for (i = 0; i < gst_caps_get_size (caps); i++) {
531 GstStructure *s = gst_caps_get_structure (caps, i);
533 for (j = 0; j < gst_structure_n_fields (s); j++) {
534 const gchar *name = gst_structure_nth_field_name (s, j);
536 if (strcmp (name, "clock-rate") && (only_clock_rate ||
537 (strcmp (name, "ssrc")))) {
538 gst_structure_remove_field (s, name);
546 same_clock_rate_fold (gpointer item, GValue * ret, gpointer user_data)
548 GstPad *mypad = user_data;
552 const GstCaps *accumcaps;
556 gst_object_unref (pad);
560 peercaps = gst_pad_peer_get_caps (pad);
562 gst_object_unref (pad);
566 othercaps = gst_caps_intersect (peercaps,
567 gst_pad_get_pad_template_caps (pad));
568 gst_caps_unref (peercaps);
570 accumcaps = gst_value_get_caps (ret);
572 clear_caps (othercaps, TRUE);
574 intersect = gst_caps_intersect (accumcaps, othercaps);
576 g_value_take_boxed (ret, intersect);
578 gst_caps_unref (othercaps);
579 gst_object_unref (pad);
581 return !gst_caps_is_empty (intersect);
585 gst_rtp_mux_getcaps (GstPad * pad)
587 GstRTPMux *mux = GST_RTP_MUX (gst_pad_get_parent (pad));
588 GstCaps *caps = NULL;
589 GstIterator *iter = NULL;
591 GstIteratorResult res;
592 GstCaps *peercaps = gst_pad_peer_get_caps (mux->srcpad);
593 GstCaps *othercaps = NULL;
596 othercaps = gst_caps_intersect (peercaps,
597 gst_pad_get_pad_template_caps (pad));
598 gst_caps_unref (peercaps);
600 othercaps = gst_caps_copy (gst_pad_get_pad_template_caps (mux->srcpad));
603 clear_caps (othercaps, FALSE);
605 g_value_init (&v, GST_TYPE_CAPS);
607 iter = gst_element_iterate_sink_pads (GST_ELEMENT (mux));
609 gst_value_set_caps (&v, othercaps);
610 res = gst_iterator_fold (iter, same_clock_rate_fold, &v, pad);
611 } while (res == GST_ITERATOR_RESYNC);
612 gst_iterator_free (iter);
614 caps = (GstCaps *) gst_value_get_caps (&v);
616 if (res == GST_ITERATOR_ERROR) {
617 gst_caps_unref (caps);
618 caps = gst_caps_new_empty ();
622 gst_caps_unref (othercaps);
623 gst_object_unref (mux);
630 gst_rtp_mux_get_property (GObject * object,
631 guint prop_id, GValue * value, GParamSpec * pspec)
635 rtp_mux = GST_RTP_MUX (object);
638 case PROP_TIMESTAMP_OFFSET:
639 g_value_set_int (value, rtp_mux->ts_offset);
641 case PROP_SEQNUM_OFFSET:
642 g_value_set_int (value, rtp_mux->seqnum_offset);
645 GST_OBJECT_LOCK (rtp_mux);
646 g_value_set_uint (value, rtp_mux->seqnum);
647 GST_OBJECT_UNLOCK (rtp_mux);
650 g_value_set_uint (value, rtp_mux->ssrc);
653 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
659 gst_rtp_mux_set_property (GObject * object,
660 guint prop_id, const GValue * value, GParamSpec * pspec)
664 rtp_mux = GST_RTP_MUX (object);
667 case PROP_TIMESTAMP_OFFSET:
668 rtp_mux->ts_offset = g_value_get_int (value);
670 case PROP_SEQNUM_OFFSET:
671 rtp_mux->seqnum_offset = g_value_get_int (value);
674 rtp_mux->ssrc = g_value_get_uint (value);
677 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
683 gst_rtp_mux_sink_event (GstPad * pad, GstEvent * event)
687 gboolean ret = FALSE;
688 gboolean forward = TRUE;
690 mux = GST_RTP_MUX (gst_pad_get_parent (pad));
692 switch (GST_EVENT_TYPE (event)) {
693 case GST_EVENT_FLUSH_STOP:
695 GstRTPMuxPadPrivate *padpriv;
697 GST_OBJECT_LOCK (mux);
698 mux->segment_pending = TRUE;
699 padpriv = gst_pad_get_element_private (pad);
701 gst_segment_init (&padpriv->segment, GST_FORMAT_UNDEFINED);
702 GST_OBJECT_UNLOCK (mux);
705 case GST_EVENT_NEWSEGMENT:
708 gdouble rate, applied_rate;
710 gint64 start, stop, position;
711 GstRTPMuxPadPrivate *padpriv;
713 gst_event_parse_new_segment_full (event, &update, &rate, &applied_rate,
714 &format, &start, &stop, &position);
716 GST_OBJECT_LOCK (mux);
717 padpriv = gst_pad_get_element_private (pad);
720 if (format == GST_FORMAT_TIME)
721 gst_segment_set_newsegment_full (&padpriv->segment, update,
722 rate, applied_rate, format, start, stop, position);
724 gst_segment_init (&padpriv->segment, GST_FORMAT_UNDEFINED);
726 GST_OBJECT_UNLOCK (mux);
727 gst_event_unref (event);
737 ret = gst_pad_push_event (mux->srcpad, event);
739 gst_object_unref (mux);
745 clear_segment (gpointer data, gpointer user_data)
748 GstRTPMux *mux = user_data;
749 GstRTPMuxPadPrivate *padpriv;
751 GST_OBJECT_LOCK (mux);
752 padpriv = gst_pad_get_element_private (pad);
754 gst_segment_init (&padpriv->segment, GST_FORMAT_UNDEFINED);
755 GST_OBJECT_UNLOCK (mux);
757 gst_object_unref (pad);
762 gst_rtp_mux_ready_to_paused (GstRTPMux * rtp_mux)
766 iter = gst_element_iterate_sink_pads (GST_ELEMENT (rtp_mux));
767 while (gst_iterator_foreach (iter, clear_segment, rtp_mux) ==
768 GST_ITERATOR_RESYNC);
769 gst_iterator_free (iter);
771 GST_OBJECT_LOCK (rtp_mux);
772 rtp_mux->segment_pending = TRUE;
774 if (rtp_mux->ssrc == -1)
775 rtp_mux->current_ssrc = g_random_int ();
777 rtp_mux->current_ssrc = rtp_mux->ssrc;
779 if (rtp_mux->seqnum_offset == -1)
780 rtp_mux->seqnum_base = g_random_int_range (0, G_MAXUINT16);
782 rtp_mux->seqnum_base = rtp_mux->seqnum_offset;
783 rtp_mux->seqnum = rtp_mux->seqnum_base;
785 if (rtp_mux->ts_offset == -1)
786 rtp_mux->ts_base = g_random_int ();
788 rtp_mux->ts_base = rtp_mux->ts_offset;
790 GST_DEBUG_OBJECT (rtp_mux, "set clock-base to %u", rtp_mux->ts_base);
792 GST_OBJECT_UNLOCK (rtp_mux);
795 static GstStateChangeReturn
796 gst_rtp_mux_change_state (GstElement * element, GstStateChange transition)
800 rtp_mux = GST_RTP_MUX (element);
802 switch (transition) {
803 case GST_STATE_CHANGE_NULL_TO_READY:
805 case GST_STATE_CHANGE_READY_TO_PAUSED:
806 gst_rtp_mux_ready_to_paused (rtp_mux);
808 case GST_STATE_CHANGE_PAUSED_TO_READY:
814 return GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
818 gst_rtp_mux_plugin_init (GstPlugin * plugin)
820 GST_DEBUG_CATEGORY_INIT (gst_rtp_mux_debug, "rtpmux", 0, "rtp muxer");
822 return gst_element_register (plugin, "rtpmux", GST_RANK_NONE,