1 /* 2 * mpegts.h - 3 * Copyright (C) 2013 Edward Hervey 4 * 5 * Authors: 6 * Edward Hervey <edward@collabora.com> 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Library General Public 10 * License as published by the Free Software Foundation; either 11 * version 2 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Library General Public License for more details. 17 * 18 * You should have received a copy of the GNU Library General Public 19 * License along with this library; if not, write to the 20 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 21 * Boston, MA 02110-1301, USA. 22 */ 23 24 #ifndef _GST_MPEGTS_PRIVATE_H_ 25 #define _GST_MPEGTS_PRIVATE_H_ 26 27 G_BEGIN_DECLS 28 29 GST_DEBUG_CATEGORY_EXTERN (mpegts_debug); 30 #define GST_CAT_DEFAULT mpegts_debug 31 32 G_GNUC_INTERNAL void __initialize_sections (void); 33 G_GNUC_INTERNAL void __initialize_descriptors (void); 34 G_GNUC_INTERNAL guint32 _calc_crc32 (const guint8 *data, guint datalen); 35 G_GNUC_INTERNAL gchar *get_encoding_and_convert (const gchar *text, guint length); 36 G_GNUC_INTERNAL gchar *convert_lang_code (guint8 * data); 37 G_GNUC_INTERNAL guint8 *dvb_text_from_utf8 (const gchar * text, gsize *out_size); 38 G_GNUC_INTERNAL GstMpegtsDescriptor *_new_descriptor (guint8 tag, guint8 length); 39 G_GNUC_INTERNAL GstMpegtsDescriptor *_new_descriptor_with_extension (guint8 tag, 40 guint8 tag_extension, guint8 length); 41 G_GNUC_INTERNAL void _packetize_descriptor_array (GPtrArray * array, 42 guint8 ** out_data); 43 G_GNUC_INTERNAL GstMpegtsSection *_gst_mpegts_section_init (guint16 pid, guint8 table_id); 44 G_GNUC_INTERNAL void _packetize_common_section (GstMpegtsSection * section, gsize length); 45 46 typedef gpointer (*GstMpegtsParseFunc) (GstMpegtsSection *section); 47 G_GNUC_INTERNAL gpointer __common_section_checks (GstMpegtsSection *section, 48 guint minsize, 49 GstMpegtsParseFunc parsefunc, 50 GDestroyNotify destroynotify); 51 52 #define __common_desc_check_base(desc, tagtype, retval) \ 53 if (G_UNLIKELY ((desc)->data == NULL)) { \ 54 GST_WARNING ("Descriptor is empty (data field == NULL)"); \ 55 return retval; \ 56 } \ 57 if (G_UNLIKELY ((desc)->tag != (tagtype))) { \ 58 GST_WARNING ("Wrong descriptor type (Got 0x%02x, expected 0x%02x)", \ 59 (desc)->tag, tagtype); \ 60 return retval; \ 61 } \ 62 63 #define __common_desc_checks(desc, tagtype, minlen, retval) \ 64 __common_desc_check_base(desc, tagtype, retval); \ 65 if (G_UNLIKELY ((desc)->length < (minlen))) { \ 66 GST_WARNING ("Descriptor too small (Got %d, expected at least %d)", \ 67 (desc)->length, minlen); \ 68 return retval; \ 69 } 70 #define __common_desc_checks_exact(desc, tagtype, len, retval) \ 71 __common_desc_check_base(desc, tagtype, retval); \ 72 if (G_UNLIKELY ((desc)->length != (len))) { \ 73 GST_WARNING ("Wrong descriptor size (Got %d, expected %d)", \ 74 (desc)->length, len); \ 75 return retval; \ 76 } 77 78 #define __common_desc_ext_check_base(desc, tagexttype, retval) \ 79 if (G_UNLIKELY ((desc)->data == NULL)) { \ 80 GST_WARNING ("Descriptor is empty (data field == NULL)"); \ 81 return retval; \ 82 } \ 83 if (G_UNLIKELY ((desc)->tag != 0x7f) || \ 84 ((desc)->tag_extension != (tagexttype))) { \ 85 GST_WARNING ("Wrong descriptor type (Got 0x%02x, expected 0x%02x)", \ 86 (desc)->tag_extension, tagexttype); \ 87 return retval; \ 88 } 89 #define __common_desc_ext_checks(desc, tagexttype, minlen, retval) \ 90 __common_desc_ext_check_base(desc, tagexttype, retval); \ 91 if (G_UNLIKELY ((desc)->length < (minlen))) { \ 92 GST_WARNING ("Descriptor too small (Got %d, expected at least %d)", \ 93 (desc)->length, minlen); \ 94 return retval; \ 95 } 96 #define __common_desc_ext_checks_exact(desc, tagexttype, len, retval) \ 97 __common_desc_ext_check_base(desc, tagexttype, retval); \ 98 if (G_UNLIKELY ((desc)->length != (len))) { \ 99 GST_WARNING ("Wrong descriptor size (Got %d, expected %d)", \ 100 (desc)->length, len); \ 101 return retval; \ 102 } 103 104 G_END_DECLS 105 106 #endif /* _GST_MPEGTS_PRIVATE_H_ */ 107