mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-06 10:42:22 +00:00
mpegts: atsc: rename TVCT to VCT as it is the same as CVCT
Make the ATSC section parse handle both TVCT and CVCT as they are nearly the same struct (CVCT uses 2 reserved bits that are ignored in TVCT). This is changing the glib type and the struct name but TVCT wasn't released in a stable package yet so there should be no problem. Also includes some parsing fixes and changes short_name to be directly stored as utf8 rather than utf16 https://bugzilla.gnome.org/show_bug.cgi?id=730642
This commit is contained in:
parent
a1866ef8c1
commit
8f6a3c0a99
4 changed files with 117 additions and 66 deletions
|
@ -34,101 +34,108 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Terrestrial Virtual Channel Table TVCT */
|
/* Terrestrial/Cable Virtual Channel Table TVCT/CVCT */
|
||||||
static GstMpegTsAtscTVCTSource *
|
static GstMpegTsAtscVCTSource *
|
||||||
_gst_mpegts_atsc_tvct_source_copy (GstMpegTsAtscTVCTSource * source)
|
_gst_mpegts_atsc_vct_source_copy (GstMpegTsAtscVCTSource * source)
|
||||||
{
|
{
|
||||||
GstMpegTsAtscTVCTSource *copy;
|
GstMpegTsAtscVCTSource *copy;
|
||||||
|
|
||||||
copy = g_slice_dup (GstMpegTsAtscTVCTSource, source);
|
copy = g_slice_dup (GstMpegTsAtscVCTSource, source);
|
||||||
copy->descriptors = g_ptr_array_ref (source->descriptors);
|
copy->descriptors = g_ptr_array_ref (source->descriptors);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gst_mpegts_atsc_tvct_source_free (GstMpegTsAtscTVCTSource * source)
|
_gst_mpegts_atsc_vct_source_free (GstMpegTsAtscVCTSource * source)
|
||||||
{
|
{
|
||||||
if (source->descriptors)
|
if (source->descriptors)
|
||||||
g_ptr_array_unref (source->descriptors);
|
g_ptr_array_unref (source->descriptors);
|
||||||
g_slice_free (GstMpegTsAtscTVCTSource, source);
|
g_slice_free (GstMpegTsAtscVCTSource, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (GstMpegTsAtscTVCTSource, gst_mpegts_atsc_tvct_source,
|
G_DEFINE_BOXED_TYPE (GstMpegTsAtscVCTSource, gst_mpegts_atsc_vct_source,
|
||||||
(GBoxedCopyFunc) _gst_mpegts_atsc_tvct_source_copy,
|
(GBoxedCopyFunc) _gst_mpegts_atsc_vct_source_copy,
|
||||||
(GFreeFunc) _gst_mpegts_atsc_tvct_source_free);
|
(GFreeFunc) _gst_mpegts_atsc_vct_source_free);
|
||||||
|
|
||||||
static GstMpegTsAtscTVCT *
|
static GstMpegTsAtscVCT *
|
||||||
_gst_mpegts_atsc_tvct_copy (GstMpegTsAtscTVCT * tvct)
|
_gst_mpegts_atsc_vct_copy (GstMpegTsAtscVCT * vct)
|
||||||
{
|
{
|
||||||
GstMpegTsAtscTVCT *copy;
|
GstMpegTsAtscVCT *copy;
|
||||||
|
|
||||||
copy = g_slice_dup (GstMpegTsAtscTVCT, tvct);
|
copy = g_slice_dup (GstMpegTsAtscVCT, vct);
|
||||||
copy->sources = g_ptr_array_ref (tvct->sources);
|
copy->sources = g_ptr_array_ref (vct->sources);
|
||||||
copy->descriptors = g_ptr_array_ref (tvct->descriptors);
|
copy->descriptors = g_ptr_array_ref (vct->descriptors);
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_gst_mpegts_atsc_tvct_free (GstMpegTsAtscTVCT * tvct)
|
_gst_mpegts_atsc_vct_free (GstMpegTsAtscVCT * vct)
|
||||||
{
|
{
|
||||||
g_ptr_array_unref (tvct->sources);
|
if (vct->sources)
|
||||||
if (tvct->descriptors)
|
g_ptr_array_unref (vct->sources);
|
||||||
g_ptr_array_unref (tvct->descriptors);
|
if (vct->descriptors)
|
||||||
g_slice_free (GstMpegTsAtscTVCT, tvct);
|
g_ptr_array_unref (vct->descriptors);
|
||||||
|
g_slice_free (GstMpegTsAtscVCT, vct);
|
||||||
}
|
}
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (GstMpegTsAtscTVCT, gst_mpegts_atsc_tvct,
|
G_DEFINE_BOXED_TYPE (GstMpegTsAtscVCT, gst_mpegts_atsc_vct,
|
||||||
(GBoxedCopyFunc) _gst_mpegts_atsc_tvct_copy,
|
(GBoxedCopyFunc) _gst_mpegts_atsc_vct_copy,
|
||||||
(GFreeFunc) _gst_mpegts_atsc_tvct_free);
|
(GFreeFunc) _gst_mpegts_atsc_vct_free);
|
||||||
|
|
||||||
static gpointer
|
static gpointer
|
||||||
_parse_atsc_tvct (GstMpegTsSection * section)
|
_parse_atsc_vct (GstMpegTsSection * section)
|
||||||
{
|
{
|
||||||
GstMpegTsAtscTVCT *tvct = NULL;
|
GstMpegTsAtscVCT *vct = NULL;
|
||||||
guint8 *data, *end, source_nb;
|
guint8 *data, *end, source_nb;
|
||||||
guint32 tmp32;
|
guint32 tmp32;
|
||||||
guint16 descriptors_loop_length, tmp16;
|
guint16 descriptors_loop_length, tmp16;
|
||||||
guint i;
|
guint i;
|
||||||
|
GError *err = NULL;
|
||||||
|
|
||||||
tvct = g_slice_new0 (GstMpegTsAtscTVCT);
|
vct = g_slice_new0 (GstMpegTsAtscVCT);
|
||||||
|
|
||||||
data = section->data;
|
data = section->data;
|
||||||
end = data + section->section_length;
|
end = data + section->section_length;
|
||||||
|
|
||||||
tvct->transport_stream_id = section->subtable_extension;
|
vct->transport_stream_id = section->subtable_extension;
|
||||||
|
|
||||||
/* Skip already parsed data */
|
/* Skip already parsed data */
|
||||||
data += 8;
|
data += 8;
|
||||||
|
|
||||||
/* minimum size */
|
/* minimum size */
|
||||||
if (data - end < 2 + 2 + 4)
|
if (end - data < 2 + 2 + 4)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
tvct->protocol_version = *data;
|
vct->protocol_version = *data;
|
||||||
data += 1;
|
data += 1;
|
||||||
|
|
||||||
source_nb = *data;
|
source_nb = *data;
|
||||||
data += 1;
|
data += 1;
|
||||||
|
|
||||||
tvct->sources = g_ptr_array_new_full (source_nb,
|
vct->sources = g_ptr_array_new_full (source_nb,
|
||||||
(GDestroyNotify) _gst_mpegts_atsc_tvct_source_free);
|
(GDestroyNotify) _gst_mpegts_atsc_vct_source_free);
|
||||||
|
|
||||||
for (i = 0; i < source_nb; i++) {
|
for (i = 0; i < source_nb; i++) {
|
||||||
GstMpegTsAtscTVCTSource *source;
|
GstMpegTsAtscVCTSource *source;
|
||||||
|
|
||||||
/* minimum 32 bytes for a entry, 2 bytes second descriptor
|
/* minimum 32 bytes for a entry, 2 bytes second descriptor
|
||||||
loop-length, 4 bytes crc */
|
loop-length, 4 bytes crc */
|
||||||
if (end - data < 32 + 2 + 4)
|
if (end - data < 32 + 2 + 4)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
source = g_slice_new0 (GstMpegTsAtscTVCTSource);
|
source = g_slice_new0 (GstMpegTsAtscVCTSource);
|
||||||
g_ptr_array_add (tvct->sources, source);
|
g_ptr_array_add (vct->sources, source);
|
||||||
|
|
||||||
/* FIXME: 7 utf16 charater
|
source->short_name =
|
||||||
GST_READ_UINT16_BE x 7 or extern method ? */
|
g_convert ((gchar *) data, 14, "utf-8", "utf-16be", NULL, NULL, &err);
|
||||||
source->short_name = g_memdup (data, 14);
|
if (err) {
|
||||||
|
GST_WARNING ("Failed to convert VCT Source short_name to utf-8: %d %s",
|
||||||
|
err->code, err->message);
|
||||||
|
GST_MEMDUMP ("UTF-16 string", data, 14);
|
||||||
|
g_error_free (err);
|
||||||
|
}
|
||||||
data += 14;
|
data += 14;
|
||||||
|
|
||||||
tmp32 = GST_READ_UINT32_BE (data);
|
tmp32 = GST_READ_UINT32_BE (data);
|
||||||
|
@ -150,7 +157,12 @@ _parse_atsc_tvct (GstMpegTsSection * section)
|
||||||
source->ETM_location = (tmp16 >> 14) & 0x3;
|
source->ETM_location = (tmp16 >> 14) & 0x3;
|
||||||
source->access_controlled = (tmp16 >> 13) & 0x1;
|
source->access_controlled = (tmp16 >> 13) & 0x1;
|
||||||
source->hidden = (tmp16 >> 12) & 0x1;
|
source->hidden = (tmp16 >> 12) & 0x1;
|
||||||
source->hide_guide = (tmp16 >> 10) & 0x1;
|
|
||||||
|
/* only used in CVCT */
|
||||||
|
source->path_select = (tmp16 >> 11) & 0x1;
|
||||||
|
source->out_of_band = (tmp16 >> 10) & 0x1;
|
||||||
|
|
||||||
|
source->hide_guide = (tmp16 >> 9) & 0x1;
|
||||||
source->service_type = tmp16 & 0x3f;
|
source->service_type = tmp16 & 0x3f;
|
||||||
data += 2;
|
data += 2;
|
||||||
|
|
||||||
|
@ -176,17 +188,17 @@ _parse_atsc_tvct (GstMpegTsSection * section)
|
||||||
if (end - data < descriptors_loop_length + 4)
|
if (end - data < descriptors_loop_length + 4)
|
||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
tvct->descriptors =
|
vct->descriptors =
|
||||||
gst_mpegts_parse_descriptors (data, descriptors_loop_length);
|
gst_mpegts_parse_descriptors (data, descriptors_loop_length);
|
||||||
if (tvct->descriptors == NULL)
|
if (vct->descriptors == NULL)
|
||||||
goto error;
|
goto error;
|
||||||
data += descriptors_loop_length;
|
data += descriptors_loop_length;
|
||||||
|
|
||||||
return (gpointer) tvct;
|
return (gpointer) vct;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (tvct)
|
if (vct)
|
||||||
_gst_mpegts_atsc_tvct_free (tvct);
|
_gst_mpegts_atsc_vct_free (vct);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -195,12 +207,12 @@ error:
|
||||||
* gst_mpegts_section_get_atsc_tvct:
|
* gst_mpegts_section_get_atsc_tvct:
|
||||||
* @section: a #GstMpegTsSection of type %GST_MPEGTS_SECTION_ATSC_TVCT
|
* @section: a #GstMpegTsSection of type %GST_MPEGTS_SECTION_ATSC_TVCT
|
||||||
*
|
*
|
||||||
* Returns the #GstMpegTsAtscTVCT contained in the @section
|
* Returns the #GstMpegTsAtscVCT contained in the @section
|
||||||
*
|
*
|
||||||
* Returns: The #GstMpegTsAtscTVCT contained in the section, or %NULL if an error
|
* Returns: The #GstMpegTsAtscVCT contained in the section, or %NULL if an error
|
||||||
* happened.
|
* happened.
|
||||||
*/
|
*/
|
||||||
const GstMpegTsAtscTVCT *
|
const GstMpegTsAtscVCT *
|
||||||
gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section)
|
gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (section->section_type == GST_MPEGTS_SECTION_ATSC_TVCT,
|
g_return_val_if_fail (section->section_type == GST_MPEGTS_SECTION_ATSC_TVCT,
|
||||||
|
@ -209,8 +221,32 @@ gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section)
|
||||||
|
|
||||||
if (!section->cached_parsed)
|
if (!section->cached_parsed)
|
||||||
section->cached_parsed =
|
section->cached_parsed =
|
||||||
__common_section_checks (section, 16, _parse_atsc_tvct,
|
__common_section_checks (section, 16, _parse_atsc_vct,
|
||||||
(GDestroyNotify) _gst_mpegts_atsc_tvct_free);
|
(GDestroyNotify) _gst_mpegts_atsc_vct_free);
|
||||||
|
|
||||||
return (const GstMpegTsAtscTVCT *) section->cached_parsed;
|
return (const GstMpegTsAtscVCT *) section->cached_parsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_mpegts_section_get_atsc_cvct:
|
||||||
|
* @section: a #GstMpegTsSection of type %GST_MPEGTS_SECTION_ATSC_CVCT
|
||||||
|
*
|
||||||
|
* Returns the #GstMpegTsAtscVCT contained in the @section
|
||||||
|
*
|
||||||
|
* Returns: The #GstMpegTsAtscVCT contained in the section, or %NULL if an error
|
||||||
|
* happened.
|
||||||
|
*/
|
||||||
|
const GstMpegTsAtscVCT *
|
||||||
|
gst_mpegts_section_get_atsc_cvct (GstMpegTsSection * section)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (section->section_type == GST_MPEGTS_SECTION_ATSC_CVCT,
|
||||||
|
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_vct,
|
||||||
|
(GDestroyNotify) _gst_mpegts_atsc_vct_free);
|
||||||
|
|
||||||
|
return (const GstMpegTsAtscVCT *) section->cached_parsed;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,21 +66,21 @@ typedef enum {
|
||||||
GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL = 0xDA,
|
GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL = 0xDA,
|
||||||
} GstMpegTsSectionATSCTableID;
|
} GstMpegTsSectionATSCTableID;
|
||||||
|
|
||||||
/* TVCT */
|
/* TVCT/CVCT */
|
||||||
#define GST_TYPE_MPEGTS_ATSC_TVCT (gst_mpegts_atsc_tvct_get_type ())
|
#define GST_TYPE_MPEGTS_ATSC_VCT (gst_mpegts_atsc_vct_get_type ())
|
||||||
#define GST_TYPE_MPEGTS_ATSC_TVCT_SOURCE (gst_mpegts_atsc_tvct_source_get_type ())
|
#define GST_TYPE_MPEGTS_ATSC_VCT_SOURCE (gst_mpegts_atsc_vct_source_get_type ())
|
||||||
|
|
||||||
typedef struct _GstMpegTsAtscTVCTSource GstMpegTsAtscTVCTSource;
|
typedef struct _GstMpegTsAtscVCTSource GstMpegTsAtscVCTSource;
|
||||||
typedef struct _GstMpegTsAtscTVCT GstMpegTsAtscTVCT;
|
typedef struct _GstMpegTsAtscVCT GstMpegTsAtscVCT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstMpegTsAtscTVCTSource:
|
* GstMpegTsAtscVCTSource:
|
||||||
*
|
*
|
||||||
* Source from a @GstMpegTsAtscTVCT
|
* Source from a @GstMpegTsAtscVCT, can be used both for TVCT and CVCT tables
|
||||||
*/
|
*/
|
||||||
struct _GstMpegTsAtscTVCTSource
|
struct _GstMpegTsAtscVCTSource
|
||||||
{
|
{
|
||||||
gunichar2 *short_name;
|
gchar *short_name;
|
||||||
guint16 major_channel_number;
|
guint16 major_channel_number;
|
||||||
guint16 minor_channel_number;
|
guint16 minor_channel_number;
|
||||||
guint8 modulation_mode;
|
guint8 modulation_mode;
|
||||||
|
@ -91,6 +91,8 @@ struct _GstMpegTsAtscTVCTSource
|
||||||
guint8 ETM_location;
|
guint8 ETM_location;
|
||||||
gboolean access_controlled;
|
gboolean access_controlled;
|
||||||
gboolean hidden;
|
gboolean hidden;
|
||||||
|
gboolean path_select; /* CVCT only - reserved bit in TVCT */
|
||||||
|
gboolean out_of_band; /* CVCT only - reserved bit in TVCT */
|
||||||
gboolean hide_guide;
|
gboolean hide_guide;
|
||||||
/* FIXME: */
|
/* FIXME: */
|
||||||
guint8 service_type;
|
guint8 service_type;
|
||||||
|
@ -99,12 +101,14 @@ struct _GstMpegTsAtscTVCTSource
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstMpegTsAtscTVCT:
|
* GstMpegTsAtscVCT:
|
||||||
*
|
*
|
||||||
* Terrestrial Virtual Channel Table (A65)
|
* Represents both:
|
||||||
|
* Terrestrial Virtual Channel Table (A65)
|
||||||
|
* Cable Virtual Channel Table (A65)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct _GstMpegTsAtscTVCT
|
struct _GstMpegTsAtscVCT
|
||||||
{
|
{
|
||||||
guint16 transport_stream_id;
|
guint16 transport_stream_id;
|
||||||
guint8 protocol_version;
|
guint8 protocol_version;
|
||||||
|
@ -112,10 +116,11 @@ struct _GstMpegTsAtscTVCT
|
||||||
GPtrArray *descriptors;
|
GPtrArray *descriptors;
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gst_mpegts_atsc_tvct_get_type (void);
|
GType gst_mpegts_atsc_vct_get_type (void);
|
||||||
GType gst_mpegts_atsc_tvct_source_get_type (void);
|
GType gst_mpegts_atsc_vct_source_get_type (void);
|
||||||
|
|
||||||
const GstMpegTsAtscTVCT * gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section);
|
const GstMpegTsAtscVCT * gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section);
|
||||||
|
const GstMpegTsAtscVCT * gst_mpegts_section_get_atsc_cvct (GstMpegTsSection * section);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -1048,6 +1048,14 @@ _identify_section (guint16 pid, guint8 table_id)
|
||||||
if (pid == 0x0014)
|
if (pid == 0x0014)
|
||||||
return GST_MPEGTS_SECTION_TOT;
|
return GST_MPEGTS_SECTION_TOT;
|
||||||
break;
|
break;
|
||||||
|
case GST_MTS_TABLE_ID_ATSC_TERRESTRIAL_VIRTUAL_CHANNEL:
|
||||||
|
if (pid == 0x1ffb)
|
||||||
|
return GST_MPEGTS_SECTION_ATSC_TVCT;
|
||||||
|
break;
|
||||||
|
case GST_MTS_TABLE_ID_ATSC_CABLE_VIRTUAL_CHANNEL:
|
||||||
|
if (pid == 0x1ffb)
|
||||||
|
return GST_MPEGTS_SECTION_ATSC_CVCT;
|
||||||
|
break;
|
||||||
/* FIXME : FILL */
|
/* FIXME : FILL */
|
||||||
default:
|
default:
|
||||||
/* Handle ranges */
|
/* Handle ranges */
|
||||||
|
|
|
@ -52,6 +52,7 @@ GType gst_mpegts_section_get_type (void);
|
||||||
* @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)
|
* @GST_MPEGTS_SECTION_ATSC_TVCT: ATSC Terrestrial Virtual Channel Table (A65)
|
||||||
|
* @GST_MPEGTS_SECTION_ATSC_CVCT: ATSC Cable Virtual Channel Table (A65)
|
||||||
*
|
*
|
||||||
* Types of #GstMpegTsSection that the library handles.
|
* Types of #GstMpegTsSection that the library handles.
|
||||||
*/
|
*/
|
||||||
|
@ -67,7 +68,8 @@ typedef enum {
|
||||||
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
|
GST_MPEGTS_SECTION_ATSC_TVCT,
|
||||||
|
GST_MPEGTS_SECTION_ATSC_CVCT
|
||||||
} GstMpegTsSectionType;
|
} GstMpegTsSectionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue