2010-09-25 11:50:51 +00:00
|
|
|
/*
|
|
|
|
* GStreamer
|
|
|
|
*
|
|
|
|
* unit test for (audio) parser
|
|
|
|
*
|
|
|
|
* Copyright (C) 2008 Nokia Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* Contact: Stefan Kost <stefan.kost@nokia.com>
|
|
|
|
*
|
|
|
|
* 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
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2010-09-25 11:50:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <gst/check/gstcheck.h>
|
|
|
|
|
2010-10-01 10:34:55 +00:00
|
|
|
#define MAX_HEADERS 10
|
|
|
|
|
2011-05-25 18:48:38 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
guint discard;
|
|
|
|
guint buffers_before_offset_skip;
|
|
|
|
guint offset_skip_amount;
|
|
|
|
const guint8 *data_to_verify;
|
|
|
|
guint data_to_verify_size;
|
|
|
|
GstCaps *caps;
|
|
|
|
gboolean no_metadata;
|
|
|
|
|
|
|
|
GstClockTime ts_counter;
|
|
|
|
gint64 offset_counter;
|
|
|
|
guint buffer_counter;
|
|
|
|
} buffer_verify_data_s;
|
|
|
|
|
2010-10-01 10:34:55 +00:00
|
|
|
typedef struct {
|
2020-05-07 16:02:40 +00:00
|
|
|
const guint8 *data;
|
|
|
|
guint size;
|
2010-10-01 10:34:55 +00:00
|
|
|
} datablob;
|
|
|
|
|
2011-05-25 18:48:38 +00:00
|
|
|
typedef gboolean (*VerifyBuffer) (buffer_verify_data_s * vdata, GstBuffer * buf);
|
|
|
|
typedef GstElement* (*ElementSetup) (const gchar * desc);
|
|
|
|
|
2010-09-25 11:50:51 +00:00
|
|
|
/* context state variables; to be set by test using this helper */
|
|
|
|
/* mandatory */
|
2018-12-16 13:46:02 +00:00
|
|
|
extern const gchar *ctx_factory;
|
|
|
|
extern GstStaticPadTemplate *ctx_sink_template;
|
|
|
|
extern GstStaticPadTemplate *ctx_src_template;
|
2010-09-25 11:50:51 +00:00
|
|
|
/* optional */
|
2018-12-16 13:46:02 +00:00
|
|
|
extern GstCaps *ctx_input_caps;
|
|
|
|
extern GstCaps *ctx_output_caps;
|
|
|
|
extern guint ctx_discard;
|
|
|
|
extern datablob ctx_headers[MAX_HEADERS];
|
|
|
|
extern gboolean ctx_no_metadata;
|
2010-09-25 11:50:51 +00:00
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern VerifyBuffer ctx_verify_buffer;
|
|
|
|
extern ElementSetup ctx_setup;
|
|
|
|
extern gboolean ctx_frame_generated;
|
2011-05-25 18:48:38 +00:00
|
|
|
|
2010-09-25 11:50:51 +00:00
|
|
|
/* no refs taken/kept, all up to caller */
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
const gchar *factory;
|
2011-05-25 18:48:38 +00:00
|
|
|
ElementSetup factory_setup;
|
2010-09-25 11:50:51 +00:00
|
|
|
GstStaticPadTemplate *sink_template;
|
|
|
|
GstStaticPadTemplate *src_template;
|
|
|
|
/* caps that go into element */
|
|
|
|
GstCaps *src_caps;
|
|
|
|
/* optional: output caps to verify */
|
|
|
|
GstCaps *sink_caps;
|
2010-10-01 10:34:55 +00:00
|
|
|
/* initial headers */
|
|
|
|
datablob headers[MAX_HEADERS];
|
|
|
|
/* initial (header) output to forego checking */
|
|
|
|
guint discard;
|
2010-09-25 11:50:51 +00:00
|
|
|
/* series of buffers; middle series considered garbage */
|
|
|
|
struct {
|
|
|
|
/* data and size */
|
2020-05-07 16:02:40 +00:00
|
|
|
const guint8 *data;
|
|
|
|
guint size;
|
2010-09-25 11:50:51 +00:00
|
|
|
/* num of frames with above data per buffer */
|
|
|
|
guint fpb;
|
|
|
|
/* num of buffers */
|
|
|
|
guint num;
|
|
|
|
} series[3];
|
|
|
|
/* sigh, weird cases */
|
|
|
|
gboolean framed;
|
|
|
|
guint dropped;
|
2010-10-01 10:34:55 +00:00
|
|
|
gboolean no_metadata;
|
2010-09-25 11:50:51 +00:00
|
|
|
} GstParserTest;
|
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
void gst_parser_test_init (GstParserTest * ptest, const guint8 * data, guint size, guint num);
|
2010-09-25 11:50:51 +00:00
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2010-09-25 11:50:51 +00:00
|
|
|
void gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps);
|
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
void gst_parser_test_normal (const guint8 *data, guint size);
|
2010-09-25 11:50:51 +00:00
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
void gst_parser_test_drain_single (const guint8 *data, guint size);
|
2010-09-25 11:50:51 +00:00
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
void gst_parser_test_drain_garbage (const guint8 *data, guint size, guint8 *garbage, guint gsize);
|
2010-09-25 11:50:51 +00:00
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
void gst_parser_test_split (const guint8 *data, guint size);
|
2010-09-25 11:50:51 +00:00
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
void gst_parser_test_skip_garbage (const guint8 *data, guint size, guint8 *garbage, guint gsize);
|
2010-09-25 11:50:51 +00:00
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
void gst_parser_test_output_caps (const guint8 *data, guint size, const gchar * input_caps,
|
2010-09-25 11:50:51 +00:00
|
|
|
const gchar * output_caps);
|
|
|
|
|
2018-12-16 13:46:02 +00:00
|
|
|
extern
|
2020-05-07 16:02:40 +00:00
|
|
|
GstCaps *gst_parser_test_get_output_caps (const guint8 *data, guint size, const gchar * input_caps);
|
2010-09-25 11:50:51 +00:00
|
|
|
|