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 { 32 guint discard; 33 guint buffers_before_offset_skip; 34 guint offset_skip_amount; 35 const guint8 *data_to_verify; 36 guint data_to_verify_size; 37 GstCaps *caps; 38 gboolean no_metadata; 39 40 GstClockTime ts_counter; 41 gint64 offset_counter; 42 guint buffer_counter; 43 } buffer_verify_data_s; 44 45 typedef struct { 46 const guint8 *data; 47 guint size; 48 } datablob; 49 50 typedef gboolean (*VerifyBuffer) (buffer_verify_data_s * vdata, GstBuffer * buf); 51 typedef GstElement* (*ElementSetup) (const gchar * desc); 52 53 /* context state variables; to be set by test using this helper */ 54 /* mandatory */ 55 extern const gchar *ctx_factory; 56 extern GstStaticPadTemplate *ctx_sink_template; 57 extern GstStaticPadTemplate *ctx_src_template; 58 /* optional */ 59 extern GstCaps *ctx_input_caps; 60 extern GstCaps *ctx_output_caps; 61 extern guint ctx_discard; 62 extern datablob ctx_headers[MAX_HEADERS]; 63 extern gboolean ctx_no_metadata; 64 65 extern VerifyBuffer ctx_verify_buffer; 66 extern ElementSetup ctx_setup; 67 extern gboolean ctx_frame_generated; 68 69 /* no refs taken/kept, all up to caller */ 70 typedef struct 71 { 72 const gchar *factory; 73 ElementSetup factory_setup; 74 GstStaticPadTemplate *sink_template; 75 GstStaticPadTemplate *src_template; 76 /* caps that go into element */ 77 GstCaps *src_caps; 78 /* optional: output caps to verify */ 79 GstCaps *sink_caps; 80 /* initial headers */ 81 datablob headers[MAX_HEADERS]; 82 /* initial (header) output to forego checking */ 83 guint discard; 84 /* series of buffers; middle series considered garbage */ 85 struct { 86 /* data and size */ 87 const guint8 *data; 88 guint size; 89 /* num of frames with above data per buffer */ 90 guint fpb; 91 /* num of buffers */ 92 guint num; 93 } series[3]; 94 /* sigh, weird cases */ 95 gboolean framed; 96 guint dropped; 97 gboolean no_metadata; 98 } GstParserTest; 99 100 extern 101 void gst_parser_test_init (GstParserTest * ptest, const guint8 * data, guint size, guint num); 102 103 extern 104 void gst_parser_test_run (GstParserTest * test, GstCaps ** out_caps); 105 106 extern 107 void gst_parser_test_normal (const guint8 *data, guint size); 108 109 extern 110 void gst_parser_test_drain_single (const guint8 *data, guint size); 111 112 extern 113 void gst_parser_test_drain_garbage (const guint8 *data, guint size, guint8 *garbage, guint gsize); 114 115 extern 116 void gst_parser_test_split (const guint8 *data, guint size); 117 118 extern 119 void gst_parser_test_skip_garbage (const guint8 *data, guint size, guint8 *garbage, guint gsize); 120 121 extern 122 void gst_parser_test_output_caps (const guint8 *data, guint size, const gchar * input_caps, 123 const gchar * output_caps); 124 125 extern 126 GstCaps *gst_parser_test_get_output_caps (const guint8 *data, guint size, const gchar * input_caps); 127 128