summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2005-01-09 01:44:08 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2005-01-09 01:44:08 +0000
commitdd6a09c36dfecc3e47d060831474887582df6bd3 (patch)
treee91b95ec2150c2f27bc4966c5373e53233823ce6
parentf3a52d2897c8637605520eef76f873d37c66c5cb (diff)
downloadgst-plugins-bad-dd6a09c36dfecc3e47d060831474887582df6bd3.tar.gz
gst-plugins-bad-dd6a09c36dfecc3e47d060831474887582df6bd3.tar.bz2
gst-plugins-bad-dd6a09c36dfecc3e47d060831474887582df6bd3.zip
ext/snapshot/gstsnapshot.c: Allocate resources when required, fix recursive signal emission and fix caps. Fixes #161667.
Original commit message from CVS: Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> * ext/snapshot/gstsnapshot.c: (gst_snapshot_class_init), (snapshot_handler), (gst_snapshot_sinkconnect), (gst_snapshot_chain): Allocate resources when required, fix recursive signal emission and fix caps. Fixes #161667.
-rw-r--r--ChangeLog10
-rw-r--r--ext/snapshot/gstsnapshot.c43
2 files changed, 34 insertions, 19 deletions
diff --git a/ChangeLog b/ChangeLog
index 680de4fe..323f77e1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-01-09 Martin Eikermann <meiker@upb.de>
+
+ Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
+
+ * ext/snapshot/gstsnapshot.c: (gst_snapshot_class_init),
+ (snapshot_handler), (gst_snapshot_sinkconnect),
+ (gst_snapshot_chain):
+ Allocate resources when required, fix recursive signal emission
+ and fix caps. Fixes #161667.
+
2005-01-09 Gergely Nagy <algernon@bonehunter.rulez.org>
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
diff --git a/ext/snapshot/gstsnapshot.c b/ext/snapshot/gstsnapshot.c
index 9b3898b9..cc259460 100644
--- a/ext/snapshot/gstsnapshot.c
+++ b/ext/snapshot/gstsnapshot.c
@@ -40,14 +40,14 @@ static GstStaticPadTemplate snapshot_src_factory =
GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
static GstStaticPadTemplate snapshot_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS (GST_VIDEO_CAPS_BGR)
+ GST_STATIC_CAPS (GST_VIDEO_CAPS_RGB)
);
/* Snapshot signals and args */
@@ -76,7 +76,7 @@ static void gst_snapshot_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_snapshot_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
-
+static void snapshot_handler (GstElement * element);
static GstElementClass *parent_class = NULL;
static guint gst_snapshot_signals[LAST_SIGNAL] = { 0 };
@@ -155,13 +155,20 @@ gst_snapshot_class_init (GstSnapshotClass * klass)
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstSnapshotClass, snapshot),
NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
- klass->snapshot = NULL;
+ klass->snapshot = snapshot_handler;
gobject_class->set_property = gst_snapshot_set_property;
gobject_class->get_property = gst_snapshot_get_property;
}
+static void
+snapshot_handler (GstElement * element)
+{
+ GstSnapshot *snapshot;
+ snapshot = GST_SNAPSHOT (element);
+ snapshot->snapshot_asked = TRUE;
+}
static gboolean
gst_snapshot_sinkconnect (GstPad * pad, const GstCaps * caps)
@@ -179,17 +186,6 @@ gst_snapshot_sinkconnect (GstPad * pad, const GstCaps * caps)
gst_structure_get_fourcc (structure, "format", &filter->format);
filter->to_bpp = 24;
- filter->png_struct_ptr =
- png_create_write_struct (PNG_LIBPNG_VER_STRING, (png_voidp) NULL,
- user_error_fn, user_warning_fn);
- if (filter->png_struct_ptr == NULL)
- g_warning ("Failed to initialize png structure");
-
- filter->png_info_ptr = png_create_info_struct (filter->png_struct_ptr);
-
- if (setjmp (filter->png_struct_ptr->jmpbuf))
- png_destroy_write_struct (&filter->png_struct_ptr, &filter->png_info_ptr);
-
gst_pad_try_set_caps (filter->srcpad, caps);
return GST_PAD_LINK_OK;
@@ -248,6 +244,19 @@ gst_snapshot_chain (GstPad * pad, GstData * _data)
if (fp == NULL)
g_warning (" Can not open %s\n", snapshot->location);
else {
+ snapshot->png_struct_ptr =
+ png_create_write_struct (PNG_LIBPNG_VER_STRING, (png_voidp) NULL,
+ user_error_fn, user_warning_fn);
+ if (snapshot->png_struct_ptr == NULL)
+ g_warning ("Failed to initialize png structure");
+
+ snapshot->png_info_ptr =
+ png_create_info_struct (snapshot->png_struct_ptr);
+
+ if (setjmp (snapshot->png_struct_ptr->jmpbuf))
+ png_destroy_write_struct (&snapshot->png_struct_ptr,
+ &snapshot->png_info_ptr);
+
png_set_filter (snapshot->png_struct_ptr, 0,
PNG_FILTER_NONE | PNG_FILTER_VALUE_NONE);
png_init_io (snapshot->png_struct_ptr, fp);
@@ -271,10 +280,6 @@ gst_snapshot_chain (GstPad * pad, GstData * _data)
&snapshot->png_info_ptr);
png_destroy_write_struct (&snapshot->png_struct_ptr, (png_infopp) NULL);
fclose (fp);
- g_signal_emit (G_OBJECT (snapshot),
- gst_snapshot_signals[SNAPSHOT_SIGNAL], 0);
-
-
}
}