mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
mpegts: Add init functions for descriptor/section
This commit is contained in:
parent
4630dfda05
commit
b1c5143b79
4 changed files with 77 additions and 11 deletions
|
@ -33,6 +33,11 @@ G_GNUC_INTERNAL void __initialize_descriptors (void);
|
||||||
G_GNUC_INTERNAL guint32 _calc_crc32 (const guint8 *data, guint datalen);
|
G_GNUC_INTERNAL guint32 _calc_crc32 (const guint8 *data, guint datalen);
|
||||||
G_GNUC_INTERNAL gchar *get_encoding_and_convert (const gchar *text, guint length);
|
G_GNUC_INTERNAL gchar *get_encoding_and_convert (const gchar *text, guint length);
|
||||||
G_GNUC_INTERNAL guint8 *dvb_text_from_utf8 (const gchar * text, gsize *out_size);
|
G_GNUC_INTERNAL guint8 *dvb_text_from_utf8 (const gchar * text, gsize *out_size);
|
||||||
|
G_GNUC_INTERNAL void _free_descriptor (GstMpegTsDescriptor *descriptor);
|
||||||
|
G_GNUC_INTERNAL GstMpegTsDescriptor *_new_descriptor (guint8 tag, guint8 length);
|
||||||
|
G_GNUC_INTERNAL GstMpegTsDescriptor *_new_descriptor_with_extension (guint8 tag,
|
||||||
|
guint8 tag_extension, guint8 length);
|
||||||
|
G_GNUC_INTERNAL GstMpegTsSection *_gst_mpegts_section_init (guint16 pid, guint8 table_id);
|
||||||
|
|
||||||
typedef gpointer (*GstMpegTsParseFunc) (GstMpegTsSection *section);
|
typedef gpointer (*GstMpegTsParseFunc) (GstMpegTsSection *section);
|
||||||
G_GNUC_INTERNAL gpointer __common_desc_checks (GstMpegTsSection *section,
|
G_GNUC_INTERNAL gpointer __common_desc_checks (GstMpegTsSection *section,
|
||||||
|
|
|
@ -627,6 +627,51 @@ failed:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstMpegTsDescriptor *
|
||||||
|
_new_descriptor (guint8 tag, guint8 length)
|
||||||
|
{
|
||||||
|
GstMpegTsDescriptor *descriptor;
|
||||||
|
guint8 *data;
|
||||||
|
|
||||||
|
descriptor = g_slice_new (GstMpegTsDescriptor);
|
||||||
|
|
||||||
|
descriptor->tag = tag;
|
||||||
|
descriptor->tag_extension = 0;
|
||||||
|
descriptor->length = length;
|
||||||
|
|
||||||
|
descriptor->data = g_malloc (length + 2);
|
||||||
|
|
||||||
|
data = descriptor->data;
|
||||||
|
|
||||||
|
*data++ = descriptor->tag;
|
||||||
|
*data = descriptor->length;
|
||||||
|
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
GstMpegTsDescriptor *
|
||||||
|
_new_descriptor_with_extension (guint8 tag, guint8 tag_extension, guint8 length)
|
||||||
|
{
|
||||||
|
GstMpegTsDescriptor *descriptor;
|
||||||
|
guint8 *data;
|
||||||
|
|
||||||
|
descriptor = g_slice_new (GstMpegTsDescriptor);
|
||||||
|
|
||||||
|
descriptor->tag = tag;
|
||||||
|
descriptor->tag_extension = tag_extension;
|
||||||
|
descriptor->length = length;
|
||||||
|
|
||||||
|
descriptor->data = g_malloc (length + 3);
|
||||||
|
|
||||||
|
data = descriptor->data;
|
||||||
|
|
||||||
|
*data++ = descriptor->tag;
|
||||||
|
*data++ = descriptor->tag_extension;
|
||||||
|
*data = descriptor->length;
|
||||||
|
|
||||||
|
return descriptor;
|
||||||
|
}
|
||||||
|
|
||||||
static GstMpegTsDescriptor *
|
static GstMpegTsDescriptor *
|
||||||
_copy_descriptor (GstMpegTsDescriptor * desc)
|
_copy_descriptor (GstMpegTsDescriptor * desc)
|
||||||
{
|
{
|
||||||
|
@ -638,7 +683,7 @@ _copy_descriptor (GstMpegTsDescriptor * desc)
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
_free_descriptor (GstMpegTsDescriptor * desc)
|
_free_descriptor (GstMpegTsDescriptor * desc)
|
||||||
{
|
{
|
||||||
g_free ((gpointer) desc->data);
|
g_free ((gpointer) desc->data);
|
||||||
|
|
|
@ -254,7 +254,7 @@ struct _GstMpegTsDescriptor
|
||||||
guint8 tag;
|
guint8 tag;
|
||||||
guint8 tag_extension;
|
guint8 tag_extension;
|
||||||
guint8 length;
|
guint8 length;
|
||||||
const guint8 *data;
|
guint8 *data;
|
||||||
};
|
};
|
||||||
|
|
||||||
GPtrArray *gst_mpegts_parse_descriptors (guint8 * buffer, gsize buf_len);
|
GPtrArray *gst_mpegts_parse_descriptors (guint8 * buffer, gsize buf_len);
|
||||||
|
|
|
@ -715,6 +715,24 @@ _identify_section (guint16 pid, guint8 table_id)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstMpegTsSection *
|
||||||
|
_gst_mpegts_section_init (guint16 pid, guint8 table_id)
|
||||||
|
{
|
||||||
|
GstMpegTsSection *section;
|
||||||
|
|
||||||
|
section = g_slice_new0 (GstMpegTsSection);
|
||||||
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (section), 0, MPEG_TYPE_TS_SECTION,
|
||||||
|
(GstMiniObjectCopyFunction) _gst_mpegts_section_copy, NULL,
|
||||||
|
(GstMiniObjectFreeFunction) _gst_mpegts_section_free);
|
||||||
|
|
||||||
|
section->pid = pid;
|
||||||
|
section->table_id = table_id;
|
||||||
|
section->current_next_indicator = TRUE;
|
||||||
|
section->section_type = _identify_section (pid, table_id);
|
||||||
|
|
||||||
|
return section;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_mpegts_section_new:
|
* gst_mpegts_section_new:
|
||||||
* @pid: the PID to which this section belongs
|
* @pid: the PID to which this section belongs
|
||||||
|
@ -739,6 +757,7 @@ gst_mpegts_section_new (guint16 pid, guint8 * data, gsize data_size)
|
||||||
{
|
{
|
||||||
GstMpegTsSection *res = NULL;
|
GstMpegTsSection *res = NULL;
|
||||||
guint8 tmp;
|
guint8 tmp;
|
||||||
|
guint8 table_id;
|
||||||
guint16 section_length;
|
guint16 section_length;
|
||||||
|
|
||||||
/* Check for length */
|
/* Check for length */
|
||||||
|
@ -746,15 +765,14 @@ gst_mpegts_section_new (guint16 pid, guint8 * data, gsize data_size)
|
||||||
if (G_UNLIKELY (data_size < section_length + 3))
|
if (G_UNLIKELY (data_size < section_length + 3))
|
||||||
goto short_packet;
|
goto short_packet;
|
||||||
|
|
||||||
res = g_slice_new0 (GstMpegTsSection);
|
/* Table id is in first byte */
|
||||||
gst_mini_object_init (GST_MINI_OBJECT_CAST (res), 0, MPEG_TYPE_TS_SECTION,
|
table_id = *data;
|
||||||
(GstMiniObjectCopyFunction) _gst_mpegts_section_copy, NULL,
|
|
||||||
(GstMiniObjectFreeFunction) _gst_mpegts_section_free);
|
res = _gst_mpegts_section_init (pid, table_id);
|
||||||
|
|
||||||
res->pid = pid;
|
|
||||||
res->data = data;
|
res->data = data;
|
||||||
/* table_id : 8 bit */
|
/* table_id (already parsed) : 8 bit */
|
||||||
res->table_id = *data++;
|
data++;
|
||||||
/* section_syntax_indicator : 1 bit
|
/* section_syntax_indicator : 1 bit
|
||||||
* other_fields (reserved) : 3 bit*/
|
* other_fields (reserved) : 3 bit*/
|
||||||
res->short_section = (*data & 0x80) == 0x00;
|
res->short_section = (*data & 0x80) == 0x00;
|
||||||
|
@ -780,8 +798,6 @@ gst_mpegts_section_new (guint16 pid, guint8 * data, gsize data_size)
|
||||||
res->last_section_number = *data;
|
res->last_section_number = *data;
|
||||||
}
|
}
|
||||||
|
|
||||||
res->section_type = _identify_section (res->pid, res->table_id);
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
short_packet:
|
short_packet:
|
||||||
|
|
Loading…
Reference in a new issue