2 * Copyright (c) 2005 Edward Hervey <bilboed@bilboed.com>
3 * Copyright (C) 2010 Sebastian Dröge <sebastian.droege@collabora.co.uk>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
22 * SECTION:element-imagefreeze
24 * The imagefreeze element generates a still frame video stream from
25 * the input. It duplicates the first frame with the framerate requested
26 * by downstream, allows seeking and answers queries.
29 * <title>Example launch line</title>
31 * gst-launch-1.0 -v filesrc location=some.png ! decodebin ! imagefreeze ! autovideosink
32 * ]| This pipeline shows a still frame stream of a PNG file.
36 /* This is based on the imagefreeze element from PiTiVi:
37 * http://git.gnome.org/browse/pitivi/tree/pitivi/elements/imagefreeze.py
44 #include <gst/glib-compat-private.h>
46 #include "gstimagefreeze.h"
48 static void gst_image_freeze_finalize (GObject * object);
50 static void gst_image_freeze_reset (GstImageFreeze * self);
52 static GstStateChangeReturn gst_image_freeze_change_state (GstElement * element,
53 GstStateChange transition);
55 static GstFlowReturn gst_image_freeze_sink_chain (GstPad * pad,
56 GstObject * parent, GstBuffer * buffer);
57 static gboolean gst_image_freeze_sink_event (GstPad * pad, GstObject * parent,
59 static gboolean gst_image_freeze_sink_setcaps (GstImageFreeze * self,
61 static GstCaps *gst_image_freeze_sink_getcaps (GstImageFreeze * self,
63 static gboolean gst_image_freeze_sink_query (GstPad * pad, GstObject * parent,
65 static void gst_image_freeze_src_loop (GstPad * pad);
66 static gboolean gst_image_freeze_src_event (GstPad * pad, GstObject * parent,
68 static gboolean gst_image_freeze_src_query (GstPad * pad, GstObject * parent,
71 static GstStaticPadTemplate sink_pad_template = GST_STATIC_PAD_TEMPLATE ("sink",
74 GST_STATIC_CAPS ("video/x-raw"));
76 static GstStaticPadTemplate src_pad_template =
77 GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
78 GST_STATIC_CAPS ("video/x-raw"));
80 GST_DEBUG_CATEGORY_STATIC (gst_image_freeze_debug);
81 #define GST_CAT_DEFAULT gst_image_freeze_debug
83 #define gst_image_freeze_parent_class parent_class
84 G_DEFINE_TYPE (GstImageFreeze, gst_image_freeze, GST_TYPE_ELEMENT);
88 gst_image_freeze_class_init (GstImageFreezeClass * klass)
90 GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
91 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
93 gobject_class->finalize = gst_image_freeze_finalize;
95 gstelement_class->change_state =
96 GST_DEBUG_FUNCPTR (gst_image_freeze_change_state);
98 gst_element_class_set_static_metadata (gstelement_class,
99 "Still frame stream generator",
101 "Generates a still frame stream from an image",
102 "Sebastian Dröge <sebastian.droege@collabora.co.uk>");
104 gst_element_class_add_pad_template (gstelement_class,
105 gst_static_pad_template_get (&sink_pad_template));
106 gst_element_class_add_pad_template (gstelement_class,
107 gst_static_pad_template_get (&src_pad_template));
111 gst_image_freeze_init (GstImageFreeze * self)
113 self->sinkpad = gst_pad_new_from_static_template (&sink_pad_template, "sink");
114 gst_pad_set_chain_function (self->sinkpad,
115 GST_DEBUG_FUNCPTR (gst_image_freeze_sink_chain));
116 gst_pad_set_event_function (self->sinkpad,
117 GST_DEBUG_FUNCPTR (gst_image_freeze_sink_event));
118 gst_pad_set_query_function (self->sinkpad,
119 GST_DEBUG_FUNCPTR (gst_image_freeze_sink_query));
120 GST_PAD_SET_PROXY_ALLOCATION (self->sinkpad);
121 gst_element_add_pad (GST_ELEMENT (self), self->sinkpad);
123 self->srcpad = gst_pad_new_from_static_template (&src_pad_template, "src");
124 gst_pad_set_event_function (self->srcpad,
125 GST_DEBUG_FUNCPTR (gst_image_freeze_src_event));
126 gst_pad_set_query_function (self->srcpad,
127 GST_DEBUG_FUNCPTR (gst_image_freeze_src_query));
128 gst_pad_use_fixed_caps (self->srcpad);
129 gst_element_add_pad (GST_ELEMENT (self), self->srcpad);
131 g_mutex_init (&self->lock);
133 gst_image_freeze_reset (self);
137 gst_image_freeze_finalize (GObject * object)
139 GstImageFreeze *self = GST_IMAGE_FREEZE (object);
141 gst_image_freeze_reset (self);
143 g_mutex_clear (&self->lock);
145 G_OBJECT_CLASS (parent_class)->finalize (object);
149 gst_image_freeze_reset (GstImageFreeze * self)
151 GST_DEBUG_OBJECT (self, "Resetting internal state");
153 g_mutex_lock (&self->lock);
154 gst_buffer_replace (&self->buffer, NULL);
156 gst_segment_init (&self->segment, GST_FORMAT_TIME);
157 self->need_segment = TRUE;
159 self->fps_n = self->fps_d = 0;
162 g_mutex_unlock (&self->lock);
164 g_atomic_int_set (&self->seeking, 0);
168 gst_image_freeze_sink_setcaps (GstImageFreeze * self, GstCaps * caps)
170 gboolean ret = FALSE;
173 GstCaps *othercaps, *intersection;
178 caps = gst_caps_copy (caps);
180 GST_DEBUG_OBJECT (pad, "Setting caps: %" GST_PTR_FORMAT, caps);
182 s = gst_caps_get_structure (caps, 0);
184 /* 1. Remove framerate */
185 gst_structure_remove_field (s, "framerate");
186 gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT, 1,
189 /* 2. Intersect with template caps */
190 othercaps = (GstCaps *) gst_pad_get_pad_template_caps (pad);
191 intersection = gst_caps_intersect (caps, othercaps);
192 GST_DEBUG_OBJECT (pad, "Intersecting: %" GST_PTR_FORMAT, caps);
193 GST_DEBUG_OBJECT (pad, "with: %" GST_PTR_FORMAT, othercaps);
194 GST_DEBUG_OBJECT (pad, "gave: %" GST_PTR_FORMAT, intersection);
195 gst_caps_unref (caps);
196 gst_caps_unref (othercaps);
198 intersection = othercaps = NULL;
200 /* 3. Intersect with downstream peer caps */
201 othercaps = gst_pad_peer_query_caps (self->srcpad, caps);
202 GST_DEBUG_OBJECT (pad, "Peer query resulted: %" GST_PTR_FORMAT, othercaps);
203 gst_caps_unref (caps);
207 /* 4. For every candidate check if it's accepted downstream
208 * and fixate framerate to nearest 25/1 */
209 n = gst_caps_get_size (caps);
210 for (i = 0; i < n; i++) {
211 GstCaps *candidate = gst_caps_new_empty ();
212 GstStructure *s = gst_structure_copy (gst_caps_get_structure (caps, i));
214 gst_caps_append_structure (candidate, s);
215 if (gst_structure_has_field_typed (s, "framerate", GST_TYPE_FRACTION) ||
216 gst_structure_fixate_field_nearest_fraction (s, "framerate", 25, 1)) {
217 if (gst_pad_peer_query_accept_caps (self->srcpad, candidate)) {
218 gst_structure_get_fraction (s, "framerate", &fps_n, &fps_d);
220 g_mutex_lock (&self->lock);
223 g_mutex_unlock (&self->lock);
224 GST_DEBUG_OBJECT (pad, "Setting caps %" GST_PTR_FORMAT, candidate);
225 gst_pad_set_caps (self->srcpad, candidate);
226 gst_caps_unref (candidate);
230 GST_WARNING_OBJECT (pad, "Invalid caps with framerate %d/%d", fps_n,
235 gst_caps_unref (candidate);
240 GST_ERROR_OBJECT (pad, "No usable caps found");
242 gst_caps_unref (caps);
247 /* remove framerate in writable @caps */
249 gst_image_freeze_remove_fps (GstImageFreeze * self, GstCaps * caps)
253 n = gst_caps_get_size (caps);
254 for (i = 0; i < n; i++) {
255 GstStructure *s = gst_caps_get_structure (caps, i);
257 gst_structure_remove_field (s, "framerate");
258 gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT,
264 gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
266 GstCaps *ret, *tmp, *templ;
270 if (gst_pad_has_current_caps (pad)) {
271 ret = gst_pad_get_current_caps (pad);
276 filter = gst_caps_copy (filter);
277 gst_image_freeze_remove_fps (self, filter);
279 templ = gst_pad_get_pad_template_caps (pad);
280 tmp = gst_pad_peer_query_caps (self->srcpad, filter);
282 GST_LOG_OBJECT (self, "peer caps %" GST_PTR_FORMAT, tmp);
283 ret = gst_caps_intersect (tmp, templ);
284 gst_caps_unref (tmp);
286 GST_LOG_OBJECT (self, "going to copy");
287 ret = gst_caps_copy (templ);
290 gst_caps_unref (templ);
292 gst_caps_unref (filter);
294 ret = gst_caps_make_writable (ret);
295 gst_image_freeze_remove_fps (self, ret);
298 GST_LOG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, ret);
304 gst_image_freeze_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
306 GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
309 GST_LOG_OBJECT (pad, "Handling query of type '%s'",
310 gst_query_type_get_name (GST_QUERY_TYPE (query)));
312 switch (GST_QUERY_TYPE (query)) {
317 gst_query_parse_caps (query, &caps);
318 caps = gst_image_freeze_sink_getcaps (self, caps);
319 gst_query_set_caps_result (query, caps);
320 gst_caps_unref (caps);
325 ret = gst_pad_query_default (pad, parent, query);
332 gst_image_freeze_convert (GstImageFreeze * self,
333 GstFormat src_format, gint64 src_value,
334 GstFormat * dest_format, gint64 * dest_value)
336 gboolean ret = FALSE;
338 if (src_format == *dest_format) {
339 *dest_value = src_value;
343 if (src_value == -1) {
348 switch (src_format) {
349 case GST_FORMAT_DEFAULT:{
350 switch (*dest_format) {
351 case GST_FORMAT_TIME:
352 g_mutex_lock (&self->lock);
353 if (self->fps_n == 0)
357 gst_util_uint64_scale (src_value, GST_SECOND * self->fps_d,
359 g_mutex_unlock (&self->lock);
367 case GST_FORMAT_TIME:{
368 switch (*dest_format) {
369 case GST_FORMAT_DEFAULT:
370 g_mutex_lock (&self->lock);
372 gst_util_uint64_scale (src_value, self->fps_n,
373 self->fps_d * GST_SECOND);
374 g_mutex_unlock (&self->lock);
390 gst_image_freeze_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
392 GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
393 gboolean ret = FALSE;
395 GST_LOG_OBJECT (pad, "Handling query of type '%s'",
396 gst_query_type_get_name (GST_QUERY_TYPE (query)));
398 switch (GST_QUERY_TYPE (query)) {
399 case GST_QUERY_CONVERT:{
400 GstFormat src_format, dest_format;
401 gint64 src_value, dest_value;
403 gst_query_parse_convert (query, &src_format, &src_value, &dest_format,
406 gst_image_freeze_convert (self, src_format, src_value, &dest_format,
409 gst_query_set_convert (query, src_format, src_value, dest_format,
413 case GST_QUERY_POSITION:{
417 gst_query_parse_position (query, &format, NULL);
419 case GST_FORMAT_DEFAULT:{
420 g_mutex_lock (&self->lock);
421 position = self->offset;
422 g_mutex_unlock (&self->lock);
426 case GST_FORMAT_TIME:{
427 g_mutex_lock (&self->lock);
428 position = self->segment.position;
429 g_mutex_unlock (&self->lock);
438 gst_query_set_position (query, format, position);
439 GST_DEBUG_OBJECT (pad,
440 "Returning position %" G_GINT64_FORMAT " in format %s", position,
441 gst_format_get_name (format));
443 GST_DEBUG_OBJECT (pad, "Position query failed");
447 case GST_QUERY_DURATION:{
451 gst_query_parse_duration (query, &format, NULL);
453 case GST_FORMAT_TIME:{
454 g_mutex_lock (&self->lock);
455 duration = self->segment.stop;
456 g_mutex_unlock (&self->lock);
460 case GST_FORMAT_DEFAULT:{
461 g_mutex_lock (&self->lock);
462 duration = self->segment.stop;
465 gst_util_uint64_scale (duration, self->fps_n,
466 GST_SECOND * self->fps_d);
467 g_mutex_unlock (&self->lock);
476 gst_query_set_duration (query, format, duration);
477 GST_DEBUG_OBJECT (pad,
478 "Returning duration %" G_GINT64_FORMAT " in format %s", duration,
479 gst_format_get_name (format));
481 GST_DEBUG_OBJECT (pad, "Duration query failed");
485 case GST_QUERY_SEEKING:{
489 gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
490 seekable = (format == GST_FORMAT_TIME || format == GST_FORMAT_DEFAULT);
492 gst_query_set_seeking (query, format, seekable, (seekable ? 0 : -1), -1);
506 gst_image_freeze_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
508 GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
511 GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
513 switch (GST_EVENT_TYPE (event)) {
518 gst_event_parse_caps (event, &caps);
519 gst_image_freeze_sink_setcaps (self, caps);
520 gst_event_unref (event);
526 /* if we receive EOS before a buffer arrives, then let it pass */
527 GST_DEBUG_OBJECT (self, "EOS without input buffer, passing on");
528 ret = gst_pad_push_event (self->srcpad, event);
532 case GST_EVENT_SEGMENT:
533 GST_DEBUG_OBJECT (pad, "Dropping event");
534 gst_event_unref (event);
537 case GST_EVENT_FLUSH_START:
538 gst_image_freeze_reset (self);
541 ret = gst_pad_push_event (self->srcpad, event);
549 gst_image_freeze_src_event (GstPad * pad, GstObject * parent, GstEvent * event)
551 GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
554 GST_LOG_OBJECT (pad, "Got %s event", GST_EVENT_TYPE_NAME (event));
556 switch (GST_EVENT_TYPE (event)) {
557 case GST_EVENT_NAVIGATION:
559 case GST_EVENT_LATENCY:
561 GST_DEBUG_OBJECT (pad, "Dropping event");
562 gst_event_unref (event);
565 case GST_EVENT_SEEK:{
569 GstSeekType start_type, stop_type;
576 gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
578 gst_event_unref (event);
580 flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
582 if (format != GST_FORMAT_TIME && format != GST_FORMAT_DEFAULT) {
583 GST_ERROR_OBJECT (pad, "Seek in invalid format: %s",
584 gst_format_get_name (format));
589 if (format == GST_FORMAT_DEFAULT) {
590 format = GST_FORMAT_TIME;
591 if (!gst_image_freeze_convert (self, GST_FORMAT_DEFAULT, start, &format,
593 || !gst_image_freeze_convert (self, GST_FORMAT_DEFAULT, stop,
595 || start == -1 || stop == -1) {
596 GST_ERROR_OBJECT (pad,
597 "Failed to convert seek from DEFAULT format into TIME format");
603 seqnum = gst_event_get_seqnum (event);
607 g_atomic_int_set (&self->seeking, 1);
608 e = gst_event_new_flush_start ();
609 gst_event_set_seqnum (e, seqnum);
610 gst_pad_push_event (self->srcpad, e);
612 gst_pad_pause_task (self->srcpad);
615 GST_PAD_STREAM_LOCK (self->srcpad);
617 g_mutex_lock (&self->lock);
619 gst_segment_do_seek (&self->segment, rate, format, flags, start_type,
620 start, stop_type, stop, NULL);
621 self->need_segment = TRUE;
622 last_stop = self->segment.position;
624 start_task = self->buffer != NULL;
625 g_mutex_unlock (&self->lock);
630 e = gst_event_new_flush_stop (TRUE);
631 gst_event_set_seqnum (e, seqnum);
632 gst_pad_push_event (self->srcpad, e);
633 g_atomic_int_set (&self->seeking, 0);
636 if (flags & GST_SEEK_FLAG_SEGMENT) {
639 m = gst_message_new_segment_start (GST_OBJECT (self),
641 gst_element_post_message (GST_ELEMENT (self), m);
644 self->seqnum = seqnum;
645 GST_PAD_STREAM_UNLOCK (self->srcpad);
647 GST_DEBUG_OBJECT (pad, "Seek successful");
650 g_mutex_lock (&self->lock);
652 if (self->buffer != NULL)
653 gst_pad_start_task (self->srcpad,
654 (GstTaskFunction) gst_image_freeze_src_loop, self->srcpad, NULL);
656 g_mutex_unlock (&self->lock);
662 case GST_EVENT_FLUSH_START:
663 gst_image_freeze_reset (self);
666 ret = gst_pad_push_event (self->sinkpad, event);
674 gst_image_freeze_sink_chain (GstPad * pad, GstObject * parent,
677 GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
679 g_return_val_if_fail (self->buffer == NULL, GST_FLOW_ERROR);
681 g_mutex_lock (&self->lock);
682 self->buffer = buffer;
684 gst_pad_start_task (self->srcpad, (GstTaskFunction) gst_image_freeze_src_loop,
686 g_mutex_unlock (&self->lock);
691 gst_image_freeze_src_loop (GstPad * pad)
693 GstImageFreeze *self = GST_IMAGE_FREEZE (GST_PAD_PARENT (pad));
696 GstClockTime timestamp, timestamp_end;
697 guint64 cstart, cstop;
698 gboolean in_seg, eos;
699 GstFlowReturn flow_ret = GST_FLOW_OK;
701 g_mutex_lock (&self->lock);
702 if (!gst_pad_has_current_caps (self->srcpad)) {
703 GST_ERROR_OBJECT (pad, "Not negotiated yet");
704 flow_ret = GST_FLOW_NOT_NEGOTIATED;
705 g_mutex_unlock (&self->lock);
710 GST_ERROR_OBJECT (pad, "Have no buffer yet");
711 flow_ret = GST_FLOW_ERROR;
712 g_mutex_unlock (&self->lock);
715 buffer = gst_buffer_copy (self->buffer);
717 g_mutex_unlock (&self->lock);
719 if (self->need_segment) {
722 GST_DEBUG_OBJECT (pad, "Pushing SEGMENT event: %" GST_SEGMENT_FORMAT,
724 e = gst_event_new_segment (&self->segment);
727 gst_event_set_seqnum (e, self->seqnum);
729 g_mutex_lock (&self->lock);
730 if (self->segment.rate >= 0) {
732 gst_util_uint64_scale (self->segment.start, self->fps_n,
733 self->fps_d * GST_SECOND);
736 gst_util_uint64_scale (self->segment.stop, self->fps_n,
737 self->fps_d * GST_SECOND);
739 g_mutex_unlock (&self->lock);
741 self->need_segment = FALSE;
743 gst_pad_push_event (self->srcpad, e);
746 g_mutex_lock (&self->lock);
747 offset = self->offset;
749 if (self->fps_n != 0) {
751 gst_util_uint64_scale (offset, self->fps_d * GST_SECOND, self->fps_n);
753 gst_util_uint64_scale (offset + 1, self->fps_d * GST_SECOND,
756 timestamp = self->segment.start;
757 timestamp_end = GST_CLOCK_TIME_NONE;
760 eos = (self->fps_n == 0 && offset > 0) ||
761 (self->segment.rate >= 0 && self->segment.stop != -1
762 && timestamp > self->segment.stop) || (self->segment.rate < 0
763 && offset == 0) || (self->segment.rate < 0
764 && self->segment.start != -1 && timestamp_end < self->segment.start);
766 if (self->fps_n == 0 && offset > 0)
770 gst_segment_clip (&self->segment, GST_FORMAT_TIME, timestamp,
771 timestamp_end, &cstart, &cstop);
774 self->segment.position = cstart;
775 if (self->segment.rate >= 0)
776 self->segment.position = cstop;
779 if (self->segment.rate >= 0)
783 g_mutex_unlock (&self->lock);
785 GST_DEBUG_OBJECT (pad, "Handling buffer with timestamp %" GST_TIME_FORMAT,
786 GST_TIME_ARGS (timestamp));
789 GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE;
790 GST_BUFFER_PTS (buffer) = cstart;
791 GST_BUFFER_DURATION (buffer) = cstop - cstart;
792 GST_BUFFER_OFFSET (buffer) = offset;
793 GST_BUFFER_OFFSET_END (buffer) = offset + 1;
794 flow_ret = gst_pad_push (self->srcpad, buffer);
795 GST_DEBUG_OBJECT (pad, "Pushing buffer resulted in %s",
796 gst_flow_get_name (flow_ret));
797 if (flow_ret != GST_FLOW_OK)
800 gst_buffer_unref (buffer);
804 flow_ret = GST_FLOW_EOS;
812 const gchar *reason = gst_flow_get_name (flow_ret);
814 GST_LOG_OBJECT (self, "pausing task, reason %s", reason);
815 gst_pad_pause_task (pad);
817 if (flow_ret == GST_FLOW_EOS) {
818 if ((self->segment.flags & GST_SEEK_FLAG_SEGMENT)) {
822 GST_DEBUG_OBJECT (pad, "Sending segment done at end of segment");
823 if (self->segment.rate >= 0) {
824 m = gst_message_new_segment_done (GST_OBJECT_CAST (self),
825 GST_FORMAT_TIME, self->segment.stop);
826 e = gst_event_new_segment_done (GST_FORMAT_TIME, self->segment.stop);
828 m = gst_message_new_segment_done (GST_OBJECT_CAST (self),
829 GST_FORMAT_TIME, self->segment.start);
830 e = gst_event_new_segment_done (GST_FORMAT_TIME, self->segment.start);
832 gst_element_post_message (GST_ELEMENT_CAST (self), m);
833 gst_pad_push_event (self->srcpad, e);
835 GstEvent *e = gst_event_new_eos ();
837 GST_DEBUG_OBJECT (pad, "Sending EOS at end of segment");
840 gst_event_set_seqnum (e, self->seqnum);
841 gst_pad_push_event (self->srcpad, e);
843 } else if (flow_ret == GST_FLOW_NOT_LINKED || flow_ret < GST_FLOW_EOS) {
844 GstEvent *e = gst_event_new_eos ();
846 GST_ELEMENT_ERROR (self, STREAM, FAILED,
847 ("Internal data stream error."),
848 ("stream stopped, reason %s", reason));
851 gst_event_set_seqnum (e, self->seqnum);
853 gst_pad_push_event (self->srcpad, e);
859 static GstStateChangeReturn
860 gst_image_freeze_change_state (GstElement * element, GstStateChange transition)
862 GstImageFreeze *self = GST_IMAGE_FREEZE (element);
863 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
865 switch (transition) {
866 case GST_STATE_CHANGE_READY_TO_PAUSED:
867 gst_image_freeze_reset (self);
869 case GST_STATE_CHANGE_PAUSED_TO_READY:
870 gst_pad_stop_task (self->srcpad);
871 gst_image_freeze_reset (self);
877 if (GST_ELEMENT_CLASS (parent_class)->change_state)
878 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
880 switch (transition) {
889 plugin_init (GstPlugin * plugin)
891 GST_DEBUG_CATEGORY_INIT (gst_image_freeze_debug, "imagefreeze", 0,
892 "imagefreeze element");
894 if (!gst_element_register (plugin, "imagefreeze", GST_RANK_NONE,
895 GST_TYPE_IMAGE_FREEZE))
901 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
904 "Still frame stream generator",
905 plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)