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_static_pad_template (gstelement_class,
106 gst_element_class_add_static_pad_template (gstelement_class,
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 try to use it downstream with framerate as
208 * near as possible to 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 gst_structure_get_fraction (s, "framerate", &fps_n, &fps_d);
219 if (gst_pad_set_caps (self->srcpad, candidate)) {
220 g_mutex_lock (&self->lock);
223 g_mutex_unlock (&self->lock);
224 GST_DEBUG_OBJECT (pad, "Setting caps %" GST_PTR_FORMAT, candidate);
226 gst_caps_unref (candidate);
230 GST_WARNING_OBJECT (pad, "Invalid caps with framerate %d/%d", fps_n,
234 gst_caps_unref (candidate);
238 GST_ERROR_OBJECT (pad, "No usable caps found");
240 gst_caps_unref (caps);
245 /* remove framerate in writable @caps */
247 gst_image_freeze_remove_fps (GstImageFreeze * self, GstCaps * caps)
251 n = gst_caps_get_size (caps);
252 for (i = 0; i < n; i++) {
253 GstStructure *s = gst_caps_get_structure (caps, i);
255 gst_structure_remove_field (s, "framerate");
256 gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT,
262 gst_image_freeze_sink_getcaps (GstImageFreeze * self, GstCaps * filter)
264 GstCaps *ret, *tmp, *templ;
270 filter = gst_caps_copy (filter);
271 gst_image_freeze_remove_fps (self, filter);
273 templ = gst_pad_get_pad_template_caps (pad);
274 tmp = gst_pad_peer_query_caps (self->srcpad, filter);
276 GST_LOG_OBJECT (self, "peer caps %" GST_PTR_FORMAT, tmp);
277 ret = gst_caps_intersect (tmp, templ);
278 gst_caps_unref (tmp);
280 GST_LOG_OBJECT (self, "going to copy");
281 ret = gst_caps_copy (templ);
284 gst_caps_unref (templ);
286 gst_caps_unref (filter);
288 ret = gst_caps_make_writable (ret);
289 gst_image_freeze_remove_fps (self, ret);
291 GST_LOG_OBJECT (pad, "Returning caps: %" GST_PTR_FORMAT, ret);
297 gst_image_freeze_sink_query (GstPad * pad, GstObject * parent, GstQuery * query)
299 GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
302 GST_LOG_OBJECT (pad, "Handling query of type '%s'",
303 gst_query_type_get_name (GST_QUERY_TYPE (query)));
305 switch (GST_QUERY_TYPE (query)) {
310 gst_query_parse_caps (query, &caps);
311 caps = gst_image_freeze_sink_getcaps (self, caps);
312 gst_query_set_caps_result (query, caps);
313 gst_caps_unref (caps);
318 ret = gst_pad_query_default (pad, parent, query);
325 gst_image_freeze_convert (GstImageFreeze * self,
326 GstFormat src_format, gint64 src_value,
327 GstFormat * dest_format, gint64 * dest_value)
329 gboolean ret = FALSE;
331 if (src_format == *dest_format) {
332 *dest_value = src_value;
336 if (src_value == -1) {
341 switch (src_format) {
342 case GST_FORMAT_DEFAULT:{
343 switch (*dest_format) {
344 case GST_FORMAT_TIME:
345 g_mutex_lock (&self->lock);
346 if (self->fps_n == 0)
350 gst_util_uint64_scale (src_value, GST_SECOND * self->fps_d,
352 g_mutex_unlock (&self->lock);
360 case GST_FORMAT_TIME:{
361 switch (*dest_format) {
362 case GST_FORMAT_DEFAULT:
363 g_mutex_lock (&self->lock);
365 gst_util_uint64_scale (src_value, self->fps_n,
366 self->fps_d * GST_SECOND);
367 g_mutex_unlock (&self->lock);
383 gst_image_freeze_src_query (GstPad * pad, GstObject * parent, GstQuery * query)
385 GstImageFreeze *self = GST_IMAGE_FREEZE (parent);
386 gboolean ret = FALSE;
388 GST_LOG_OBJECT (pad, "Handling query of type '%s'",
389 gst_query_type_get_name (GST_QUERY_TYPE (query)));
391 switch (GST_QUERY_TYPE (query)) {
392 case GST_QUERY_CONVERT:{
393 GstFormat src_format, dest_format;
394 gint64 src_value, dest_value;
396 gst_query_parse_convert (query, &src_format, &src_value, &dest_format,
399 gst_image_freeze_convert (self, src_format, src_value, &dest_format,
402 gst_query_set_convert (query, src_format, src_value, dest_format,
406 case GST_QUERY_POSITION:{
410 gst_query_parse_position (query, &format, NULL);
412 case GST_FORMAT_DEFAULT:{
413 g_mutex_lock (&self->lock);
414 position = self->offset;
415 g_mutex_unlock (&self->lock);
419 case GST_FORMAT_TIME:{
420 g_mutex_lock (&self->lock);
421 position = self->segment.position;
422 g_mutex_unlock (&self->lock);
431 gst_query_set_position (query, format, position);
432 GST_DEBUG_OBJECT (pad,
433 "Returning position %" G_GINT64_FORMAT " in format %s", position,
434 gst_format_get_name (format));
436 GST_DEBUG_OBJECT (pad, "Position query failed");
440 case GST_QUERY_DURATION:{
444 gst_query_parse_duration (query, &format, NULL);
446 case GST_FORMAT_TIME:{
447 g_mutex_lock (&self->lock);
448 duration = self->segment.stop;
449 g_mutex_unlock (&self->lock);
453 case GST_FORMAT_DEFAULT:{
454 g_mutex_lock (&self->lock);
455 duration = self->segment.stop;
458 gst_util_uint64_scale (duration, self->fps_n,
459 GST_SECOND * self->fps_d);
460 g_mutex_unlock (&self->lock);
469 gst_query_set_duration (query, format, duration);
470 GST_DEBUG_OBJECT (pad,
471 "Returning duration %" G_GINT64_FORMAT " in format %s", duration,
472 gst_format_get_name (format));
474 GST_DEBUG_OBJECT (pad, "Duration query failed");
478 case GST_QUERY_SEEKING:{
482 gst_query_parse_seeking (query, &format, NULL, NULL, NULL);
483 seekable = (format == GST_FORMAT_TIME || format == GST_FORMAT_DEFAULT);
485 gst_query_set_seeking (query, format, seekable, (seekable ? 0 : -1), -1);
489 case GST_QUERY_LATENCY:
490 /* This will only return an accurate latency for the first buffer since
491 * all further buffers outputted by us are just copies of that one, and
492 * the latency is 0 in that case. However, latency changes are not
493 * straightforward, so let's do the conservative fix for now. */
494 ret = gst_pad_query_default (pad, parent, query);
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 seqnum = gst_event_get_seqnum (event);
577 gst_event_parse_seek (event, &rate, &format, &flags, &start_type, &start,
579 gst_event_unref (event);
581 flush = ! !(flags & GST_SEEK_FLAG_FLUSH);
583 if (format != GST_FORMAT_TIME && format != GST_FORMAT_DEFAULT) {
584 GST_ERROR_OBJECT (pad, "Seek in invalid format: %s",
585 gst_format_get_name (format));
590 if (format == GST_FORMAT_DEFAULT) {
591 format = GST_FORMAT_TIME;
592 if (!gst_image_freeze_convert (self, GST_FORMAT_DEFAULT, start, &format,
594 || !gst_image_freeze_convert (self, GST_FORMAT_DEFAULT, stop,
596 || start == -1 || stop == -1) {
597 GST_ERROR_OBJECT (pad,
598 "Failed to convert seek from DEFAULT format into TIME format");
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_mutex_lock (&self->lock);
681 GST_DEBUG_OBJECT (pad, "Already have a buffer, dropping");
682 gst_buffer_unref (buffer);
683 g_mutex_unlock (&self->lock);
687 self->buffer = buffer;
689 gst_pad_start_task (self->srcpad, (GstTaskFunction) gst_image_freeze_src_loop,
691 g_mutex_unlock (&self->lock);
696 gst_image_freeze_src_loop (GstPad * pad)
698 GstImageFreeze *self = GST_IMAGE_FREEZE (GST_PAD_PARENT (pad));
701 GstClockTime timestamp, timestamp_end;
702 guint64 cstart, cstop;
703 gboolean in_seg, eos;
704 GstFlowReturn flow_ret = GST_FLOW_OK;
706 g_mutex_lock (&self->lock);
707 if (!gst_pad_has_current_caps (self->srcpad)) {
708 GST_ERROR_OBJECT (pad, "Not negotiated yet");
709 flow_ret = GST_FLOW_NOT_NEGOTIATED;
710 g_mutex_unlock (&self->lock);
715 GST_ERROR_OBJECT (pad, "Have no buffer yet");
716 flow_ret = GST_FLOW_ERROR;
717 g_mutex_unlock (&self->lock);
720 buffer = gst_buffer_copy (self->buffer);
722 g_mutex_unlock (&self->lock);
724 if (self->need_segment) {
727 GST_DEBUG_OBJECT (pad, "Pushing SEGMENT event: %" GST_SEGMENT_FORMAT,
729 e = gst_event_new_segment (&self->segment);
732 gst_event_set_seqnum (e, self->seqnum);
734 g_mutex_lock (&self->lock);
735 if (self->segment.rate >= 0) {
737 gst_util_uint64_scale (self->segment.start, self->fps_n,
738 self->fps_d * GST_SECOND);
741 gst_util_uint64_scale (self->segment.stop, self->fps_n,
742 self->fps_d * GST_SECOND);
744 g_mutex_unlock (&self->lock);
746 self->need_segment = FALSE;
748 gst_pad_push_event (self->srcpad, e);
751 g_mutex_lock (&self->lock);
752 offset = self->offset;
754 if (self->fps_n != 0) {
756 gst_util_uint64_scale (offset, self->fps_d * GST_SECOND, self->fps_n);
758 gst_util_uint64_scale (offset + 1, self->fps_d * GST_SECOND,
761 timestamp = self->segment.start;
762 timestamp_end = GST_CLOCK_TIME_NONE;
765 eos = (self->fps_n == 0 && offset > 0) ||
766 (self->segment.rate >= 0 && self->segment.stop != -1
767 && timestamp > self->segment.stop) || (self->segment.rate < 0
768 && offset == 0) || (self->segment.rate < 0
769 && self->segment.start != -1 && timestamp_end < self->segment.start);
771 if (self->fps_n == 0 && offset > 0)
775 gst_segment_clip (&self->segment, GST_FORMAT_TIME, timestamp,
776 timestamp_end, &cstart, &cstop);
779 self->segment.position = cstart;
780 if (self->segment.rate >= 0)
781 self->segment.position = cstop;
784 if (self->segment.rate >= 0)
788 g_mutex_unlock (&self->lock);
790 GST_DEBUG_OBJECT (pad, "Handling buffer with timestamp %" GST_TIME_FORMAT,
791 GST_TIME_ARGS (timestamp));
794 GST_BUFFER_DTS (buffer) = GST_CLOCK_TIME_NONE;
795 GST_BUFFER_PTS (buffer) = cstart;
796 GST_BUFFER_DURATION (buffer) = cstop - cstart;
797 GST_BUFFER_OFFSET (buffer) = offset;
798 GST_BUFFER_OFFSET_END (buffer) = offset + 1;
799 flow_ret = gst_pad_push (self->srcpad, buffer);
800 GST_DEBUG_OBJECT (pad, "Pushing buffer resulted in %s",
801 gst_flow_get_name (flow_ret));
802 if (flow_ret != GST_FLOW_OK)
805 gst_buffer_unref (buffer);
809 flow_ret = GST_FLOW_EOS;
817 const gchar *reason = gst_flow_get_name (flow_ret);
819 GST_LOG_OBJECT (self, "pausing task, reason %s", reason);
820 gst_pad_pause_task (pad);
822 if (flow_ret == GST_FLOW_EOS) {
823 if ((self->segment.flags & GST_SEEK_FLAG_SEGMENT)) {
827 GST_DEBUG_OBJECT (pad, "Sending segment done at end of segment");
828 if (self->segment.rate >= 0) {
829 m = gst_message_new_segment_done (GST_OBJECT_CAST (self),
830 GST_FORMAT_TIME, self->segment.stop);
831 e = gst_event_new_segment_done (GST_FORMAT_TIME, self->segment.stop);
833 m = gst_message_new_segment_done (GST_OBJECT_CAST (self),
834 GST_FORMAT_TIME, self->segment.start);
835 e = gst_event_new_segment_done (GST_FORMAT_TIME, self->segment.start);
837 gst_element_post_message (GST_ELEMENT_CAST (self), m);
838 gst_pad_push_event (self->srcpad, e);
840 GstEvent *e = gst_event_new_eos ();
842 GST_DEBUG_OBJECT (pad, "Sending EOS at end of segment");
845 gst_event_set_seqnum (e, self->seqnum);
846 gst_pad_push_event (self->srcpad, e);
848 } else if (flow_ret == GST_FLOW_NOT_LINKED || flow_ret < GST_FLOW_EOS) {
849 GstEvent *e = gst_event_new_eos ();
851 GST_ELEMENT_FLOW_ERROR (self, flow_ret);
854 gst_event_set_seqnum (e, self->seqnum);
856 gst_pad_push_event (self->srcpad, e);
862 static GstStateChangeReturn
863 gst_image_freeze_change_state (GstElement * element, GstStateChange transition)
865 GstImageFreeze *self = GST_IMAGE_FREEZE (element);
866 GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
868 switch (transition) {
869 case GST_STATE_CHANGE_READY_TO_PAUSED:
870 gst_image_freeze_reset (self);
872 case GST_STATE_CHANGE_PAUSED_TO_READY:
873 gst_pad_stop_task (self->srcpad);
874 gst_image_freeze_reset (self);
880 if (GST_ELEMENT_CLASS (parent_class)->change_state)
881 ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
883 switch (transition) {
892 plugin_init (GstPlugin * plugin)
894 GST_DEBUG_CATEGORY_INIT (gst_image_freeze_debug, "imagefreeze", 0,
895 "imagefreeze element");
897 if (!gst_element_register (plugin, "imagefreeze", GST_RANK_NONE,
898 GST_TYPE_IMAGE_FREEZE))
904 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
907 "Still frame stream generator",
908 plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)