Port gtk-doc comments to their equivalent markdown syntax
[platform/upstream/gstreamer.git] / libs / gst / check / gstconsistencychecker.c
index 576b575..cf1dbf7 100644 (file)
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
  * SECTION:gstcheckconsistencychecker
+ * @title: GstStreamConsistencyChecker
  * @short_description: Data flow consistency checker for GStreamer unit tests.
  *
  * These macros and functions are for internal use of the unit tests found
  * inside the 'check' directories of various GStreamer packages.
- *
- * Since: 0.10.24
  */
 
 #include "gstconsistencychecker.h"
@@ -40,6 +39,8 @@ struct _GstStreamConsistency
   volatile gboolean segment;
   volatile gboolean eos;
   volatile gboolean expect_flush;
+  volatile gboolean saw_serialized_event;
+  volatile gboolean saw_stream_start;
   GstObject *parent;
   GList *pads;
 };
@@ -65,13 +66,15 @@ source_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
         GST_TIME_ARGS (GST_BUFFER_PTS (GST_BUFFER_CAST (data))),
         GST_TIME_ARGS (GST_BUFFER_DTS (GST_BUFFER_CAST (data))));
     /* If an EOS went through, a buffer would be invalid */
-    fail_if (consist->eos, "Buffer received after EOS");
+    fail_if (consist->eos, "Buffer received after EOS on pad %s:%s",
+        GST_DEBUG_PAD_NAME (pad));
     /* Buffers need to be preceded by a segment event */
-    fail_unless (consist->segment, "Buffer received without segment");
+    fail_unless (consist->segment, "Buffer received without segment "
+        "on pad %s:%s", GST_DEBUG_PAD_NAME (pad));
   } else if (GST_IS_EVENT (data)) {
     GstEvent *event = (GstEvent *) data;
 
-    GST_DEBUG_OBJECT (pad, "%s", GST_EVENT_TYPE_NAME (event));
+    GST_DEBUG_OBJECT (pad, "Event : %s", GST_EVENT_TYPE_NAME (event));
     switch (GST_EVENT_TYPE (event)) {
       case GST_EVENT_FLUSH_START:
         /* getting two flush_start in a row seems to be okay
@@ -82,25 +85,33 @@ source_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
       case GST_EVENT_FLUSH_STOP:
         /* Receiving a flush-stop is only valid after receiving a flush-start */
         fail_unless (consist->flushing,
-            "Received a FLUSH_STOP without a FLUSH_START");
-        fail_if (consist->eos, "Received a FLUSH_STOP after an EOS");
+            "Received a FLUSH_STOP without a FLUSH_START on pad %s:%s",
+            GST_DEBUG_PAD_NAME (pad));
+        fail_if (consist->eos, "Received a FLUSH_STOP after an EOS on "
+            "pad %s:%s", GST_DEBUG_PAD_NAME (pad));
         consist->flushing = consist->expect_flush = FALSE;
         break;
       case GST_EVENT_STREAM_START:
-      case GST_EVENT_STREAM_CONFIG:
+        fail_if (consist->saw_serialized_event && !consist->saw_stream_start,
+            "Got a STREAM_START event after a serialized event on pad %s:%s",
+            GST_DEBUG_PAD_NAME (pad));
+        consist->saw_stream_start = TRUE;
+        break;
       case GST_EVENT_CAPS:
         /* ok to have these before segment event */
         /* FIXME check order more precisely, if so spec'ed somehow ? */
         break;
       case GST_EVENT_SEGMENT:
         fail_if ((consist->expect_flush && consist->flushing),
-            "Received SEGMENT while in a flushing seek");
+            "Received SEGMENT while in a flushing seek on pad %s:%s",
+            GST_DEBUG_PAD_NAME (pad));
         consist->segment = TRUE;
         consist->eos = FALSE;
         break;
       case GST_EVENT_EOS:
         /* FIXME : not 100% sure about whether two eos in a row is valid */
-        fail_if (consist->eos, "Received EOS just after another EOS");
+        fail_if (consist->eos, "Received EOS just after another EOS on "
+            "pad %s:%s", GST_DEBUG_PAD_NAME (pad));
         consist->eos = TRUE;
         consist->segment = FALSE;
         break;
