]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gstreamer0-10.git/blob - plugins/elements/gstidentity.c
plugins/elements/gstidentity.*: Emit bus message if check-perfect is true and we...
[glsdk/gstreamer0-10.git] / plugins / elements / gstidentity.c
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *                    2005 Wim Taymans <wim@fluendo.com>
5  *
6  * gstidentity.c:
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public
19  * License along with this library; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  */
25 #ifdef HAVE_CONFIG_H
26 #  include "config.h"
27 #endif
29 #include <stdlib.h>
31 #include "../../gst/gst-i18n-lib.h"
32 #include "gstidentity.h"
33 #include <gst/gstmarshal.h>
35 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
36     GST_PAD_SINK,
37     GST_PAD_ALWAYS,
38     GST_STATIC_CAPS_ANY);
40 static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
41     GST_PAD_SRC,
42     GST_PAD_ALWAYS,
43     GST_STATIC_CAPS_ANY);
45 GST_DEBUG_CATEGORY_STATIC (gst_identity_debug);
46 #define GST_CAT_DEFAULT gst_identity_debug
48 static const GstElementDetails gst_identity_details =
49 GST_ELEMENT_DETAILS ("Identity",
50     "Generic",
51     "Pass data without modification",
52     "Erik Walthinsen <omega@cse.ogi.edu>");
55 /* Identity signals and args */
56 enum
57 {
58   SIGNAL_HANDOFF,
59   /* FILL ME */
60   LAST_SIGNAL
61 };
63 #define DEFAULT_SLEEP_TIME              0
64 #define DEFAULT_DUPLICATE               1
65 #define DEFAULT_ERROR_AFTER             -1
66 #define DEFAULT_DROP_PROBABILITY        0.0
67 #define DEFAULT_DATARATE                0
68 #define DEFAULT_SILENT                  FALSE
69 #define DEFAULT_SINGLE_SEGMENT          FALSE
70 #define DEFAULT_DUMP                    FALSE
71 #define DEFAULT_SYNC                    FALSE
72 #define DEFAULT_CHECK_PERFECT           FALSE
74 enum
75 {
76   PROP_0,
77   PROP_SLEEP_TIME,
78   PROP_ERROR_AFTER,
79   PROP_DROP_PROBABILITY,
80   PROP_DATARATE,
81   PROP_SILENT,
82   PROP_SINGLE_SEGMENT,
83   PROP_LAST_MESSAGE,
84   PROP_DUMP,
85   PROP_SYNC,
86   PROP_CHECK_PERFECT
87 };
90 #define _do_init(bla) \
91     GST_DEBUG_CATEGORY_INIT (gst_identity_debug, "identity", 0, "identity element");
93 GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstBaseTransform,
94     GST_TYPE_BASE_TRANSFORM, _do_init);
96 static void gst_identity_finalize (GObject * object);
97 static void gst_identity_set_property (GObject * object, guint prop_id,
98     const GValue * value, GParamSpec * pspec);
99 static void gst_identity_get_property (GObject * object, guint prop_id,
100     GValue * value, GParamSpec * pspec);
102 static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
103 static GstFlowReturn gst_identity_transform_ip (GstBaseTransform * trans,
104     GstBuffer * buf);
105 static gboolean gst_identity_start (GstBaseTransform * trans);
106 static gboolean gst_identity_stop (GstBaseTransform * trans);
108 static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
110 static void
111 gst_identity_base_init (gpointer g_class)
113   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
115   gst_element_class_add_pad_template (gstelement_class,
116       gst_static_pad_template_get (&srctemplate));
117   gst_element_class_add_pad_template (gstelement_class,
118       gst_static_pad_template_get (&sinktemplate));
119   gst_element_class_set_details (gstelement_class, &gst_identity_details);
122 static void
123 gst_identity_finalize (GObject * object)
125   GstIdentity *identity;
127   identity = GST_IDENTITY (object);
129   g_free (identity->last_message);
131   G_OBJECT_CLASS (parent_class)->finalize (object);
134 /* fixme: do something about this */
135 static void
136 marshal_VOID__MINIOBJECT (GClosure * closure, GValue * return_value,
137     guint n_param_values, const GValue * param_values, gpointer invocation_hint,
138     gpointer marshal_data)
140   typedef void (*marshalfunc_VOID__MINIOBJECT) (gpointer obj, gpointer arg1,
141       gpointer data2);
142   register marshalfunc_VOID__MINIOBJECT callback;
143   register GCClosure *cc = (GCClosure *) closure;
144   register gpointer data1, data2;
146   g_return_if_fail (n_param_values == 2);
148   if (G_CCLOSURE_SWAP_DATA (closure)) {
149     data1 = closure->data;
150     data2 = g_value_peek_pointer (param_values + 0);
151   } else {
152     data1 = g_value_peek_pointer (param_values + 0);
153     data2 = closure->data;
154   }
155   callback =
156       (marshalfunc_VOID__MINIOBJECT) (marshal_data ? marshal_data : cc->
157       callback);
159   callback (data1, gst_value_get_mini_object (param_values + 1), data2);
162 static void
163 gst_identity_class_init (GstIdentityClass * klass)
165   GObjectClass *gobject_class;
166   GstElementClass *gstelement_class;
167   GstBaseTransformClass *gstbasetrans_class;
169   gobject_class = G_OBJECT_CLASS (klass);
170   gstelement_class = GST_ELEMENT_CLASS (klass);
171   gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
173   gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_identity_set_property);
174   gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_identity_get_property);
176   g_object_class_install_property (gobject_class, PROP_SLEEP_TIME,
177       g_param_spec_uint ("sleep-time", "Sleep time",
178           "Microseconds to sleep between processing", 0, G_MAXUINT,
179           DEFAULT_SLEEP_TIME, G_PARAM_READWRITE));
180   g_object_class_install_property (gobject_class, PROP_ERROR_AFTER,
181       g_param_spec_int ("error_after", "Error After", "Error after N buffers",
182           G_MININT, G_MAXINT, DEFAULT_ERROR_AFTER, G_PARAM_READWRITE));
183   g_object_class_install_property (gobject_class,
184       PROP_DROP_PROBABILITY, g_param_spec_float ("drop_probability",
185           "Drop Probability",
186           "The Probability a buffer is dropped (not implemented)", 0.0, 1.0,
187           DEFAULT_DROP_PROBABILITY, G_PARAM_READWRITE));
188   g_object_class_install_property (gobject_class, PROP_DATARATE,
189       g_param_spec_int ("datarate", "Datarate",
190           "(Re)timestamps buffers with number of bytes per second (0 = inactive)",
191           0, G_MAXINT, DEFAULT_DATARATE, G_PARAM_READWRITE));
192   g_object_class_install_property (gobject_class, PROP_SILENT,
193       g_param_spec_boolean ("silent", "silent", "silent", DEFAULT_SILENT,
194           G_PARAM_READWRITE));
195   g_object_class_install_property (gobject_class, PROP_SINGLE_SEGMENT,
196       g_param_spec_boolean ("single-segment", "Single Segment",
197           "Timestamp buffers and eat newsegments so as to appear as one segment",
198           DEFAULT_SINGLE_SEGMENT, G_PARAM_READWRITE));
199   g_object_class_install_property (gobject_class, PROP_LAST_MESSAGE,
200       g_param_spec_string ("last-message", "last-message", "last-message", NULL,
201           G_PARAM_READABLE));
202   g_object_class_install_property (gobject_class, PROP_DUMP,
203       g_param_spec_boolean ("dump", "Dump", "Dump buffer contents to stdout",
204           DEFAULT_DUMP, G_PARAM_READWRITE));
205   g_object_class_install_property (gobject_class, PROP_SYNC,
206       g_param_spec_boolean ("sync", "Synchronize",
207           "Synchronize to pipeline clock", DEFAULT_SYNC, G_PARAM_READWRITE));
208   g_object_class_install_property (gobject_class, PROP_CHECK_PERFECT,
209       g_param_spec_boolean ("check-perfect", "Check For Perfect Stream",
210           "Verify that the stream is time- and data-contiguous",
211           DEFAULT_CHECK_PERFECT, G_PARAM_READWRITE));
213    /**
214    * GstIdentity::handoff:
215    * @identity: the identity instance
216    * @buffer: the buffer that just has been received
217    * @pad: the pad that received it
218    *
219    * This signal gets emitted before passing the buffer downstream.
220    */
221   gst_identity_signals[SIGNAL_HANDOFF] =
222       g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
223       G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
224       marshal_VOID__MINIOBJECT, G_TYPE_NONE, 1, GST_TYPE_BUFFER);
226   gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_identity_finalize);
228   gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_identity_event);
229   gstbasetrans_class->transform_ip =
230       GST_DEBUG_FUNCPTR (gst_identity_transform_ip);
231   gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_identity_start);
232   gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_identity_stop);
235 static void
236 gst_identity_init (GstIdentity * identity, GstIdentityClass * g_class)
238   gst_base_transform_set_passthrough (GST_BASE_TRANSFORM (identity), TRUE);
240   identity->sleep_time = DEFAULT_SLEEP_TIME;
241   identity->error_after = DEFAULT_ERROR_AFTER;
242   identity->drop_probability = DEFAULT_DROP_PROBABILITY;
243   identity->datarate = DEFAULT_DATARATE;
244   identity->silent = DEFAULT_SILENT;
245   identity->single_segment = DEFAULT_SINGLE_SEGMENT;
246   identity->sync = DEFAULT_SYNC;
247   identity->check_perfect = DEFAULT_CHECK_PERFECT;
248   identity->dump = DEFAULT_DUMP;
249   identity->last_message = NULL;
252 static gboolean
253 gst_identity_event (GstBaseTransform * trans, GstEvent * event)
255   GstIdentity *identity;
256   gboolean ret = TRUE;
258   identity = GST_IDENTITY (trans);
260   if (!identity->silent) {
261     const GstStructure *s;
262     gchar *sstr;
264     GST_OBJECT_LOCK (identity);
265     g_free (identity->last_message);
267     if ((s = gst_event_get_structure (event)))
268       sstr = gst_structure_to_string (s);
269     else
270       sstr = g_strdup ("");
272     identity->last_message =
273         g_strdup_printf ("event   ******* (%s:%s) E (type: %d, %s) %p",
274         GST_DEBUG_PAD_NAME (trans->sinkpad), GST_EVENT_TYPE (event), sstr,
275         event);
276     g_free (sstr);
277     GST_OBJECT_UNLOCK (identity);
279     g_object_notify (G_OBJECT (identity), "last_message");
280   }
282   if (identity->single_segment
283       && (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT)) {
284     if (trans->have_newsegment == FALSE) {
285       GstEvent *news;
286       GstFormat format;
288       gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL,
289           NULL);
291       /* This is the first newsegment, send out a (0, -1) newsegment */
292       news = gst_event_new_new_segment (TRUE, 1.0, format, 0, -1, 0);
294       if (!(gst_pad_event_default (trans->sinkpad, news)))
295         return FALSE;
296     }
297   }
299   GST_BASE_TRANSFORM_CLASS (parent_class)->event (trans, event);
301   if (identity->single_segment
302       && (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT)) {
303     /* eat up segments */
304     ret = FALSE;
305   }
307   return ret;
310 static void
311 gst_identity_check_perfect (GstIdentity * identity, GstBuffer * buf)
313   GstClockTime timestamp;
315   timestamp = GST_BUFFER_TIMESTAMP (buf);
317   /* see if we need to do perfect stream checking */
318   /* invalid timestamp drops us out of check.  FIXME: maybe warn ? */
319   if (timestamp != GST_CLOCK_TIME_NONE) {
320     /* check if we had a previous buffer to compare to */
321     if (identity->prev_timestamp != GST_CLOCK_TIME_NONE &&
322         identity->prev_duration != GST_CLOCK_TIME_NONE) {
323       guint64 offset, t_expected;
324       gint64 dt;
326       t_expected = identity->prev_timestamp + identity->prev_duration;
327       dt = timestamp - t_expected;
328       if (dt != 0) {
329         GST_WARNING_OBJECT (identity,
330             "Buffer not time-contiguous with previous one: " "prev ts %"
331             GST_TIME_FORMAT ", prev dur %" GST_TIME_FORMAT ", new ts %"
332             GST_TIME_FORMAT " (expected ts %" GST_TIME_FORMAT ", delta=%c%"
333             GST_TIME_FORMAT ")", GST_TIME_ARGS (identity->prev_timestamp),
334             GST_TIME_ARGS (identity->prev_duration), GST_TIME_ARGS (timestamp),
335             GST_TIME_ARGS (t_expected), (dt < 0) ? '-' : '+',
336             GST_TIME_ARGS ((dt < 0) ? (GstClockTime) (-dt) : dt));
337         /*
338          * "non-perfect" bus message:
339          * @identity: the identity instance
340          * @prev-timestamp: the previous buffer timestamp
341          * @prev-duration: the previous buffer duration
342          * @prev-offset: the previous buffer offset
343          * @prev-offset-end: the previous buffer offset end
344          * @cur-timestamp: the current buffer timestamp 
345          * @cur-duration: the current buffer duration
346          * @cur-offset: the current buffer offset
347          * @cur-offset_end: the current buffer offset end
348          *
349          * This bus message gets emitted if check-perfect property is set and
350          * a non perfect stream is detected between the last buffer and
351          * the newly received buffer.
352          */
353         gst_element_post_message (GST_ELEMENT (identity),
354             gst_message_new_element (GST_OBJECT (identity),
355                 gst_structure_new ("non-perfect", "prev-timestamp",
356                     G_TYPE_UINT64, identity->prev_timestamp, "prev-duration",
357                     G_TYPE_UINT64, identity->prev_duration, "prev-offset",
358                     G_TYPE_UINT64, identity->prev_offset, "prev-offset-end",
359                     G_TYPE_UINT64, identity->prev_offset_end, "cur-timestamp",
360                     G_TYPE_UINT64, timestamp, "cur-duration", G_TYPE_UINT64,
361                     GST_BUFFER_DURATION (buf), "cur-offset", G_TYPE_UINT64,
362                     GST_BUFFER_OFFSET (buf), "cur-offset-end", G_TYPE_UINT64,
363                     GST_BUFFER_OFFSET_END (buf), NULL)));
365       }
367       offset = GST_BUFFER_OFFSET (buf);
368       if (identity->prev_offset_end != offset) {
369         GST_WARNING_OBJECT (identity,
370             "Buffer not data-contiguous with previous one: "
371             "prev offset_end %" G_GINT64_FORMAT ", new offset %"
372             G_GINT64_FORMAT, identity->prev_offset_end, offset);
373       }
374     } else {
375       GST_DEBUG_OBJECT (identity, "can't check time-contiguity, no timestamp "
376           "and/or duration were set on previous buffer");
377     }
379     /* update prev values */
380     identity->prev_timestamp = timestamp;
381     identity->prev_duration = GST_BUFFER_DURATION (buf);
382     identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf);
383     identity->prev_offset = GST_BUFFER_OFFSET (buf);
384   }
387 static GstFlowReturn
388 gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
390   GstFlowReturn ret = GST_FLOW_OK;
391   GstIdentity *identity = GST_IDENTITY (trans);
392   GstClockTime runtimestamp = G_GINT64_CONSTANT (0);
394   if (identity->check_perfect)
395     gst_identity_check_perfect (identity, buf);
397   if (identity->error_after >= 0) {
398     identity->error_after--;
399     if (identity->error_after == 0) {
400       GST_ELEMENT_ERROR (identity, CORE, FAILED,
401           (_("Failed after iterations as requested.")), (NULL));
402       return GST_FLOW_ERROR;
403     }
404   }
406   if (identity->drop_probability > 0.0) {
407     if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
408       if (!identity->silent) {
409         GST_OBJECT_LOCK (identity);
410         g_free (identity->last_message);
411         identity->last_message =
412             g_strdup_printf
413             ("dropping   ******* (%s:%s)i (%d bytes, timestamp: %"
414             GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
415             G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT
416             ", flags: %d) %p", GST_DEBUG_PAD_NAME (trans->sinkpad),
417             GST_BUFFER_SIZE (buf), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
418             GST_TIME_ARGS (GST_BUFFER_DURATION (buf)), GST_BUFFER_OFFSET (buf),
419             GST_BUFFER_OFFSET_END (buf), GST_BUFFER_FLAGS (buf), buf);
420         GST_OBJECT_UNLOCK (identity);
421         g_object_notify (G_OBJECT (identity), "last-message");
422       }
423       /* FIXME, this does not drop the buffer in basetransform. Actually
424        * dropping the buffer in transform_ip is not possible without a new
425        * custom GstFlowReturn value. */
426       return GST_FLOW_OK;
427     }
428   }
430   if (identity->dump) {
431     gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
432   }
434   if (!identity->silent) {
435     GST_OBJECT_LOCK (identity);
436     g_free (identity->last_message);
437     identity->last_message =
438         g_strdup_printf ("chain   ******* (%s:%s)i (%d bytes, timestamp: %"
439         GST_TIME_FORMAT ", duration: %" GST_TIME_FORMAT ", offset: %"
440         G_GINT64_FORMAT ", offset_end: % " G_GINT64_FORMAT ", flags: %d) %p",
441         GST_DEBUG_PAD_NAME (trans->sinkpad), GST_BUFFER_SIZE (buf),
442         GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (buf)),
443         GST_TIME_ARGS (GST_BUFFER_DURATION (buf)),
444         GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
445         GST_BUFFER_FLAGS (buf), buf);
446     GST_OBJECT_UNLOCK (identity);
447     g_object_notify (G_OBJECT (identity), "last-message");
448   }
450   if (identity->datarate > 0) {
451     GstClockTime time = identity->offset * GST_SECOND / identity->datarate;
453     GST_BUFFER_TIMESTAMP (buf) = time;
454     GST_BUFFER_DURATION (buf) =
455         GST_BUFFER_SIZE (buf) * GST_SECOND / identity->datarate;
456   }
458   g_signal_emit (G_OBJECT (identity), gst_identity_signals[SIGNAL_HANDOFF], 0,
459       buf);
461   if (trans->segment.format == GST_FORMAT_TIME)
462     runtimestamp = gst_segment_to_running_time (&trans->segment,
463         GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));
465   if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) {
466     GstClock *clock;
468     GST_OBJECT_LOCK (identity);
469     if ((clock = GST_ELEMENT (identity)->clock)) {
470       GstClockReturn cret;
471       GstClockTime timestamp;
473       timestamp = runtimestamp + GST_ELEMENT (identity)->base_time;
475       /* save id if we need to unlock */
476       /* FIXME: actually unlock this somewhere in the state changes */
477       identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);
478       GST_OBJECT_UNLOCK (identity);
480       cret = gst_clock_id_wait (identity->clock_id, NULL);
482       GST_OBJECT_LOCK (identity);
483       if (identity->clock_id) {
484         gst_clock_id_unref (identity->clock_id);
485         identity->clock_id = NULL;
486       }
487       if (cret == GST_CLOCK_UNSCHEDULED)
488         ret = GST_FLOW_UNEXPECTED;
489     }
490     GST_OBJECT_UNLOCK (identity);
491   }
493   identity->offset += GST_BUFFER_SIZE (buf);
495   if (identity->sleep_time && ret == GST_FLOW_OK)
496     g_usleep (identity->sleep_time);
498   if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME)
499       && (ret == GST_FLOW_OK)) {
500     GST_BUFFER_TIMESTAMP (buf) = runtimestamp;
501     GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
502     GST_BUFFER_OFFSET_END (buf) = GST_CLOCK_TIME_NONE;
503   }
505   return ret;
508 static void
509 gst_identity_set_property (GObject * object, guint prop_id,
510     const GValue * value, GParamSpec * pspec)
512   GstIdentity *identity;
514   identity = GST_IDENTITY (object);
516   switch (prop_id) {
517     case PROP_SLEEP_TIME:
518       identity->sleep_time = g_value_get_uint (value);
519       break;
520     case PROP_SILENT:
521       identity->silent = g_value_get_boolean (value);
522       break;
523     case PROP_SINGLE_SEGMENT:
524       identity->single_segment = g_value_get_boolean (value);
525       break;
526     case PROP_DUMP:
527       identity->dump = g_value_get_boolean (value);
528       break;
529     case PROP_ERROR_AFTER:
530       identity->error_after = g_value_get_int (value);
531       break;
532     case PROP_DROP_PROBABILITY:
533       identity->drop_probability = g_value_get_float (value);
534       break;
535     case PROP_DATARATE:
536       identity->datarate = g_value_get_int (value);
537       break;
538     case PROP_SYNC:
539       identity->sync = g_value_get_boolean (value);
540       break;
541     case PROP_CHECK_PERFECT:
542       identity->check_perfect = g_value_get_boolean (value);
543       break;
544     default:
545       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
546       break;
547   }
550 static void
551 gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
552     GParamSpec * pspec)
554   GstIdentity *identity;
556   identity = GST_IDENTITY (object);
558   switch (prop_id) {
559     case PROP_SLEEP_TIME:
560       g_value_set_uint (value, identity->sleep_time);
561       break;
562     case PROP_ERROR_AFTER:
563       g_value_set_int (value, identity->error_after);
564       break;
565     case PROP_DROP_PROBABILITY:
566       g_value_set_float (value, identity->drop_probability);
567       break;
568     case PROP_DATARATE:
569       g_value_set_int (value, identity->datarate);
570       break;
571     case PROP_SILENT:
572       g_value_set_boolean (value, identity->silent);
573       break;
574     case PROP_SINGLE_SEGMENT:
575       g_value_set_boolean (value, identity->single_segment);
576       break;
577     case PROP_DUMP:
578       g_value_set_boolean (value, identity->dump);
579       break;
580     case PROP_LAST_MESSAGE:
581       GST_OBJECT_LOCK (identity);
582       g_value_set_string (value, identity->last_message);
583       GST_OBJECT_UNLOCK (identity);
584       break;
585     case PROP_SYNC:
586       g_value_set_boolean (value, identity->sync);
587       break;
588     case PROP_CHECK_PERFECT:
589       g_value_set_boolean (value, identity->check_perfect);
590       break;
591     default:
592       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
593       break;
594   }
597 static gboolean
598 gst_identity_start (GstBaseTransform * trans)
600   GstIdentity *identity;
602   identity = GST_IDENTITY (trans);
604   identity->offset = 0;
605   identity->prev_timestamp = GST_CLOCK_TIME_NONE;
606   identity->prev_duration = GST_CLOCK_TIME_NONE;
607   identity->prev_offset_end = -1;
608   identity->prev_offset = -1;
610   return TRUE;
613 static gboolean
614 gst_identity_stop (GstBaseTransform * trans)
616   GstIdentity *identity;
618   identity = GST_IDENTITY (trans);
620   GST_OBJECT_LOCK (identity);
621   g_free (identity->last_message);
622   identity->last_message = NULL;
623   GST_OBJECT_UNLOCK (identity);
625   return TRUE;