1 /* 2 * GStreamer 3 * 4 * unit test for (audio) parser 5 * 6 * Copyright (C) 2008 Nokia Corporation. All rights reserved. 7 * 8 * Contact: Stefan Kost <stefan.kost@nokia.com> 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Library General Public 12 * License as published by the Free Software Foundation; either 13 * version 2 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Library General Public License for more details. 19 * 20 * You should have received a copy of the GNU Library General Public 21 * License along with this library; if not, write to the 22 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 23 * Boston, MA 02110-1301, USA. 24 */ 25 26 #include <gst/check/gstcheck.h> 27 28 #define MAX_HEADERS 10 29 30 typedef struct { 31 guint8 *data; 32 guint size; 33 } datablob; 34 35 /* context state variables; to be set by test using this helper */ 36 /* mandatory */ 37 extern const gchar *ctx_factory; 38 extern GstStaticPadTemplate *ctx_sink_template; 39 extern GstStaticPadTemplate *ctx_src_template; 40 /* optional */ 41 extern GstCaps *ctx_input_caps; 42 extern GstCaps *ctx_output_caps; 43 extern guint ctx_discard; 44 extern datablob ctx_headers[MAX_HEADERS]; 45 extern gboolean ctx_no_metadata; 46 47 /* no refs taken/kept, all up to caller */ 48 typedef struct 49 { 50 const gchar *factory; 51 GstStaticPadTemplate *sink_template; 52 GstStaticPadTemplate *src_template; 53 /* caps that go into element */ 54 GstCaps *src_caps; 55 /* optional: output caps to verify */ 56 GstCaps *sink_caps; 57 /* initial headers */ 58 datablob headers[MAX_HEADERS]; 59 /* initial (header) output to forego checking */ 60 guint discard; 61 /* series of buffers; middle series considered garbage */ 62 struct { 63 /* data and size */ 64 guint8 *data; 65 guint size; 66 /* num of frames with above data per buffer */ 67 guint fpb; 68 /* num of buffers */ 69 guint num; 70 } series[3]; 71 /* sigh, weird cases */ 72 gboolean framed; 73 guint dropped; 74 gboolean no_metadata; 75 } GstParserTest; 76 77 void gst_parser_test_init (GstParserTest * ptest, guint8 * data, guint size, guint num); 78 79 void gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps); 80 81 void gst_parser_test_normal (guint8 *data, guint size); 82 83 void gst_parser_test_drain_single (guint8 *data, guint size); 84 85 void gst_parser_test_drain_garbage (guint8 *data, guint size, guint8 *garbage, guint gsize); 86 87 void gst_parser_test_split (guint8 *data, guint size); 88 89 void gst_parser_test_skip_garbage (guint8 *data, guint size, guint8 *garbage, guint gsize); 90 91 void gst_parser_test_output_caps (guint8 *data, guint size, const gchar * input_caps, 92 const gchar * output_caps); 93 94 GstCaps *gst_parser_test_get_output_caps (guint8 *data, guint size, const gchar * input_caps); 95 96