summaryrefslogtreecommitdiff
path: root/tests/check/elements/parser.h
blob: dc447ae560ddff3109900d42eaacfe081694b14d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
/*
 * 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
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#include <gst/check/gstcheck.h>

#define MAX_HEADERS 10

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;

typedef struct {
    const guint8     *data;
    guint             size;
} datablob;

typedef gboolean (*VerifyBuffer) (buffer_verify_data_s * vdata, GstBuffer * buf);
typedef GstElement* (*ElementSetup) (const gchar * desc);

/* context state variables; to be set by test using this helper */
/* mandatory */
extern const gchar *ctx_factory;
extern GstStaticPadTemplate *ctx_sink_template;
extern GstStaticPadTemplate *ctx_src_template;
/* optional */
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;

extern VerifyBuffer ctx_verify_buffer;
extern ElementSetup ctx_setup;
extern gboolean ctx_frame_generated;

/* no refs taken/kept, all up to caller */
typedef struct
{
  const gchar          *factory;
  ElementSetup         factory_setup;
  GstStaticPadTemplate *sink_template;
  GstStaticPadTemplate *src_template;
  /* caps that go into element */
  GstCaps              *src_caps;
  /* optional: output caps to verify */
  GstCaps              *sink_caps;
  /* initial headers */
  datablob              headers[MAX_HEADERS];
  /* initial (header) output to forego checking */
  guint                 discard;
  /* series of buffers; middle series considered garbage */
  struct {
    /* data and size */
    const guint8     *data;
    guint             size;
    /* num of frames with above data per buffer */
    guint      fpb;
    /* num of buffers */
    guint      num;
  } series[3];
  /* sigh, weird cases */
  gboolean              framed;
  guint                 dropped;
  gboolean              no_metadata;
} GstParserTest;

extern
void gst_parser_test_init (GstParserTest * ptest, const guint8 * data, guint size, guint num);

extern
void gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps);

extern
void gst_parser_test_normal (const guint8 *data, guint size);

extern
void gst_parser_test_drain_single (const guint8 *data, guint size);

extern
void gst_parser_test_drain_garbage (const guint8 *data, guint size, guint8 *garbage, guint gsize);

extern
void gst_parser_test_split (const guint8 *data, guint size);

extern
void gst_parser_test_skip_garbage (const guint8 *data, guint size, guint8 *garbage, guint gsize);

extern
void gst_parser_test_output_caps (const guint8 *data, guint size, const gchar * input_caps,
                                  const gchar * output_caps);

extern
GstCaps *gst_parser_test_get_output_caps (const guint8 *data, guint size, const gchar * input_caps);