LCOV - code coverage report
Current view: top level - plugins/elements - gstidentity.c (source / functions) Hit Total Coverage
Test: GStreamer 0.10.32.1 Lines: 148 299 49.5 %
Date: 2011-03-25 Functions: 15 20 75.0 %
Branches: 44 223 19.7 %

           Branch data     Line data    Source code
       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                 :            :  */
      23                 :            : /**
      24                 :            :  * SECTION:element-identity
      25                 :            :  *
      26                 :            :  * Dummy element that passes incomming data through unmodified. It has some
      27                 :            :  * useful diagnostic functions, such as offset and timestamp checking.
      28                 :            :  */
      29                 :            : 
      30                 :            : #ifdef HAVE_CONFIG_H
      31                 :            : #  include "config.h"
      32                 :            : #endif
      33                 :            : 
      34                 :            : #include <stdlib.h>
      35                 :            : 
      36                 :            : #include "../../gst/gst-i18n-lib.h"
      37                 :            : #include "gstidentity.h"
      38                 :            : #include <gst/gstmarshal.h>
      39                 :            : 
      40                 :            : static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
      41                 :            :     GST_PAD_SINK,
      42                 :            :     GST_PAD_ALWAYS,
      43                 :            :     GST_STATIC_CAPS_ANY);
      44                 :            : 
      45                 :            : static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
      46                 :            :     GST_PAD_SRC,
      47                 :            :     GST_PAD_ALWAYS,
      48                 :            :     GST_STATIC_CAPS_ANY);
      49                 :            : 
      50                 :            : GST_DEBUG_CATEGORY_STATIC (gst_identity_debug);
      51                 :            : #define GST_CAT_DEFAULT gst_identity_debug
      52                 :            : 
      53                 :            : /* Identity signals and args */
      54                 :            : enum
      55                 :            : {
      56                 :            :   SIGNAL_HANDOFF,
      57                 :            :   /* FILL ME */
      58                 :            :   LAST_SIGNAL
      59                 :            : };
      60                 :            : 
      61                 :            : #define DEFAULT_SLEEP_TIME              0
      62                 :            : #define DEFAULT_DUPLICATE               1
      63                 :            : #define DEFAULT_ERROR_AFTER             -1
      64                 :            : #define DEFAULT_DROP_PROBABILITY        0.0
      65                 :            : #define DEFAULT_DATARATE                0
      66                 :            : #define DEFAULT_SILENT                  FALSE
      67                 :            : #define DEFAULT_SINGLE_SEGMENT          FALSE
      68                 :            : #define DEFAULT_DUMP                    FALSE
      69                 :            : #define DEFAULT_SYNC                    FALSE
      70                 :            : #define DEFAULT_CHECK_PERFECT           FALSE
      71                 :            : #define DEFAULT_CHECK_IMPERFECT_TIMESTAMP FALSE
      72                 :            : #define DEFAULT_CHECK_IMPERFECT_OFFSET    FALSE
      73                 :            : #define DEFAULT_SIGNAL_HANDOFFS           TRUE
      74                 :            : 
      75                 :            : enum
      76                 :            : {
      77                 :            :   PROP_0,
      78                 :            :   PROP_SLEEP_TIME,
      79                 :            :   PROP_ERROR_AFTER,
      80                 :            :   PROP_DROP_PROBABILITY,
      81                 :            :   PROP_DATARATE,
      82                 :            :   PROP_SILENT,
      83                 :            :   PROP_SINGLE_SEGMENT,
      84                 :            :   PROP_LAST_MESSAGE,
      85                 :            :   PROP_DUMP,
      86                 :            :   PROP_SYNC,
      87                 :            :   PROP_CHECK_PERFECT,
      88                 :            :   PROP_CHECK_IMPERFECT_TIMESTAMP,
      89                 :            :   PROP_CHECK_IMPERFECT_OFFSET,
      90                 :            :   PROP_SIGNAL_HANDOFFS
      91                 :            : };
      92                 :            : 
      93                 :            : 
      94                 :            : #define _do_init(bla) \
      95                 :            :     GST_DEBUG_CATEGORY_INIT (gst_identity_debug, "identity", 0, "identity element");
      96                 :            : 
      97 [ +  + ][ +  - ]:        378 : GST_BOILERPLATE_FULL (GstIdentity, gst_identity, GstBaseTransform,
      98                 :        378 :     GST_TYPE_BASE_TRANSFORM, _do_init);
      99                 :            : 
     100                 :            : static void gst_identity_finalize (GObject * object);
     101                 :            : static void gst_identity_set_property (GObject * object, guint prop_id,
     102                 :            :     const GValue * value, GParamSpec * pspec);
     103                 :            : static void gst_identity_get_property (GObject * object, guint prop_id,
     104                 :            :     GValue * value, GParamSpec * pspec);
     105                 :            : 
     106                 :            : static gboolean gst_identity_event (GstBaseTransform * trans, GstEvent * event);
     107                 :            : static GstFlowReturn gst_identity_transform_ip (GstBaseTransform * trans,
     108                 :            :     GstBuffer * buf);
     109                 :            : static GstFlowReturn gst_identity_prepare_output_buffer (GstBaseTransform
     110                 :            :     * trans, GstBuffer * in_buf, gint out_size, GstCaps * out_caps,
     111                 :            :     GstBuffer ** out_buf);
     112                 :            : static gboolean gst_identity_start (GstBaseTransform * trans);
     113                 :            : static gboolean gst_identity_stop (GstBaseTransform * trans);
     114                 :            : 
     115                 :            : static guint gst_identity_signals[LAST_SIGNAL] = { 0 };
     116                 :            : 
     117                 :            : static GParamSpec *pspec_last_message = NULL;
     118                 :            : 
     119                 :            : static void
     120                 :         24 : gst_identity_base_init (gpointer g_class)
     121                 :            : {
     122                 :         24 :   GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
     123                 :            : 
     124                 :         24 :   gst_element_class_set_details_simple (gstelement_class,
     125                 :            :       "Identity",
     126                 :            :       "Generic",
     127                 :            :       "Pass data without modification", "Erik Walthinsen <omega@cse.ogi.edu>");
     128                 :         24 :   gst_element_class_add_pad_template (gstelement_class,
     129                 :            :       gst_static_pad_template_get (&srctemplate));
     130                 :         24 :   gst_element_class_add_pad_template (gstelement_class,
     131                 :            :       gst_static_pad_template_get (&sinktemplate));
     132                 :         24 : }
     133                 :            : 
     134                 :            : static void
     135                 :         42 : gst_identity_finalize (GObject * object)
     136                 :            : {
     137                 :            :   GstIdentity *identity;
     138                 :            : 
     139                 :         42 :   identity = GST_IDENTITY (object);
     140                 :            : 
     141                 :         42 :   g_free (identity->last_message);
     142                 :            : 
     143                 :            : #if !GLIB_CHECK_VERSION(2,26,0)
     144                 :            :   g_static_rec_mutex_free (&identity->notify_lock);
     145                 :            : #endif
     146                 :            : 
     147                 :         42 :   G_OBJECT_CLASS (parent_class)->finalize (object);
     148                 :         42 : }
     149                 :            : 
     150                 :            : /* fixme: do something about this */
     151                 :            : static void
     152                 :          0 : marshal_VOID__MINIOBJECT (GClosure * closure, GValue * return_value,
     153                 :            :     guint n_param_values, const GValue * param_values, gpointer invocation_hint,
     154                 :            :     gpointer marshal_data)
     155                 :            : {
     156                 :            :   typedef void (*marshalfunc_VOID__MINIOBJECT) (gpointer obj, gpointer arg1,
     157                 :            :       gpointer data2);
     158                 :            :   register marshalfunc_VOID__MINIOBJECT callback;
     159                 :          0 :   register GCClosure *cc = (GCClosure *) closure;
     160                 :            :   register gpointer data1, data2;
     161                 :            : 
     162         [ #  # ]:          0 :   g_return_if_fail (n_param_values == 2);
     163                 :            : 
     164         [ #  # ]:          0 :   if (G_CCLOSURE_SWAP_DATA (closure)) {
     165                 :          0 :     data1 = closure->data;
     166                 :          0 :     data2 = g_value_peek_pointer (param_values + 0);
     167                 :            :   } else {
     168                 :          0 :     data1 = g_value_peek_pointer (param_values + 0);
     169                 :          0 :     data2 = closure->data;
     170                 :            :   }
     171                 :          0 :   callback =
     172         [ #  # ]:          0 :       (marshalfunc_VOID__MINIOBJECT) (marshal_data ? marshal_data :
     173                 :            :       cc->callback);
     174                 :            : 
     175                 :          0 :   callback (data1, gst_value_get_mini_object (param_values + 1), data2);
     176                 :            : }
     177                 :            : 
     178                 :            : static void
     179                 :         24 : gst_identity_class_init (GstIdentityClass * klass)
     180                 :            : {
     181                 :            :   GObjectClass *gobject_class;
     182                 :            :   GstBaseTransformClass *gstbasetrans_class;
     183                 :            : 
     184                 :         24 :   gobject_class = G_OBJECT_CLASS (klass);
     185                 :         24 :   gstbasetrans_class = GST_BASE_TRANSFORM_CLASS (klass);
     186                 :            : 
     187                 :         24 :   gobject_class->set_property = gst_identity_set_property;
     188                 :         24 :   gobject_class->get_property = gst_identity_get_property;
     189                 :            : 
     190                 :         24 :   g_object_class_install_property (gobject_class, PROP_SLEEP_TIME,
     191                 :            :       g_param_spec_uint ("sleep-time", "Sleep time",
     192                 :            :           "Microseconds to sleep between processing", 0, G_MAXUINT,
     193                 :            :           DEFAULT_SLEEP_TIME, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     194                 :         24 :   g_object_class_install_property (gobject_class, PROP_ERROR_AFTER,
     195                 :            :       g_param_spec_int ("error-after", "Error After", "Error after N buffers",
     196                 :            :           G_MININT, G_MAXINT, DEFAULT_ERROR_AFTER,
     197                 :            :           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     198                 :         24 :   g_object_class_install_property (gobject_class, PROP_DROP_PROBABILITY,
     199                 :            :       g_param_spec_float ("drop-probability", "Drop Probability",
     200                 :            :           "The Probability a buffer is dropped", 0.0, 1.0,
     201                 :            :           DEFAULT_DROP_PROBABILITY,
     202                 :            :           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     203                 :         24 :   g_object_class_install_property (gobject_class, PROP_DATARATE,
     204                 :            :       g_param_spec_int ("datarate", "Datarate",
     205                 :            :           "(Re)timestamps buffers with number of bytes per second (0 = inactive)",
     206                 :            :           0, G_MAXINT, DEFAULT_DATARATE,
     207                 :            :           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     208                 :         24 :   g_object_class_install_property (gobject_class, PROP_SILENT,
     209                 :            :       g_param_spec_boolean ("silent", "silent", "silent", DEFAULT_SILENT,
     210                 :            :           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     211                 :         24 :   g_object_class_install_property (gobject_class, PROP_SINGLE_SEGMENT,
     212                 :            :       g_param_spec_boolean ("single-segment", "Single Segment",
     213                 :            :           "Timestamp buffers and eat newsegments so as to appear as one segment",
     214                 :            :           DEFAULT_SINGLE_SEGMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     215                 :         24 :   pspec_last_message = g_param_spec_string ("last-message", "last-message",
     216                 :            :       "last-message", NULL, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
     217                 :         24 :   g_object_class_install_property (gobject_class, PROP_LAST_MESSAGE,
     218                 :            :       pspec_last_message);
     219                 :         24 :   g_object_class_install_property (gobject_class, PROP_DUMP,
     220                 :            :       g_param_spec_boolean ("dump", "Dump", "Dump buffer contents to stdout",
     221                 :            :           DEFAULT_DUMP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     222                 :         24 :   g_object_class_install_property (gobject_class, PROP_SYNC,
     223                 :            :       g_param_spec_boolean ("sync", "Synchronize",
     224                 :            :           "Synchronize to pipeline clock", DEFAULT_SYNC,
     225                 :            :           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     226                 :         24 :   g_object_class_install_property (gobject_class, PROP_CHECK_PERFECT,
     227                 :            :       g_param_spec_boolean ("check-perfect", "Check For Perfect Stream",
     228                 :            :           "Verify that the stream is time- and data-contiguous. "
     229                 :            :           "This only logs in the debug log.  This will be deprecated in favor "
     230                 :            :           "of the check-imperfect-timestamp/offset properties.",
     231                 :            :           DEFAULT_CHECK_PERFECT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     232                 :         24 :   g_object_class_install_property (gobject_class,
     233                 :            :       PROP_CHECK_IMPERFECT_TIMESTAMP,
     234                 :            :       g_param_spec_boolean ("check-imperfect-timestamp",
     235                 :            :           "Check for discontiguous timestamps",
     236                 :            :           "Send element messages if timestamps and durations do not match up",
     237                 :            :           DEFAULT_CHECK_IMPERFECT_TIMESTAMP,
     238                 :            :           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     239                 :         24 :   g_object_class_install_property (gobject_class, PROP_CHECK_IMPERFECT_OFFSET,
     240                 :            :       g_param_spec_boolean ("check-imperfect-offset",
     241                 :            :           "Check for discontiguous offset",
     242                 :            :           "Send element messages if offset and offset_end do not match up",
     243                 :            :           DEFAULT_CHECK_IMPERFECT_OFFSET,
     244                 :            :           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     245                 :            : 
     246                 :            :   /**
     247                 :            :    * GstIdentity:signal-handoffs
     248                 :            :    *
     249                 :            :    * If set to #TRUE, the identity will emit a handoff signal when handling a buffer.
     250                 :            :    * When set to #FALSE, no signal will be emited, which might improve performance.
     251                 :            :    *
     252                 :            :    * Since: 0.10.16
     253                 :            :    */
     254                 :         24 :   g_object_class_install_property (gobject_class, PROP_SIGNAL_HANDOFFS,
     255                 :            :       g_param_spec_boolean ("signal-handoffs",
     256                 :            :           "Signal handoffs", "Send a signal before pushing the buffer",
     257                 :            :           DEFAULT_SIGNAL_HANDOFFS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
     258                 :            : 
     259                 :            :   /**
     260                 :            :    * GstIdentity::handoff:
     261                 :            :    * @identity: the identity instance
     262                 :            :    * @buffer: the buffer that just has been received
     263                 :            :    * @pad: the pad that received it
     264                 :            :    *
     265                 :            :    * This signal gets emitted before passing the buffer downstream.
     266                 :            :    */
     267                 :         24 :   gst_identity_signals[SIGNAL_HANDOFF] =
     268                 :         24 :       g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST,
     269                 :            :       G_STRUCT_OFFSET (GstIdentityClass, handoff), NULL, NULL,
     270                 :            :       marshal_VOID__MINIOBJECT, G_TYPE_NONE, 1, GST_TYPE_BUFFER);
     271                 :            : 
     272                 :         24 :   gobject_class->finalize = gst_identity_finalize;
     273                 :            : 
     274                 :         24 :   gstbasetrans_class->event = GST_DEBUG_FUNCPTR (gst_identity_event);
     275                 :         24 :   gstbasetrans_class->transform_ip =
     276                 :         24 :       GST_DEBUG_FUNCPTR (gst_identity_transform_ip);
     277                 :         24 :   gstbasetrans_class->prepare_output_buffer =
     278                 :         24 :       GST_DEBUG_FUNCPTR (gst_identity_prepare_output_buffer);
     279                 :         24 :   gstbasetrans_class->start = GST_DEBUG_FUNCPTR (gst_identity_start);
     280                 :         24 :   gstbasetrans_class->stop = GST_DEBUG_FUNCPTR (gst_identity_stop);
     281                 :         24 : }
     282                 :            : 
     283                 :            : static void
     284                 :         45 : gst_identity_init (GstIdentity * identity, GstIdentityClass * g_class)
     285                 :            : {
     286                 :         45 :   identity->sleep_time = DEFAULT_SLEEP_TIME;
     287                 :         45 :   identity->error_after = DEFAULT_ERROR_AFTER;
     288                 :         45 :   identity->drop_probability = DEFAULT_DROP_PROBABILITY;
     289                 :         45 :   identity->datarate = DEFAULT_DATARATE;
     290                 :         45 :   identity->silent = DEFAULT_SILENT;
     291                 :         45 :   identity->single_segment = DEFAULT_SINGLE_SEGMENT;
     292                 :         45 :   identity->sync = DEFAULT_SYNC;
     293                 :         45 :   identity->check_perfect = DEFAULT_CHECK_PERFECT;
     294                 :         45 :   identity->check_imperfect_timestamp = DEFAULT_CHECK_IMPERFECT_TIMESTAMP;
     295                 :         45 :   identity->check_imperfect_offset = DEFAULT_CHECK_IMPERFECT_OFFSET;
     296                 :         45 :   identity->dump = DEFAULT_DUMP;
     297                 :         45 :   identity->last_message = NULL;
     298                 :         45 :   identity->signal_handoffs = DEFAULT_SIGNAL_HANDOFFS;
     299                 :            : 
     300                 :            : #if !GLIB_CHECK_VERSION(2,26,0)
     301                 :            :   g_static_rec_mutex_init (&identity->notify_lock);
     302                 :            : #endif
     303                 :            : 
     304                 :         45 :   gst_base_transform_set_gap_aware (GST_BASE_TRANSFORM_CAST (identity), TRUE);
     305                 :         45 : }
     306                 :            : 
     307                 :            : static void
     308                 :         39 : gst_identity_notify_last_message (GstIdentity * identity)
     309                 :            : {
     310                 :            :   /* FIXME: this hacks around a bug in GLib/GObject: doing concurrent
     311                 :            :    * g_object_notify() on the same object might lead to crashes, see
     312                 :            :    * http://bugzilla.gnome.org/show_bug.cgi?id=166020#c60 and follow-ups.
     313                 :            :    * So we really don't want to do a g_object_notify() here for out-of-band
     314                 :            :    * events with the streaming thread possibly also doing a g_object_notify()
     315                 :            :    * for an in-band buffer or event. This is fixed in GLib >= 2.26 */
     316                 :            : #if !GLIB_CHECK_VERSION(2,26,0)
     317                 :            :   g_static_rec_mutex_lock (&identity->notify_lock);
     318                 :            :   g_object_notify ((GObject *) identity, "last-message");
     319                 :            :   g_static_rec_mutex_unlock (&identity->notify_lock);
     320                 :            : #else
     321                 :         39 :   g_object_notify_by_pspec ((GObject *) identity, pspec_last_message);
     322                 :            : #endif
     323                 :         39 : }
     324                 :            : 
     325                 :            : static gboolean
     326                 :         13 : gst_identity_event (GstBaseTransform * trans, GstEvent * event)
     327                 :            : {
     328                 :            :   GstIdentity *identity;
     329                 :         13 :   gboolean ret = TRUE;
     330                 :            : 
     331                 :         13 :   identity = GST_IDENTITY (trans);
     332                 :            : 
     333         [ +  + ]:         13 :   if (!identity->silent) {
     334                 :            :     const GstStructure *s;
     335                 :            :     gchar *sstr;
     336                 :            : 
     337                 :          5 :     GST_OBJECT_LOCK (identity);
     338                 :          5 :     g_free (identity->last_message);
     339                 :            : 
     340         [ +  + ]:          5 :     if ((s = gst_event_get_structure (event)))
     341                 :          3 :       sstr = gst_structure_to_string (s);
     342                 :            :     else
     343                 :          2 :       sstr = g_strdup ("");
     344                 :            : 
     345                 :          5 :     identity->last_message =
     346 [ +  - ][ +  - ]:         15 :         g_strdup_printf ("event   ******* (%s:%s) E (type: %d, %s) %p",
     347 [ +  - ][ +  - ]:         10 :         GST_DEBUG_PAD_NAME (trans->sinkpad), GST_EVENT_TYPE (event), sstr,
                 [ +  - ]
     348                 :            :         event);
     349                 :          5 :     g_free (sstr);
     350                 :          5 :     GST_OBJECT_UNLOCK (identity);
     351                 :            : 
     352                 :          5 :     gst_identity_notify_last_message (identity);
     353                 :            :   }
     354                 :            : 
     355         [ -  + ]:         13 :   if (identity->single_segment
     356         [ #  # ]:          0 :       && (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT)) {
     357         [ #  # ]:          0 :     if (trans->have_newsegment == FALSE) {
     358                 :            :       GstEvent *news;
     359                 :            :       GstFormat format;
     360                 :            : 
     361                 :          0 :       gst_event_parse_new_segment (event, NULL, NULL, &format, NULL, NULL,
     362                 :            :           NULL);
     363                 :            : 
     364                 :            :       /* This is the first newsegment, send out a (0, -1) newsegment */
     365                 :          0 :       news = gst_event_new_new_segment (TRUE, 1.0, format, 0, -1, 0);
     366                 :            : 
     367                 :          0 :       gst_pad_event_default (trans->sinkpad, news);
     368                 :            :     }
     369                 :            :   }
     370                 :            : 
     371                 :            :   /* Reset previous timestamp, duration and offsets on NEWSEGMENT
     372                 :            :    * to prevent false warnings when checking for perfect streams */
     373         [ +  + ]:         13 :   if (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT) {
     374                 :         10 :     identity->prev_timestamp = identity->prev_duration = GST_CLOCK_TIME_NONE;
     375                 :         10 :     identity->prev_offset = identity->prev_offset_end = GST_BUFFER_OFFSET_NONE;
     376                 :            :   }
     377                 :            : 
     378                 :         13 :   ret = parent_class->event (trans, event);
     379                 :            : 
     380         [ -  + ]:         13 :   if (identity->single_segment
     381         [ #  # ]:          0 :       && (GST_EVENT_TYPE (event) == GST_EVENT_NEWSEGMENT)) {
     382                 :            :     /* eat up segments */
     383                 :          0 :     ret = FALSE;
     384                 :            :   }
     385                 :            : 
     386                 :         13 :   return ret;
     387                 :            : }
     388                 :            : 
     389                 :            : static GstFlowReturn
     390                 :         44 : gst_identity_prepare_output_buffer (GstBaseTransform * trans,
     391                 :            :     GstBuffer * in_buf, gint out_size, GstCaps * out_caps, GstBuffer ** out_buf)
     392                 :            : {
     393                 :         44 :   GstIdentity *identity = GST_IDENTITY (trans);
     394                 :            : 
     395                 :            :   /* only bother if we may have to alter metadata */
     396 [ +  - ][ -  + ]:         44 :   if (identity->datarate > 0 || identity->single_segment) {
     397         [ #  # ]:          0 :     if (gst_buffer_is_metadata_writable (in_buf))
     398                 :          0 :       *out_buf = gst_buffer_ref (in_buf);
     399                 :            :     else {
     400                 :            :       /* make even less writable */
     401                 :          0 :       gst_buffer_ref (in_buf);
     402                 :            :       /* extra ref is dropped going through the official process */
     403                 :          0 :       *out_buf = gst_buffer_make_metadata_writable (in_buf);
     404                 :            :     }
     405                 :            :   } else
     406                 :         44 :     *out_buf = gst_buffer_ref (in_buf);
     407                 :            : 
     408                 :         44 :   return GST_FLOW_OK;
     409                 :            : }
     410                 :            : 
     411                 :            : static void
     412                 :          0 : gst_identity_check_perfect (GstIdentity * identity, GstBuffer * buf)
     413                 :            : {
     414                 :            :   GstClockTime timestamp;
     415                 :            : 
     416                 :          0 :   timestamp = GST_BUFFER_TIMESTAMP (buf);
     417                 :            : 
     418                 :            :   /* see if we need to do perfect stream checking */
     419                 :            :   /* invalid timestamp drops us out of check.  FIXME: maybe warn ? */
     420         [ #  # ]:          0 :   if (timestamp != GST_CLOCK_TIME_NONE) {
     421                 :            :     /* check if we had a previous buffer to compare to */
     422 [ #  # ][ #  # ]:          0 :     if (identity->prev_timestamp != GST_CLOCK_TIME_NONE &&
     423                 :          0 :         identity->prev_duration != GST_CLOCK_TIME_NONE) {
     424                 :            :       guint64 offset, t_expected;
     425                 :            :       gint64 dt;
     426                 :            : 
     427                 :          0 :       t_expected = identity->prev_timestamp + identity->prev_duration;
     428                 :          0 :       dt = timestamp - t_expected;
     429         [ #  # ]:          0 :       if (dt != 0) {
     430 [ #  # ][ #  # ]:          0 :         GST_WARNING_OBJECT (identity,
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     431                 :            :             "Buffer not time-contiguous with previous one: " "prev ts %"
     432                 :            :             GST_TIME_FORMAT ", prev dur %" GST_TIME_FORMAT ", new ts %"
     433                 :            :             GST_TIME_FORMAT " (expected ts %" GST_TIME_FORMAT ", delta=%c%"
     434                 :            :             GST_TIME_FORMAT ")", GST_TIME_ARGS (identity->prev_timestamp),
     435                 :            :             GST_TIME_ARGS (identity->prev_duration), GST_TIME_ARGS (timestamp),
     436                 :            :             GST_TIME_ARGS (t_expected), (dt < 0) ? '-' : '+',
     437                 :            :             GST_TIME_ARGS ((dt < 0) ? (GstClockTime) (-dt) : dt));
     438                 :            :       }
     439                 :            : 
     440                 :          0 :       offset = GST_BUFFER_OFFSET (buf);
     441 [ #  # ][ #  # ]:          0 :       if (identity->prev_offset_end != offset &&
     442         [ #  # ]:          0 :           identity->prev_offset_end != GST_BUFFER_OFFSET_NONE &&
     443                 :            :           offset != GST_BUFFER_OFFSET_NONE) {
     444         [ #  # ]:          0 :         GST_WARNING_OBJECT (identity,
     445                 :            :             "Buffer not data-contiguous with previous one: "
     446                 :            :             "prev offset_end %" G_GINT64_FORMAT ", new offset %"
     447                 :            :             G_GINT64_FORMAT, identity->prev_offset_end, offset);
     448                 :            :       }
     449                 :            :     } else {
     450         [ #  # ]:          0 :       GST_DEBUG_OBJECT (identity, "can't check time-contiguity, no timestamp "
     451                 :            :           "and/or duration were set on previous buffer");
     452                 :            :     }
     453                 :            :   }
     454                 :          0 : }
     455                 :            : 
     456                 :            : static void
     457                 :          0 : gst_identity_check_imperfect_timestamp (GstIdentity * identity, GstBuffer * buf)
     458                 :            : {
     459                 :          0 :   GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buf);
     460                 :            : 
     461                 :            :   /* invalid timestamp drops us out of check.  FIXME: maybe warn ? */
     462         [ #  # ]:          0 :   if (timestamp != GST_CLOCK_TIME_NONE) {
     463                 :            :     /* check if we had a previous buffer to compare to */
     464 [ #  # ][ #  # ]:          0 :     if (identity->prev_timestamp != GST_CLOCK_TIME_NONE &&
     465                 :          0 :         identity->prev_duration != GST_CLOCK_TIME_NONE) {
     466                 :            :       GstClockTime t_expected;
     467                 :            :       GstClockTimeDiff dt;
     468                 :            : 
     469                 :          0 :       t_expected = identity->prev_timestamp + identity->prev_duration;
     470                 :          0 :       dt = GST_CLOCK_DIFF (t_expected, timestamp);
     471         [ #  # ]:          0 :       if (dt != 0) {
     472                 :            :         /*
     473                 :            :          * "imperfect-timestamp" bus message:
     474                 :            :          * @identity:        the identity instance
     475                 :            :          * @prev-timestamp:  the previous buffer timestamp
     476                 :            :          * @prev-duration:   the previous buffer duration
     477                 :            :          * @prev-offset:     the previous buffer offset
     478                 :            :          * @prev-offset-end: the previous buffer offset end
     479                 :            :          * @cur-timestamp:   the current buffer timestamp
     480                 :            :          * @cur-duration:    the current buffer duration
     481                 :            :          * @cur-offset:      the current buffer offset
     482                 :            :          * @cur-offset-end:  the current buffer offset end
     483                 :            :          *
     484                 :            :          * This bus message gets emitted if the check-imperfect-timestamp
     485                 :            :          * property is set and there is a gap in time between the
     486                 :            :          * last buffer and the newly received buffer.
     487                 :            :          */
     488                 :          0 :         gst_element_post_message (GST_ELEMENT (identity),
     489                 :          0 :             gst_message_new_element (GST_OBJECT (identity),
     490                 :            :                 gst_structure_new ("imperfect-timestamp",
     491                 :            :                     "prev-timestamp", G_TYPE_UINT64,
     492                 :            :                     identity->prev_timestamp, "prev-duration", G_TYPE_UINT64,
     493                 :            :                     identity->prev_duration, "prev-offset", G_TYPE_UINT64,
     494                 :            :                     identity->prev_offset, "prev-offset-end", G_TYPE_UINT64,
     495                 :            :                     identity->prev_offset_end, "cur-timestamp", G_TYPE_UINT64,
     496                 :            :                     timestamp, "cur-duration", G_TYPE_UINT64,
     497                 :            :                     GST_BUFFER_DURATION (buf), "cur-offset", G_TYPE_UINT64,
     498                 :            :                     GST_BUFFER_OFFSET (buf), "cur-offset-end", G_TYPE_UINT64,
     499                 :            :                     GST_BUFFER_OFFSET_END (buf), NULL)));
     500                 :            :       }
     501                 :            :     } else {
     502         [ #  # ]:          0 :       GST_DEBUG_OBJECT (identity, "can't check data-contiguity, no "
     503                 :            :           "offset_end was set on previous buffer");
     504                 :            :     }
     505                 :            :   }
     506                 :          0 : }
     507                 :            : 
     508                 :            : static void
     509                 :          0 : gst_identity_check_imperfect_offset (GstIdentity * identity, GstBuffer * buf)
     510                 :            : {
     511                 :            :   guint64 offset;
     512                 :            : 
     513                 :          0 :   offset = GST_BUFFER_OFFSET (buf);
     514                 :            : 
     515 [ #  # ][ #  # ]:          0 :   if (identity->prev_offset_end != offset &&
     516         [ #  # ]:          0 :       identity->prev_offset_end != GST_BUFFER_OFFSET_NONE &&
     517                 :            :       offset != GST_BUFFER_OFFSET_NONE) {
     518                 :            :     /*
     519                 :            :      * "imperfect-offset" bus message:
     520                 :            :      * @identity:        the identity instance
     521                 :            :      * @prev-timestamp:  the previous buffer timestamp
     522                 :            :      * @prev-duration:   the previous buffer duration
     523                 :            :      * @prev-offset:     the previous buffer offset
     524                 :            :      * @prev-offset-end: the previous buffer offset end
     525                 :            :      * @cur-timestamp:   the current buffer timestamp
     526                 :            :      * @cur-duration:    the current buffer duration
     527                 :            :      * @cur-offset:      the current buffer offset
     528                 :            :      * @cur-offset-end:  the current buffer offset end
     529                 :            :      *
     530                 :            :      * This bus message gets emitted if the check-imperfect-offset
     531                 :            :      * property is set and there is a gap in offsets between the
     532                 :            :      * last buffer and the newly received buffer.
     533                 :            :      */
     534                 :          0 :     gst_element_post_message (GST_ELEMENT (identity),
     535                 :          0 :         gst_message_new_element (GST_OBJECT (identity),
     536                 :            :             gst_structure_new ("imperfect-offset", "prev-timestamp",
     537                 :            :                 G_TYPE_UINT64, identity->prev_timestamp, "prev-duration",
     538                 :            :                 G_TYPE_UINT64, identity->prev_duration, "prev-offset",
     539                 :            :                 G_TYPE_UINT64, identity->prev_offset, "prev-offset-end",
     540                 :            :                 G_TYPE_UINT64, identity->prev_offset_end, "cur-timestamp",
     541                 :            :                 G_TYPE_UINT64, GST_BUFFER_TIMESTAMP (buf), "cur-duration",
     542                 :            :                 G_TYPE_UINT64, GST_BUFFER_DURATION (buf), "cur-offset",
     543                 :            :                 G_TYPE_UINT64, GST_BUFFER_OFFSET (buf), "cur-offset-end",
     544                 :            :                 G_TYPE_UINT64, GST_BUFFER_OFFSET_END (buf), NULL)));
     545                 :            :   } else {
     546         [ #  # ]:          0 :     GST_DEBUG_OBJECT (identity, "can't check offset contiguity, no offset "
     547                 :            :         "and/or offset_end were set on previous buffer");
     548                 :            :   }
     549                 :          0 : }
     550                 :            : 
     551                 :            : static const gchar *
     552                 :         68 : print_pretty_time (gchar * ts_str, gsize ts_str_len, GstClockTime ts)
     553                 :            : {
     554         [ +  + ]:         68 :   if (ts == GST_CLOCK_TIME_NONE)
     555                 :         35 :     return "none";
     556                 :            : 
     557 [ +  - ][ +  - ]:         33 :   g_snprintf (ts_str, ts_str_len, "%" GST_TIME_FORMAT, GST_TIME_ARGS (ts));
         [ +  - ][ +  - ]
     558                 :         68 :   return ts_str;
     559                 :            : }
     560                 :            : 
     561                 :            : static void
     562                 :         34 : gst_identity_update_last_message_for_buffer (GstIdentity * identity,
     563                 :            :     const gchar * action, GstBuffer * buf)
     564                 :            : {
     565                 :            :   gchar ts_str[64], dur_str[64];
     566                 :            : 
     567                 :         34 :   GST_OBJECT_LOCK (identity);
     568                 :            : 
     569                 :         34 :   g_free (identity->last_message);
     570 [ +  - ][ +  - ]:        102 :   identity->last_message = g_strdup_printf ("%s   ******* (%s:%s)i "
     571                 :            :       "(%u bytes, timestamp: %s, duration: %s, offset: %" G_GINT64_FORMAT ", "
     572                 :            :       "offset_end: % " G_GINT64_FORMAT ", flags: %d) %p", action,
     573 [ +  - ][ +  - ]:         68 :       GST_DEBUG_PAD_NAME (GST_BASE_TRANSFORM_CAST (identity)->sinkpad),
                 [ +  - ]
     574                 :            :       GST_BUFFER_SIZE (buf),
     575                 :            :       print_pretty_time (ts_str, sizeof (ts_str), GST_BUFFER_TIMESTAMP (buf)),
     576                 :            :       print_pretty_time (dur_str, sizeof (dur_str), GST_BUFFER_DURATION (buf)),
     577                 :            :       GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf),
     578                 :            :       GST_BUFFER_FLAGS (buf), buf);
     579                 :            : 
     580                 :         34 :   GST_OBJECT_UNLOCK (identity);
     581                 :            : 
     582                 :         34 :   gst_identity_notify_last_message (identity);
     583                 :         34 : }
     584                 :            : 
     585                 :            : static GstFlowReturn
     586                 :         44 : gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
     587                 :            : {
     588                 :         44 :   GstFlowReturn ret = GST_FLOW_OK;
     589                 :         44 :   GstIdentity *identity = GST_IDENTITY (trans);
     590                 :         44 :   GstClockTime runtimestamp = G_GINT64_CONSTANT (0);
     591                 :            : 
     592         [ -  + ]:         44 :   if (identity->check_perfect)
     593                 :          0 :     gst_identity_check_perfect (identity, buf);
     594         [ -  + ]:         44 :   if (identity->check_imperfect_timestamp)
     595                 :          0 :     gst_identity_check_imperfect_timestamp (identity, buf);
     596         [ -  + ]:         44 :   if (identity->check_imperfect_offset)
     597                 :          0 :     gst_identity_check_imperfect_offset (identity, buf);
     598                 :            : 
     599                 :            :   /* update prev values */
     600                 :         44 :   identity->prev_timestamp = GST_BUFFER_TIMESTAMP (buf);
     601                 :         44 :   identity->prev_duration = GST_BUFFER_DURATION (buf);
     602                 :         44 :   identity->prev_offset_end = GST_BUFFER_OFFSET_END (buf);
     603                 :         44 :   identity->prev_offset = GST_BUFFER_OFFSET (buf);
     604                 :            : 
     605         [ -  + ]:         44 :   if (identity->error_after >= 0) {
     606                 :          0 :     identity->error_after--;
     607         [ #  # ]:          0 :     if (identity->error_after == 0) {
     608 [ #  # ][ #  # ]:          0 :       GST_ELEMENT_ERROR (identity, CORE, FAILED,
         [ #  # ][ #  # ]
     609                 :            :           (_("Failed after iterations as requested.")), (NULL));
     610                 :          0 :       return GST_FLOW_ERROR;
     611                 :            :     }
     612                 :            :   }
     613                 :            : 
     614         [ -  + ]:         44 :   if (identity->drop_probability > 0.0) {
     615         [ #  # ]:          0 :     if ((gfloat) (1.0 * rand () / (RAND_MAX)) < identity->drop_probability) {
     616         [ #  # ]:          0 :       if (!identity->silent) {
     617                 :          0 :         gst_identity_update_last_message_for_buffer (identity, "dropping", buf);
     618                 :            :       }
     619                 :            :       /* return DROPPED to basetransform. */
     620                 :          0 :       return GST_BASE_TRANSFORM_FLOW_DROPPED;
     621                 :            :     }
     622                 :            :   }
     623                 :            : 
     624         [ -  + ]:         44 :   if (identity->dump) {
     625                 :          0 :     gst_util_dump_mem (GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf));
     626                 :            :   }
     627                 :            : 
     628         [ +  + ]:         44 :   if (!identity->silent) {
     629                 :         34 :     gst_identity_update_last_message_for_buffer (identity, "chain", buf);
     630                 :            :   }
     631                 :            : 
     632         [ -  + ]:         44 :   if (identity->datarate > 0) {
     633                 :          0 :     GstClockTime time = gst_util_uint64_scale_int (identity->offset,
     634                 :            :         GST_SECOND, identity->datarate);
     635                 :            : 
     636                 :          0 :     GST_BUFFER_TIMESTAMP (buf) = time;
     637                 :          0 :     GST_BUFFER_DURATION (buf) =
     638                 :          0 :         GST_BUFFER_SIZE (buf) * GST_SECOND / identity->datarate;
     639                 :            :   }
     640                 :            : 
     641         [ +  - ]:         44 :   if (identity->signal_handoffs)
     642                 :         44 :     g_signal_emit (identity, gst_identity_signals[SIGNAL_HANDOFF], 0, buf);
     643                 :            : 
     644         [ -  + ]:         44 :   if (trans->segment.format == GST_FORMAT_TIME)
     645                 :          0 :     runtimestamp = gst_segment_to_running_time (&trans->segment,
     646                 :          0 :         GST_FORMAT_TIME, GST_BUFFER_TIMESTAMP (buf));
     647                 :            : 
     648 [ -  + ][ #  # ]:         44 :   if ((identity->sync) && (trans->segment.format == GST_FORMAT_TIME)) {
     649                 :            :     GstClock *clock;
     650                 :            : 
     651                 :          0 :     GST_OBJECT_LOCK (identity);
     652         [ #  # ]:          0 :     if ((clock = GST_ELEMENT (identity)->clock)) {
     653                 :            :       GstClockReturn cret;
     654                 :            :       GstClockTime timestamp;
     655                 :            : 
     656                 :          0 :       timestamp = runtimestamp + GST_ELEMENT (identity)->base_time;
     657                 :            : 
     658                 :            :       /* save id if we need to unlock */
     659                 :            :       /* FIXME: actually unlock this somewhere in the state changes */
     660                 :          0 :       identity->clock_id = gst_clock_new_single_shot_id (clock, timestamp);
     661                 :          0 :       GST_OBJECT_UNLOCK (identity);
     662                 :            : 
     663                 :          0 :       cret = gst_clock_id_wait (identity->clock_id, NULL);
     664                 :            : 
     665                 :          0 :       GST_OBJECT_LOCK (identity);
     666         [ #  # ]:          0 :       if (identity->clock_id) {
     667                 :          0 :         gst_clock_id_unref (identity->clock_id);
     668                 :          0 :         identity->clock_id = NULL;
     669                 :            :       }
     670         [ #  # ]:          0 :       if (cret == GST_CLOCK_UNSCHEDULED)
     671                 :          0 :         ret = GST_FLOW_UNEXPECTED;
     672                 :            :     }
     673                 :          0 :     GST_OBJECT_UNLOCK (identity);
     674                 :            :   }
     675                 :            : 
     676                 :         44 :   identity->offset += GST_BUFFER_SIZE (buf);
     677                 :            : 
     678 [ -  + ][ #  # ]:         44 :   if (identity->sleep_time && ret == GST_FLOW_OK)
     679                 :          0 :     g_usleep (identity->sleep_time);
     680                 :            : 
     681 [ -  + ][ #  # ]:         44 :   if (identity->single_segment && (trans->segment.format == GST_FORMAT_TIME)
     682         [ #  # ]:          0 :       && (ret == GST_FLOW_OK)) {
     683                 :          0 :     GST_BUFFER_TIMESTAMP (buf) = runtimestamp;
     684                 :          0 :     GST_BUFFER_OFFSET (buf) = GST_CLOCK_TIME_NONE;
     685                 :          0 :     GST_BUFFER_OFFSET_END (buf) = GST_CLOCK_TIME_NONE;
     686                 :            :   }
     687                 :            : 
     688                 :         44 :   return ret;
     689                 :            : }
     690                 :            : 
     691                 :            : static void
     692                 :         20 : gst_identity_set_property (GObject * object, guint prop_id,
     693                 :            :     const GValue * value, GParamSpec * pspec)
     694                 :            : {
     695                 :            :   GstIdentity *identity;
     696                 :            : 
     697                 :         20 :   identity = GST_IDENTITY (object);
     698                 :            : 
     699   [ -  +  -  -  :         20 :   switch (prop_id) {
          -  -  -  -  -  
             -  -  -  - ]
     700                 :            :     case PROP_SLEEP_TIME:
     701                 :          0 :       identity->sleep_time = g_value_get_uint (value);
     702                 :          0 :       break;
     703                 :            :     case PROP_SILENT:
     704                 :         20 :       identity->silent = g_value_get_boolean (value);
     705                 :         20 :       break;
     706                 :            :     case PROP_SINGLE_SEGMENT:
     707                 :          0 :       identity->single_segment = g_value_get_boolean (value);
     708                 :          0 :       break;
     709                 :            :     case PROP_DUMP:
     710                 :          0 :       identity->dump = g_value_get_boolean (value);
     711                 :          0 :       break;
     712                 :            :     case PROP_ERROR_AFTER:
     713                 :          0 :       identity->error_after = g_value_get_int (value);
     714                 :          0 :       break;
     715                 :            :     case PROP_DROP_PROBABILITY:
     716                 :          0 :       identity->drop_probability = g_value_get_float (value);
     717                 :          0 :       break;
     718                 :            :     case PROP_DATARATE:
     719                 :          0 :       identity->datarate = g_value_get_int (value);
     720                 :          0 :       break;
     721                 :            :     case PROP_SYNC:
     722                 :          0 :       identity->sync = g_value_get_boolean (value);
     723                 :          0 :       break;
     724                 :            :     case PROP_CHECK_PERFECT:
     725                 :          0 :       identity->check_perfect = g_value_get_boolean (value);
     726                 :          0 :       break;
     727                 :            :     case PROP_CHECK_IMPERFECT_TIMESTAMP:
     728                 :          0 :       identity->check_imperfect_timestamp = g_value_get_boolean (value);
     729                 :          0 :       break;
     730                 :            :     case PROP_CHECK_IMPERFECT_OFFSET:
     731                 :          0 :       identity->check_imperfect_offset = g_value_get_boolean (value);
     732                 :          0 :       break;
     733                 :            :     case PROP_SIGNAL_HANDOFFS:
     734                 :          0 :       identity->signal_handoffs = g_value_get_boolean (value);
     735                 :          0 :       break;
     736                 :            :     default:
     737                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     738                 :          0 :       break;
     739                 :            :   }
     740                 :         20 : }
     741                 :            : 
     742                 :            : static void
     743                 :          0 : gst_identity_get_property (GObject * object, guint prop_id, GValue * value,
     744                 :            :     GParamSpec * pspec)
     745                 :            : {
     746                 :            :   GstIdentity *identity;
     747                 :            : 
     748                 :          0 :   identity = GST_IDENTITY (object);
     749                 :            : 
     750   [ #  #  #  #  :          0 :   switch (prop_id) {
          #  #  #  #  #  
             #  #  #  #  
                      # ]
     751                 :            :     case PROP_SLEEP_TIME:
     752                 :          0 :       g_value_set_uint (value, identity->sleep_time);
     753                 :          0 :       break;
     754                 :            :     case PROP_ERROR_AFTER:
     755                 :          0 :       g_value_set_int (value, identity->error_after);
     756                 :          0 :       break;
     757                 :            :     case PROP_DROP_PROBABILITY:
     758                 :          0 :       g_value_set_float (value, identity->drop_probability);
     759                 :          0 :       break;
     760                 :            :     case PROP_DATARATE:
     761                 :          0 :       g_value_set_int (value, identity->datarate);
     762                 :          0 :       break;
     763                 :            :     case PROP_SILENT:
     764                 :          0 :       g_value_set_boolean (value, identity->silent);
     765                 :          0 :       break;
     766                 :            :     case PROP_SINGLE_SEGMENT:
     767                 :          0 :       g_value_set_boolean (value, identity->single_segment);
     768                 :          0 :       break;
     769                 :            :     case PROP_DUMP:
     770                 :          0 :       g_value_set_boolean (value, identity->dump);
     771                 :          0 :       break;
     772                 :            :     case PROP_LAST_MESSAGE:
     773                 :          0 :       GST_OBJECT_LOCK (identity);
     774                 :          0 :       g_value_set_string (value, identity->last_message);
     775                 :          0 :       GST_OBJECT_UNLOCK (identity);
     776                 :          0 :       break;
     777                 :            :     case PROP_SYNC:
     778                 :          0 :       g_value_set_boolean (value, identity->sync);
     779                 :          0 :       break;
     780                 :            :     case PROP_CHECK_PERFECT:
     781                 :          0 :       g_value_set_boolean (value, identity->check_perfect);
     782                 :          0 :       break;
     783                 :            :     case PROP_CHECK_IMPERFECT_TIMESTAMP:
     784                 :          0 :       g_value_set_boolean (value, identity->check_imperfect_timestamp);
     785                 :          0 :       break;
     786                 :            :     case PROP_CHECK_IMPERFECT_OFFSET:
     787                 :          0 :       g_value_set_boolean (value, identity->check_imperfect_offset);
     788                 :          0 :       break;
     789                 :            :     case PROP_SIGNAL_HANDOFFS:
     790                 :          0 :       g_value_set_boolean (value, identity->signal_handoffs);
     791                 :          0 :       break;
     792                 :            :     default:
     793                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     794                 :          0 :       break;
     795                 :            :   }
     796                 :          0 : }
     797                 :            : 
     798                 :            : static gboolean
     799                 :         19 : gst_identity_start (GstBaseTransform * trans)
     800                 :            : {
     801                 :            :   GstIdentity *identity;
     802                 :            : 
     803                 :         19 :   identity = GST_IDENTITY (trans);
     804                 :            : 
     805                 :         19 :   identity->offset = 0;
     806                 :         19 :   identity->prev_timestamp = GST_CLOCK_TIME_NONE;
     807                 :         19 :   identity->prev_duration = GST_CLOCK_TIME_NONE;
     808                 :         19 :   identity->prev_offset_end = GST_BUFFER_OFFSET_NONE;
     809                 :         19 :   identity->prev_offset = GST_BUFFER_OFFSET_NONE;
     810                 :            : 
     811                 :         19 :   return TRUE;
     812                 :            : }
     813                 :            : 
     814                 :            : static gboolean
     815                 :         19 : gst_identity_stop (GstBaseTransform * trans)
     816                 :            : {
     817                 :            :   GstIdentity *identity;
     818                 :            : 
     819                 :         19 :   identity = GST_IDENTITY (trans);
     820                 :            : 
     821                 :         19 :   GST_OBJECT_LOCK (identity);
     822                 :         19 :   g_free (identity->last_message);
     823                 :         19 :   identity->last_message = NULL;
     824                 :         19 :   GST_OBJECT_UNLOCK (identity);
     825                 :            : 
     826                 :         19 :   return TRUE;
     827                 :            : }

Generated by: LCOV version 1.9