@@ -111,11 +122,20 @@ source_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
       default:
         if (GST_EVENT_IS_SERIALIZED (event) && GST_EVENT_IS_DOWNSTREAM (event)) {
           fail_if (consist->eos, "Event received after EOS");
-          fail_unless (consist->segment, "Event received before segment");
+          fail_unless (consist->segment, "Event %s received before segment "
+              "on pad %s:%s", GST_EVENT_TYPE_NAME (event),
+              GST_DEBUG_PAD_NAME (pad));
         }
         /* FIXME : Figure out what to do for other events */
         break;
     }
+    if (GST_EVENT_IS_SERIALIZED (event)) {
+      fail_if (!consist->saw_stream_start
+          && GST_EVENT_TYPE (event) != GST_EVENT_STREAM_START,
+          "Got a serialized event (%s) before a STREAM_START on pad %s:%s",
+          GST_EVENT_TYPE_NAME (event), GST_DEBUG_PAD_NAME (pad));
+      consist->saw_serialized_event = TRUE;
+    }
   }
 
   return TRUE;
@@ -134,9 +154,11 @@ sink_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
     GST_DEBUG_OBJECT (pad, "Buffer %" GST_TIME_FORMAT,
         GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (GST_BUFFER (data))));
     /* If an EOS went through, a buffer would be invalid */
-    fail_if (consist->eos, "Buffer received after EOS");
+    fail_if (consist->eos, "Buffer received after EOS on pad %s:%s",
+        GST_DEBUG_PAD_NAME (pad));
     /* Buffers need to be preceded by a segment event */
-    fail_unless (consist->segment, "Buffer received without segment");
+    fail_unless (consist->segment, "Buffer received without segment "
+        "on pad %s:%s", GST_DEBUG_PAD_NAME (pad));
   } else if (GST_IS_EVENT (data)) {
     GstEvent *event = (GstEvent *) data;
 
@@ -154,7 +176,8 @@ sink_pad_data_cb (GstPad * pad, GstPadProbeInfo * info,
       }
       case GST_EVENT_SEGMENT:
         fail_if ((consist->expect_flush && consist->flushing),
-            "Received SEGMENT while in a flushing seek");
+            "Received SEGMENT while in a flushing seek on pad %s:%s",
+            GST_DEBUG_PAD_NAME (pad));
         consist->segment = TRUE;
         consist->eos = FALSE;
         break;
@@ -191,15 +214,13 @@ add_pad (GstStreamConsistency * consist, GstPad * pad)
 }
 
 /**
- * gst_consistency_checker_new:
+ * gst_consistency_checker_new: (skip)
  * @pad: The #GstPad on which the dataflow will be checked.
  *
  * Sets up a data probe on the given pad which will raise assertions if the
  * data flow is inconsistent.
  *
  * Returns: A #GstStreamConsistency structure used to track data flow.
- *
- * Since: 0.10.24
  */
 GstStreamConsistency *
 gst_consistency_checker_new (GstPad * pad)
@@ -226,8 +247,6 @@ gst_consistency_checker_new (GstPad * pad)
  * data flow is inconsistent.
  *
  * Returns: %TRUE if the pad was added
- *
- * Since: 0.10.37
  */
 gboolean
 gst_consistency_checker_add_pad (GstStreamConsistency * consist, GstPad * pad)
@@ -245,16 +264,17 @@ gst_consistency_checker_add_pad (GstStreamConsistency * consist, GstPad * pad)
  * @consist: The #GstStreamConsistency to reset.
  *
  * Reset the stream checker's internal variables.
- *
- * Since: 0.10.24
  */
 
 void
 gst_consistency_checker_reset (GstStreamConsistency * consist)
 {
-  consist->eos = FALSE;
   consist->flushing = FALSE;
   consist->segment = FALSE;
+  consist->eos = FALSE;
+  consist->expect_flush = FALSE;
+  consist->saw_serialized_event = FALSE;
+  consist->saw_stream_start = FALSE;
 }
 
 /**
@@ -262,8 +282,6 @@ gst_consistency_checker_reset (GstStreamConsistency * consist)
  * @consist: The #GstStreamConsistency to free.
  *
  * Frees the allocated data and probes associated with @consist.
- *
- * Since: 0.10.24
  */
 
 void