mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
gst/mpegtsparse/: Added descriptor searching infrastructure from Fluendo TS demuxer.
Original commit message from CVS: * gst/mpegtsparse/Makefile.am: * gst/mpegtsparse/gstmpegdesc.c: * gst/mpegtsparse/gstmpegdesc.h: * gst/mpegtsparse/mpegtspacketizer.c: * gst/mpegtsparse/mpegtsparse.c: Added descriptor searching infrastructure from Fluendo TS demuxer. Add channel name and provider to the sdt structure sent in the bus message.
This commit is contained in:
parent
9b1dd1311d
commit
32b0966ec7
6 changed files with 532 additions and 4 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2008-01-22 Zaheer Abbas Merali <zaheerabbas at merali dot org>
|
||||
|
||||
* gst/mpegtsparse/Makefile.am:
|
||||
* gst/mpegtsparse/gstmpegdesc.c:
|
||||
* gst/mpegtsparse/gstmpegdesc.h:
|
||||
* gst/mpegtsparse/mpegtspacketizer.c:
|
||||
* gst/mpegtsparse/mpegtsparse.c:
|
||||
Added descriptor searching infrastructure from Fluendo TS demuxer.
|
||||
Add channel name and provider to the sdt structure sent in the
|
||||
bus message.
|
||||
|
||||
2008-01-22 Julien Moutte <julien@fluendo.com>
|
||||
|
||||
* gst/h264parse/gsth264parse.c: (gst_h264_parse_chain_forward):
|
||||
|
|
|
@ -2,7 +2,8 @@ plugin_LTLIBRARIES = libgstmpegtsparse.la
|
|||
|
||||
libgstmpegtsparse_la_SOURCES = \
|
||||
mpegtsparse.c \
|
||||
mpegtspacketizer.c
|
||||
mpegtspacketizer.c \
|
||||
gstmpegdesc.c
|
||||
|
||||
libgstmpegtsparse_la_CFLAGS = $(GST_CFLAGS)
|
||||
libgstmpegtsparse_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
|
||||
|
@ -10,4 +11,5 @@ libgstmpegtsparse_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
|||
|
||||
noinst_HEADERS = \
|
||||
mpegtsparse.h \
|
||||
mpegtspacketizer.h
|
||||
mpegtspacketizer.h \
|
||||
gstmpegdesc.h
|
||||
|
|
198
gst/mpegtsparse/gstmpegdesc.c
Normal file
198
gst/mpegtsparse/gstmpegdesc.c
Normal file
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Fluendo MPEG Demuxer plugin.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Fluendo, S.L.
|
||||
* Portions created by Fluendo, S.L. are Copyright (C) 2005
|
||||
* Fluendo, S.L. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Wim Taymans <wim@fluendo.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU Lesser General Public License Version 2 or later (the "LGPL"),
|
||||
* in which case the provisions of the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of the MPL or the LGPL.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
#include "gstmpegdesc.h"
|
||||
|
||||
GST_DEBUG_CATEGORY (gstflumpegdesc_debug);
|
||||
#define GST_CAT_DEFAULT (gstflumpegdesc_debug)
|
||||
|
||||
void
|
||||
gst_mpeg_descriptor_free (GstMPEGDescriptor * desc)
|
||||
{
|
||||
g_return_if_fail (desc != NULL);
|
||||
|
||||
g_free (desc);
|
||||
}
|
||||
|
||||
static guint
|
||||
gst_mpeg_descriptor_parse_1 (guint8 * data, guint size)
|
||||
{
|
||||
guint8 tag;
|
||||
guint8 length;
|
||||
|
||||
/* need at least 2 bytes for tag and length */
|
||||
if (size < 2)
|
||||
return 0;
|
||||
|
||||
tag = *data++;
|
||||
length = *data++;
|
||||
size -= 2;
|
||||
|
||||
GST_DEBUG ("tag: 0x%02x, length: %d", tag, length);
|
||||
|
||||
if (length > size)
|
||||
return 0;
|
||||
|
||||
return length + 2;;
|
||||
}
|
||||
|
||||
GstMPEGDescriptor *
|
||||
gst_mpeg_descriptor_parse (guint8 * data, guint size)
|
||||
{
|
||||
guint8 *current;
|
||||
guint consumed, total, n_desc;
|
||||
GstMPEGDescriptor *result;
|
||||
|
||||
g_return_val_if_fail (data != NULL, NULL);
|
||||
|
||||
current = data;
|
||||
total = 0;
|
||||
n_desc = 0;
|
||||
|
||||
do {
|
||||
consumed = gst_mpeg_descriptor_parse_1 (current, size);
|
||||
|
||||
if (consumed > 0) {
|
||||
current += consumed;
|
||||
total += consumed;
|
||||
size -= consumed;
|
||||
n_desc++;
|
||||
}
|
||||
}
|
||||
while (consumed > 0);
|
||||
|
||||
GST_DEBUG ("parsed %d descriptors", n_desc);
|
||||
|
||||
if (total == 0)
|
||||
return NULL;
|
||||
|
||||
result = g_malloc (sizeof (GstMPEGDescriptor) + total);
|
||||
result->n_desc = n_desc;
|
||||
result->data_length = total;
|
||||
result->data = ((guint8 *) result) + sizeof (GstMPEGDescriptor);
|
||||
|
||||
memcpy (result->data, data, total);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
guint
|
||||
gst_mpeg_descriptor_n_desc (GstMPEGDescriptor * desc)
|
||||
{
|
||||
g_return_val_if_fail (desc != NULL, 0);
|
||||
|
||||
return desc->n_desc;
|
||||
}
|
||||
|
||||
guint8 *
|
||||
gst_mpeg_descriptor_find (GstMPEGDescriptor * desc, gint tag)
|
||||
{
|
||||
gint length;
|
||||
guint8 *current;
|
||||
guint size;
|
||||
|
||||
g_return_val_if_fail (desc != NULL, NULL);
|
||||
|
||||
current = desc->data;
|
||||
length = desc->data_length;
|
||||
|
||||
while (length > 0) {
|
||||
if (DESC_TAG (current) == tag)
|
||||
return current;
|
||||
|
||||
size = DESC_LENGTH (current) + 2;
|
||||
|
||||
current += size;
|
||||
length -= size;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* array needs freeing afterwards */
|
||||
GArray *
|
||||
gst_mpeg_descriptor_find_all (GstMPEGDescriptor * desc, gint tag)
|
||||
{
|
||||
GArray *all;
|
||||
|
||||
gint length;
|
||||
guint8 *current;
|
||||
guint size;
|
||||
|
||||
g_return_val_if_fail (desc != NULL, NULL);
|
||||
all = g_array_new (TRUE, TRUE, sizeof (guint8 *));
|
||||
|
||||
current = desc->data;
|
||||
length = desc->data_length;
|
||||
|
||||
while (length > 0) {
|
||||
if (DESC_TAG (current) == tag)
|
||||
g_array_append_val (all, current);
|
||||
size = DESC_LENGTH (current) + 2;
|
||||
|
||||
current += size;
|
||||
length -= size;
|
||||
}
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
guint8 *
|
||||
gst_mpeg_descriptor_nth (GstMPEGDescriptor * desc, guint i)
|
||||
{
|
||||
gint length;
|
||||
guint8 *current;
|
||||
guint size;
|
||||
|
||||
g_return_val_if_fail (desc != NULL, NULL);
|
||||
|
||||
if (i > desc->n_desc)
|
||||
return NULL;
|
||||
|
||||
current = desc->data;
|
||||
length = desc->data_length;
|
||||
|
||||
while (length > 0) {
|
||||
if (i == 0)
|
||||
return current;
|
||||
|
||||
size = DESC_LENGTH (current) + 2;
|
||||
|
||||
current += size;
|
||||
length -= size;
|
||||
i--;
|
||||
|
||||
}
|
||||
return NULL;
|
||||
}
|
283
gst/mpegtsparse/gstmpegdesc.h
Normal file
283
gst/mpegtsparse/gstmpegdesc.h
Normal file
|
@ -0,0 +1,283 @@
|
|||
/*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/.
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS"
|
||||
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing rights and limitations
|
||||
* under the License.
|
||||
*
|
||||
* The Original Code is Fluendo MPEG Demuxer plugin.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Fluendo, S.L.
|
||||
* Portions created by Fluendo, S.L. are Copyright (C) 2005
|
||||
* Fluendo, S.L. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Wim Taymans <wim@fluendo.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* the GNU Lesser General Public License Version 2 or later (the "LGPL"),
|
||||
* in which case the provisions of the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of the MPL or the LGPL.
|
||||
*/
|
||||
|
||||
#ifndef __GST_MPEG_DESC_H__
|
||||
#define __GST_MPEG_DESC_H__
|
||||
|
||||
#include <glib.h>
|
||||
/*
|
||||
* descriptor_tag TS PS Identification
|
||||
* 0 n/a n/a Reserved
|
||||
* 1 n/a n/a Reserved
|
||||
* 2 X X video_stream_descriptor
|
||||
* 3 X X audio_stream_descriptor
|
||||
* 4 X X hierarchy_descriptor
|
||||
* 5 X X registration_descriptor
|
||||
* 6 X X data_stream_alignment_descriptor
|
||||
* 7 X X target_background_grid_descriptor
|
||||
* 8 X X video_window_descriptor
|
||||
* 9 X X CA_descriptor
|
||||
* 10 X X ISO_639_language_descriptor
|
||||
* 11 X X system_clock_descriptor
|
||||
* 12 X X multiplex_buffer_utilization_descriptor
|
||||
* 13 X X copyright_descriptor
|
||||
* 14 X maximum bitrate descriptor
|
||||
* 15 X X private data indicator descriptor
|
||||
* 16 X X smoothing buffer descriptor
|
||||
* 17 X STD_descriptor
|
||||
* 18 X X IBP descriptor
|
||||
* 19-63 n/a n/a ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved
|
||||
* 64-255 n/a n/a User Private
|
||||
*/
|
||||
#define DESC_VIDEO_STREAM 2
|
||||
#define DESC_AUDIO_STREAM 3
|
||||
#define DESC_HIERARCHY 4
|
||||
#define DESC_REGISTRATION 5
|
||||
#define DESC_DATA_STREAM_ALIGNMENT 6
|
||||
#define DESC_TARGET_BACKGROUND_GRID 7
|
||||
#define DESC_VIDEO_WINDOW 8
|
||||
#define DESC_CA 9
|
||||
#define DESC_ISO_639_LANGUAGE 10
|
||||
#define DESC_SYSTEM_CLOCK 11
|
||||
#define DESC_MULTIPLEX_BUFFER_UTILISATION 12
|
||||
#define DESC_COPYRIGHT 13
|
||||
#define DESC_MAXIMUM_BITRATE 14
|
||||
#define DESC_PRIVATE_DATA_INDICATOR 15
|
||||
#define DESC_SMOOTHING_BUFFER 16
|
||||
#define DESC_STD 17
|
||||
#define DESC_IBP 18
|
||||
|
||||
#define DESC_DIRAC_TC_PRIVATE 0xAC
|
||||
|
||||
/* DVB tags */
|
||||
#define DESC_DVB_NETWORK_NAME 0x40
|
||||
#define DESC_DVB_SERVICE_LIST 0x41
|
||||
#define DESC_DVB_STUFFING 0x42
|
||||
#define DESC_DVB_SATELLITE_DELIVERY_SYSTEM 0x43
|
||||
#define DESC_DVB_CABLE_DELIVERY_SYSTEM 0x44
|
||||
#define DESC_DVB_VBI_DATA 0x45
|
||||
#define DESC_DVB_VBI_TELETEXT 0x46
|
||||
#define DESC_DVB_BOUQUET_NAME 0x47
|
||||
#define DESC_DVB_SERVICE 0x48
|
||||
#define DESC_DVB_COUNTRY_AVAILABILITY 0x49
|
||||
#define DESC_DVB_LINKAGE 0x4A
|
||||
#define DESC_DVB_NVOD_REFERENCE 0x4B
|
||||
#define DESC_DVB_TIME_SHIFTED_SERVICE 0x4C
|
||||
#define DESC_DVB_SHORT_EVENT 0x4D
|
||||
#define DESC_DVB_EXTENDED_EVENT 0x4E
|
||||
#define DESC_DVB_TIME_SHIFTED_EVENT 0x4F
|
||||
#define DESC_DVB_COMPONENT 0x50
|
||||
#define DESC_DVB_MOSAIC 0x51
|
||||
#define DESC_DVB_STREAM_IDENTIFIER 0x52
|
||||
#define DESC_DVB_CA_IDENTIFIER 0x53
|
||||
#define DESC_DVB_CONTENT 0x54
|
||||
#define DESC_DVB_PARENTAL_RATING 0x55
|
||||
#define DESC_DVB_TELETEXT 0x56
|
||||
#define DESC_DVB_TELEPHONE 0x57
|
||||
#define DESC_DVB_LOCAL_TIME_OFFSET 0x58
|
||||
#define DESC_DVB_SUBTITLING 0x59
|
||||
#define DESC_DVB_TERRESTRIAL_DELIVERY_SYSTEM 0x5A
|
||||
#define DESC_DVB_MULTILINGUAL_NETWORK_NAME 0x5B
|
||||
#define DESC_DVB_MULTILINGUAL_BOUQUET_NAME 0x5C
|
||||
#define DESC_DVB_MULTILINGUAL_SERVICE_NAME 0x5D
|
||||
#define DESC_DVB_MULTILINGUAL_COMPONENT 0x5E
|
||||
#define DESC_DVB_PRIVATE_DATA 0x5F
|
||||
#define DESC_DVB_SERVICE_MOVE 0x60
|
||||
#define DESC_DVB_SHORT_SMOOTHING_BUFFER 0x61
|
||||
#define DESC_DVB_FREQUENCY_LIST 0x62
|
||||
#define DESC_DVB_PARTIAL_TRANSPORT_STREAM 0x63
|
||||
#define DESC_DVB_DATA_BROADCAST 0x64
|
||||
#define DESC_DVB_SCRAMBLING 0x65
|
||||
#define DESC_DVB_DATA_BROADCAST_ID 0x66
|
||||
#define DESC_DVB_TRANSPORT_STREAM 0x67
|
||||
#define DESC_DVB_DSNG 0x68
|
||||
#define DESC_DVB_PDC 0x69
|
||||
#define DESC_DVB_AC3 0x6A
|
||||
#define DESC_DVB_ANCILLARY_DATA 0x6B
|
||||
#define DESC_DVB_CELL_LIST 0x6C
|
||||
#define DESC_DVB_CELL_FREQUENCY_LINK 0x6D
|
||||
#define DESC_DVB_ANNOUNCEMENT_SUPPORT 0x6E
|
||||
#define DESC_DVB_APPLICATION_SIGNALLING 0x6F
|
||||
#define DESC_DVB_ADAPTATION_FIELD_DATA 0x70
|
||||
#define DESC_DVB_SERVICE_IDENTIFIER 0x71
|
||||
#define DESC_DVB_SERVICE_AVAILABILITY 0x72
|
||||
#define DESC_DVB_DEFAULT_AUTHORITY 0x73
|
||||
#define DESC_DVB_RELATED_CONTENT 0x74
|
||||
#define DESC_DVB_TVA_ID 0x75
|
||||
#define DESC_DVB_CONTENT_IDENTIFIER 0x76
|
||||
#define DESC_DVB_TIMESLICE_FEC_IDENTIFIER 0x77
|
||||
#define DESC_DVB_ECM_REPETITION_RATE 0x78
|
||||
#define DESC_DVB_S2_SATELLITE_DELIVERY_SYSTEM 0x79
|
||||
#define DESC_DVB_ENHANCED_AC3 0x7A
|
||||
#define DESC_DVB_DTS 0x7B
|
||||
#define DESC_DVB_AAC 0x7C
|
||||
/* 0x7D and 0x7E are reserved for future use */
|
||||
#define DESC_DVB_EXTENSION 0x7F
|
||||
/* 0x80 - 0xFE are user defined */
|
||||
/* 0xFF is forbidden */
|
||||
|
||||
/* common for all descriptors */
|
||||
#define DESC_TAG(desc) (desc[0])
|
||||
#define DESC_LENGTH(desc) (desc[1])
|
||||
|
||||
/* video_stream_descriptor */
|
||||
#define DESC_VIDEO_STREAM_multiple_framerate_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||
#define DESC_VIDEO_STREAM_frame_rate_code(desc) (((desc)[2] & 0x38) >> 3)
|
||||
#define DESC_VIDEO_STREAM_MPEG_1_only_flag(desc) (((desc)[2] & 0x04) == 0x04)
|
||||
#define DESC_VIDEO_STREAM_constrained_parameter_flag(desc) (((desc)[2] & 0x02) == 0x02)
|
||||
#define DESC_VIDEO_STREAM_still_picture_flag(desc) (((desc)[2] & 0x01) == 0x01)
|
||||
/* if (MPEG_1_only_flag == 1) */
|
||||
#define DESC_VIDEO_STREAM_profile_and_level_indication(desc) ((desc)[3])
|
||||
#define DESC_VIDEO_STREAM_chroma_format(desc) (((desc)[4] & 0xc0) >> 6)
|
||||
#define DESC_VIDEO_STREAM_frame_rate_extension_flag(desc) (((desc)[4] & 0x20) == 0x20)
|
||||
|
||||
/* audio_stream_descriptor */
|
||||
#define DESC_AUDIO_STREAM_free_format_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||
#define DESC_AUDIO_STREAM_ID(desc) (((desc)[2] & 0x40) == 0x40)
|
||||
#define DESC_AUDIO_STREAM_layer(desc) (((desc)[2] & 0x30) >> 4)
|
||||
#define DESC_AUDIO_STREAM_variable_rate_audio_indicator(desc) (((desc)[2] & 0x08) == 0x08)
|
||||
|
||||
/* hierarchy_descriptor */
|
||||
#define DESC_HIERARCHY_hierarchy_type(desc) (((desc)[2] & 0x0f))
|
||||
#define DESC_HIERARCHY_hierarchy_layer_index(desc) (((desc)[3] & 0x3f))
|
||||
#define DESC_HIERARCHY_hierarchy_embedded_layer_index(desc) (((desc)[4] & 0x3f))
|
||||
#define DESC_HIERARCHY_hierarchy_channel(desc) (((desc)[5] & 0x3f))
|
||||
|
||||
/* registration_descriptor */
|
||||
#define DESC_REGISTRATION_format_identifier(desc) (GST_READ_UINT32_BE ((desc)+2))
|
||||
#define DESC_REGISTRATION_additional_ident_info_len(desc) ((desc)[1] - 4)
|
||||
#define DESC_REGISTRATION_additional_ident_info(desc) (&(desc)[6])
|
||||
|
||||
/* data_stream_alignment_descriptor */
|
||||
#define DESC_DATA_STREAM_ALIGNMENT_alignment_type(desc) ((desc)[2])
|
||||
|
||||
/* target_background_grid_descriptor */
|
||||
#define DESC_TARGET_BACKGROUND_GRID_horizontal_size(desc) (GST_READ_UINT16_BE ((desc)+2) >> 2)
|
||||
#define DESC_TARGET_BACKGROUND_GRID_vertical_size(desc) ((GST_READ_UINT32_BE ((desc)+2) & 0x0003fff0) >> 4)
|
||||
#define DESC_TARGET_BACKGROUND_GRID_aspect_ratio_information(desc) ((desc)[5] & 0x0f)
|
||||
|
||||
/* video_window_descriptor */
|
||||
#define DESC_VIDEO_WINDOW_horizontal_offset(desc) (GST_READ_UINT16_BE ((desc)+2) >> 2)
|
||||
#define DESC_VIDEO_WINDOW_vertical_offset(desc) ((GST_READ_UINT32_BE ((desc)+2) & 0x0003fff0) >> 4)
|
||||
#define DESC_VIDEO_WINDOW_window_priority(desc) ((desc)[5] & 0x0f)
|
||||
|
||||
/* CA_descriptor */
|
||||
#define DESC_CA_system_ID(desc) (GST_READ_UINT16_BE ((desc)+2))
|
||||
#define DESC_CA_PID(desc) (GST_READ_UINT16_BE ((desc)+2) & 0x1fff)
|
||||
|
||||
/* ISO_639_language_descriptor */
|
||||
#define DESC_ISO_639_LANGUAGE_codes_n(desc) ((desc[1]) >> 2)
|
||||
#define DESC_ISO_639_LANGUAGE_language_code_nth(desc,i) (&(desc[2 + (4*i)]))
|
||||
#define DESC_ISO_639_LANGUAGE_audio_type_nth(desc,i) ((desc)[5 + (4*i)])
|
||||
|
||||
/* system_clock_descriptor */
|
||||
#define DESC_SYSTEM_CLOCK_external_clock_reference_indicator(desc) (((desc)[2] & 0x80) == 0x80)
|
||||
#define DESC_SYSTEM_CLOCK_clock_accuracy_integer(desc) ((desc)[2] & 0x3f)
|
||||
#define DESC_SYSTEM_CLOCK_clock_accuracy_exponent(desc) (((desc)[3] & 0xe0) >> 5)
|
||||
|
||||
/* multiplex_buffer_utilization_descriptor */
|
||||
#define DESC_MULTIPLEX_BUFFER_UTILISATION_bound_valid_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||
#define DESC_MULTIPLEX_BUFFER_UTILISATION_LTW_offset_lower_bound(desc) (GST_READ_UINT16_BE ((desc)+2) & 0x7fff)
|
||||
#define DESC_MULTIPLEX_BUFFER_UTILISATION_LTW_offset_upper_bound(desc) (GST_READ_UINT16_BE ((desc)+4) & 0x7fff)
|
||||
|
||||
/* copyright_descriptor */
|
||||
#define DESC_COPYRIGHT_copyright_identifier(desc) (GST_READ_UINT32_BE ((desc)+2))
|
||||
#define DESC_COPYRIGHT_additional_copyright_info_len(desc) ((desc)[1] - 4)
|
||||
#define DESC_COPYRIGHT_additional_copyright_info(desc) (&(desc)[6])
|
||||
|
||||
/* maximum_bitrate_descriptor */
|
||||
#define DESC_MAXIMUM_BITRAT_maximum_bitrate(desc) (((((guint32)desc[2]) & 0x3f) << 16) | \
|
||||
GST_READ_UINT16_BE ((desc)+3))
|
||||
|
||||
/* private_data_indicator_descriptor */
|
||||
#define DESC_PRIVATE_DATA_INDICATOR_indicator(desc) (GST_READ_UINT32_BE(&desc[2]))
|
||||
|
||||
/* smoothing_buffer_descriptor */
|
||||
#define DESC_SMOOTHING_BUFFER_sb_leak_rate(desc) (((((guint32)desc[2]) & 0x3f) << 16) | \
|
||||
GST_READ_UINT16_BE ((desc)+3))
|
||||
#define DESC_SMOOTHING_BUFFER_sb_size(desc) (((((guint32)desc[5]) & 0x3f) << 16) | \
|
||||
GST_READ_UINT16_BE ((desc)+6))
|
||||
/* STD_descriptor */
|
||||
#define DESC_STD_leak_valid_flag(desc) (((desc)[2] & 0x01) == 0x01)
|
||||
|
||||
/* ibp_descriptor */
|
||||
#define DESC_IBP_closed_gop_flag(desc) (((desc)[2] & 0x80) == 0x80)
|
||||
#define DESC_IBP_identical_gop_flag(desc) (((desc)[2] & 0x40) == 0x40)
|
||||
#define DESC_IBP_max_gop_length(desc) (GST_READ_UINT16_BE ((desc)+6) & 0x3fff)
|
||||
|
||||
/* time_code descriptor */
|
||||
#define DESC_TIMECODE_video_pid(desc) (GST_READ_UINT16_BE ((desc) + 2) & 0x1fff)
|
||||
|
||||
/* Stream identifier descriptor */
|
||||
#define DESC_DVB_STREAM_IDENTIFIER_component_tag(desc) (desc[2])
|
||||
|
||||
/* DVB Network Name descriptor */
|
||||
#define DESC_DVB_NETWORK_NAME_length(desc) (GST_READ_UINT8((desc)+2))
|
||||
#define DESC_DVB_NETWORK_NAME_text(desc) (desc+3)
|
||||
|
||||
/* DVB Service Descriptor */
|
||||
#define DESC_DVB_SERVICE_type(desc) (desc[2])
|
||||
#define DESC_DVB_SERVICE_provider_name_length(desc) (desc[3])
|
||||
#define DESC_DVB_SERVICE_provider_name_text(desc) (desc+4)
|
||||
#define DESC_DVB_SERVICE_name_length(desc) (desc[4 + DESC_DVB_SERVICE_provider_name_length(desc)])
|
||||
#define DESC_DVB_SERVICE_name_text(desc) (desc + 5 + DESC_DVB_SERVICE_provider_name_length(desc))
|
||||
|
||||
/* DVB Component Descriptor */
|
||||
#define DESC_DVB_COMPONENT_stream_content(desc) (desc[2] & 0x0F)
|
||||
#define DESC_DVB_COMPONENT_type(desc) (desc[3])
|
||||
#define DESC_DVB_COMPONENT_tag(desc) (desc[4])
|
||||
#define DESC_DVB_COMPONENT_language(desc) (desc + 5)
|
||||
|
||||
/* DVB Bouquet Name Descriptor */
|
||||
#define DESC_DVB_BOUQUET_NAME_text(desc) (desc + 2)
|
||||
|
||||
/* DVB Short Event Descriptor */
|
||||
#define DESC_DVB_SHORT_EVENT_name_text(desc) (desc + 6)
|
||||
#define DESC_DVB_SHORT_EVENT_name_length(desc) (desc[5])
|
||||
#define DESC_DVB_SHORT_EVENT_description_text(desc) (desc + 6 + DESC_DVB_SHORT_EVENT_name_length(desc) + 1)
|
||||
#define DESC_DVB_SHORT_EVENT_description_length(desc) (desc[6 + DESC_DVB_SHORT_EVENT_name_length(desc)])
|
||||
|
||||
typedef struct {
|
||||
guint n_desc;
|
||||
guint8 data_length;
|
||||
guint8 *data;
|
||||
} GstMPEGDescriptor;
|
||||
|
||||
GstMPEGDescriptor* gst_mpeg_descriptor_parse (guint8 *data, guint size);
|
||||
void gst_mpeg_descriptor_free (GstMPEGDescriptor *desc);
|
||||
|
||||
guint gst_mpeg_descriptor_n_desc (GstMPEGDescriptor *desc);
|
||||
guint8* gst_mpeg_descriptor_find (GstMPEGDescriptor *desc, gint tag);
|
||||
GArray* gst_mpeg_descriptor_find_all (GstMPEGDescriptor * desc, gint tag);
|
||||
|
||||
guint8* gst_mpeg_descriptor_nth (GstMPEGDescriptor *desc, guint i);
|
||||
|
||||
#endif /* __GST_MPEG_DESC_H__ */
|
|
@ -22,6 +22,7 @@
|
|||
*/
|
||||
|
||||
#include "mpegtspacketizer.h"
|
||||
#include "gstmpegdesc.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (mpegts_packetizer_debug);
|
||||
#define GST_CAT_DEFAULT mpegts_packetizer_debug
|
||||
|
@ -318,7 +319,7 @@ mpegts_packetizer_parse_descriptors (MpegTSPacketizer * packetizer,
|
|||
/* include tag and length */
|
||||
desc = g_string_new_len ((gchar *) data - 2, length + 2);
|
||||
data += length;
|
||||
|
||||
/* G_TYPE_GSTING is a GBoxed type and is used so properly marshalled from python */
|
||||
g_value_init (&value, G_TYPE_GSTRING);
|
||||
g_value_take_boxed (&value, desc);
|
||||
g_value_array_append (descriptors, &value);
|
||||
|
@ -808,6 +809,37 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
|
|||
gst_structure_free (service);
|
||||
goto error;
|
||||
}
|
||||
guint8 *service_descriptor;
|
||||
GstMPEGDescriptor *mpegdescriptor =
|
||||
gst_mpeg_descriptor_parse (data, descriptors_loop_length);
|
||||
service_descriptor =
|
||||
gst_mpeg_descriptor_find (mpegdescriptor, DESC_DVB_SERVICE);
|
||||
if (service_descriptor != NULL) {
|
||||
guint serviceprovider_name_length =
|
||||
DESC_DVB_SERVICE_provider_name_length (service_descriptor);
|
||||
gchar *serviceprovider_name =
|
||||
(gchar *) DESC_DVB_SERVICE_provider_name_text (service_descriptor);
|
||||
guint servicename_length =
|
||||
DESC_DVB_SERVICE_name_length (service_descriptor);
|
||||
gchar *servicename =
|
||||
(gchar *) DESC_DVB_SERVICE_name_text (service_descriptor);
|
||||
if (servicename[0] < 0x20) {
|
||||
servicename_length -= 1;
|
||||
servicename += 1;
|
||||
}
|
||||
if (serviceprovider_name[0] < 0x20) {
|
||||
serviceprovider_name_length -= 1;
|
||||
serviceprovider_name += 1;
|
||||
}
|
||||
|
||||
gst_structure_set (service, "name", G_TYPE_STRING,
|
||||
g_strndup (servicename, servicename_length), NULL);
|
||||
gst_structure_set (service, "provider-name", G_TYPE_STRING,
|
||||
g_strndup (serviceprovider_name, serviceprovider_name_length),
|
||||
NULL);
|
||||
}
|
||||
|
||||
gst_mpeg_descriptor_free (mpegdescriptor);
|
||||
|
||||
descriptors = g_value_array_new (0);
|
||||
if (!mpegts_packetizer_parse_descriptors (packetizer,
|
||||
|
@ -819,6 +851,8 @@ mpegts_packetizer_parse_sdt (MpegTSPacketizer * packetizer,
|
|||
|
||||
gst_structure_set (service, "descriptors", G_TYPE_VALUE_ARRAY,
|
||||
descriptors, NULL);
|
||||
/* get provider and service name from descriptors */
|
||||
|
||||
g_value_array_free (descriptors);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ static GstStateChangeReturn mpegts_parse_change_state (GstElement * element,
|
|||
|
||||
GST_BOILERPLATE (MpegTSParse, mpegts_parse, GstElement, GST_TYPE_ELEMENT);
|
||||
|
||||
static const guint32 crc_tab[256] = {
|
||||
static guint32 crc_tab[256] = {
|
||||
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9, 0x130476dc, 0x17c56b6b,
|
||||
0x1a864db2, 0x1e475005, 0x2608edb8, 0x22c9f00f, 0x2f8ad6d6, 0x2b4bcb61,
|
||||
0x350c9b64, 0x31cd86d3, 0x3c8ea00a, 0x384fbdbd, 0x4c11db70, 0x48d0c6c7,
|
||||
|
|
Loading…
Reference in a new issue