2013-06-23 06:41:12 +00:00
|
|
|
/*
|
|
|
|
* mpegts.h -
|
|
|
|
* Copyright (C) 2013 Edward Hervey
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Edward Hervey <edward@collabora.com>
|
|
|
|
*
|
2014-10-07 10:12:04 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
2013-06-23 06:41:12 +00:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GST_MPEGTS_PRIVATE_H_
|
|
|
|
#define _GST_MPEGTS_PRIVATE_H_
|
|
|
|
|
2014-01-06 15:01:22 +00:00
|
|
|
G_BEGIN_DECLS
|
|
|
|
|
2017-08-11 13:39:07 +00:00
|
|
|
GST_DEBUG_CATEGORY_EXTERN (mpegts_debug);
|
|
|
|
#define GST_CAT_DEFAULT mpegts_debug
|
2013-06-23 06:41:12 +00:00
|
|
|
|
2020-12-14 09:50:02 +00:00
|
|
|
G_GNUC_INTERNAL void __initialize_sections (void);
|
2013-07-03 15:59:02 +00:00
|
|
|
G_GNUC_INTERNAL void __initialize_descriptors (void);
|
|
|
|
G_GNUC_INTERNAL guint32 _calc_crc32 (const guint8 *data, guint datalen);
|
2013-07-03 16:52:18 +00:00
|
|
|
G_GNUC_INTERNAL gchar *get_encoding_and_convert (const gchar *text, guint length);
|
2014-06-01 08:44:23 +00:00
|
|
|
G_GNUC_INTERNAL gchar *convert_lang_code (guint8 * data);
|
2013-10-30 09:43:21 +00:00
|
|
|
G_GNUC_INTERNAL guint8 *dvb_text_from_utf8 (const gchar * text, gsize *out_size);
|
2014-06-25 12:50:05 +00:00
|
|
|
G_GNUC_INTERNAL GstMpegtsDescriptor *_new_descriptor (guint8 tag, guint8 length);
|
|
|
|
G_GNUC_INTERNAL GstMpegtsDescriptor *_new_descriptor_with_extension (guint8 tag,
|
2013-10-28 13:39:49 +00:00
|
|
|
guint8 tag_extension, guint8 length);
|
2013-10-28 13:44:13 +00:00
|
|
|
G_GNUC_INTERNAL void _packetize_descriptor_array (GPtrArray * array,
|
|
|
|
guint8 ** out_data);
|
2014-06-25 12:50:05 +00:00
|
|
|
G_GNUC_INTERNAL GstMpegtsSection *_gst_mpegts_section_init (guint16 pid, guint8 table_id);
|
|
|
|
G_GNUC_INTERNAL void _packetize_common_section (GstMpegtsSection * section, gsize length);
|
2013-06-23 06:41:12 +00:00
|
|
|
|
2014-06-25 12:50:05 +00:00
|
|
|
typedef gpointer (*GstMpegtsParseFunc) (GstMpegtsSection *section);
|
|
|
|
G_GNUC_INTERNAL gpointer __common_section_checks (GstMpegtsSection *section,
|
2014-02-20 17:14:51 +00:00
|
|
|
guint minsize,
|
2014-06-25 12:50:05 +00:00
|
|
|
GstMpegtsParseFunc parsefunc,
|
2014-02-20 17:14:51 +00:00
|
|
|
GDestroyNotify destroynotify);
|
2013-07-08 06:42:18 +00:00
|
|
|
|
2014-02-24 14:52:53 +00:00
|
|
|
#define __common_desc_check_base(desc, tagtype, retval) \
|
|
|
|
if (G_UNLIKELY ((desc)->data == NULL)) { \
|
|
|
|
GST_WARNING ("Descriptor is empty (data field == NULL)"); \
|
|
|
|
return retval; \
|
|
|
|
} \
|
|
|
|
if (G_UNLIKELY ((desc)->tag != (tagtype))) { \
|
|
|
|
GST_WARNING ("Wrong descriptor type (Got 0x%02x, expected 0x%02x)", \
|
|
|
|
(desc)->tag, tagtype); \
|
|
|
|
return retval; \
|
|
|
|
} \
|
|
|
|
|
|
|
|
#define __common_desc_checks(desc, tagtype, minlen, retval) \
|
|
|
|
__common_desc_check_base(desc, tagtype, retval); \
|
|
|
|
if (G_UNLIKELY ((desc)->length < (minlen))) { \
|
|
|
|
GST_WARNING ("Descriptor too small (Got %d, expected at least %d)", \
|
|
|
|
(desc)->length, minlen); \
|
|
|
|
return retval; \
|
|
|
|
}
|
|
|
|
#define __common_desc_checks_exact(desc, tagtype, len, retval) \
|
|
|
|
__common_desc_check_base(desc, tagtype, retval); \
|
|
|
|
if (G_UNLIKELY ((desc)->length != (len))) { \
|
|
|
|
GST_WARNING ("Wrong descriptor size (Got %d, expected %d)", \
|
|
|
|
(desc)->length, len); \
|
|
|
|
return retval; \
|
|
|
|
}
|
2014-02-20 18:08:33 +00:00
|
|
|
|
2014-03-30 19:02:10 +00:00
|
|
|
#define __common_desc_ext_check_base(desc, tagexttype, retval) \
|
|
|
|
if (G_UNLIKELY ((desc)->data == NULL)) { \
|
|
|
|
GST_WARNING ("Descriptor is empty (data field == NULL)"); \
|
|
|
|
return retval; \
|
|
|
|
} \
|
|
|
|
if (G_UNLIKELY ((desc)->tag != 0x7f) || \
|
|
|
|
((desc)->tag_extension != (tagexttype))) { \
|
|
|
|
GST_WARNING ("Wrong descriptor type (Got 0x%02x, expected 0x%02x)", \
|
|
|
|
(desc)->tag_extension, tagexttype); \
|
|
|
|
return retval; \
|
|
|
|
}
|
|
|
|
#define __common_desc_ext_checks(desc, tagexttype, minlen, retval) \
|
|
|
|
__common_desc_ext_check_base(desc, tagexttype, retval); \
|
|
|
|
if (G_UNLIKELY ((desc)->length < (minlen))) { \
|
|
|
|
GST_WARNING ("Descriptor too small (Got %d, expected at least %d)", \
|
|
|
|
(desc)->length, minlen); \
|
|
|
|
return retval; \
|
|
|
|
}
|
|
|
|
#define __common_desc_ext_checks_exact(desc, tagexttype, len, retval) \
|
|
|
|
__common_desc_ext_check_base(desc, tagexttype, retval); \
|
|
|
|
if (G_UNLIKELY ((desc)->length != (len))) { \
|
|
|
|
GST_WARNING ("Wrong descriptor size (Got %d, expected %d)", \
|
|
|
|
(desc)->length, len); \
|
|
|
|
return retval; \
|
|
|
|
}
|
|
|
|
|
2014-01-06 15:01:22 +00:00
|
|
|
G_END_DECLS
|
|
|
|
|
2013-06-23 06:41:12 +00:00
|
|
|
#endif /* _GST_MPEGTS_PRIVATE_H_ */
|