mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-07 07:58:51 +00:00
mpegts: add atsc terrestrial virtual channel table
https://bugzilla.gnome.org/show_bug.cgi?id=727460
This commit is contained in:
parent
7d97a4b20b
commit
f566d17202
6 changed files with 273 additions and 11 deletions
|
@ -363,6 +363,10 @@ gst_mpeg_ts_stream_type_get_type
|
||||||
<SECTION>
|
<SECTION>
|
||||||
<FILE>gst-atsc-section</FILE>
|
<FILE>gst-atsc-section</FILE>
|
||||||
GstMpegTsSectionATSCTableID
|
GstMpegTsSectionATSCTableID
|
||||||
|
<SUBSECTION tvct>
|
||||||
|
GstMpegTsAtscTVCTSource
|
||||||
|
GstMpegTsAtscTVCT
|
||||||
|
gst_mpegts_section_get_atsc_tvct
|
||||||
<SUBSECTION Standard>
|
<SUBSECTION Standard>
|
||||||
GST_TYPE_MPEG_TS_SECTION_ATSC_TABLE_ID
|
GST_TYPE_MPEG_TS_SECTION_ATSC_TABLE_ID
|
||||||
gst_mpeg_ts_section_atsc_table_id_get_type
|
gst_mpeg_ts_section_atsc_table_id_get_type
|
||||||
|
|
|
@ -4,7 +4,8 @@ libgstmpegts_@GST_API_VERSION@_la_SOURCES = \
|
||||||
gstmpegtssection.c \
|
gstmpegtssection.c \
|
||||||
gstmpegtsdescriptor.c \
|
gstmpegtsdescriptor.c \
|
||||||
gst-dvb-descriptor.c \
|
gst-dvb-descriptor.c \
|
||||||
gst-dvb-section.c
|
gst-dvb-section.c \
|
||||||
|
gst-atsc-section.c
|
||||||
|
|
||||||
libgstmpegts_@GST_API_VERSION@includedir = \
|
libgstmpegts_@GST_API_VERSION@includedir = \
|
||||||
$(includedir)/gstreamer-@GST_API_VERSION@/gst/mpegts
|
$(includedir)/gstreamer-@GST_API_VERSION@/gst/mpegts
|
||||||
|
|
213
gst-libs/gst/mpegts/gst-atsc-section.c
Normal file
213
gst-libs/gst/mpegts/gst-atsc-section.c
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2014 Stefan Ringel
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Stefan Ringel <linuxtv@stefanringel.de>
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include "mpegts.h"
|
||||||
|
#include "gstmpegts-private.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SECTION:gst-atsc-section
|
||||||
|
* @title: ATSC variants of MPEG-TS sections
|
||||||
|
* @short_description: Sections for the various ATSC specifications
|
||||||
|
* @include: gst/mpegts/mpegts.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Terrestrial Virtual Channel Table TVCT */
|
||||||
|
static GstMpegTsAtscTVCTSource *
|
||||||
|
_gst_mpegts_atsc_tvct_source_copy (GstMpegTsAtscTVCTSource * source)
|
||||||
|
{
|
||||||
|
GstMpegTsAtscTVCTSource *copy;
|
||||||
|
|
||||||
|
copy = g_slice_dup (GstMpegTsAtscTVCTSource, source);
|
||||||
|
copy->descriptors = g_ptr_array_ref (source->descriptors);
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gst_mpegts_atsc_tvct_source_free (GstMpegTsAtscTVCTSource * source)
|
||||||
|
{
|
||||||
|
g_ptr_array_unref (source->descriptors);
|
||||||
|
g_slice_free (GstMpegTsAtscTVCTSource, source);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE (GstMpegTsAtscTVCTSource, gst_mpegts_atsc_tvct_source,
|
||||||
|
(GBoxedCopyFunc) _gst_mpegts_atsc_tvct_source_copy,
|
||||||
|
(GFreeFunc) _gst_mpegts_atsc_tvct_source_free);
|
||||||
|
|
||||||
|
static GstMpegTsAtscTVCT *
|
||||||
|
_gst_mpegts_atsc_tvct_copy (GstMpegTsAtscTVCT * tvct)
|
||||||
|
{
|
||||||
|
GstMpegTsAtscTVCT *copy;
|
||||||
|
|
||||||
|
copy = g_slice_dup (GstMpegTsAtscTVCT, tvct);
|
||||||
|
copy->sources = g_ptr_array_ref (tvct->sources);
|
||||||
|
copy->descriptors = g_ptr_array_ref (tvct->descriptors);
|
||||||
|
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_gst_mpegts_atsc_tvct_free (GstMpegTsAtscTVCT * tvct)
|
||||||
|
{
|
||||||
|
g_ptr_array_unref (tvct->sources);
|
||||||
|
g_ptr_array_unref (tvct->descriptors);
|
||||||
|
g_slice_free (GstMpegTsAtscTVCT, tvct);
|
||||||
|
}
|
||||||
|
|
||||||
|
G_DEFINE_BOXED_TYPE (GstMpegTsAtscTVCT, gst_mpegts_atsc_tvct,
|
||||||
|
(GBoxedCopyFunc) _gst_mpegts_atsc_tvct_copy,
|
||||||
|
(GFreeFunc) _gst_mpegts_atsc_tvct_free);
|
||||||
|
|
||||||
|
static gpointer
|
||||||
|
_parse_atsc_tvct (GstMpegTsSection * section)
|
||||||
|
{
|
||||||
|
GstMpegTsAtscTVCT *tvct = NULL;
|
||||||
|
guint8 *data, *end, source_nb;
|
||||||
|
guint32 tmp32;
|
||||||
|
guint16 descriptors_loop_length, tmp16;
|
||||||
|
|
||||||
|
tvct = g_slice_new0 (GstMpegTsAtscTVCT);
|
||||||
|
|
||||||
|
data = section->data;
|
||||||
|
end = data + section->section_length;
|
||||||
|
|
||||||
|
tvct->transport_stream_id = section->subtable_extension;
|
||||||
|
|
||||||
|
/* Skip already parsed data */
|
||||||
|
data += 8;
|
||||||
|
|
||||||
|
/* minimum size */
|
||||||
|
if (data - end < 2 + 2 + 4)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
tvct->protocol_version = *data;
|
||||||
|
data += 1;
|
||||||
|
|
||||||
|
source_nb = *data;
|
||||||
|
data += 1;
|
||||||
|
|
||||||
|
tvct->sources = g_ptr_array_new_full (source_nb,
|
||||||
|
(GDestroyNotify) _gst_mpegts_atsc_tvct_source_free);
|
||||||
|
|
||||||
|
for (guint i = 0; i < source_nb; i++) {
|
||||||
|
GstMpegTsAtscTVCTSource *source;
|
||||||
|
|
||||||
|
/* minimum 32 bytes for a entry, 2 bytes second descriptor
|
||||||
|
loop-length, 4 bytes crc */
|
||||||
|
if (end - data < 32 + 2 + 4)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
source = g_slice_new0 (GstMpegTsAtscTVCTSource);
|
||||||
|
g_ptr_array_add (tvct->sources, source);
|
||||||
|
|
||||||
|
/* FIXME: 7 utf16 charater
|
||||||
|
GST_READ_UINT16_BE x 7 or extern method ? */
|
||||||
|
source->short_name = g_memdup (data, 14);
|
||||||
|
data += 14;
|
||||||
|
|
||||||
|
tmp32 = GST_READ_UINT32_BE (data);
|
||||||
|
source->major_channel_number = (tmp32 >> 18) & 0x03FF;
|
||||||
|
source->minor_channel_number = (tmp32 >> 8) & 0x03FF;
|
||||||
|
source->modulation_mode = tmp32 & 0xF;
|
||||||
|
data += 4;
|
||||||
|
|
||||||
|
source->carrier_frequency = GST_READ_UINT32_BE (data);
|
||||||
|
data += 4;
|
||||||
|
|
||||||
|
source->channel_TSID = GST_READ_UINT16_BE (data);
|
||||||
|
data += 2;
|
||||||
|
|
||||||
|
source->program_number = GST_READ_UINT16_BE (data);
|
||||||
|
data += 2;
|
||||||
|
|
||||||
|
tmp16 = GST_READ_UINT16_BE (data);
|
||||||
|
source->ETM_location = (tmp16 >> 14) & 0x3;
|
||||||
|
source->access_controlled = (tmp16 >> 13) & 0x1;
|
||||||
|
source->hidden = (tmp16 >> 12) & 0x1;
|
||||||
|
source->hide_guide = (tmp16 >> 10) & 0x1;
|
||||||
|
source->service_type = tmp16 & 0x3f;
|
||||||
|
data += 2;
|
||||||
|
|
||||||
|
source->source_id = GST_READ_UINT16_BE (data);
|
||||||
|
data += 2;
|
||||||
|
|
||||||
|
descriptors_loop_length = GST_READ_UINT16_BE (data) & 0x03FF;
|
||||||
|
data += 2;
|
||||||
|
|
||||||
|
if (end - data < descriptors_loop_length + 6)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
source->descriptors =
|
||||||
|
gst_mpegts_parse_descriptors (data, descriptors_loop_length);
|
||||||
|
if (source->descriptors == NULL)
|
||||||
|
goto error;
|
||||||
|
data += descriptors_loop_length;
|
||||||
|
}
|
||||||
|
|
||||||
|
descriptors_loop_length = GST_READ_UINT16_BE (data) & 0x03FF;
|
||||||
|
data += 2;
|
||||||
|
|
||||||
|
if (end - data < descriptors_loop_length + 4)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
tvct->descriptors =
|
||||||
|
gst_mpegts_parse_descriptors (data, descriptors_loop_length);
|
||||||
|
if (tvct->descriptors == NULL)
|
||||||
|
goto error;
|
||||||
|
data += descriptors_loop_length;
|
||||||
|
|
||||||
|
return (gpointer) tvct;
|
||||||
|
|
||||||
|
error:
|
||||||
|
if (tvct)
|
||||||
|
_gst_mpegts_atsc_tvct_free (tvct);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_mpegts_section_get_atsc_tvct:
|
||||||
|
* @section: a #GstMpegTsSection of type %GST_MPEGTS_SECTION_ATSC_TVCT
|
||||||
|
*
|
||||||
|
* Returns the #GstMpegTsAtscTVCT contained in the @section
|
||||||
|
*
|
||||||
|
* Returns: The #GstMpegTsAtscTVCT contained in the section, or %NULL if an error
|
||||||
|
* happened.
|
||||||
|
*/
|
||||||
|
const GstMpegTsAtscTVCT *
|
||||||
|
gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (section->section_type == GST_MPEGTS_SECTION_ATSC_TVCT,
|
||||||
|
NULL);
|
||||||
|
g_return_val_if_fail (section->cached_parsed || section->data, NULL);
|
||||||
|
|
||||||
|
if (!section->cached_parsed)
|
||||||
|
section->cached_parsed =
|
||||||
|
__common_section_checks (section, 16, _parse_atsc_tvct,
|
||||||
|
(GDestroyNotify) _gst_mpegts_atsc_tvct_free);
|
||||||
|
|
||||||
|
return (const GstMpegTsAtscTVCT *) section->cached_parsed;
|
||||||
|
}
|
|
@ -66,6 +66,57 @@ typedef enum {
|
||||||
GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL = 0xDA,
|
GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL = 0xDA,
|
||||||
} GstMpegTsSectionATSCTableID;
|
} GstMpegTsSectionATSCTableID;
|
||||||
|
|
||||||
|
/* TVCT */
|
||||||
|
#define GST_TYPE_MPEGTS_ATSC_TVCT (gst_mpegts_atsc_tvct_get_type ())
|
||||||
|
#define GST_TYPE_MPEGTS_ATSC_TVCT_SOURCE (gst_mpegts_atsc_tvct_source_get_type ())
|
||||||
|
|
||||||
|
typedef struct _GstMpegTsAtscTVCTSource GstMpegTsAtscTVCTSource;
|
||||||
|
typedef struct _GstMpegTsAtscTVCT GstMpegTsAtscTVCT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstMpegTsAtscTVCTSource:
|
||||||
|
*
|
||||||
|
* Source from a @GstMpegTsAtscTVCT
|
||||||
|
*/
|
||||||
|
struct _GstMpegTsAtscTVCTSource
|
||||||
|
{
|
||||||
|
gunichar2 *short_name;
|
||||||
|
guint16 major_channel_number;
|
||||||
|
guint16 minor_channel_number;
|
||||||
|
guint8 modulation_mode;
|
||||||
|
guint32 carrier_frequency;
|
||||||
|
guint16 channel_TSID;
|
||||||
|
guint16 program_number;
|
||||||
|
/* FIXME: */
|
||||||
|
guint8 ETM_location;
|
||||||
|
gboolean access_controlled;
|
||||||
|
gboolean hidden;
|
||||||
|
gboolean hide_guide;
|
||||||
|
/* FIXME: */
|
||||||
|
guint8 service_type;
|
||||||
|
guint16 source_id;
|
||||||
|
GPtrArray *descriptors;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GstMpegTsAtscTVCT:
|
||||||
|
*
|
||||||
|
* Terrestrial Virtual Channel Table (A65)
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
struct _GstMpegTsAtscTVCT
|
||||||
|
{
|
||||||
|
guint16 transport_stream_id;
|
||||||
|
guint8 protocol_version;
|
||||||
|
GPtrArray *sources;
|
||||||
|
GPtrArray *descriptors;
|
||||||
|
};
|
||||||
|
|
||||||
|
GType gst_mpegts_atsc_tvct_get_type (void);
|
||||||
|
GType gst_mpegts_atsc_tvct_source_get_type (void);
|
||||||
|
|
||||||
|
const GstMpegTsAtscTVCT * gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_MPEGTS_SECTION_H */
|
#endif /* GST_MPEGTS_SECTION_H */
|
||||||
|
|
|
@ -52,15 +52,6 @@
|
||||||
* and other specifications mentionned in the documentation.
|
* and other specifications mentionned in the documentation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* FIXME : Move this to proper file once we have a C file for it */
|
|
||||||
/**
|
|
||||||
* SECTION:gst-atsc-section
|
|
||||||
* @title: ATSC variants of MPEG-TS sections
|
|
||||||
* @short_description: Sections for the various ATSC specifications
|
|
||||||
* @include: gst/mpegts/mpegts.h
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TODO
|
* TODO
|
||||||
*
|
*
|
||||||
|
|
|
@ -51,6 +51,7 @@ GType gst_mpegts_section_get_type (void);
|
||||||
* @GST_MPEGTS_SECTION_SDT: Service Description Table (EN 300 468)
|
* @GST_MPEGTS_SECTION_SDT: Service Description Table (EN 300 468)
|
||||||
* @GST_MPEGTS_SECTION_TDT: Time and Date Table (EN 300 468)
|
* @GST_MPEGTS_SECTION_TDT: Time and Date Table (EN 300 468)
|
||||||
* @GST_MPEGTS_SECTION_TOT: Time Offset Table (EN 300 468)
|
* @GST_MPEGTS_SECTION_TOT: Time Offset Table (EN 300 468)
|
||||||
|
* @GST_MPEGTS_SECTION_ATSC_TVCT: ATSC Terrestrial Virtual Channel Table (A65)
|
||||||
*
|
*
|
||||||
* Types of #GstMpegTsSection that the library handles.
|
* Types of #GstMpegTsSection that the library handles.
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +66,8 @@ typedef enum {
|
||||||
GST_MPEGTS_SECTION_BAT,
|
GST_MPEGTS_SECTION_BAT,
|
||||||
GST_MPEGTS_SECTION_SDT,
|
GST_MPEGTS_SECTION_SDT,
|
||||||
GST_MPEGTS_SECTION_TDT,
|
GST_MPEGTS_SECTION_TDT,
|
||||||
GST_MPEGTS_SECTION_TOT
|
GST_MPEGTS_SECTION_TOT,
|
||||||
|
GST_MPEGTS_SECTION_ATSC_TVCT
|
||||||
} GstMpegTsSectionType;
|
} GstMpegTsSectionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue