/* GStreamer
 *
 * unit test for uvch264_demux
 *
 * Copyright (C) <2012> Collabora Ltd.
 *   Author: Youness Alaoui <youness.alaoui@collabora.co.uk>
 * Copyright (C) <2008> Sebastian Dröge <sebastian.droege@collabora.co.uk>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * 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., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include <gst/check/gstcheck.h>
#include <string.h>

static GstElement *demux;
static GstPad *mjpg_pad, *h264_pad, *yuy2_pad, *nv12_pad, *jpg_pad;
static gboolean have_h264_eos, have_yuy2_eos, have_nv12_eos, have_jpg_eos;
static GstBuffer *buffer_h264, *buffer_yuy2, *buffer_nv12, *buffer_jpg;
static GstCaps *negotiated_caps_h264, *negotiated_caps_yuy2;
static GstCaps *negotiated_caps_nv12, *negotiated_caps_jpg;
static GError *gerror;
static gchar *error_debug;

static GstStaticPadTemplate mjpg_template =
GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("image/jpeg, width=640, height=480, framerate=15/1"));

static GstStaticPadTemplate sink_template =
GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS,
    GST_STATIC_CAPS_ANY);

#define STRINGIFY_(x) #x
#define STRINGIFY(x) STRINGIFY_ (x)
#define DATADIR STRINGIFY (UVCH264DEMUX_DATADIR)
#define VALID_H264_JPG_MJPG_FILENAME  DATADIR "/valid_h264_jpg.mjpg"
#define VALID_H264_JPG_JPG_FILENAME   DATADIR "/valid_h264_jpg.jpg"
#define VALID_H264_JPG_H264_FILENAME  DATADIR "/valid_h264_jpg.h264"
#define VALID_H264_YUY2_MJPG_FILENAME DATADIR "/valid_h264_yuy2.mjpg"
#define VALID_H264_YUY2_YUY2_FILENAME DATADIR "/valid_h264_yuy2.yuy2"
#define VALID_H264_YUY2_H264_FILENAME DATADIR "/valid_h264_yuy2.h264"

#define _sink_chain_func(type)                                          \
static GstFlowReturn                                                    \
 _sink_##type##_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer) \
{                                                                       \
  fail_unless (negotiated_caps_##type != NULL);                         \
                                                                        \
  buffer_##type = buffer;                                               \
                                                                        \
  return GST_FLOW_OK;                                                   \
}

#define _sink_event_func(type)                          \
static gboolean                                         \
 _sink_##type##_event (GstPad * pad, GstObject * parent, GstEvent * event)  \
{                                                       \
  if (GST_EVENT_TYPE (event) == GST_EVENT_EOS)          \
    have_##type##_eos = TRUE;                           \
                                                        \
  if (GST_EVENT_TYPE (event) == GST_EVENT_CAPS) {       \
    gst_event_parse_caps (event, &negotiated_caps_##type); \
    gst_caps_ref (negotiated_caps_##type);              \
  }                                                     \
                                                        \
  gst_event_unref (event);                              \
                                                        \
  return TRUE;                                          \
}


_sink_chain_func (h264);
_sink_chain_func (yuy2);
_sink_chain_func (nv12);
_sink_chain_func (jpg);

_sink_event_func (h264);
_sink_event_func (yuy2);
_sink_event_func (nv12);
_sink_event_func (jpg);


static GstBusSyncReply
_bus_sync_handler (GstBus * bus, GstMessage * message, gpointer data)
{
  if (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR) {
    fail_unless (gerror == NULL && error_debug == NULL);
    fail_unless (GST_MESSAGE_SRC (message) == GST_OBJECT (demux));
    gst_message_parse_error (message, &gerror, &error_debug);
  }
  return GST_BUS_PASS;
}

static void
_teardown_test (void)
{
  GstBus *bus;
  gst_element_set_state (demux, GST_STATE_NULL);

  bus = GST_ELEMENT_BUS (demux);
  gst_bus_set_flushing (bus, TRUE);
  gst_object_unref (bus);

  gst_pad_set_active (mjpg_pad, FALSE);
  gst_object_unref (mjpg_pad);
  if (h264_pad) {
    gst_pad_set_active (h264_pad, FALSE);
    gst_object_unref (h264_pad);
  }
  if (yuy2_pad) {
    gst_pad_set_active (yuy2_pad, FALSE);
    gst_object_unref (yuy2_pad);
  }
  if (nv12_pad) {
    gst_pad_set_active (nv12_pad, FALSE);
    gst_object_unref (nv12_pad);
  }
  if (jpg_pad) {
    gst_pad_set_active (jpg_pad, FALSE);
    gst_object_unref (jpg_pad);
  }
  if (gerror) {
    g_error_free (gerror);
    gerror = NULL;
  }
  if (error_debug) {
    g_free (error_debug);
    error_debug = NULL;
  }

  gst_object_unref (demux);
  mjpg_pad = h264_pad = yuy2_pad = nv12_pad = jpg_pad = NULL;
  demux = NULL;

  gst_caps_replace (&negotiated_caps_h264, NULL);
  gst_caps_replace (&negotiated_caps_yuy2, NULL);
  gst_caps_replace (&negotiated_caps_nv12, NULL);
  gst_caps_replace (&negotiated_caps_jpg, NULL);
}

static void
_setup_test (gboolean link_h264, gboolean link_yuy2, gboolean link_nv12,
    gboolean link_jpg)
{
  GstCaps *caps;
  GstPad *sinkpad, *h264pad, *yuy2pad, *nv12pad, *jpgpad;
  GstBus *bus;

  bus = gst_bus_new ();

  have_h264_eos = have_yuy2_eos = have_nv12_eos = have_jpg_eos = FALSE;
  buffer_h264 = buffer_yuy2 = buffer_nv12 = buffer_jpg = NULL;

  demux = gst_element_factory_make ("uvch264mjpgdemux", NULL);
  fail_unless (demux != NULL);

  gst_element_set_bus (demux, bus);
  gst_bus_set_sync_handler (bus, _bus_sync_handler, NULL, NULL);

  mjpg_pad = gst_pad_new_from_static_template (&mjpg_template, "src");
  fail_unless (mjpg_pad != NULL);
  sinkpad = gst_element_get_static_pad (demux, "sink");
  fail_unless (sinkpad != NULL);
  fail_unless (gst_pad_link (mjpg_pad, sinkpad) == GST_PAD_LINK_OK);
  gst_object_unref (sinkpad);

  gst_pad_set_active (mjpg_pad, TRUE);

  if (link_h264) {
    h264pad = gst_element_get_static_pad (demux, "h264");
    fail_unless (h264pad != NULL);

    h264_pad = gst_pad_new_from_static_template (&sink_template, "h264");
    fail_unless (h264_pad != NULL);
    gst_pad_set_chain_function (h264_pad, _sink_h264_chain);
    gst_pad_set_event_function (h264_pad, _sink_h264_event);

    fail_unless (gst_pad_link (h264pad, h264_pad) == GST_PAD_LINK_OK);
    gst_object_unref (h264pad);

    gst_pad_set_active (h264_pad, TRUE);
  }
  if (link_yuy2) {
    yuy2pad = gst_element_get_static_pad (demux, "yuy2");
    fail_unless (yuy2pad != NULL);

    yuy2_pad = gst_pad_new_from_static_template (&sink_template, "yuy2");
    fail_unless (yuy2_pad != NULL);
    gst_pad_set_chain_function (yuy2_pad, _sink_yuy2_chain);
    gst_pad_set_event_function (yuy2_pad, _sink_yuy2_event);

    fail_unless (gst_pad_link (yuy2pad, yuy2_pad) == GST_PAD_LINK_OK);
    gst_object_unref (yuy2pad);

    gst_pad_set_active (yuy2_pad, TRUE);
  }
  if (link_nv12) {
    nv12pad = gst_element_get_static_pad (demux, "nv12");
    fail_unless (nv12pad != NULL);

    nv12_pad = gst_pad_new_from_static_template (&sink_template, "nv12");
    fail_unless (nv12_pad != NULL);
    gst_pad_set_chain_function (nv12_pad, _sink_nv12_chain);
    gst_pad_set_event_function (nv12_pad, _sink_nv12_event);

    fail_unless (gst_pad_link (nv12pad, nv12_pad) == GST_PAD_LINK_OK);
    gst_object_unref (nv12pad);
    gst_pad_set_active (nv12_pad, TRUE);
  }
  if (link_jpg) {
    jpgpad = gst_element_get_static_pad (demux, "jpeg");
    fail_unless (jpgpad != NULL);

    jpg_pad = gst_pad_new_from_static_template (&sink_template, "jpeg");
    fail_unless (jpg_pad != NULL);
    gst_pad_set_chain_function (jpg_pad, _sink_jpg_chain);
    gst_pad_set_event_function (jpg_pad, _sink_jpg_event);

    fail_unless (gst_pad_link (jpgpad, jpg_pad) == GST_PAD_LINK_OK);
    gst_object_unref (jpgpad);

    gst_pad_set_active (jpg_pad, TRUE);
  }

  gst_element_set_state (demux, GST_STATE_PLAYING);

  caps = gst_static_pad_template_get_caps (&mjpg_template);
  gst_check_setup_events_with_stream_id (mjpg_pad, demux, caps,
      GST_FORMAT_TIME, "uvch264demux-test");
  gst_caps_unref (caps);
}

static GstBuffer *
_buffer_from_file (const gchar * filename)
{
  GstBuffer *buffer;
  gchar *contents = NULL;
  gsize length = 0;

  fail_unless (g_file_get_contents (filename, &contents, &length, NULL));

  buffer = gst_buffer_new_wrapped (contents, length);
  GST_BUFFER_OFFSET (buffer) = 0;

  return buffer;
}

GST_START_TEST (test_valid_h264_jpg)
{
  GstCaps *mjpg_caps = gst_static_pad_template_get_caps (&mjpg_template);
  GstCaps *h264_caps;
  GstBuffer *buffer;
  gchar *h264_data, *jpg_data;
  gsize h264_size, jpg_size;

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  h264_caps = gst_caps_new_simple ("video/x-h264",
      "width", G_TYPE_INT, 640, "height", G_TYPE_INT, 480,
      "framerate", GST_TYPE_FRACTION, 15, 1, NULL);
  buffer = _buffer_from_file (VALID_H264_JPG_MJPG_FILENAME);

  fail_unless (g_file_get_contents (VALID_H264_JPG_H264_FILENAME,
          &h264_data, &h264_size, NULL));
  fail_unless (g_file_get_contents (VALID_H264_JPG_JPG_FILENAME,
          &jpg_data, &jpg_size, NULL));

  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_OK);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos);
  fail_unless (have_yuy2_eos);
  fail_unless (have_nv12_eos);
  fail_unless (have_jpg_eos);
  fail_unless (buffer_h264 != NULL);
  fail_unless (buffer_jpg != NULL);
  fail_unless (buffer_nv12 == NULL);
  fail_unless (buffer_yuy2 == NULL);
  fail_unless (gerror == NULL && error_debug == NULL);
  fail_unless (gst_caps_is_always_compatible (negotiated_caps_h264, h264_caps));
  fail_unless (gst_caps_is_always_compatible (negotiated_caps_jpg, mjpg_caps));
  fail_unless (gst_buffer_get_size (buffer_h264) == h264_size);
  fail_unless (gst_buffer_get_size (buffer_jpg) == jpg_size);
  fail_unless (gst_buffer_memcmp (buffer_h264, 0, h264_data, h264_size) == 0);
  fail_unless (gst_buffer_memcmp (buffer_jpg, 0, jpg_data, jpg_size) == 0);

  gst_caps_unref (mjpg_caps);
  gst_caps_unref (h264_caps);
  g_free (h264_data);
  g_free (jpg_data);
  gst_buffer_unref (buffer_h264);
  gst_buffer_unref (buffer_jpg);
  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_valid_h264_yuy2)
{
  GstCaps *h264_caps;
  GstCaps *yuy2_caps;
  GstBuffer *buffer;
  gchar *h264_data, *yuy2_data;
  gsize h264_size, yuy2_size;

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  h264_caps = gst_caps_new_simple ("video/x-h264",
      "width", G_TYPE_INT, 640, "height", G_TYPE_INT, 480,
      "framerate", GST_TYPE_FRACTION, 15, 1, NULL);
  yuy2_caps = gst_caps_new_simple ("video/x-raw",
      "format", G_TYPE_STRING, "YUY2",
      "width", G_TYPE_INT, 160, "height", G_TYPE_INT, 90,
      "framerate", GST_TYPE_FRACTION, 15, 1, NULL);
  buffer = _buffer_from_file (VALID_H264_YUY2_MJPG_FILENAME);
  fail_unless (g_file_get_contents (VALID_H264_YUY2_H264_FILENAME,
          &h264_data, &h264_size, NULL));
  fail_unless (g_file_get_contents (VALID_H264_YUY2_YUY2_FILENAME,
          &yuy2_data, &yuy2_size, NULL));

  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_OK);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos);
  fail_unless (have_yuy2_eos);
  fail_unless (have_nv12_eos);
  fail_unless (have_jpg_eos);
  fail_unless (buffer_h264 != NULL);
  fail_unless (buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL);
  fail_unless (buffer_yuy2 != NULL);
  fail_unless (gerror == NULL && error_debug == NULL);
  fail_unless (gst_caps_is_always_compatible (negotiated_caps_h264, h264_caps));
  fail_unless (gst_caps_is_always_compatible (negotiated_caps_yuy2, yuy2_caps));
  fail_unless (gst_buffer_get_size (buffer_h264) == h264_size);
  fail_unless (gst_buffer_get_size (buffer_yuy2) == yuy2_size);
  fail_unless (gst_buffer_memcmp (buffer_h264, 0, h264_data, h264_size) == 0);
  fail_unless (gst_buffer_memcmp (buffer_yuy2, 0, yuy2_data, yuy2_size) == 0);

  gst_caps_unref (yuy2_caps);
  gst_caps_unref (h264_caps);
  g_free (h264_data);
  g_free (yuy2_data);
  gst_buffer_unref (buffer_h264);
  gst_buffer_unref (buffer_yuy2);
  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_no_data)
{
  GstBuffer *buffer = gst_buffer_new ();

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_OK);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg != NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror == NULL && error_debug == NULL);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_data_zero)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_memset (buffer, 0, 0, 1024);
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_OK);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_no_marker_size)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_ERROR);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror != NULL);
  fail_unless (gerror->domain == GST_STREAM_ERROR);
  fail_unless (gerror->code == GST_STREAM_ERROR_DEMUX);
  fail_unless (memcmp (gerror->message,
          "Not enough data to read marker size",
          strlen (gerror->message)) == 0);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_not_enough_data)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00, 0xff, 0x00, 0x00
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_ERROR);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror != NULL);
  fail_unless (gerror->domain == GST_STREAM_ERROR);
  fail_unless (gerror->code == GST_STREAM_ERROR_DEMUX);
  fail_unless (memcmp (gerror->message,
          "Not enough data to read marker content",
          strlen (gerror->message)) == 0);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_no_aux_header)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00, 0x02, 0x00, 0x00,
    0xff, 0xd9
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_ERROR);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror != NULL);
  fail_unless (gerror->domain == GST_STREAM_ERROR);
  fail_unless (gerror->code == GST_STREAM_ERROR_DEMUX);
  fail_unless (memcmp (gerror->message,
          "Not enough data to read aux header", strlen (gerror->message)) == 0);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_empty_aux_data)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00, 0x1C, 0x00, 0x01,
    0x16, 0x00, 0x48, 0x32, 0x36, 0x34, 0x80, 0x07,
    0x38, 0x04, 0x2a, 0x2c, 0x0a, 0x00, 0x1b, 0x00,
    0x40, 0x62, 0xcb, 0x0a, 0x00, 0x00, 0x00, 0x00,
    0xff, 0xd9
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_OK);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror == NULL);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_unknown_fcc)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00, 0x2C, 0x00, 0x01,
    0x16, 0x00, 0x48, 0x30, 0x30, 0x30, 0x80, 0x07,
    0x38, 0x04, 0x2a, 0x2c, 0x0a, 0x00, 0x1b, 0x00,
    0x40, 0x62, 0xcb, 0x0a, 0x10, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xff, 0xd9
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_ERROR);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror != NULL);
  fail_unless (gerror->domain == GST_STREAM_ERROR);
  fail_unless (gerror->code == GST_STREAM_ERROR_DEMUX);
  fail_unless (memcmp (gerror->message,
          "Unknown auxiliary stream format : H000",
          strlen (gerror->message)) == 0);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_not_enough_aux_data)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00, 0x1C, 0x00, 0x01,
    0x16, 0x00, 0x48, 0x32, 0x36, 0x34, 0x80, 0x07,
    0x38, 0x04, 0x2a, 0x2c, 0x0a, 0x00, 0x1b, 0x00,
    0x40, 0x62, 0xcb, 0x0a, 0x10, 0x00, 0x00, 0x00,
    0xff, 0xd9
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_ERROR);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror != NULL);
  fail_unless (gerror->domain == GST_STREAM_ERROR);
  fail_unless (gerror->code == GST_STREAM_ERROR_DEMUX);
  fail_unless (memcmp (gerror->message,
          "Incomplete auxiliary stream. 16 bytes missing",
          strlen (gerror->message)) == 0);

  _teardown_test ();
}

GST_END_TEST;

GST_START_TEST (test_too_much_aux_data)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00, 0x3C, 0x00, 0x01,
    0x16, 0x00, 0x48, 0x32, 0x36, 0x34, 0x80, 0x07,
    0x38, 0x04, 0x2a, 0x2c, 0x0a, 0x00, 0x1b, 0x00,
    0x40, 0x62, 0xcb, 0x0a, 0x10, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xff, 0xd9
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_ERROR);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 == NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror != NULL);
  fail_unless (gerror->domain == GST_STREAM_ERROR);
  fail_unless (gerror->code == GST_STREAM_ERROR_DEMUX);
  fail_unless (memcmp (gerror->message,
          "Expected 16 auxiliary data, got 32 bytes",
          strlen (gerror->message)) == 0);

  _teardown_test ();
}

GST_END_TEST;


GST_START_TEST (test_no_sos_marker)
{
  GstBuffer *buffer = gst_buffer_new_and_alloc (1024);
  const guchar data[] = {
    0xff, 0xd8, 0xff, 0xe4, 0x00, 0x2C, 0x00, 0x01,
    0x16, 0x00, 0x48, 0x32, 0x36, 0x34, 0x80, 0x07,
    0x38, 0x04, 0x2a, 0x2c, 0x0a, 0x00, 0x1b, 0x00,
    0x40, 0x62, 0xcb, 0x0a, 0x10, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0xff, 0xd9
  };
  const guchar h264_data[] = {
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
  };

  _setup_test (TRUE, TRUE, TRUE, TRUE);

  gst_buffer_fill (buffer, 0, data, sizeof (data));
  gst_buffer_set_size (buffer, sizeof (data));
  fail_unless (gst_pad_push (mjpg_pad, buffer) == GST_FLOW_OK);
  fail_unless (gst_pad_push_event (mjpg_pad, gst_event_new_eos ()));

  fail_unless (have_h264_eos && have_yuy2_eos && have_nv12_eos && have_jpg_eos);
  fail_unless (buffer_h264 != NULL && buffer_jpg == NULL);
  fail_unless (buffer_nv12 == NULL && buffer_yuy2 == NULL);
  fail_unless (gerror == NULL);
  fail_unless (gst_buffer_get_size (buffer_h264) == sizeof (h264_data));
  fail_if (gst_buffer_memcmp (buffer_h264, 0, h264_data, sizeof (h264_data)));

  _teardown_test ();
}

GST_END_TEST;

static Suite *
uvch264demux_suite (void)
{
  Suite *s = suite_create ("uvch264demux");
  TCase *tc_chain = tcase_create ("general");

  suite_add_tcase (s, tc_chain);
  tcase_set_timeout (tc_chain, 180);
  tcase_add_test (tc_chain, test_valid_h264_jpg);
  tcase_add_test (tc_chain, test_valid_h264_yuy2);
  tcase_add_test (tc_chain, test_no_data);
  tcase_add_test (tc_chain, test_data_zero);
  tcase_add_test (tc_chain, test_no_marker_size);
  tcase_add_test (tc_chain, test_not_enough_data);
  tcase_add_test (tc_chain, test_no_aux_header);
  tcase_add_test (tc_chain, test_empty_aux_data);
  tcase_add_test (tc_chain, test_unknown_fcc);
  tcase_add_test (tc_chain, test_no_sos_marker);
  tcase_add_test (tc_chain, test_not_enough_aux_data);
  tcase_add_test (tc_chain, test_too_much_aux_data);

  return s;
}

GST_CHECK_MAIN (uvch264demux);
