summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorDave Robillard <dave@drobilla.net>2009-07-03 20:01:36 -0400
committerDave Robillard <dave@drobilla.net>2009-07-03 20:01:36 -0400
commite289c875a5e0ee56dd8289e78b63f36f709b6534 (patch)
tree9bd2b450261bbc0fa522bf27d9a89d017308687e /gst
parented06ed3b658b49b1313df38909bcb2f907be83a7 (diff)
parentcaba48f261421d397900471b19350da2e5a4a4e5 (diff)
downloadgst-plugins-bad-e289c875a5e0ee56dd8289e78b63f36f709b6534.tar.gz
gst-plugins-bad-e289c875a5e0ee56dd8289e78b63f36f709b6534.tar.bz2
gst-plugins-bad-e289c875a5e0ee56dd8289e78b63f36f709b6534.zip
Merge branch 'fdo' into lv2
Diffstat (limited to 'gst')
-rw-r--r--gst/camerabin/camerabinpreview.c15
-rw-r--r--gst/camerabin/camerabinvideo.c8
-rw-r--r--gst/camerabin/gstcamerabin.c87
-rw-r--r--gst/debugutils/Makefile.am4
-rw-r--r--gst/debugutils/debugutilsbad.c5
-rw-r--r--gst/debugutils/gstcapssetter.c350
-rw-r--r--gst/debugutils/gstcapssetter.h62
-rw-r--r--gst/freeze/Makefile.am1
-rw-r--r--gst/frei0r/gstfrei0r.c47
-rw-r--r--gst/frei0r/gstfrei0rfilter.c27
-rw-r--r--gst/frei0r/gstfrei0rfilter.h2
-rw-r--r--gst/frei0r/gstfrei0rmixer.c29
-rw-r--r--gst/frei0r/gstfrei0rsrc.c26
-rw-r--r--gst/mpegdemux/mpegtspacketizer.c37
-rw-r--r--gst/rtpmanager/Makefile.am2
-rw-r--r--gst/rtpmanager/gstrtpbin.c240
-rw-r--r--gst/rtpmanager/gstrtpbin.h2
-rw-r--r--gst/rtpmanager/gstrtpclient.c484
-rw-r--r--gst/rtpmanager/gstrtpclient.h56
-rw-r--r--gst/rtpmanager/gstrtpmanager.c5
-rw-r--r--gst/rtpmanager/gstrtpsession.c112
-rw-r--r--gst/rtpmanager/rtpsession.c153
-rw-r--r--gst/rtpmanager/rtpsession.h3
-rw-r--r--gst/rtpmanager/rtpsource.c99
-rw-r--r--gst/rtpmanager/rtpsource.h3
-rw-r--r--gst/shapewipe/gstshapewipe.c279
-rw-r--r--gst/shapewipe/gstshapewipe.h1
27 files changed, 940 insertions, 1199 deletions
diff --git a/gst/camerabin/camerabinpreview.c b/gst/camerabin/camerabinpreview.c
index b64b2143..9b12bbac 100644
--- a/gst/camerabin/camerabinpreview.c
+++ b/gst/camerabin/camerabinpreview.c
@@ -183,7 +183,7 @@ gst_camerabin_preview_convert (GstCameraBin * camera, GstBuffer * buf)
if (!src || !sink) {
GST_WARNING ("pipeline doesn't have src / sink elements");
- goto no_pipeline;
+ goto missing_elements;
}
g_object_set (src, "size", (gint64) GST_BUFFER_SIZE (buf),
@@ -234,6 +234,7 @@ gst_camerabin_preview_convert (GstCameraBin * camera, GstBuffer * buf)
g_return_val_if_reached (NULL);
}
}
+ gst_message_unref (msg);
} else {
g_warning ("Could not make preview image: %s", "timeout during conversion");
result = NULL;
@@ -245,9 +246,21 @@ gst_camerabin_preview_convert (GstCameraBin * camera, GstBuffer * buf)
GST_BUFFER_FLAGS (buf) = bflags;
+done:
+ if (src)
+ gst_object_unref (src);
+ if (sink)
+ gst_object_unref (sink);
+
return result;
/* ERRORS */
+missing_elements:
+ {
+ g_warning ("Could not make preview image: %s",
+ "missing elements in pipeline (unknown error)");
+ goto done;
+ }
no_pipeline:
{
g_warning ("Could not make preview image: %s",
diff --git a/gst/camerabin/camerabinvideo.c b/gst/camerabin/camerabinvideo.c
index 2569772a..4bbc5057 100644
--- a/gst/camerabin/camerabinvideo.c
+++ b/gst/camerabin/camerabinvideo.c
@@ -398,6 +398,7 @@ camerabin_video_pad_tee_src0_have_buffer (GstPad * pad, GstBuffer * buffer,
GstEvent *event;
GstObject *tee;
GstPad *sinkpad;
+
vid->adjust_ts_video = GST_BUFFER_TIMESTAMP (buffer) - vid->last_ts_video;
vid->calculate_adjust_ts_video = FALSE;
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
@@ -417,7 +418,6 @@ camerabin_video_pad_tee_src0_have_buffer (GstPad * pad, GstBuffer * buffer,
if (GST_BUFFER_DURATION_IS_VALID (buffer))
vid->last_ts_video += GST_BUFFER_DURATION (buffer);
-
GST_LOG ("buffer out with size %d ts %" GST_TIME_FORMAT,
GST_BUFFER_SIZE (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
return TRUE;
@@ -442,6 +442,7 @@ camerabin_video_pad_aud_src_have_buffer (GstPad * pad, GstBuffer * buffer,
if (vid->calculate_adjust_ts_aud) {
GstEvent *event;
GstPad *peerpad = NULL;
+
vid->adjust_ts_aud = GST_BUFFER_TIMESTAMP (buffer) - vid->last_ts_aud;
vid->calculate_adjust_ts_aud = FALSE;
event = gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_TIME,
@@ -459,6 +460,7 @@ camerabin_video_pad_aud_src_have_buffer (GstPad * pad, GstBuffer * buffer,
vid->last_ts_aud = GST_BUFFER_TIMESTAMP (buffer);
if (GST_BUFFER_DURATION_IS_VALID (buffer))
vid->last_ts_aud += GST_BUFFER_DURATION (buffer);
+
GST_LOG ("buffer out with size %d ts %" GST_TIME_FORMAT,
GST_BUFFER_SIZE (buffer), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buffer)));
return TRUE;
@@ -549,6 +551,7 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
vid_sinkpad = gst_element_get_static_pad (vid->tee, "sink");
}
gst_ghost_pad_set_target (GST_GHOST_PAD (vid->sinkpad), vid_sinkpad);
+ gst_object_unref (vid_sinkpad);
/* Add queue element for video */
@@ -668,6 +671,7 @@ gst_camerabin_video_create_elements (GstCameraBinVideo * vid)
/* Never let video bin eos events reach view finder */
gst_pad_add_event_probe (vid_srcpad,
G_CALLBACK (gst_camerabin_drop_eos_probe), vid);
+ gst_object_unref (vid_srcpad);
pad = gst_element_get_static_pad (vid->aud_src, "src");
gst_pad_add_buffer_probe (pad,
@@ -702,10 +706,12 @@ gst_camerabin_video_destroy_elements (GstCameraBinVideo * vid)
/* Release tee request pads */
if (vid->tee_video_srcpad) {
gst_element_release_request_pad (vid->tee, vid->tee_video_srcpad);
+ gst_object_unref (vid->tee_video_srcpad);
vid->tee_video_srcpad = NULL;
}
if (vid->tee_vf_srcpad) {
gst_element_release_request_pad (vid->tee, vid->tee_vf_srcpad);
+ gst_object_unref (vid->tee_vf_srcpad);
vid->tee_vf_srcpad = NULL;
}
diff --git a/gst/camerabin/gstcamerabin.c b/gst/camerabin/gstcamerabin.c
index 0a110f50..9d8a14cc 100644
--- a/gst/camerabin/gstcamerabin.c
+++ b/gst/camerabin/gstcamerabin.c
@@ -500,8 +500,7 @@ camerabin_setup_src_elements (GstCameraBin * camera)
if (camera->fps_n > 0 && camera->fps_d > 0) {
if (camera->night_mode) {
- GST_WARNING_OBJECT (camera,
- "night mode, lowest allowed fps will be forced");
+ GST_INFO_OBJECT (camera, "night mode, lowest allowed fps will be forced");
camera->pre_night_fps_n = camera->fps_n;
camera->pre_night_fps_d = camera->fps_d;
detect_framerate = TRUE;
@@ -531,7 +530,9 @@ camerabin_setup_src_elements (GstCameraBin * camera)
g_object_set (camera->src_zoom_scale, "method",
CAMERABIN_DEFAULT_ZOOM_METHOD, NULL);
+ /* we create new caps in any way and they take ownership of the structure st */
gst_caps_replace (&camera->view_finder_caps, new_caps);
+ gst_caps_unref (new_caps);
/* Set caps for view finder mode */
gst_camerabin_set_capsfilter_caps (camera, camera->view_finder_caps);
@@ -805,22 +806,27 @@ camerabin_destroy_elements (GstCameraBin * camera)
/* Release request pads */
if (camera->pad_view_vid) {
gst_element_release_request_pad (camera->view_in_sel, camera->pad_view_vid);
+ gst_object_unref (camera->pad_view_vid);
camera->pad_view_vid = NULL;
}
if (camera->pad_src_vid) {
gst_element_release_request_pad (camera->src_out_sel, camera->pad_src_vid);
+ gst_object_unref (camera->pad_src_vid);
camera->pad_src_vid = NULL;
}
if (camera->pad_src_img) {
gst_element_release_request_pad (camera->src_out_sel, camera->pad_src_img);
+ gst_object_unref (camera->pad_src_img);
camera->pad_src_img = NULL;
}
if (camera->pad_view_src) {
gst_element_release_request_pad (camera->view_in_sel, camera->pad_view_src);
+ /* don't unref, we have not requested it */
camera->pad_view_src = NULL;
}
if (camera->pad_src_view) {
gst_element_release_request_pad (camera->src_out_sel, camera->pad_src_view);
+ gst_object_unref (camera->pad_src_view);
camera->pad_src_view = NULL;
}
@@ -856,6 +862,8 @@ camerabin_destroy_elements (GstCameraBin * camera)
static void
camerabin_dispose_elements (GstCameraBin * camera)
{
+ GST_INFO ("cleaning");
+
if (camera->capture_mutex) {
g_mutex_free (camera->capture_mutex);
camera->capture_mutex = NULL;
@@ -878,24 +886,18 @@ camerabin_dispose_elements (GstCameraBin * camera)
camera->user_vid_src = NULL;
}
+ /* Free caps */
if (camera->image_capture_caps) {
- gst_caps_unref (camera->image_capture_caps);
- camera->image_capture_caps = NULL;
+ gst_caps_replace (&camera->image_capture_caps, NULL);
}
-
if (camera->view_finder_caps) {
- gst_caps_unref (camera->view_finder_caps);
- camera->view_finder_caps = NULL;
+ gst_caps_replace (&camera->view_finder_caps, NULL);
}
-
if (camera->allowed_caps) {
- gst_caps_unref (camera->allowed_caps);
- camera->allowed_caps = NULL;
+ gst_caps_replace (&camera->allowed_caps, NULL);
}
-
if (camera->preview_caps) {
- gst_caps_unref (camera->preview_caps);
- camera->preview_caps = NULL;
+ gst_caps_replace (&camera->preview_caps, NULL);
}
if (camera->event_tags) {
@@ -1685,6 +1687,7 @@ gst_camerabin_send_preview (GstCameraBin * camera, GstBuffer * buffer)
if (prev) {
s = gst_structure_new (PREVIEW_MESSAGE_NAME,
"buffer", GST_TYPE_BUFFER, prev, NULL);
+ gst_buffer_unref (prev);
msg = gst_message_new_element (GST_OBJECT (camera), s);
@@ -2202,30 +2205,32 @@ gst_camerabin_update_aspect_filter (GstCameraBin * camera, GstCaps * new_caps)
if (sink_pad) {
sink_caps = gst_pad_get_caps (sink_pad);
gst_object_unref (sink_pad);
- if (sink_caps && !gst_caps_is_any (sink_caps)) {
- GST_DEBUG_OBJECT (camera, "sink element caps %" GST_PTR_FORMAT,
- sink_caps);
- /* Get maximum resolution that view finder sink accepts */
- st = gst_caps_get_structure (sink_caps, 0);
- if (gst_structure_has_field_typed (st, "width", GST_TYPE_INT_RANGE)) {
- range = gst_structure_get_value (st, "width");
- sink_w = gst_value_get_int_range_max (range);
- }
- if (gst_structure_has_field_typed (st, "height", GST_TYPE_INT_RANGE)) {
- range = gst_structure_get_value (st, "height");
- sink_h = gst_value_get_int_range_max (range);
+ if (sink_caps) {
+ if (!gst_caps_is_any (sink_caps)) {
+ GST_DEBUG_OBJECT (camera, "sink element caps %" GST_PTR_FORMAT,
+ sink_caps);
+ /* Get maximum resolution that view finder sink accepts */
+ st = gst_caps_get_structure (sink_caps, 0);
+ if (gst_structure_has_field_typed (st, "width", GST_TYPE_INT_RANGE)) {
+ range = gst_structure_get_value (st, "width");
+ sink_w = gst_value_get_int_range_max (range);
+ }
+ if (gst_structure_has_field_typed (st, "height", GST_TYPE_INT_RANGE)) {
+ range = gst_structure_get_value (st, "height");
+ sink_h = gst_value_get_int_range_max (range);
+ }
+ GST_DEBUG_OBJECT (camera, "sink element accepts max %dx%d", sink_w,
+ sink_h);
+
+ /* Get incoming frames' resolution */
+ if (sink_h && sink_w) {
+ st = gst_caps_get_structure (new_caps, 0);
+ gst_structure_get_int (st, "width", &in_w);
+ gst_structure_get_int (st, "height", &in_h);
+ GST_DEBUG_OBJECT (camera, "new caps with %dx%d", in_w, in_h);
+ }
}
gst_caps_unref (sink_caps);
- GST_DEBUG_OBJECT (camera, "sink element accepts max %dx%d", sink_w,
- sink_h);
-
- /* Get incoming frames' resolution */
- if (sink_h && sink_w) {
- st = gst_caps_get_structure (new_caps, 0);
- gst_structure_get_int (st, "width", &in_w);
- gst_structure_get_int (st, "height", &in_h);
- GST_DEBUG_OBJECT (camera, "new caps with %dx%d", in_w, in_h);
- }
}
}
@@ -2251,13 +2256,14 @@ gst_camerabin_update_aspect_filter (GstCameraBin * camera, GstCaps * new_caps)
G_TYPE_INT, target_h, NULL);
} else {
GST_DEBUG_OBJECT (camera, "no scaling");
- ar_caps = gst_caps_ref (new_caps);
+ ar_caps = new_caps;
}
GST_DEBUG_OBJECT (camera, "aspect ratio filter caps %" GST_PTR_FORMAT,
ar_caps);
g_object_set (G_OBJECT (camera->aspect_filter), "caps", ar_caps, NULL);
- gst_caps_unref (ar_caps);
+ if (ar_caps != new_caps)
+ gst_caps_unref (ar_caps);
#endif
}
@@ -2742,7 +2748,6 @@ gst_camerabin_dispose (GObject * object)
gst_camerabin_preview_destroy_pipeline (camera);
camerabin_destroy_elements (camera);
-
camerabin_dispose_elements (camera);
G_OBJECT_CLASS (parent_class)->dispose (object);
@@ -2860,7 +2865,9 @@ gst_camerabin_set_property (GObject * object, guint prop_id,
if (camera->view_finder_caps) {
gst_caps_unref (camera->view_finder_caps);
}
- camera->view_finder_caps = gst_caps_copy (gst_value_get_caps (value));
+ /* just ref, we don't modify it inplace */
+ camera->view_finder_caps =
+ gst_caps_ref ((GstCaps *) gst_value_get_caps (value));
GST_OBJECT_UNLOCK (camera);
if (GST_STATE (camera) != GST_STATE_NULL) {
gst_camerabin_set_capsfilter_caps (camera, camera->view_finder_caps);
@@ -3139,6 +3146,8 @@ gst_camerabin_user_start (GstCameraBin * camera)
if (camera->capturing) {
GST_WARNING_OBJECT (camera, "capturing \"%s\" ongoing, set new filename",
camera->filename->str);
+ /* FIXME: we need to send something more to the app, so that it does not for
+ * for img-done */
g_mutex_unlock (camera->capture_mutex);
return;
}
diff --git a/gst/debugutils/Makefile.am b/gst/debugutils/Makefile.am
index 3b93fa91..60fb794a 100644
--- a/gst/debugutils/Makefile.am
+++ b/gst/debugutils/Makefile.am
@@ -1,10 +1,10 @@
plugin_LTLIBRARIES = libgstdebugutilsbad.la
-libgstdebugutilsbad_la_SOURCES = fpsdisplaysink.c debugutilsbad.c
+libgstdebugutilsbad_la_SOURCES = fpsdisplaysink.c gstcapssetter.c debugutilsbad.c
libgstdebugutilsbad_la_CFLAGS = $(GST_CFLAGS) $(GST_BASE_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS)
libgstdebugutilsbad_la_LIBADD = $(GST_BASE_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstinterfaces-$(GST_MAJORMINOR)
libgstdebugutilsbad_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstdebugutilsbad_la_LIBTOOLFLAGS = --tag=disable-static
-noinst_HEADERS = fpsdisplaysink.h
+noinst_HEADERS = fpsdisplaysink.h gstcapssetter.h
diff --git a/gst/debugutils/debugutilsbad.c b/gst/debugutils/debugutilsbad.c
index b1fb6e05..d1b10263 100644
--- a/gst/debugutils/debugutilsbad.c
+++ b/gst/debugutils/debugutilsbad.c
@@ -24,12 +24,15 @@
#include <gst/gst.h>
GType fps_display_sink_get_type (void);
+GType gst_caps_setter_get_type (void);
static gboolean
plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "fpsdisplaysink", GST_RANK_NONE,
- fps_display_sink_get_type ());
+ fps_display_sink_get_type ()) &&
+ gst_element_register (plugin, "capssetter", GST_RANK_NONE,
+ gst_caps_setter_get_type ());
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
diff --git a/gst/debugutils/gstcapssetter.c b/gst/debugutils/gstcapssetter.c
new file mode 100644
index 00000000..12077c0d
--- /dev/null
+++ b/gst/debugutils/gstcapssetter.c
@@ -0,0 +1,350 @@
+/* GStreamer Element
+ * Copyright (C) 2006-2009 Mark Nauwelaerts <mnauw@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1307, USA.
+ */
+
+/**
+ * SECTION:element-capssetter
+ *
+ * <refsect2>
+ * <para>
+ * Sets or merges caps on a stream's buffers.
+ * That is, a buffer's caps are updated using (fields of)
+ * <link linkend="GstCapsSetter--caps">caps</link>. Note that this may
+ * contain multiple structures (though not likely recommended), but each
+ * of these must be fixed (or will otherwise be rejected).
+ * </para>
+ * <para>
+ * If <link linkend="GstCapsSetter--join">join</link>
+ * is TRUE, then the incoming caps' mime-type is compared to the mime-type(s)
+ * of provided caps and only matching structure(s) are considered for updating.
+ * </para>
+ * <para>
+ * If <link linkend="GstCapsSetter--replace">replace</link>
+ * is TRUE, then any caps update is preceded by clearing existing fields,
+ * making provided fields (as a whole) replace incoming ones.
+ * Otherwise, no clearing is performed, in which case provided fields are
+ * added/merged onto incoming caps
+ * </para>
+ * <para>
+ * Although this element might mainly serve as debug helper,
+ * it can also practically be used to correct a faulty pixel-aspect-ratio,
+ * or to modify a yuv fourcc value to effectively swap chroma components or such
+ * alike.
+ * </para>
+ * </refsect2>
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstcapssetter.h"
+
+#include <string.h>
+
+
+GST_DEBUG_CATEGORY_STATIC (caps_setter_debug);
+#define GST_CAT_DEFAULT caps_setter_debug
+
+
+/* signals and args */
+enum
+{
+ /* FILL ME */
+ LAST_SIGNAL
+};
+
+enum
+{
+ PROP_0,
+ PROP_CAPS,
+ PROP_JOIN,
+ PROP_REPLACE
+ /* FILL ME */
+};
+
+#define DEFAULT_JOIN TRUE
+#define DEFAULT_REPLACE FALSE
+
+static GstElementDetails caps_setter_details =
+GST_ELEMENT_DETAILS ("CapsSetter",
+ "Generic",
+ "Set/merge caps on stream",
+ "Mark Nauwelaerts <mnauw@users.sourceforge.net>");
+
+static GstStaticPadTemplate gst_caps_setter_src_template =
+GST_STATIC_PAD_TEMPLATE (GST_BASE_TRANSFORM_SRC_NAME,
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+static GstStaticPadTemplate gst_caps_setter_sink_template =
+GST_STATIC_PAD_TEMPLATE (GST_BASE_TRANSFORM_SINK_NAME,
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ GST_STATIC_CAPS_ANY);
+
+
+static gboolean gst_caps_setter_transform_size (GstBaseTransform * trans,
+ GstPadDirection direction, GstCaps * caps, guint size,
+ GstCaps * othercaps, guint * othersize);
+static GstCaps *gst_caps_setter_transform_caps (GstBaseTransform * trans,
+ GstPadDirection direction, GstCaps * caps);
+static GstFlowReturn gst_caps_setter_transform_ip (GstBaseTransform * btrans,
+ GstBuffer * in);
+
+static void gst_caps_setter_finalize (GObject * object);
+
+static void gst_caps_setter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec);
+static void gst_caps_setter_get_property (GObject * object, guint prop_id,
+ GValue * value, GParamSpec * pspec);
+
+GST_BOILERPLATE (GstCapsSetter, gst_caps_setter, GstBaseTransform,
+ GST_TYPE_BASE_TRANSFORM);
+
+static void
+gst_caps_setter_base_init (gpointer g_class)
+{
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ gst_element_class_set_details (element_class, &caps_setter_details);
+
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_caps_setter_sink_template));
+ gst_element_class_add_pad_template (element_class,
+ gst_static_pad_template_get (&gst_caps_setter_src_template));
+}
+
+static void
+gst_caps_setter_class_init (GstCapsSetterClass * g_class)
+{
+ GObjectClass *gobject_class;
+ GstBaseTransformClass *trans_class;
+
+ gobject_class = G_OBJECT_CLASS (g_class);
+ trans_class = GST_BASE_TRANSFORM_CLASS (g_class);
+
+ GST_DEBUG_CATEGORY_INIT (caps_setter_debug, "capssetter", 0, "capssetter");
+
+ gobject_class->set_property = gst_caps_setter_set_property;
+ gobject_class->get_property = gst_caps_setter_get_property;
+
+ gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_caps_setter_finalize);
+
+ g_object_class_install_property (gobject_class, PROP_CAPS,
+ g_param_spec_boxed ("caps", "Merge caps",
+ "Merge these caps (thereby overwriting) in the stream",
+ GST_TYPE_CAPS, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_JOIN,
+ g_param_spec_boolean ("join", "Join",
+ "Match incoming caps' mime-type to mime-type of provided caps",
+ DEFAULT_JOIN, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_REPLACE,
+ g_param_spec_boolean ("replace", "Replace",
+ "Drop fields of incoming caps", DEFAULT_REPLACE, G_PARAM_READWRITE));
+
+ trans_class->transform_size =
+ GST_DEBUG_FUNCPTR (gst_caps_setter_transform_size);
+ trans_class->transform_caps =
+ GST_DEBUG_FUNCPTR (gst_caps_setter_transform_caps);
+ /* dummy seems needed */
+ trans_class->transform_ip = GST_DEBUG_FUNCPTR (gst_caps_setter_transform_ip);
+}
+
+static void
+gst_caps_setter_init (GstCapsSetter * filter, GstCapsSetterClass * g_class)
+{
+ filter->caps = gst_caps_new_any ();
+ filter->join = DEFAULT_JOIN;
+ filter->replace = DEFAULT_REPLACE;
+}
+
+static void
+gst_caps_setter_finalize (GObject * object)
+{
+ GstCapsSetter *filter = GST_CAPS_SETTER (object);
+
+ gst_caps_replace (&filter->caps, NULL);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static gboolean
+gst_caps_setter_transform_size (GstBaseTransform * trans,
+ GstPadDirection direction, GstCaps * caps, guint size,
+ GstCaps * othercaps, guint * othersize)
+{
+ *othersize = size;
+
+ return TRUE;
+}
+
+static GstCaps *
+gst_caps_setter_transform_caps (GstBaseTransform * trans,
+ GstPadDirection direction, GstCaps * caps)
+{
+ GstCapsSetter *filter;
+ GstCaps *ret, *filter_caps;
+ GstStructure *structure, *merge;
+ const gchar *name;
+ gint i, j;
+
+ filter = GST_CAPS_SETTER (trans);
+
+ GST_DEBUG_OBJECT (trans, "receiving caps: %" GST_PTR_FORMAT, caps);
+
+ ret = gst_caps_copy (caps);
+
+ /* this function is always called with a simple caps */
+ if (!GST_CAPS_IS_SIMPLE (ret) || direction != GST_PAD_SINK)
+ return ret;
+
+ structure = gst_caps_get_structure (ret, 0);
+ name = gst_structure_get_name (structure);
+
+ GST_OBJECT_LOCK (filter);
+ filter_caps = gst_caps_ref (filter->caps);
+ GST_OBJECT_UNLOCK (filter);
+
+ for (i = 0; i < gst_caps_get_size (filter_caps); ++i) {
+ merge = gst_caps_get_structure (filter_caps, i);
+ if (gst_structure_has_name (merge, name) || !filter->join) {
+
+ if (!filter->join)
+ gst_structure_set_name (structure, gst_structure_get_name (merge));
+
+ if (filter->replace)
+ gst_structure_remove_all_fields (structure);
+
+ for (j = 0; j < gst_structure_n_fields (merge); ++j) {
+ const gchar *fname;
+
+ fname = gst_structure_nth_field_name (merge, j);
+ gst_structure_set_value (structure, fname,
+ gst_structure_get_value (merge, fname));
+ }
+ }
+ }
+
+ GST_DEBUG_OBJECT (trans, "returning caps: %" GST_PTR_FORMAT, ret);
+
+ gst_caps_unref (filter_caps);
+
+ return ret;
+}
+
+static GstFlowReturn
+gst_caps_setter_transform_ip (GstBaseTransform * btrans, GstBuffer * in)
+{
+ return GST_FLOW_OK;
+}
+
+static gboolean
+gst_caps_is_fixed_foreach (GQuark field_id, const GValue * value,
+ gpointer unused)
+{
+ return gst_value_is_fixed (value);
+}
+
+static void
+gst_caps_setter_set_property (GObject * object, guint prop_id,
+ const GValue * value, GParamSpec * pspec)
+{
+ GstCapsSetter *filter;
+
+ g_return_if_fail (GST_IS_CAPS_SETTER (object));
+ filter = GST_CAPS_SETTER (object);
+
+ switch (prop_id) {
+ case PROP_CAPS:{
+ GstCaps *new_caps;
+ const GstCaps *new_caps_val = gst_value_get_caps (value);
+ gint i;
+
+ if (new_caps_val == NULL) {
+ new_caps = gst_caps_new_any ();
+ } else {
+ new_caps = gst_caps_copy (new_caps_val);
+ }
+
+ for (i = 0; new_caps && (i < gst_caps_get_size (new_caps)); ++i) {
+ GstStructure *s;
+
+ s = gst_caps_get_structure (new_caps, i);
+ if (!gst_structure_foreach (s, gst_caps_is_fixed_foreach, NULL)) {
+ GST_ERROR_OBJECT (filter, "rejected unfixed caps: %" GST_PTR_FORMAT,
+ new_caps);
+ gst_caps_unref (new_caps);
+ new_caps = NULL;
+ break;
+ }
+ }
+
+ if (new_caps) {
+ GST_OBJECT_LOCK (filter);
+ gst_caps_replace (&filter->caps, new_caps);
+ /* drop extra ref */
+ gst_caps_unref (new_caps);
+ GST_OBJECT_UNLOCK (filter);
+
+ GST_DEBUG_OBJECT (filter, "set new caps %" GST_PTR_FORMAT, new_caps);
+ }
+
+ /* try to activate these new caps next time around */
+ gst_base_transform_reconfigure (GST_BASE_TRANSFORM (filter));
+ break;
+ }
+ case PROP_JOIN:
+ filter->join = g_value_get_boolean (value);
+ break;
+ case PROP_REPLACE:
+ filter->replace = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gst_caps_setter_get_property (GObject * object, guint prop_id, GValue * value,
+ GParamSpec * pspec)
+{
+ GstCapsSetter *filter;
+
+ g_return_if_fail (GST_IS_CAPS_SETTER (object));
+ filter = GST_CAPS_SETTER (object);
+
+ switch (prop_id) {
+ case PROP_CAPS:
+ gst_value_set_caps (value, filter->caps);
+ break;
+ case PROP_JOIN:
+ g_value_set_boolean (value, filter->join);
+ break;
+ case PROP_REPLACE:
+ g_value_set_boolean (value, filter->replace);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
diff --git a/gst/debugutils/gstcapssetter.h b/gst/debugutils/gstcapssetter.h
new file mode 100644
index 00000000..e792931c
--- /dev/null
+++ b/gst/debugutils/gstcapssetter.h
@@ -0,0 +1,62 @@
+/* GStreamer Element
+ * Copyright (C) 2006-2009 Mark Nauwelaerts <mnauw@users.sourceforge.net>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1307, USA.
+ */
+
+
+#ifndef __GST_CAPS_SETTER_H__
+#define __GST_CAPS_SETTER_H__
+
+#include <gst/base/gstbasetransform.h>
+
+G_BEGIN_DECLS
+
+#define GST_TYPE_CAPS_SETTER \
+ (gst_caps_setter_get_type())
+#define GST_CAPS_SETTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CAPS_SETTER,GstCapsSetter))
+#define GST_CAPS_SETTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CAPS_SETTER,GstCapsSetterClass))
+#define GST_IS_CAPS_SETTER(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CAPS_SETTER))
+#define GST_IS_CAPS_SETTER_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CAPS_SETTER))
+
+GType gst_caps_setter_get_type (void);
+
+typedef struct _GstCapsSetter GstCapsSetter;
+typedef struct _GstCapsSetterClass GstCapsSetterClass;
+
+struct _GstCapsSetter
+{
+ GstBaseTransform parent;
+
+ /* properties */
+ GstCaps *caps;
+ gboolean join;
+ gboolean replace;
+};
+
+
+struct _GstCapsSetterClass
+{
+ GstBaseTransformClass parent_class;
+};
+
+G_END_DECLS
+
+#endif /* __GST_CAPS_SETTER_H__ */
diff --git a/gst/freeze/Makefile.am b/gst/freeze/Makefile.am
index 525e476e..9d07aa84 100644
--- a/gst/freeze/Makefile.am
+++ b/gst/freeze/Makefile.am
@@ -4,6 +4,7 @@ libgstfreeze_la_SOURCES = gstfreeze.c
libgstfreeze_la_CFLAGS = $(GST_CFLAGS)
libgstfreeze_la_LIBADD = ${GST_LIBS}
libgstfreeze_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
+libgstfreeze_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstfreeze.h
diff --git a/gst/frei0r/gstfrei0r.c b/gst/frei0r/gstfrei0r.c
index 0f7ba5c5..3cfc939b 100644
--- a/gst/frei0r/gstfrei0r.c
+++ b/gst/frei0r/gstfrei0r.c
@@ -86,51 +86,71 @@ gst_frei0r_klass_install_properties (GObjectClass * gobject_class,
case F0R_PARAM_BOOL:
g_object_class_install_property (gobject_class, count++,
g_param_spec_boolean (prop_name, param_info->name,
- param_info->explanation, FALSE,
+ param_info->explanation, properties[i].default_value.data.b,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
properties[i].n_prop_ids = 1;
break;
- case F0R_PARAM_DOUBLE:
+ case F0R_PARAM_DOUBLE:{
+ gdouble def = properties[i].default_value.data.d;
+
+ /* If the default is NAN, +-INF we use 0.0 */
+ if (!(def <= G_MAXDOUBLE && def >= -G_MAXDOUBLE))
+ def = 0.0;
+
g_object_class_install_property (gobject_class, count++,
g_param_spec_double (prop_name, param_info->name,
- param_info->explanation, -G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
+ param_info->explanation, -G_MAXDOUBLE, G_MAXDOUBLE, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
properties[i].n_prop_ids = 1;
break;
+ }
case F0R_PARAM_STRING:
g_object_class_install_property (gobject_class, count++,
g_param_spec_string (prop_name, param_info->name,
- param_info->explanation, NULL,
+ param_info->explanation, properties[i].default_value.data.s,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
properties[i].n_prop_ids = 1;
break;
case F0R_PARAM_COLOR:{
gchar *prop_name_full;
gchar *prop_nick_full;
+ gdouble def;
+ def = properties[i].default_value.data.color.r;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-r", NULL);
prop_nick_full = g_strconcat (param_info->name, "-R", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_float (prop_name_full, prop_nick_full,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
+ def = properties[i].default_value.data.color.g;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-g", NULL);
prop_nick_full = g_strconcat (param_info->name, "-G", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_float (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
+ def = properties[i].default_value.data.color.b;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-b", NULL);
prop_nick_full = g_strconcat (param_info->name, "-B", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_float (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
@@ -141,21 +161,30 @@ gst_frei0r_klass_install_properties (GObjectClass * gobject_class,
case F0R_PARAM_POSITION:{
gchar *prop_name_full;
gchar *prop_nick_full;
+ gdouble def;
+ def = properties[i].default_value.data.position.x;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-x", NULL);
prop_nick_full = g_strconcat (param_info->name, "-X", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_double (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
+ def = properties[i].default_value.data.position.y;
+ /* If the default is out of range we use 0.0 */
+ if (!(def <= 1.0 && def >= 0.0))
+ def = 0.0;
prop_name_full = g_strconcat (prop_name, "-Y", NULL);
prop_nick_full = g_strconcat (param_info->name, "-X", NULL);
g_object_class_install_property (gobject_class, count++,
g_param_spec_double (prop_name_full, param_info->name,
- param_info->explanation, 0.0, 1.0, 0.0,
+ param_info->explanation, 0.0, 1.0, def,
G_PARAM_READWRITE | GST_PARAM_CONTROLLABLE));
g_free (prop_name_full);
g_free (prop_nick_full);
diff --git a/gst/frei0r/gstfrei0rfilter.c b/gst/frei0r/gstfrei0rfilter.c
index 43d8fc67..eda78adf 100644
--- a/gst/frei0r/gstfrei0rfilter.c
+++ b/gst/frei0r/gstfrei0rfilter.c
@@ -40,22 +40,11 @@ gst_frei0r_filter_set_caps (GstBaseTransform * trans, GstCaps * incaps,
GstCaps * outcaps)
{
GstFrei0rFilter *self = GST_FREI0R_FILTER (trans);
- GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (trans);
GstVideoFormat fmt;
- gint width, height;
- if (!gst_video_format_parse_caps (incaps, &fmt, &width, &height))
+ if (!gst_video_format_parse_caps (incaps, &fmt, &self->width, &self->height))
return FALSE;
- if (self->f0r_instance) {
- klass->ftable->destruct (self->f0r_instance);
- self->f0r_instance = NULL;
- }
-
- self->f0r_instance =
- gst_frei0r_instance_construct (klass->ftable, klass->properties,
- klass->n_properties, self->property_cache, width, height);
-
return TRUE;
}
@@ -70,6 +59,8 @@ gst_frei0r_filter_stop (GstBaseTransform * trans)
self->f0r_instance = NULL;
}
+ self->width = self->height = 0;
+
return TRUE;
}
@@ -81,9 +72,17 @@ gst_frei0r_filter_transform (GstBaseTransform * trans, GstBuffer * inbuf,
GstFrei0rFilterClass *klass = GST_FREI0R_FILTER_GET_CLASS (trans);
gdouble time;
- if (!self->f0r_instance)
+ if (G_UNLIKELY (self->width <= 0 || self->height <= 0))
return GST_FLOW_NOT_NEGOTIATED;
+ if (G_UNLIKELY (!self->f0r_instance)) {
+ self->f0r_instance =
+ gst_frei0r_instance_construct (klass->ftable, klass->properties,
+ klass->n_properties, self->property_cache, self->width, self->height);
+ if (G_UNLIKELY (!self->f0r_instance))
+ return GST_FLOW_ERROR;
+ }
+
time = ((gdouble) GST_BUFFER_TIMESTAMP (inbuf)) / GST_SECOND;
if (klass->ftable->update2)
@@ -195,6 +194,8 @@ gst_frei0r_filter_init (GstFrei0rFilter * self, GstFrei0rFilterClass * klass)
{
self->property_cache =
gst_frei0r_property_cache_init (klass->properties, klass->n_properties);
+ gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SINK_PAD (self));
+ gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SRC_PAD (self));
}
gboolean
diff --git a/gst/frei0r/gstfrei0rfilter.h b/gst/frei0r/gstfrei0rfilter.h
index ded2172b..b85c3f6e 100644
--- a/gst/frei0r/gstfrei0rfilter.h
+++ b/gst/frei0r/gstfrei0rfilter.h
@@ -42,6 +42,8 @@ typedef struct _GstFrei0rFilterClass GstFrei0rFilterClass;
struct _GstFrei0rFilter {
GstVideoFilter parent;
+ gint width, height;
+
f0r_instance_t *f0r_instance;
GstFrei0rPropertyValue *property_cache;
};
diff --git a/gst/frei0r/gstfrei0rmixer.c b/gst/frei0r/gstfrei0rmixer.c
index 745c330e..8f3ee4ba 100644
--- a/gst/frei0r/gstfrei0rmixer.c
+++ b/gst/frei0r/gstfrei0rmixer.c
@@ -45,8 +45,16 @@ gst_frei0r_mixer_reset (GstFrei0rMixer * self)
self->f0r_instance = NULL;
}
+ if (self->property_cache)
+ gst_frei0r_property_cache_free (klass->properties, self->property_cache,
+ klass->n_properties);
+ self->property_cache = NULL;
+
gst_caps_replace (&self->caps, NULL);
gst_event_replace (&self->newseg_event, NULL);
+
+ self->fmt = GST_VIDEO_FORMAT_UNKNOWN;
+ self->width = self->height = 0;
}
static void
@@ -195,7 +203,6 @@ static gboolean
gst_frei0r_mixer_set_caps (GstPad * pad, GstCaps * caps)
{
GstFrei0rMixer *self = GST_FREI0R_MIXER (gst_pad_get_parent (pad));
- GstFrei0rMixerClass *klass = GST_FREI0R_MIXER_GET_CLASS (self);
gboolean ret = TRUE;
gst_caps_replace (&self->caps, caps);
@@ -215,16 +222,6 @@ gst_frei0r_mixer_set_caps (GstPad * pad, GstCaps * caps)
ret = FALSE;
goto out;
}
-
- if (self->f0r_instance) {
- klass->ftable->destruct (self->f0r_instance);
- self->f0r_instance = NULL;
- }
-
- self->f0r_instance =
- gst_frei0r_instance_construct (klass->ftable, klass->properties,
- klass->n_properties, self->property_cache, self->width, self->height);
-
}
out:
@@ -543,9 +540,17 @@ gst_frei0r_mixer_collected (GstCollectPads * pads, GstFrei0rMixer * self)
GstFrei0rMixerClass *klass = GST_FREI0R_MIXER_GET_CLASS (self);
gdouble time;
- if (G_UNLIKELY (!self->f0r_instance))
+ if (G_UNLIKELY (self->width <= 0 || self->height <= 0))
return GST_FLOW_NOT_NEGOTIATED;
+ if (G_UNLIKELY (!self->f0r_instance)) {
+ self->f0r_instance =
+ gst_frei0r_instance_construct (klass->ftable, klass->properties,
+ klass->n_properties, self->property_cache, self->width, self->height);
+ if (G_UNLIKELY (!self->f0r_instance))
+ return GST_FLOW_ERROR;
+ }
+
if (self->newseg_event) {
gst_pad_push_event (self->src, self->newseg_event);
self->newseg_event = NULL;
diff --git a/gst/frei0r/gstfrei0rsrc.c b/gst/frei0r/gstfrei0rsrc.c
index a713e1e9..2d637f95 100644
--- a/gst/frei0r/gstfrei0rsrc.c
+++ b/gst/frei0r/gstfrei0rsrc.c
@@ -39,22 +39,12 @@ static gboolean
gst_frei0r_src_set_caps (GstBaseSrc * src, GstCaps * caps)
{
GstFrei0rSrc *self = GST_FREI0R_SRC (src);
- GstFrei0rSrcClass *klass = GST_FREI0R_SRC_GET_CLASS (src);
if (!gst_video_format_parse_caps (caps, &self->fmt, &self->width,
&self->height)
|| !gst_video_parse_caps_framerate (caps, &self->fps_n, &self->fps_d))
return FALSE;
- if (self->f0r_instance) {
- klass->ftable->destruct (self->f0r_instance);
- self->f0r_instance = NULL;
- }
-
- self->f0r_instance =
- gst_frei0r_instance_construct (klass->ftable, klass->properties,
- klass->n_properties, self->property_cache, self->width, self->height);
-
return TRUE;
}
@@ -80,9 +70,18 @@ gst_frei0r_src_create (GstPushSrc * src, GstBuffer ** buf)
*buf = NULL;
- if (G_UNLIKELY (!self->f0r_instance))
+ if (G_UNLIKELY (self->width <= 0 || self->height <= 0))
return GST_FLOW_NOT_NEGOTIATED;
+ if (G_UNLIKELY (!self->f0r_instance)) {
+ self->f0r_instance =
+ gst_frei0r_instance_construct (klass->ftable, klass->properties,
+ klass->n_properties, self->property_cache, self->width, self->height);
+
+ if (G_UNLIKELY (!self->f0r_instance))
+ return GST_FLOW_ERROR;
+ }
+
newsize = gst_video_format_get_size (self->fmt, self->width, self->height);
ret =
@@ -147,6 +146,11 @@ gst_frei0r_src_stop (GstBaseSrc * basesrc)
self->f0r_instance = NULL;
}
+ self->fmt = GST_VIDEO_FORMAT_UNKNOWN;
+ self->width = self->height = 0;
+ self->fps_n = self->fps_d = 0;
+ self->n_frames = 0;
+
return TRUE;
}
diff --git a/gst/mpegdemux/mpegtspacketizer.c b/gst/mpegdemux/mpegtspacketizer.c
index b986fa60..c9fc325f 100644
--- a/gst/mpegdemux/mpegtspacketizer.c
+++ b/gst/mpegdemux/mpegtspacketizer.c
@@ -1264,17 +1264,16 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
service_id = GST_READ_UINT16_BE (data);
data += 2;
- /* reserved */
- data += 1;
+ EIT_schedule = ((*data & 0x02) == 2);
+ EIT_present_following = (*data & 0x01) == 1;
+ data += 1;
tmp = GST_READ_UINT16_BE (data);
- data += 2;
- EIT_schedule = (tmp >> 15);
- EIT_present_following = (tmp >> 14) & 0x01;
- running_status = (tmp >> 5) & 0x03;
- scrambled = (tmp >> 4) & 0x01;
+ running_status = (*data >> 5) & 0x07;
+ scrambled = (*data >> 4) & 0x01;
descriptors_loop_length = tmp & 0x0FFF;
+ data += 2;
/* TODO send tag event down relevant pad for channel name and provider */
service_name = g_strdup_printf ("service-%d", service_id);
@@ -1307,7 +1306,26 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
(gchar *) DESC_DVB_SERVICE_name_text (service_descriptor);
if (servicename_length + serviceprovider_name_length + 2 <=
DESC_LENGTH (service_descriptor)) {
-
+ gchar *running_status_tmp;
+ switch (running_status) {
+ case 0:
+ running_status_tmp = "undefined";
+ break;
+ case 1:
+ running_status_tmp = "not running";
+ break;
+ case 2:
+ running_status_tmp = "starts in a few seconds";
+ break;
+ case 3:
+ running_status_tmp = "pausing";
+ break;
+ case 4:
+ running_status_tmp = "running";
+ break;
+ default:
+ running_status_tmp = "reserved";
+ }
servicename_tmp =
get_encoding_and_convert (servicename, servicename_length);
serviceprovider_name_tmp =
@@ -1317,7 +1335,8 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
gst_structure_set (service,
"name", G_TYPE_STRING, servicename_tmp,
"provider-name", G_TYPE_STRING, serviceprovider_name_tmp,
- "scrambled", G_TYPE_BOOLEAN, scrambled, NULL);
+ "scrambled", G_TYPE_BOOLEAN, scrambled,
+ "running-status", G_TYPE_STRING, running_status_tmp, NULL);
g_free (servicename_tmp);
g_free (serviceprovider_name_tmp);
diff --git a/gst/rtpmanager/Makefile.am b/gst/rtpmanager/Makefile.am
index 2d53d63e..8080f303 100644
--- a/gst/rtpmanager/Makefile.am
+++ b/gst/rtpmanager/Makefile.am
@@ -12,7 +12,6 @@ BUILT_SOURCES = $(built_sources) $(built_headers)
libgstrtpmanager_la_SOURCES = gstrtpmanager.c \
gstrtpbin.c \
- gstrtpclient.c \
gstrtpjitterbuffer.c \
gstrtpptdemux.c \
gstrtpssrcdemux.c \
@@ -26,7 +25,6 @@ nodist_libgstrtpmanager_la_SOURCES = \
$(built_sources)
noinst_HEADERS = gstrtpbin.h \
- gstrtpclient.h \
gstrtpjitterbuffer.h \
gstrtpptdemux.h \
gstrtpssrcdemux.h \
diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c
index 482cf017..c09b0ab9 100644
--- a/gst/rtpmanager/gstrtpbin.c
+++ b/gst/rtpmanager/gstrtpbin.c
@@ -238,26 +238,14 @@ enum
};
#define DEFAULT_LATENCY_MS 200
-#define DEFAULT_SDES_CNAME NULL
-#define DEFAULT_SDES_NAME NULL
-#define DEFAULT_SDES_EMAIL NULL
-#define DEFAULT_SDES_PHONE NULL
-#define DEFAULT_SDES_LOCATION NULL
-#define DEFAULT_SDES_TOOL NULL
-#define DEFAULT_SDES_NOTE NULL
+#define DEFAULT_SDES NULL
#define DEFAULT_DO_LOST FALSE
enum
{
PROP_0,
PROP_LATENCY,
- PROP_SDES_CNAME,
- PROP_SDES_NAME,
- PROP_SDES_EMAIL,
- PROP_SDES_PHONE,
- PROP_SDES_LOCATION,
- PROP_SDES_TOOL,
- PROP_SDES_NOTE,
+ PROP_SDES,
PROP_DO_LOST,
PROP_LAST
};
@@ -271,10 +259,6 @@ static guint gst_rtp_bin_signals[LAST_SIGNAL] = { 0 };
static GstCaps *pt_map_requested (GstElement * element, guint pt,
GstRtpBinSession * session);
-static const gchar *sdes_type_to_name (GstRTCPSDESType type);
-static void gst_rtp_bin_set_sdes_string (GstRtpBin * bin,
- GstRTCPSDESType type, const gchar * data);
-
static void free_stream (GstRtpBinStream * stream);
/* Manages the RTP stream for one SSRC.
@@ -304,10 +288,9 @@ struct _GstRtpBinStream
/* the PT demuxer of the SSRC */
GstElement *demux;
gulong demux_newpad_sig;
+ gulong demux_padremoved_sig;
gulong demux_ptreq_sig;
gulong demux_pt_change_sig;
- /* ghostpads from the ptdemuxer */
- GSList *pads;
/* if we have calculated a valid unix_delta for this stream */
gboolean have_sync;
@@ -515,7 +498,6 @@ create_session (GstRtpBin * rtpbin, gint id)
{
GstRtpBinSession *sess;
GstElement *session, *demux;
- gint i;
GstState target;
if (!(session = gst_element_factory_make ("gstrtpsession", NULL)))
@@ -538,9 +520,7 @@ create_session (GstRtpBin * rtpbin, gint id)
g_object_set (session, "ntp-ns-base", rtpbin->priv->ntp_ns_base, NULL);
/* configure SDES items */
GST_OBJECT_LOCK (rtpbin);
- for (i = GST_RTCP_SDES_CNAME; i < GST_RTCP_SDES_PRIV; i++) {
- g_object_set (session, sdes_type_to_name (i), rtpbin->sdes[i], NULL);
- }
+ g_object_set (session, "sdes", rtpbin->sdes, NULL);
GST_OBJECT_UNLOCK (rtpbin);
/* provide clock_rate to the session manager when needed */
@@ -1171,7 +1151,6 @@ static void
free_stream (GstRtpBinStream * stream)
{
GstRtpBinSession *session;
- GSList *walk;
session = stream->session;
@@ -1184,17 +1163,13 @@ free_stream (GstRtpBinStream * stream)
gst_element_set_state (stream->demux, GST_STATE_NULL);
gst_element_set_state (stream->buffer, GST_STATE_NULL);
+ /* now remove this signal, we need this while going to NULL because it to
+ * do some cleanups */
+ 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 (session->bin), stream->demux);
- for (walk = stream->pads; walk; walk = g_slist_next (walk)) {
- GstPad *gpad = GST_PAD_CAST (walk->data);
-
- gst_pad_set_active (gpad, FALSE);
- gst_element_remove_pad (GST_ELEMENT_CAST (session->bin), gpad);
- }
- g_slist_free (stream->pads);
-
g_free (stream);
}
@@ -1448,40 +1423,10 @@ gst_rtp_bin_class_init (GstRtpBinClass * klass)
NULL, NULL, gst_rtp_bin_marshal_VOID__UINT_UINT, G_TYPE_NONE, 2,
G_TYPE_UINT, G_TYPE_UINT);
- g_object_class_install_property (gobject_class, PROP_SDES_CNAME,
- g_param_spec_string ("sdes-cname", "SDES CNAME",
- "The CNAME to put in SDES messages of this session",
- DEFAULT_SDES_CNAME, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_NAME,
- g_param_spec_string ("sdes-name", "SDES NAME",
- "The NAME to put in SDES messages of this session",
- DEFAULT_SDES_NAME, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_EMAIL,
- g_param_spec_string ("sdes-email", "SDES EMAIL",
- "The EMAIL to put in SDES messages of this session",
- DEFAULT_SDES_EMAIL, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_PHONE,
- g_param_spec_string ("sdes-phone", "SDES PHONE",
- "The PHONE to put in SDES messages of this session",
- DEFAULT_SDES_PHONE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_LOCATION,
- g_param_spec_string ("sdes-location", "SDES LOCATION",
- "The LOCATION to put in SDES messages of this session",
- DEFAULT_SDES_LOCATION, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_TOOL,
- g_param_spec_string ("sdes-tool", "SDES TOOL",
- "The TOOL to put in SDES messages of this session",
- DEFAULT_SDES_TOOL, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_NOTE,
- g_param_spec_string ("sdes-note", "SDES NOTE",
- "The NOTE to put in SDES messages of this session",
- DEFAULT_SDES_NOTE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_SDES,
+ g_param_spec_boxed ("sdes", "SDES",
+ "The SDES items of this session",
+ GST_TYPE_STRUCTURE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_DO_LOST,
g_param_spec_boolean ("do-lost", "Do Lost",
@@ -1517,11 +1462,11 @@ gst_rtp_bin_init (GstRtpBin * rtpbin, GstRtpBinClass * klass)
/* some default SDES entries */
str = g_strdup_printf ("%s@%s", g_get_user_name (), g_get_host_name ());
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_CNAME, str);
+ rtpbin->sdes = gst_structure_new ("application/x-rtp-source-sdes",
+ "cname", G_TYPE_STRING, str,
+ "name", G_TYPE_STRING, g_get_real_name (),
+ "tool", G_TYPE_STRING, "GStreamer", NULL);
g_free (str);
-
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_NAME, g_get_real_name ());
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_TOOL, "GStreamer");
}
static void
@@ -1547,12 +1492,11 @@ static void
gst_rtp_bin_finalize (GObject * object)
{
GstRtpBin *rtpbin;
- gint i;
rtpbin = GST_RTP_BIN (object);
- for (i = 0; i < 9; i++)
- g_free (rtpbin->sdes[i]);
+ if (rtpbin->sdes)
+ gst_structure_free (rtpbin->sdes);
g_mutex_free (rtpbin->priv->bin_lock);
g_mutex_free (rtpbin->priv->dyn_lock);
@@ -1560,77 +1504,37 @@ gst_rtp_bin_finalize (GObject * object)
G_OBJECT_CLASS (parent_class)->finalize (object);
}
-static const gchar *
-sdes_type_to_name (GstRTCPSDESType type)
-{
- const gchar *result;
-
- switch (type) {
- case GST_RTCP_SDES_CNAME:
- result = "sdes-cname";
- break;
- case GST_RTCP_SDES_NAME:
- result = "sdes-name";
- break;
- case GST_RTCP_SDES_EMAIL:
- result = "sdes-email";
- break;
- case GST_RTCP_SDES_PHONE:
- result = "sdes-phone";
- break;
- case GST_RTCP_SDES_LOC:
- result = "sdes-location";
- break;
- case GST_RTCP_SDES_TOOL:
- result = "sdes-tool";
- break;
- case GST_RTCP_SDES_NOTE:
- result = "sdes-note";
- break;
- case GST_RTCP_SDES_PRIV:
- result = "sdes-priv";
- break;
- default:
- result = NULL;
- break;
- }
- return result;
-}
static void
-gst_rtp_bin_set_sdes_string (GstRtpBin * bin, GstRTCPSDESType type,
- const gchar * data)
+gst_rtp_bin_set_sdes_struct (GstRtpBin * bin, const GstStructure * sdes)
{
GSList *item;
- const gchar *name;
- if (type < 0 || type > 8)
+ if (sdes == NULL)
return;
GST_RTP_BIN_LOCK (bin);
GST_OBJECT_LOCK (bin);
- g_free (bin->sdes[type]);
- bin->sdes[type] = g_strdup (data);
- name = sdes_type_to_name (type);
+ if (bin->sdes)
+ gst_structure_free (bin->sdes);
+ bin->sdes = gst_structure_copy (sdes);
+
/* store in all sessions */
for (item = bin->sessions; item; item = g_slist_next (item))
- g_object_set (item->data, name, bin->sdes[type], NULL);
+ g_object_set (item->data, "sdes", sdes, NULL);
GST_OBJECT_UNLOCK (bin);
GST_RTP_BIN_UNLOCK (bin);
}
-static gchar *
-gst_rtp_bin_get_sdes_string (GstRtpBin * bin, GstRTCPSDESType type)
+static GstStructure *
+gst_rtp_bin_get_sdes_struct (GstRtpBin * bin)
{
- gchar *result;
-
- if (type < 0 || type > 8)
- return NULL;
+ GstStructure *result;
GST_OBJECT_LOCK (bin);
- result = g_strdup (bin->sdes[type]);
+ result = gst_structure_copy (bin->sdes);
GST_OBJECT_UNLOCK (bin);
return result;
@@ -1652,33 +1556,8 @@ gst_rtp_bin_set_property (GObject * object, guint prop_id,
/* propegate the property down to the jitterbuffer */
gst_rtp_bin_propagate_property_to_jitterbuffer (rtpbin, "latency", value);
break;
- case PROP_SDES_CNAME:
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_CNAME,
- g_value_get_string (value));
- break;
- case PROP_SDES_NAME:
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_NAME,
- g_value_get_string (value));
- break;
- case PROP_SDES_EMAIL:
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_EMAIL,
- g_value_get_string (value));
- break;
- case PROP_SDES_PHONE:
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_PHONE,
- g_value_get_string (value));
- break;
- case PROP_SDES_LOCATION:
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_LOC,
- g_value_get_string (value));
- break;
- case PROP_SDES_TOOL:
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_TOOL,
- g_value_get_string (value));
- break;
- case PROP_SDES_NOTE:
- gst_rtp_bin_set_sdes_string (rtpbin, GST_RTCP_SDES_NOTE,
- g_value_get_string (value));
+ case PROP_SDES:
+ gst_rtp_bin_set_sdes_struct (rtpbin, g_value_get_boxed (value));
break;
case PROP_DO_LOST:
GST_RTP_BIN_LOCK (rtpbin);
@@ -1706,33 +1585,8 @@ gst_rtp_bin_get_property (GObject * object, guint prop_id,
g_value_set_uint (value, rtpbin->latency);
GST_RTP_BIN_UNLOCK (rtpbin);
break;
- case PROP_SDES_CNAME:
- g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
- GST_RTCP_SDES_CNAME));
- break;
- case PROP_SDES_NAME:
- g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
- GST_RTCP_SDES_NAME));
- break;
- case PROP_SDES_EMAIL:
- g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
- GST_RTCP_SDES_EMAIL));
- break;
- case PROP_SDES_PHONE:
- g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
- GST_RTCP_SDES_PHONE));
- break;
- case PROP_SDES_LOCATION:
- g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
- GST_RTCP_SDES_LOC));
- break;
- case PROP_SDES_TOOL:
- g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
- GST_RTCP_SDES_TOOL));
- break;
- case PROP_SDES_NOTE:
- g_value_take_string (value, gst_rtp_bin_get_sdes_string (rtpbin,
- GST_RTCP_SDES_NOTE));
+ case PROP_SDES:
+ g_value_take_boxed (value, gst_rtp_bin_get_sdes_struct (rtpbin));
break;
case PROP_DO_LOST:
GST_RTP_BIN_LOCK (rtpbin);
@@ -1884,13 +1738,11 @@ new_payload_found (GstElement * element, guint pt, GstPad * pad,
stream->session->id, stream->ssrc, pt);
gpad = gst_ghost_pad_new_from_template (padname, pad, templ);
g_free (padname);
+ g_object_set_data (G_OBJECT (pad), "GstRTPBin.ghostpad", gpad);
gst_pad_set_caps (gpad, GST_PAD_CAPS (pad));
gst_pad_set_active (gpad, TRUE);
gst_element_add_pad (GST_ELEMENT_CAST (rtpbin), gpad);
-
- stream->pads = g_slist_prepend (stream->pads, gpad);
-
GST_RTP_BIN_SHUTDOWN_UNLOCK (rtpbin);
return;
@@ -1902,6 +1754,27 @@ shutdown:
}
}
+static void
+payload_pad_removed (GstElement * element, GstPad * pad,
+ GstRtpBinStream * stream)
+{
+ GstRtpBin *rtpbin;
+ GstPad *gpad;
+
+ rtpbin = stream->bin;
+
+ GST_DEBUG ("payload pad removed");
+
+ GST_RTP_BIN_DYN_LOCK (rtpbin);
+ if ((gpad = g_object_get_data (G_OBJECT (pad), "GstRTPBin.ghostpad"))) {
+ g_object_set_data (G_OBJECT (pad), "GstRTPBin.ghostpad", NULL);
+
+ gst_pad_set_active (gpad, FALSE);
+ gst_element_remove_pad (GST_ELEMENT_CAST (rtpbin), gpad);
+ }
+ GST_RTP_BIN_DYN_UNLOCK (rtpbin);
+}
+
static GstCaps *
pt_map_requested (GstElement * element, guint pt, GstRtpBinSession * session)
{
@@ -2009,6 +1882,9 @@ new_ssrc_pad_found (GstElement * element, guint ssrc, GstPad * pad,
* new pad by ghosting it. */
stream->demux_newpad_sig = g_signal_connect (stream->demux,
"new-payload-type", (GCallback) new_payload_found, stream);
+ stream->demux_padremoved_sig = g_signal_connect (stream->demux,
+ "pad-removed", (GCallback) payload_pad_removed, stream);
+
/* connect to the request-pt-map signal. This signal will be emited by the
* demuxer so that it can apply a proper caps on the buffers for the
* depayloaders. */
diff --git a/gst/rtpmanager/gstrtpbin.h b/gst/rtpmanager/gstrtpbin.h
index f47048e5..bed6ad02 100644
--- a/gst/rtpmanager/gstrtpbin.h
+++ b/gst/rtpmanager/gstrtpbin.h
@@ -53,7 +53,7 @@ struct _GstRtpBin {
GSList *clients;
/* the default SDES items for sessions */
- gchar *sdes[9];
+ GstStructure *sdes;
/*< private >*/
GstRtpBinPrivate *priv;
diff --git a/gst/rtpmanager/gstrtpclient.c b/gst/rtpmanager/gstrtpclient.c
deleted file mode 100644
index 2fccbfd7..00000000
--- a/gst/rtpmanager/gstrtpclient.c
+++ /dev/null
@@ -1,484 +0,0 @@
-/* GStreamer
- * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * 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.
- */
-
-/**
- * SECTION:element-gstrtpclient
- * @see_also: gstrtpjitterbuffer, gstrtpbin, gstrtpsession
- *
- * This element handles RTP data from one client. It accepts multiple RTP streams that
- * should be synchronized together.
- *
- * Normally the SSRCs that map to the same CNAME (as given in the RTCP SDES messages)
- * should be synchronized.
- *
- * <refsect2>
- * <title>Example pipelines</title>
- * |[
- * FIXME: gst-launch
- * ]| FIXME: describe
- * </refsect2>
- *
- * Last reviewed on 2007-04-02 (0.10.5)
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#include "gstrtpclient.h"
-
-/* elementfactory information */
-static const GstElementDetails rtpclient_details =
-GST_ELEMENT_DETAILS ("RTP Client",
- "Filter/Network/RTP",
- "Implement an RTP client",
- "Wim Taymans <wim.taymans@gmail.com>");
-
-/* sink pads */
-static GstStaticPadTemplate rtpclient_rtp_sink_template =
-GST_STATIC_PAD_TEMPLATE ("rtp_sink_%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS ("application/x-rtp")
- );
-
-static GstStaticPadTemplate rtpclient_sync_sink_template =
-GST_STATIC_PAD_TEMPLATE ("sync_sink_%d",
- GST_PAD_SINK,
- GST_PAD_REQUEST,
- GST_STATIC_CAPS ("application/x-rtcp")
- );
-
-/* src pads */
-static GstStaticPadTemplate rtpclient_rtp_src_template =
-GST_STATIC_PAD_TEMPLATE ("rtp_src_%d_%d",
- GST_PAD_SRC,
- GST_PAD_SOMETIMES,
- GST_STATIC_CAPS ("application/x-rtp")
- );
-
-#define GST_RTP_CLIENT_GET_PRIVATE(obj) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GST_TYPE_RTP_CLIENT, GstRtpClientPrivate))
-
-struct _GstRtpClientPrivate
-{
- gint foo;
-};
-
-/* all the info needed to handle the stream with SSRC */
-typedef struct
-{
- GstRtpClient *client;
-
- /* the SSRC of this stream */
- guint32 ssrc;
-
- /* RTP and RTCP in */
- GstPad *rtp_sink;
- GstPad *sync_sink;
-
- /* the jitterbuffer */
- GstElement *jitterbuffer;
- /* the payload demuxer */
- GstElement *ptdemux;
- /* the new-pad signal */
- gulong new_pad_sig;
-} GstRtpClientStream;
-
-/* the PT demuxer found a new payload type */
-static void
-new_pad (GstElement * element, GstPad * pad, GstRtpClientStream * stream)
-{
-}
-
-/* create a new stream for SSRC.
- *
- * We create a jitterbuffer and an payload demuxer for the SSRC. The sinkpad of
- * the jitterbuffer is ghosted to the bin. We connect a pad-added signal to
- * rtpptdemux so that we can ghost the payload pads outside.
- *
- * +-----------------+ +---------------+
- * | rtpjitterbuffer | | rtpptdemux |
- * +- sink src - sink |
- * / +-----------------+ +---------------+
- *
- */
-static GstRtpClientStream *
-create_stream (GstRtpClient * rtpclient, guint32 ssrc)
-{
- GstRtpClientStream *stream;
- gchar *name;
- GstPad *srcpad, *sinkpad;
- GstPadLinkReturn res;
-
- stream = g_new0 (GstRtpClientStream, 1);
- stream->ssrc = ssrc;
- stream->client = rtpclient;
-
- stream->jitterbuffer = gst_element_factory_make ("gstrtpjitterbuffer", NULL);
- if (!stream->jitterbuffer)
- goto no_jitterbuffer;
-
- stream->ptdemux = gst_element_factory_make ("gstrtpptdemux", NULL);
- if (!stream->ptdemux)
- goto no_ptdemux;
-
- /* add elements to bin */
- gst_bin_add (GST_BIN_CAST (rtpclient), stream->jitterbuffer);
- gst_bin_add (GST_BIN_CAST (rtpclient), stream->ptdemux);
-
- /* link jitterbuffer and PT demuxer */
- srcpad = gst_element_get_static_pad (stream->jitterbuffer, "src");
- sinkpad = gst_element_get_static_pad (stream->ptdemux, "sink");
- res = gst_pad_link (srcpad, sinkpad);
- gst_object_unref (srcpad);
- gst_object_unref (sinkpad);
-
- if (res != GST_PAD_LINK_OK)
- goto could_not_link;
-
- /* add stream to list */
- rtpclient->streams = g_list_prepend (rtpclient->streams, stream);
-
- /* ghost sinkpad */
- name = g_strdup_printf ("rtp_sink_%d", ssrc);
- sinkpad = gst_element_get_static_pad (stream->jitterbuffer, "sink");
- stream->rtp_sink = gst_ghost_pad_new (name, sinkpad);
- gst_object_unref (sinkpad);
- g_free (name);
- gst_element_add_pad (GST_ELEMENT_CAST (rtpclient), stream->rtp_sink);
-
- /* add signal to ptdemuxer */
- stream->new_pad_sig =
- g_signal_connect (G_OBJECT (stream->ptdemux), "pad-added",
- G_CALLBACK (new_pad), stream);
-
- return stream;
-
- /* ERRORS */
-no_jitterbuffer:
- {
- g_free (stream);
- g_warning ("gstrtpclient: could not create gstrtpjitterbuffer element");
- return NULL;
- }
-no_ptdemux:
- {
- gst_object_unref (stream->jitterbuffer);
- g_free (stream);
- g_warning ("gstrtpclient: could not create gstrtpptdemux element");
- return NULL;
- }
-could_not_link:
- {
- gst_bin_remove (GST_BIN_CAST (rtpclient), stream->jitterbuffer);
- gst_bin_remove (GST_BIN_CAST (rtpclient), stream->ptdemux);
- g_free (stream);
- g_warning ("gstrtpclient: could not link jitterbuffer and ptdemux element");
- return NULL;
- }
-}
-
-#if 0
-static void
-free_stream (GstRtpClientStream * stream)
-{
- gst_object_unref (stream->jitterbuffer);
- g_free (stream);
-}
-#endif
-
-/* find the stream for the given SSRC, return NULL if the stream did not exist
- */
-static GstRtpClientStream *
-find_stream_by_ssrc (GstRtpClient * client, guint32 ssrc)
-{
- GstRtpClientStream *stream;
- GList *walk;
-
- for (walk = client->streams; walk; walk = g_list_next (walk)) {
- stream = (GstRtpClientStream *) walk->data;
- if (stream->ssrc == ssrc)
- return stream;
- }
- return NULL;
-}
-
-/* signals and args */
-enum
-{
- /* FILL ME */
- LAST_SIGNAL
-};
-
-enum
-{
- PROP_0
-};
-
-/* GObject vmethods */
-static void gst_rtp_client_finalize (GObject * object);
-static void gst_rtp_client_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec);
-static void gst_rtp_client_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec);
-
-/* GstElement vmethods */
-static GstStateChangeReturn gst_rtp_client_change_state (GstElement * element,
- GstStateChange transition);
-static GstPad *gst_rtp_client_request_new_pad (GstElement * element,
- GstPadTemplate * templ, const gchar * name);
-static void gst_rtp_client_release_pad (GstElement * element, GstPad * pad);
-
-/*static guint gst_rtp_client_signals[LAST_SIGNAL] = { 0 }; */
-
-GST_BOILERPLATE (GstRtpClient, gst_rtp_client, GstBin, GST_TYPE_BIN);
-
-static void
-gst_rtp_client_base_init (gpointer klass)
-{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
-
- /* sink pads */
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&rtpclient_rtp_sink_template));
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&rtpclient_sync_sink_template));
-
- /* src pads */
- gst_element_class_add_pad_template (element_class,
- gst_static_pad_template_get (&rtpclient_rtp_src_template));
-
- gst_element_class_set_details (element_class, &rtpclient_details);
-}
-
-static void
-gst_rtp_client_class_init (GstRtpClientClass * klass)
-{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
-
- gobject_class = (GObjectClass *) klass;
- gstelement_class = (GstElementClass *) klass;
-
- g_type_class_add_private (klass, sizeof (GstRtpClientPrivate));
-
- gobject_class->finalize = gst_rtp_client_finalize;
- gobject_class->set_property = gst_rtp_client_set_property;
- gobject_class->get_property = gst_rtp_client_get_property;
-
- gstelement_class->change_state =
- GST_DEBUG_FUNCPTR (gst_rtp_client_change_state);
- gstelement_class->request_new_pad =
- GST_DEBUG_FUNCPTR (gst_rtp_client_request_new_pad);
- gstelement_class->release_pad =
- GST_DEBUG_FUNCPTR (gst_rtp_client_release_pad);
-}
-
-static void
-gst_rtp_client_init (GstRtpClient * rtpclient, GstRtpClientClass * klass)
-{
- rtpclient->priv = GST_RTP_CLIENT_GET_PRIVATE (rtpclient);
-}
-
-static void
-gst_rtp_client_finalize (GObject * object)
-{
- GstRtpClient *rtpclient;
-
- rtpclient = GST_RTP_CLIENT (object);
-
- G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gst_rtp_client_set_property (GObject * object, guint prop_id,
- const GValue * value, GParamSpec * pspec)
-{
- GstRtpClient *rtpclient;
-
- rtpclient = GST_RTP_CLIENT (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static void
-gst_rtp_client_get_property (GObject * object, guint prop_id,
- GValue * value, GParamSpec * pspec)
-{
- GstRtpClient *rtpclient;
-
- rtpclient = GST_RTP_CLIENT (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
-static GstStateChangeReturn
-gst_rtp_client_change_state (GstElement * element, GstStateChange transition)
-{
- GstStateChangeReturn res;
- GstRtpClient *rtpclient;
-
- rtpclient = GST_RTP_CLIENT (element);
-
- switch (transition) {
- case GST_STATE_CHANGE_NULL_TO_READY:
- break;
- case GST_STATE_CHANGE_READY_TO_PAUSED:
- break;
- case GST_STATE_CHANGE_PAUSED_TO_PLAYING:
- break;
- default:
- break;
- }
-
- res = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
-
- switch (transition) {
- case GST_STATE_CHANGE_PLAYING_TO_PAUSED:
- break;
- case GST_STATE_CHANGE_PAUSED_TO_READY:
- break;
- case GST_STATE_CHANGE_READY_TO_NULL:
- break;
- default:
- break;
- }
- return res;
-}
-
-/* We have 2 request pads (rtp_sink_%d and sync_sink_%d), the %d is assumed to
- * be the SSRC of the stream.
- *
- * We require that the rtp pad is requested first for a particular SSRC, then
- * (optionaly) the sync pad can be requested. If no sync pad is requested, no
- * sync information can be exchanged for this stream.
- */
-static GstPad *
-gst_rtp_client_request_new_pad (GstElement * element,
- GstPadTemplate * templ, const gchar * name)
-{
- GstRtpClient *rtpclient;
- GstElementClass *klass;
- GstPadTemplate *rtp_sink_templ, *sync_sink_templ;
- guint32 ssrc;
- GstRtpClientStream *stream;
- GstPad *result;
-
- g_return_val_if_fail (templ != NULL, NULL);
- g_return_val_if_fail (GST_IS_RTP_CLIENT (element), NULL);
-
- if (templ->direction != GST_PAD_SINK)
- goto wrong_direction;
-
- rtpclient = GST_RTP_CLIENT (element);
- klass = GST_ELEMENT_GET_CLASS (element);
-
- /* figure out the template */
- rtp_sink_templ = gst_element_class_get_pad_template (klass, "rtp_sink_%d");
- sync_sink_templ = gst_element_class_get_pad_template (klass, "sync_sink_%d");
-
- if (templ != rtp_sink_templ && templ != sync_sink_templ)
- goto wrong_template;
-
- if (templ == rtp_sink_templ) {
- /* create new rtp sink pad. If a stream with the pad number already exists
- * we have an error, else we create the sinkpad, add a jitterbuffer and
- * ptdemuxer. */
- if (name == NULL || strlen (name) < 9)
- goto no_name;
-
- ssrc = atoi (&name[9]);
-
- /* see if a stream with that name exists, if so we have an error. */
- stream = find_stream_by_ssrc (rtpclient, ssrc);
- if (stream != NULL)
- goto stream_exists;
-
- /* ok, create new stream */
- stream = create_stream (rtpclient, ssrc);
- if (stream == NULL)
- goto stream_not_found;
-
- result = stream->rtp_sink;
- } else {
- /* create new rtp sink pad. We can only do this if the RTP pad was
- * requested before, meaning the session with the padnumber must exist. */
- if (name == NULL || strlen (name) < 10)
- goto no_name;
-
- ssrc = atoi (&name[10]);
-
- /* find stream */
- stream = find_stream_by_ssrc (rtpclient, ssrc);
- if (stream == NULL)
- goto stream_not_found;
-
- stream->sync_sink =
- gst_pad_new_from_static_template (&rtpclient_sync_sink_template, name);
- gst_element_add_pad (GST_ELEMENT_CAST (rtpclient), stream->sync_sink);
-
- result = stream->sync_sink;
- }
-
- return result;
-
- /* ERRORS */
-wrong_direction:
- {
- g_warning ("gstrtpclient: request pad that is not a SINK pad");
- return NULL;
- }
-wrong_template:
- {
- g_warning ("gstrtpclient: this is not our template");
- return NULL;
- }
-no_name:
- {
- g_warning ("gstrtpclient: no padname was specified");
- return NULL;
- }
-stream_exists:
- {
- g_warning ("gstrtpclient: stream with SSRC %d already registered", ssrc);
- return NULL;
- }
-stream_not_found:
- {
- g_warning ("gstrtpclient: stream with SSRC %d not yet registered", ssrc);
- return NULL;
- }
-}
-
-static void
-gst_rtp_client_release_pad (GstElement * element, GstPad * pad)
-{
-}
diff --git a/gst/rtpmanager/gstrtpclient.h b/gst/rtpmanager/gstrtpclient.h
deleted file mode 100644
index cb2f7753..00000000
--- a/gst/rtpmanager/gstrtpclient.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/* GStreamer
- * Copyright (C) <2007> Wim Taymans <wim.taymans@gmail.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
- *
- * 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.
- */
-
-#ifndef __GST_RTP_CLIENT_H__
-#define __GST_RTP_CLIENT_H__
-
-#include <gst/gst.h>
-
-#define GST_TYPE_RTP_CLIENT \
- (gst_rtp_client_get_type())
-#define GST_RTP_CLIENT(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_RTP_CLIENT,GstRtpClient))
-#define GST_RTP_CLIENT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_RTP_CLIENT,GstRtpClientClass))
-#define GST_IS_RTP_CLIENT(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_RTP_CLIENT))
-#define GST_IS_RTP_CLIENT_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_RTP_CLIENT))
-
-typedef struct _GstRtpClient GstRtpClient;
-typedef struct _GstRtpClientClass GstRtpClientClass;
-typedef struct _GstRtpClientPrivate GstRtpClientPrivate;
-
-struct _GstRtpClient {
- GstBin parent_bin;
-
- /* a list of streams from a client */
- GList *streams;
-
- /*< private >*/
- GstRtpClientPrivate *priv;
-};
-
-struct _GstRtpClientClass {
- GstBinClass parent_class;
-};
-
-GType gst_rtp_client_get_type (void);
-
-#endif /* __GST_RTP_CLIENT_H__ */
diff --git a/gst/rtpmanager/gstrtpmanager.c b/gst/rtpmanager/gstrtpmanager.c
index 99779522..f38a77a8 100644
--- a/gst/rtpmanager/gstrtpmanager.c
+++ b/gst/rtpmanager/gstrtpmanager.c
@@ -22,7 +22,6 @@
#endif
#include "gstrtpbin.h"
-#include "gstrtpclient.h"
#include "gstrtpjitterbuffer.h"
#include "gstrtpptdemux.h"
#include "gstrtpsession.h"
@@ -35,10 +34,6 @@ plugin_init (GstPlugin * plugin)
GST_TYPE_RTP_BIN))
return FALSE;
- if (!gst_element_register (plugin, "gstrtpclient", GST_RANK_NONE,
- GST_TYPE_RTP_CLIENT))
- return FALSE;
-
if (!gst_element_register (plugin, "gstrtpjitterbuffer", GST_RANK_NONE,
GST_TYPE_RTP_JITTER_BUFFER))
return FALSE;
diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c
index 9407ee52..dcddb689 100644
--- a/gst/rtpmanager/gstrtpsession.c
+++ b/gst/rtpmanager/gstrtpsession.c
@@ -200,13 +200,7 @@ enum
#define DEFAULT_NTP_NS_BASE 0
#define DEFAULT_BANDWIDTH RTP_STATS_BANDWIDTH
#define DEFAULT_RTCP_FRACTION RTP_STATS_RTCP_BANDWIDTH
-#define DEFAULT_SDES_CNAME NULL
-#define DEFAULT_SDES_NAME NULL
-#define DEFAULT_SDES_EMAIL NULL
-#define DEFAULT_SDES_PHONE NULL
-#define DEFAULT_SDES_LOCATION NULL
-#define DEFAULT_SDES_TOOL NULL
-#define DEFAULT_SDES_NOTE NULL
+#define DEFAULT_SDES NULL
#define DEFAULT_NUM_SOURCES 0
#define DEFAULT_NUM_ACTIVE_SOURCES 0
@@ -216,13 +210,7 @@ enum
PROP_NTP_NS_BASE,
PROP_BANDWIDTH,
PROP_RTCP_FRACTION,
- PROP_SDES_CNAME,
- PROP_SDES_NAME,
- PROP_SDES_EMAIL,
- PROP_SDES_PHONE,
- PROP_SDES_LOCATION,
- PROP_SDES_TOOL,
- PROP_SDES_NOTE,
+ PROP_SDES,
PROP_NUM_SOURCES,
PROP_NUM_ACTIVE_SOURCES,
PROP_INTERNAL_SESSION,
@@ -555,40 +543,10 @@ gst_rtp_session_class_init (GstRtpSessionClass * klass)
"The fraction of the bandwidth used for RTCP",
0.0, G_MAXDOUBLE, DEFAULT_RTCP_FRACTION, G_PARAM_READWRITE));
- g_object_class_install_property (gobject_class, PROP_SDES_CNAME,
- g_param_spec_string ("sdes-cname", "SDES CNAME",
- "The CNAME to put in SDES messages of this session",
- DEFAULT_SDES_CNAME, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_NAME,
- g_param_spec_string ("sdes-name", "SDES NAME",
- "The NAME to put in SDES messages of this session",
- DEFAULT_SDES_NAME, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_EMAIL,
- g_param_spec_string ("sdes-email", "SDES EMAIL",
- "The EMAIL to put in SDES messages of this session",
- DEFAULT_SDES_EMAIL, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_PHONE,
- g_param_spec_string ("sdes-phone", "SDES PHONE",
- "The PHONE to put in SDES messages of this session",
- DEFAULT_SDES_PHONE, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_LOCATION,
- g_param_spec_string ("sdes-location", "SDES LOCATION",
- "The LOCATION to put in SDES messages of this session",
- DEFAULT_SDES_LOCATION, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_TOOL,
- g_param_spec_string ("sdes-tool", "SDES TOOL",
- "The TOOL to put in SDES messages of this session",
- DEFAULT_SDES_TOOL, G_PARAM_READWRITE));
-
- g_object_class_install_property (gobject_class, PROP_SDES_NOTE,
- g_param_spec_string ("sdes-note", "SDES NOTE",
- "The NOTE to put in SDES messages of this session",
- DEFAULT_SDES_NOTE, G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_SDES,
+ g_param_spec_boxed ("sdes", "SDES",
+ "The SDES items of this session",
+ GST_TYPE_STRUCTURE, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_NUM_SOURCES,
g_param_spec_uint ("num-sources", "Num Sources",
@@ -704,33 +662,8 @@ gst_rtp_session_set_property (GObject * object, guint prop_id,
case PROP_RTCP_FRACTION:
rtp_session_set_rtcp_fraction (priv->session, g_value_get_double (value));
break;
- case PROP_SDES_CNAME:
- rtp_session_set_sdes_string (priv->session, GST_RTCP_SDES_CNAME,
- g_value_get_string (value));
- break;
- case PROP_SDES_NAME:
- rtp_session_set_sdes_string (priv->session, GST_RTCP_SDES_NAME,
- g_value_get_string (value));
- break;
- case PROP_SDES_EMAIL:
- rtp_session_set_sdes_string (priv->session, GST_RTCP_SDES_EMAIL,
- g_value_get_string (value));
- break;
- case PROP_SDES_PHONE:
- rtp_session_set_sdes_string (priv->session, GST_RTCP_SDES_PHONE,
- g_value_get_string (value));
- break;
- case PROP_SDES_LOCATION:
- rtp_session_set_sdes_string (priv->session, GST_RTCP_SDES_LOC,
- g_value_get_string (value));
- break;
- case PROP_SDES_TOOL:
- rtp_session_set_sdes_string (priv->session, GST_RTCP_SDES_TOOL,
- g_value_get_string (value));
- break;
- case PROP_SDES_NOTE:
- rtp_session_set_sdes_string (priv->session, GST_RTCP_SDES_NOTE,
- g_value_get_string (value));
+ case PROP_SDES:
+ rtp_session_set_sdes_struct (priv->session, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -760,33 +693,8 @@ gst_rtp_session_get_property (GObject * object, guint prop_id,
case PROP_RTCP_FRACTION:
g_value_set_double (value, rtp_session_get_rtcp_fraction (priv->session));
break;
- case PROP_SDES_CNAME:
- g_value_take_string (value, rtp_session_get_sdes_string (priv->session,
- GST_RTCP_SDES_CNAME));
- break;
- case PROP_SDES_NAME:
- g_value_take_string (value, rtp_session_get_sdes_string (priv->session,
- GST_RTCP_SDES_NAME));
- break;
- case PROP_SDES_EMAIL:
- g_value_take_string (value, rtp_session_get_sdes_string (priv->session,
- GST_RTCP_SDES_EMAIL));
- break;
- case PROP_SDES_PHONE:
- g_value_take_string (value, rtp_session_get_sdes_string (priv->session,
- GST_RTCP_SDES_PHONE));
- break;
- case PROP_SDES_LOCATION:
- g_value_take_string (value, rtp_session_get_sdes_string (priv->session,
- GST_RTCP_SDES_LOC));
- break;
- case PROP_SDES_TOOL:
- g_value_take_string (value, rtp_session_get_sdes_string (priv->session,
- GST_RTCP_SDES_TOOL));
- break;
- case PROP_SDES_NOTE:
- g_value_take_string (value, rtp_session_get_sdes_string (priv->session,
- GST_RTCP_SDES_NOTE));
+ case PROP_SDES:
+ g_value_take_boxed (value, rtp_session_get_sdes_struct (priv->session));
break;
case PROP_NUM_SOURCES:
g_value_set_uint (value, rtp_session_get_num_sources (priv->session));
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index cda04182..fa46f501 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -49,13 +49,7 @@ enum
#define DEFAULT_BANDWIDTH RTP_STATS_BANDWIDTH
#define DEFAULT_RTCP_FRACTION RTP_STATS_RTCP_BANDWIDTH
#define DEFAULT_RTCP_MTU 1400
-#define DEFAULT_SDES_CNAME NULL
-#define DEFAULT_SDES_NAME NULL
-#define DEFAULT_SDES_EMAIL NULL
-#define DEFAULT_SDES_PHONE NULL
-#define DEFAULT_SDES_LOCATION NULL
-#define DEFAULT_SDES_TOOL NULL
-#define DEFAULT_SDES_NOTE NULL
+#define DEFAULT_SDES NULL
#define DEFAULT_NUM_SOURCES 0
#define DEFAULT_NUM_ACTIVE_SOURCES 0
#define DEFAULT_SOURCES NULL
@@ -68,13 +62,7 @@ enum
PROP_BANDWIDTH,
PROP_RTCP_FRACTION,
PROP_RTCP_MTU,
- PROP_SDES_CNAME,
- PROP_SDES_NAME,
- PROP_SDES_EMAIL,
- PROP_SDES_PHONE,
- PROP_SDES_LOCATION,
- PROP_SDES_TOOL,
- PROP_SDES_NOTE,
+ PROP_SDES,
PROP_NUM_SOURCES,
PROP_NUM_ACTIVE_SOURCES,
PROP_SOURCES,
@@ -273,40 +261,10 @@ rtp_session_class_init (RTPSessionClass * klass)
16, G_MAXINT16, DEFAULT_RTCP_MTU,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
- g_object_class_install_property (gobject_class, PROP_SDES_CNAME,
- g_param_spec_string ("sdes-cname", "SDES CNAME",
- "The CNAME to put in SDES messages of this session",
- DEFAULT_SDES_CNAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_SDES_NAME,
- g_param_spec_string ("sdes-name", "SDES NAME",
- "The NAME to put in SDES messages of this session",
- DEFAULT_SDES_NAME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_SDES_EMAIL,
- g_param_spec_string ("sdes-email", "SDES EMAIL",
- "The EMAIL to put in SDES messages of this session",
- DEFAULT_SDES_EMAIL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_SDES_PHONE,
- g_param_spec_string ("sdes-phone", "SDES PHONE",
- "The PHONE to put in SDES messages of this session",
- DEFAULT_SDES_PHONE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_SDES_LOCATION,
- g_param_spec_string ("sdes-location", "SDES LOCATION",
- "The LOCATION to put in SDES messages of this session",
- DEFAULT_SDES_LOCATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_SDES_TOOL,
- g_param_spec_string ("sdes-tool", "SDES TOOL",
- "The TOOL to put in SDES messages of this session",
- DEFAULT_SDES_TOOL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (gobject_class, PROP_SDES_NOTE,
- g_param_spec_string ("sdes-note", "SDES NOTE",
- "The NOTE to put in SDES messages of this session",
- DEFAULT_SDES_NOTE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (gobject_class, PROP_SDES,
+ g_param_spec_boxed ("sdes", "SDES",
+ "The SDES items of this session",
+ GST_TYPE_STRUCTURE, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_NUM_SOURCES,
g_param_spec_uint ("num-sources", "Num Sources",
@@ -426,6 +384,7 @@ copy_source (gpointer key, RTPSource * source, GValueArray * arr)
g_value_init (&value, RTP_TYPE_SOURCE);
g_value_take_object (&value, source);
+ /* copies the value */
g_value_array_append (arr, &value);
}
@@ -469,33 +428,8 @@ rtp_session_set_property (GObject * object, guint prop_id,
case PROP_RTCP_MTU:
sess->mtu = g_value_get_uint (value);
break;
- case PROP_SDES_CNAME:
- rtp_session_set_sdes_string (sess, GST_RTCP_SDES_CNAME,
- g_value_get_string (value));
- break;
- case PROP_SDES_NAME:
- rtp_session_set_sdes_string (sess, GST_RTCP_SDES_NAME,
- g_value_get_string (value));
- break;
- case PROP_SDES_EMAIL:
- rtp_session_set_sdes_string (sess, GST_RTCP_SDES_EMAIL,
- g_value_get_string (value));
- break;
- case PROP_SDES_PHONE:
- rtp_session_set_sdes_string (sess, GST_RTCP_SDES_PHONE,
- g_value_get_string (value));
- break;
- case PROP_SDES_LOCATION:
- rtp_session_set_sdes_string (sess, GST_RTCP_SDES_LOC,
- g_value_get_string (value));
- break;
- case PROP_SDES_TOOL:
- rtp_session_set_sdes_string (sess, GST_RTCP_SDES_TOOL,
- g_value_get_string (value));
- break;
- case PROP_SDES_NOTE:
- rtp_session_set_sdes_string (sess, GST_RTCP_SDES_NOTE,
- g_value_get_string (value));
+ case PROP_SDES:
+ rtp_session_set_sdes_struct (sess, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -527,33 +461,8 @@ rtp_session_get_property (GObject * object, guint prop_id,
case PROP_RTCP_MTU:
g_value_set_uint (value, sess->mtu);
break;
- case PROP_SDES_CNAME:
- g_value_take_string (value, rtp_session_get_sdes_string (sess,
- GST_RTCP_SDES_CNAME));
- break;
- case PROP_SDES_NAME:
- g_value_take_string (value, rtp_session_get_sdes_string (sess,
- GST_RTCP_SDES_NAME));
- break;
- case PROP_SDES_EMAIL:
- g_value_take_string (value, rtp_session_get_sdes_string (sess,
- GST_RTCP_SDES_EMAIL));
- break;
- case PROP_SDES_PHONE:
- g_value_take_string (value, rtp_session_get_sdes_string (sess,
- GST_RTCP_SDES_PHONE));
- break;
- case PROP_SDES_LOCATION:
- g_value_take_string (value, rtp_session_get_sdes_string (sess,
- GST_RTCP_SDES_LOC));
- break;
- case PROP_SDES_TOOL:
- g_value_take_string (value, rtp_session_get_sdes_string (sess,
- GST_RTCP_SDES_TOOL));
- break;
- case PROP_SDES_NOTE:
- g_value_take_string (value, rtp_session_get_sdes_string (sess,
- GST_RTCP_SDES_NOTE));
+ case PROP_SDES:
+ g_value_take_boxed (value, rtp_session_get_sdes_struct (sess));
break;
case PROP_NUM_SOURCES:
g_value_set_uint (value, rtp_session_get_num_sources (sess));
@@ -957,6 +866,45 @@ rtp_session_get_sdes_string (RTPSession * sess, GstRTCPSDESType type)
return result;
}
+/**
+ * rtp_session_get_sdes_struct:
+ * @sess: an #RTSPSession
+ *
+ * Get the SDES data as a #GstStructure
+ *
+ * Returns: a GstStructure with SDES items for @sess.
+ */
+GstStructure *
+rtp_session_get_sdes_struct (RTPSession * sess)
+{
+ GstStructure *result;
+
+ g_return_val_if_fail (RTP_IS_SESSION (sess), NULL);
+
+ RTP_SESSION_LOCK (sess);
+ result = rtp_source_get_sdes_struct (sess->source);
+ RTP_SESSION_UNLOCK (sess);
+
+ return result;
+}
+
+/**
+ * rtp_session_set_sdes_struct:
+ * @sess: an #RTSPSession
+ * @sdes: a #GstStructure
+ *
+ * Set the SDES data as a #GstStructure.
+ */
+void
+rtp_session_set_sdes_struct (RTPSession * sess, const GstStructure * sdes)
+{
+ g_return_if_fail (RTP_IS_SESSION (sess));
+
+ RTP_SESSION_LOCK (sess);
+ rtp_source_set_sdes_struct (sess->source, sdes);
+ RTP_SESSION_UNLOCK (sess);
+}
+
static GstFlowReturn
source_push_rtp (RTPSource * source, gpointer data, RTPSession * session)
{
@@ -1392,7 +1340,6 @@ rtp_session_create_new_ssrc (RTPSession * sess)
GINT_TO_POINTER (ssrc)) == NULL)
break;
}
-
return ssrc;
}
diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h
index 6312f1c1..25e228b0 100644
--- a/gst/rtpmanager/rtpsession.h
+++ b/gst/rtpmanager/rtpsession.h
@@ -267,6 +267,9 @@ gboolean rtp_session_set_sdes_string (RTPSession *sess, GstRTCPSDE
const gchar *cname);
gchar* rtp_session_get_sdes_string (RTPSession *sess, GstRTCPSDESType type);
+GstStructure * rtp_session_get_sdes_struct (RTPSession *sess);
+void rtp_session_set_sdes_struct (RTPSession *sess, const GstStructure *sdes);
+
/* handling sources */
RTPSource* rtp_session_get_internal_source (RTPSession *sess);
diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c
index 209c17b5..40cdd238 100644
--- a/gst/rtpmanager/rtpsource.c
+++ b/gst/rtpmanager/rtpsource.c
@@ -188,52 +188,13 @@ rtp_source_finalize (GObject * object)
G_OBJECT_CLASS (rtp_source_parent_class)->finalize (object);
}
-#define MAX_ADDRESS 64
-static void
-make_address_string (GstNetAddress * addr, gchar * dest, gulong n)
-{
- switch (gst_netaddress_get_net_type (addr)) {
- case GST_NET_TYPE_IP4:
- {
- guint32 address;
- guint16 port;
-
- gst_netaddress_get_ip4_address (addr, &address, &port);
- address = g_ntohl (address);
-
- g_snprintf (dest, n, "%d.%d.%d.%d:%d", (address >> 24) & 0xff,
- (address >> 16) & 0xff, (address >> 8) & 0xff, address & 0xff,
- g_ntohs (port));
- break;
- }
- case GST_NET_TYPE_IP6:
- {
- guint8 address[16];
- guint16 port;
-
- gst_netaddress_get_ip6_address (addr, address, &port);
-
- g_snprintf (dest, n, "[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]:%d",
- (address[0] << 8) | address[1], (address[2] << 8) | address[3],
- (address[4] << 8) | address[5], (address[6] << 8) | address[7],
- (address[8] << 8) | address[9], (address[10] << 8) | address[11],
- (address[12] << 8) | address[13], (address[14] << 8) | address[15],
- g_ntohs (port));
- break;
- }
- default:
- dest[0] = 0;
- break;
- }
-}
-
static GstStructure *
rtp_source_create_stats (RTPSource * src)
{
GstStructure *s;
gboolean is_sender = src->is_sender;
gboolean internal = src->internal;
- gchar address_str[MAX_ADDRESS];
+ gchar address_str[GST_NETADDRESS_MAX_LEN];
/* common data for all types of sources */
s = gst_structure_new ("application/x-rtp-source-stats",
@@ -246,11 +207,13 @@ rtp_source_create_stats (RTPSource * src)
/* add address and port */
if (src->have_rtp_from) {
- make_address_string (&src->rtp_from, address_str, sizeof (address_str));
+ gst_netaddress_to_string (&src->rtp_from, address_str,
+ sizeof (address_str));
gst_structure_set (s, "rtp-from", G_TYPE_STRING, address_str, NULL);
}
if (src->have_rtcp_from) {
- make_address_string (&src->rtcp_from, address_str, sizeof (address_str));
+ gst_netaddress_to_string (&src->rtcp_from, address_str,
+ sizeof (address_str));
gst_structure_set (s, "rtcp-from", G_TYPE_STRING, address_str, NULL);
}
@@ -316,8 +279,16 @@ rtp_source_create_stats (RTPSource * src)
return s;
}
-static GstStructure *
-rtp_source_create_sdes (RTPSource * src)
+/**
+ * rtp_source_get_sdes_struct:
+ * @src: an #RTSPSource
+ *
+ * Get the SDES data as a GstStructure
+ *
+ * Returns: a GstStructure with SDES items for @src.
+ */
+GstStructure *
+rtp_source_get_sdes_struct (RTPSource * src)
{
GstStructure *s;
gchar *str;
@@ -356,6 +327,44 @@ rtp_source_create_sdes (RTPSource * src)
return s;
}
+/**
+ * rtp_source_set_sdes_struct:
+ * @src: an #RTSPSource
+ * @sdes: a #GstStructure with SDES info
+ *
+ * Set the SDES items from @sdes.
+ */
+void
+rtp_source_set_sdes_struct (RTPSource * src, const GstStructure * sdes)
+{
+ const gchar *str;
+
+ if (!gst_structure_has_name (sdes, "application/x-rtp-source-sdes"))
+ return;
+
+ if ((str = gst_structure_get_string (sdes, "cname"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_CNAME, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "name"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_NAME, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "email"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_EMAIL, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "phone"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_PHONE, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "location"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_LOC, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "tool"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_TOOL, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "note"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_NOTE, str);
+ }
+}
+
static void
rtp_source_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@@ -396,7 +405,7 @@ rtp_source_get_property (GObject * object, guint prop_id,
g_value_set_boolean (value, rtp_source_is_sender (src));
break;
case PROP_SDES:
- g_value_take_boxed (value, rtp_source_create_sdes (src));
+ g_value_take_boxed (value, rtp_source_get_sdes_struct (src));
break;
case PROP_STATS:
g_value_take_boxed (value, rtp_source_create_stats (src));
diff --git a/gst/rtpmanager/rtpsource.h b/gst/rtpmanager/rtpsource.h
index 8286f2ec..8355bc0c 100644
--- a/gst/rtpmanager/rtpsource.h
+++ b/gst/rtpmanager/rtpsource.h
@@ -187,6 +187,9 @@ gboolean rtp_source_get_sdes (RTPSource *src, GstRTCPSDESType
guint8 **data, guint *len);
gchar* rtp_source_get_sdes_string (RTPSource *src, GstRTCPSDESType type);
+GstStructure * rtp_source_get_sdes_struct (RTPSource * src);
+void rtp_source_set_sdes_struct (RTPSource * src, const GstStructure *sdes);
+
/* handling network address */
void rtp_source_set_rtp_from (RTPSource *src, GstNetAddress *address);
void rtp_source_set_rtcp_from (RTPSource *src, GstNetAddress *address);
diff --git a/gst/shapewipe/gstshapewipe.c b/gst/shapewipe/gstshapewipe.c
index 4029c494..655cfc50 100644
--- a/gst/shapewipe/gstshapewipe.c
+++ b/gst/shapewipe/gstshapewipe.c
@@ -93,10 +93,10 @@ enum
};
static GstStaticPadTemplate video_sink_pad_template =
-GST_STATIC_PAD_TEMPLATE ("video_sink",
+ GST_STATIC_PAD_TEMPLATE ("video_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")));
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") " ; " GST_VIDEO_CAPS_ARGB));
static GstStaticPadTemplate mask_sink_pad_template =
GST_STATIC_PAD_TEMPLATE ("mask_sink",
@@ -112,8 +112,8 @@ static GstStaticPadTemplate mask_sink_pad_template =
"height = " GST_VIDEO_SIZE_RANGE ", " "framerate = 0/1"));
static GstStaticPadTemplate src_pad_template =
-GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV")));
+ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_YUV ("AYUV") " ; " GST_VIDEO_CAPS_ARGB));
GST_DEBUG_CATEGORY_STATIC (gst_shape_wipe_debug);
#define GST_CAT_DEFAULT gst_shape_wipe_debug
@@ -273,6 +273,7 @@ gst_shape_wipe_reset (GstShapeWipe * self)
g_cond_signal (self->mask_cond);
+ self->fmt = GST_VIDEO_FORMAT_UNKNOWN;
self->width = self->height = 0;
self->mask_position = 0.0;
self->mask_border = 0.0;
@@ -309,6 +310,7 @@ gst_shape_wipe_video_sink_setcaps (GstPad * pad, GstCaps * caps)
GstShapeWipe *self = GST_SHAPE_WIPE (gst_pad_get_parent (pad));
gboolean ret = TRUE;
GstStructure *s;
+ GstVideoFormat fmt;
gint width, height;
gint fps_n, fps_d;
@@ -316,13 +318,13 @@ gst_shape_wipe_video_sink_setcaps (GstPad * pad, GstCaps * caps)
s = gst_caps_get_structure (caps, 0);
- if (!gst_structure_get_int (s, "width", &width) ||
- !gst_structure_get_int (s, "height", &height) ||
+ if (!gst_video_format_parse_caps (caps, &fmt, &width, &height) ||
!gst_structure_get_fraction (s, "framerate", &fps_n, &fps_d)) {
ret = FALSE;
goto done;
}
+ self->fmt = fmt;
if (self->width != width || self->height != height) {
g_mutex_lock (self->mask_mutex);
self->width = width;
@@ -402,13 +404,20 @@ gst_shape_wipe_video_sink_getcaps (GstPad * pad)
n = gst_caps_get_size (tmp);
+ tmp2 = gst_caps_new_empty ();
for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (tmp, i);
+ GstStructure *c;
- gst_structure_remove_fields (s, "bpp", "depth", "endianness", "framerate",
+ gst_structure_remove_fields (s, "format", "bpp", "depth", "endianness",
+ "framerate", "red_mask", "green_mask", "blue_mask", "alpha_mask",
NULL);
gst_structure_set_name (s, "video/x-raw-yuv");
+ c = gst_structure_copy (s);
+ gst_structure_set_name (c, "video/x-raw-rgb");
+ gst_caps_append_structure (tmp2, c);
}
+ gst_caps_append (tmp, tmp2);
intersection = gst_caps_intersect (tmp, ret);
gst_caps_unref (tmp);
@@ -498,7 +507,9 @@ gst_shape_wipe_mask_sink_getcaps (GstPad * pad)
GstStructure *t;
gst_structure_set_name (s, "video/x-raw-gray");
- gst_structure_remove_fields (s, "format", "framerate", NULL);
+ gst_structure_remove_fields (s, "format", "framerate", "bpp", "depth",
+ "endianness", "framerate", "red_mask", "green_mask", "blue_mask",
+ "alpha_mask", NULL);
if (self->width && self->height)
gst_structure_set (s, "width", G_TYPE_INT, self->width, "height",
@@ -514,7 +525,7 @@ gst_shape_wipe_mask_sink_getcaps (GstPad * pad)
gst_caps_append_structure (tmp, t);
}
- gst_caps_merge (ret, tmp);
+ gst_caps_append (ret, tmp);
tmp = gst_pad_peer_get_caps (pad);
if (tmp) {
@@ -591,13 +602,20 @@ gst_shape_wipe_src_getcaps (GstPad * pad)
tmp = intersection;
n = gst_caps_get_size (tmp);
+ tmp2 = gst_caps_new_empty ();
for (i = 0; i < n; i++) {
GstStructure *s = gst_caps_get_structure (tmp, i);
+ GstStructure *c;
- gst_structure_remove_fields (s, "bpp", "depth", "endianness", "framerate",
+ gst_structure_remove_fields (s, "format", "bpp", "depth", "endianness",
+ "framerate", "red_mask", "green_mask", "blue_mask", "alpha_mask",
NULL);
gst_structure_set_name (s, "video/x-raw-yuv");
+ c = gst_structure_copy (s);
+
+ gst_caps_append_structure (tmp2, c);
}
+ gst_caps_append (tmp, tmp2);
intersection = gst_caps_intersect (tmp, ret);
gst_caps_unref (tmp);
@@ -729,118 +747,128 @@ gst_shape_wipe_do_qos (GstShapeWipe * self, GstClockTime timestamp)
return TRUE;
}
-static GstFlowReturn
-gst_shape_wipe_blend_16 (GstShapeWipe * self, GstBuffer * inbuf,
- GstBuffer * maskbuf, GstBuffer * outbuf)
-{
- const guint16 *mask = (const guint16 *) GST_BUFFER_DATA (maskbuf);
- const guint8 *input = (const guint8 *) GST_BUFFER_DATA (inbuf);
- guint8 *output = (guint8 *) GST_BUFFER_DATA (outbuf);
- guint i, j;
- guint mask_increment = GST_ROUND_UP_2 (self->width) - self->width;
- gfloat position = self->mask_position;
- gfloat low = position - (self->mask_border / 2.0f);
- gfloat high = position + (self->mask_border / 2.0f);
-
- if (low < 0.0f) {
- high = 0.0f;
- low = 0.0f;
- }
-
- if (high > 1.0f) {
- low = 1.0f;
- high = 1.0f;
- }
-
- for (i = 0; i < self->height; i++) {
- for (j = 0; j < self->width; j++) {
- gfloat in = *mask / 65536.0f;
-
- if (in < low) {
- output[0] = 0x00; /* A */
- output[1] = 0x00; /* Y */
- output[2] = 0x80; /* U */
- output[3] = 0x80; /* V */
- } else if (in >= high) {
- output[0] = 0xff; /* A */
- output[1] = input[1]; /* Y */
- output[2] = input[2]; /* U */
- output[3] = input[3]; /* V */
- } else {
- gfloat val = 255.0f * ((in - low) / (high - low));
-
- output[0] = CLAMP (val, 0, 255); /* A */
- output[1] = input[1]; /* Y */
- output[2] = input[2]; /* U */
- output[3] = input[3]; /* V */
- }
-
- mask++;
- input += 4;
- output += 4;
- }
- mask += mask_increment;
- }
-
- return GST_FLOW_OK;
+#define CREATE_AYUV_FUNCTIONS(depth, scale) \
+static GstFlowReturn \
+gst_shape_wipe_blend_ayuv_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
+ GstBuffer * maskbuf, GstBuffer * outbuf) \
+{ \
+ const guint##depth *mask = (const guint##depth *) GST_BUFFER_DATA (maskbuf); \
+ const guint8 *input = (const guint8 *) GST_BUFFER_DATA (inbuf); \
+ guint8 *output = (guint8 *) GST_BUFFER_DATA (outbuf); \
+ guint i, j; \
+ guint mask_increment = ((depth == 16) ? GST_ROUND_UP_2 (self->width) : \
+ GST_ROUND_UP_4 (self->width)) - self->width; \
+ gfloat position = self->mask_position; \
+ gfloat low = position - (self->mask_border / 2.0f); \
+ gfloat high = position + (self->mask_border / 2.0f); \
+ \
+ if (low < 0.0f) { \
+ high = 0.0f; \
+ low = 0.0f; \
+ } \
+ \
+ if (high > 1.0f) { \
+ low = 1.0f; \
+ high = 1.0f; \
+ } \
+ \
+ for (i = 0; i < self->height; i++) { \
+ for (j = 0; j < self->width; j++) { \
+ gfloat in = *mask / scale; \
+ \
+ if (in < low) { \
+ output[0] = 0x00; /* A */ \
+ output[1] = 0x00; /* Y */ \
+ output[2] = 0x80; /* U */ \
+ output[3] = 0x80; /* V */ \
+ } else if (in >= high) { \
+ output[0] = 0xff; /* A */ \
+ output[1] = input[1]; /* Y */ \
+ output[2] = input[2]; /* U */ \
+ output[3] = input[3]; /* V */ \
+ } else { \
+ gfloat val = 255.0f * ((in - low) / (high - low)); \
+ \
+ output[0] = CLAMP (val, 0, 255); /* A */ \
+ output[1] = input[1]; /* Y */ \
+ output[2] = input[2]; /* U */ \
+ output[3] = input[3]; /* V */ \
+ } \
+ \
+ mask++; \
+ input += 4; \
+ output += 4; \
+ } \
+ mask += mask_increment; \
+ } \
+ \
+ return GST_FLOW_OK; \
}
-static GstFlowReturn
-gst_shape_wipe_blend_8 (GstShapeWipe * self, GstBuffer * inbuf,
- GstBuffer * maskbuf, GstBuffer * outbuf)
-{
- const guint8 *mask = (const guint8 *) GST_BUFFER_DATA (maskbuf);
- const guint8 *input = (const guint8 *) GST_BUFFER_DATA (inbuf);
- guint8 *output = (guint8 *) GST_BUFFER_DATA (outbuf);
- guint i, j;
- guint mask_increment = GST_ROUND_UP_4 (self->width) - self->width;
- gfloat position = self->mask_position;
- gfloat low = position - (self->mask_border / 2.0f);
- gfloat high = position + (self->mask_border / 2.0f);
-
- if (low < 0.0f) {
- high = 0.0f;
- low = 0.0f;
- }
-
- if (high > 1.0f) {
- low = 1.0f;
- high = 1.0f;
- }
-
- for (i = 0; i < self->height; i++) {
- for (j = 0; j < self->width; j++) {
- gfloat in = *mask / 256.0f;
-
- if (in < low) {
- output[0] = 0x00; /* A */
- output[1] = 0x00; /* Y */
- output[2] = 0x80; /* U */
- output[3] = 0x80; /* V */
- } else if (in >= high) {
- output[0] = 0xff; /* A */
- output[1] = input[1]; /* Y */
- output[2] = input[2]; /* U */
- output[3] = input[3]; /* V */
- } else {
- gfloat val = 255.0f * ((in - low) / (high - low));
-
- output[0] = CLAMP (val, 0, 255); /* A */
- output[1] = input[1]; /* Y */
- output[2] = input[2]; /* U */
- output[3] = input[3]; /* V */
- }
-
- mask++;
- input += 4;
- output += 4;
- }
- mask += mask_increment;
- }
-
- return GST_FLOW_OK;
+CREATE_AYUV_FUNCTIONS (16, 65536.0f);
+CREATE_AYUV_FUNCTIONS (8, 256.0f);
+
+#define CREATE_ARGB_FUNCTIONS(depth, scale) \
+static GstFlowReturn \
+gst_shape_wipe_blend_argb_##depth (GstShapeWipe * self, GstBuffer * inbuf, \
+ GstBuffer * maskbuf, GstBuffer * outbuf) \
+{ \
+ const guint##depth *mask = (const guint##depth *) GST_BUFFER_DATA (maskbuf); \
+ const guint8 *input = (const guint8 *) GST_BUFFER_DATA (inbuf); \
+ guint8 *output = (guint8 *) GST_BUFFER_DATA (outbuf); \
+ guint i, j; \
+ guint mask_increment = ((depth == 16) ? GST_ROUND_UP_2 (self->width) : \
+ GST_ROUND_UP_4 (self->width)) - self->width; \
+ gfloat position = self->mask_position; \
+ gfloat low = position - (self->mask_border / 2.0f); \
+ gfloat high = position + (self->mask_border / 2.0f); \
+ \
+ if (low < 0.0f) { \
+ high = 0.0f; \
+ low = 0.0f; \
+ } \
+ \
+ if (high > 1.0f) { \
+ low = 1.0f; \
+ high = 1.0f; \
+ } \
+ \
+ for (i = 0; i < self->height; i++) { \
+ for (j = 0; j < self->width; j++) { \
+ gfloat in = *mask / scale; \
+ \
+ if (in < low) { \
+ output[0] = 0x00; /* A */ \
+ output[1] = 0x00; /* R */ \
+ output[2] = 0x00; /* G */ \
+ output[3] = 0x00; /* B */ \
+ } else if (in >= high) { \
+ output[0] = 0xff; /* A */ \
+ output[1] = input[1]; /* R */ \
+ output[2] = input[2]; /* G */ \
+ output[3] = input[3]; /* B */ \
+ } else { \
+ gfloat val = 255.0f * ((in - low) / (high - low)); \
+ \
+ output[0] = CLAMP (val, 0, 255); /* A */ \
+ output[1] = input[1]; /* R */ \
+ output[2] = input[2]; /* G */ \
+ output[3] = input[3]; /* B */ \
+ } \
+ \
+ mask++; \
+ input += 4; \
+ output += 4; \
+ } \
+ mask += mask_increment; \
+ } \
+ \
+ return GST_FLOW_OK; \
}
+CREATE_ARGB_FUNCTIONS (16, 65536.0f);
+CREATE_ARGB_FUNCTIONS (8, 256.0f);
+
static GstFlowReturn
gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
{
@@ -850,6 +878,9 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
GstClockTime timestamp;
gboolean new_outbuf = FALSE;
+ if (G_UNLIKELY (self->fmt == GST_VIDEO_FORMAT_UNKNOWN))
+ return GST_FLOW_NOT_NEGOTIATED;
+
timestamp = GST_BUFFER_TIMESTAMP (buffer);
timestamp =
gst_segment_to_stream_time (&self->segment, GST_FORMAT_TIME, timestamp);
@@ -898,10 +929,16 @@ gst_shape_wipe_video_sink_chain (GstPad * pad, GstBuffer * buffer)
outbuf = buffer;
}
- if (self->mask_bpp == 16)
- ret = gst_shape_wipe_blend_16 (self, buffer, mask, outbuf);
+ if (self->fmt == GST_VIDEO_FORMAT_AYUV && self->mask_bpp == 16)
+ ret = gst_shape_wipe_blend_ayuv_16 (self, buffer, mask, outbuf);
+ else if (self->fmt == GST_VIDEO_FORMAT_AYUV)
+ ret = gst_shape_wipe_blend_ayuv_8 (self, buffer, mask, outbuf);
+ else if (self->fmt == GST_VIDEO_FORMAT_ARGB && self->mask_bpp == 16)
+ ret = gst_shape_wipe_blend_argb_16 (self, buffer, mask, outbuf);
+ else if (self->fmt == GST_VIDEO_FORMAT_ARGB)
+ ret = gst_shape_wipe_blend_argb_8 (self, buffer, mask, outbuf);
else
- ret = gst_shape_wipe_blend_8 (self, buffer, mask, outbuf);
+ g_assert_not_reached ();
gst_buffer_unref (mask);
if (new_outbuf)
diff --git a/gst/shapewipe/gstshapewipe.h b/gst/shapewipe/gstshapewipe.h
index 2cc44831..f6196c69 100644
--- a/gst/shapewipe/gstshapewipe.h
+++ b/gst/shapewipe/gstshapewipe.h
@@ -59,6 +59,7 @@ struct _GstShapeWipe
GCond *mask_cond;
gint mask_bpp;
+ GstVideoFormat fmt;
gint width, height;
gdouble proportion;