mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-28 04:31:06 +00:00
[MOVED FROM GST-P-FARSIGHT] Only accept RTP streams that have the same clock-rate
20070323163139-65035-fc0b17b0b8a7a041f48994c4f26e96568168bf95.gz
This commit is contained in:
parent
a7afa08394
commit
45c083c2df
2 changed files with 52 additions and 23 deletions
|
@ -54,12 +54,14 @@ GST_ELEMENT_DETAILS ("RTP muxer",
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
ARG_0,
|
ARG_0,
|
||||||
|
PROP_CLOCK_RATE,
|
||||||
PROP_SEQNUM_OFFSET,
|
PROP_SEQNUM_OFFSET,
|
||||||
PROP_SEQNUM
|
PROP_SEQNUM
|
||||||
/* FILL ME */
|
/* FILL ME */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DEFAULT_SEQNUM_OFFSET -1
|
#define DEFAULT_SEQNUM_OFFSET -1
|
||||||
|
#define DEFAULT_CLOCK_RATE 0
|
||||||
|
|
||||||
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
static GstStaticPadTemplate src_factory = GST_STATIC_PAD_TEMPLATE ("src",
|
||||||
GST_PAD_SRC,
|
GST_PAD_SRC,
|
||||||
|
@ -148,6 +150,10 @@ gst_rtp_mux_class_init (GstRTPMuxClass * klass)
|
||||||
gobject_class->get_property = gst_rtp_mux_get_property;
|
gobject_class->get_property = gst_rtp_mux_get_property;
|
||||||
gobject_class->set_property = gst_rtp_mux_set_property;
|
gobject_class->set_property = gst_rtp_mux_set_property;
|
||||||
|
|
||||||
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_CLOCK_RATE,
|
||||||
|
g_param_spec_uint ("clock-rate", "clockrate",
|
||||||
|
"The clock-rate of the RTP streams",
|
||||||
|
0, G_MAXUINT, DEFAULT_CLOCK_RATE, G_PARAM_READWRITE));
|
||||||
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM_OFFSET,
|
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_SEQNUM_OFFSET,
|
||||||
g_param_spec_int ("seqnum-offset", "Sequence number Offset",
|
g_param_spec_int ("seqnum-offset", "Sequence number Offset",
|
||||||
"Offset to add to all outgoing seqnum (-1 = random)", -1, G_MAXINT,
|
"Offset to add to all outgoing seqnum (-1 = random)", -1, G_MAXINT,
|
||||||
|
@ -174,6 +180,7 @@ gst_rtp_mux_init (GstRTPMux * rtp_mux)
|
||||||
gst_element_add_pad (GST_ELEMENT (rtp_mux), rtp_mux->srcpad);
|
gst_element_add_pad (GST_ELEMENT (rtp_mux), rtp_mux->srcpad);
|
||||||
|
|
||||||
rtp_mux->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
|
rtp_mux->seqnum_offset = DEFAULT_SEQNUM_OFFSET;
|
||||||
|
rtp_mux->clock_rate = DEFAULT_CLOCK_RATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -275,39 +282,53 @@ gst_rtp_mux_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gst_rtp_mux_set_clock_rate (GstRTPMux *rtp_mux, gint clock_rate)
|
||||||
|
{
|
||||||
|
gint ret = TRUE;
|
||||||
|
|
||||||
|
if (rtp_mux->clock_rate == 0) {
|
||||||
|
rtp_mux->clock_rate = clock_rate;
|
||||||
|
ret = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (rtp_mux->clock_rate != clock_rate) {
|
||||||
|
GST_WARNING_OBJECT (rtp_mux, "Clock-rate already set to: %u",
|
||||||
|
rtp_mux->clock_rate);
|
||||||
|
ret = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_rtp_mux_setcaps (GstPad *pad, GstCaps *caps)
|
gst_rtp_mux_setcaps (GstPad *pad, GstCaps *caps)
|
||||||
{
|
{
|
||||||
/*GstRTPMux *rtp_mux;
|
GstRTPMux *rtp_mux;
|
||||||
GstCaps *old_caps;
|
gboolean ret = TRUE;
|
||||||
GstCaps *new_caps;
|
|
||||||
gint i;
|
gint i;
|
||||||
gboolean ret;
|
|
||||||
|
|
||||||
rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
|
rtp_mux = GST_RTP_MUX (gst_pad_get_parent (pad));
|
||||||
|
|
||||||
new_caps = gst_caps_copy (caps);
|
for (i = 0;i < gst_caps_get_size (caps); i++) {
|
||||||
|
gint clock_rate;
|
||||||
|
GstStructure *structure;
|
||||||
|
|
||||||
/ * We want our own seq base on the caps * /
|
structure = gst_caps_get_structure (caps, 0);
|
||||||
for (i=0; i< gst_caps_get_size (new_caps); i++) {
|
if (gst_structure_get_int (structure, "clock-rate", &clock_rate)) {
|
||||||
GstStructure *structure = gst_caps_get_structure (new_caps, i);
|
ret = gst_rtp_mux_set_clock_rate (rtp_mux, clock_rate);
|
||||||
gst_structure_set (structure,
|
if (!ret)
|
||||||
"seqnum-base", G_TYPE_UINT, rtp_mux->seqnum_base, NULL);
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
old_caps = GST_PAD_CAPS (rtp_mux->srcpad);
|
|
||||||
if (old_caps != NULL) {
|
|
||||||
new_caps = gst_caps_union (old_caps, new_caps);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
GST_DEBUG_OBJECT (rtp_mux,
|
GST_DEBUG_OBJECT (rtp_mux,
|
||||||
"seting caps %" GST_PTR_FORMAT " on src pad..", caps);
|
"seting caps %" GST_PTR_FORMAT " on src pad..", caps);
|
||||||
ret = gst_pad_set_caps (rtp_mux->srcpad, new_caps);
|
ret = gst_pad_set_caps (rtp_mux->srcpad, caps);
|
||||||
gst_caps_unref (new_caps);
|
}
|
||||||
|
|
||||||
return ret;*/
|
return ret;
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -319,6 +340,9 @@ gst_rtp_mux_get_property (GObject * object,
|
||||||
rtp_mux = GST_RTP_MUX (object);
|
rtp_mux = GST_RTP_MUX (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_CLOCK_RATE:
|
||||||
|
g_value_set_uint (value, rtp_mux->clock_rate);
|
||||||
|
break;
|
||||||
case PROP_SEQNUM_OFFSET:
|
case PROP_SEQNUM_OFFSET:
|
||||||
g_value_set_int (value, rtp_mux->seqnum_offset);
|
g_value_set_int (value, rtp_mux->seqnum_offset);
|
||||||
break;
|
break;
|
||||||
|
@ -340,6 +364,9 @@ gst_rtp_mux_set_property (GObject * object,
|
||||||
rtp_mux = GST_RTP_MUX (object);
|
rtp_mux = GST_RTP_MUX (object);
|
||||||
|
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
|
case PROP_CLOCK_RATE:
|
||||||
|
rtp_mux->clock_rate = g_value_get_uint (value);
|
||||||
|
break;
|
||||||
case PROP_SEQNUM_OFFSET:
|
case PROP_SEQNUM_OFFSET:
|
||||||
rtp_mux->seqnum_offset = g_value_get_int (value);
|
rtp_mux->seqnum_offset = g_value_get_int (value);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -58,6 +58,8 @@ struct _GstRTPMux
|
||||||
guint16 seqnum_base;
|
guint16 seqnum_base;
|
||||||
gint16 seqnum_offset;
|
gint16 seqnum_offset;
|
||||||
guint16 seqnum;
|
guint16 seqnum;
|
||||||
|
|
||||||
|
guint32 clock_rate;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GstRTPMuxClass
|
struct _GstRTPMuxClass
|
||||||
|
|
Loading…
Reference in a new issue