*
*/
-/* Terrestrial Virtual Channel Table TVCT */
-static GstMpegTsAtscTVCTSource *
-_gst_mpegts_atsc_tvct_source_copy (GstMpegTsAtscTVCTSource * source)
+/* Terrestrial/Cable Virtual Channel Table TVCT/CVCT */
+static GstMpegTsAtscVCTSource *
+_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);
return copy;
}
static void
-_gst_mpegts_atsc_tvct_source_free (GstMpegTsAtscTVCTSource * source)
+_gst_mpegts_atsc_vct_source_free (GstMpegTsAtscVCTSource * source)
{
if (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,
- (GBoxedCopyFunc) _gst_mpegts_atsc_tvct_source_copy,
- (GFreeFunc) _gst_mpegts_atsc_tvct_source_free);
+G_DEFINE_BOXED_TYPE (GstMpegTsAtscVCTSource, gst_mpegts_atsc_vct_source,
+ (GBoxedCopyFunc) _gst_mpegts_atsc_vct_source_copy,
+ (GFreeFunc) _gst_mpegts_atsc_vct_source_free);
-static GstMpegTsAtscTVCT *
-_gst_mpegts_atsc_tvct_copy (GstMpegTsAtscTVCT * tvct)
+static GstMpegTsAtscVCT *
+_gst_mpegts_atsc_vct_copy (GstMpegTsAtscVCT * vct)
{
- GstMpegTsAtscTVCT *copy;
+ GstMpegTsAtscVCT *copy;
- copy = g_slice_dup (GstMpegTsAtscTVCT, tvct);
- copy->sources = g_ptr_array_ref (tvct->sources);
- copy->descriptors = g_ptr_array_ref (tvct->descriptors);
+ copy = g_slice_dup (GstMpegTsAtscVCT, vct);
+ copy->sources = g_ptr_array_ref (vct->sources);
+ copy->descriptors = g_ptr_array_ref (vct->descriptors);
return copy;
}
static void
-_gst_mpegts_atsc_tvct_free (GstMpegTsAtscTVCT * tvct)
+_gst_mpegts_atsc_vct_free (GstMpegTsAtscVCT * vct)
{
- g_ptr_array_unref (tvct->sources);
- if (tvct->descriptors)
- g_ptr_array_unref (tvct->descriptors);
- g_slice_free (GstMpegTsAtscTVCT, tvct);
+ if (vct->sources)
+ g_ptr_array_unref (vct->sources);
+ if (vct->descriptors)
+ g_ptr_array_unref (vct->descriptors);
+ g_slice_free (GstMpegTsAtscVCT, vct);
}
-G_DEFINE_BOXED_TYPE (GstMpegTsAtscTVCT, gst_mpegts_atsc_tvct,
- (GBoxedCopyFunc) _gst_mpegts_atsc_tvct_copy,
- (GFreeFunc) _gst_mpegts_atsc_tvct_free);
+G_DEFINE_BOXED_TYPE (GstMpegTsAtscVCT, gst_mpegts_atsc_vct,
+ (GBoxedCopyFunc) _gst_mpegts_atsc_vct_copy,
+ (GFreeFunc) _gst_mpegts_atsc_vct_free);
static gpointer
-_parse_atsc_tvct (GstMpegTsSection * section)
+_parse_atsc_vct (GstMpegTsSection * section)
{
- GstMpegTsAtscTVCT *tvct = NULL;
+ GstMpegTsAtscVCT *vct = NULL;
guint8 *data, *end, source_nb;
guint32 tmp32;
guint16 descriptors_loop_length, tmp16;
guint i;
+ GError *err = NULL;
- tvct = g_slice_new0 (GstMpegTsAtscTVCT);
+ vct = g_slice_new0 (GstMpegTsAtscVCT);
data = section->data;
end = data + section->section_length;
- tvct->transport_stream_id = section->subtable_extension;
+ vct->transport_stream_id = section->subtable_extension;
/* Skip already parsed data */
data += 8;
/* minimum size */
- if (data - end < 2 + 2 + 4)
+ if (end - data < 2 + 2 + 4)
goto error;
- tvct->protocol_version = *data;
+ vct->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);
+ vct->sources = g_ptr_array_new_full (source_nb,
+ (GDestroyNotify) _gst_mpegts_atsc_vct_source_free);
for (i = 0; i < source_nb; i++) {
- GstMpegTsAtscTVCTSource *source;
+ GstMpegTsAtscVCTSource *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);
+ source = g_slice_new0 (GstMpegTsAtscVCTSource);
+ g_ptr_array_add (vct->sources, source);
+
+ source->short_name =
+ g_convert ((gchar *) data, 14, "utf-8", "utf-16be", NULL, NULL, &err);
+ 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;
tmp32 = GST_READ_UINT32_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;
+
+ /* 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;
data += 2;
if (end - data < descriptors_loop_length + 4)
goto error;
- tvct->descriptors =
+ vct->descriptors =
gst_mpegts_parse_descriptors (data, descriptors_loop_length);
- if (tvct->descriptors == NULL)
+ if (vct->descriptors == NULL)
goto error;
data += descriptors_loop_length;
- return (gpointer) tvct;
+ return (gpointer) vct;
error:
- if (tvct)
- _gst_mpegts_atsc_tvct_free (tvct);
+ if (vct)
+ _gst_mpegts_atsc_vct_free (vct);
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 #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.
*/
-const GstMpegTsAtscTVCT *
+const GstMpegTsAtscVCT *
gst_mpegts_section_get_atsc_tvct (GstMpegTsSection * section)
{
g_return_val_if_fail (section->section_type == GST_MPEGTS_SECTION_ATSC_TVCT,
if (!section->cached_parsed)
section->cached_parsed =
- __common_section_checks (section, 16, _parse_atsc_tvct,
- (GDestroyNotify) _gst_mpegts_atsc_tvct_free);
+ __common_section_checks (section, 16, _parse_atsc_vct,
+ (GDestroyNotify) _gst_mpegts_atsc_vct_free);
+
+ 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 GstMpegTsAtscTVCT *) section->cached_parsed;
+ return (const GstMpegTsAtscVCT *) section->cached_parsed;
}
GST_MTS_TABLE_ID_ATSC_SATELLITE_VIRTUAL_CHANNEL = 0xDA,
} 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 ())
+/* TVCT/CVCT */
+#define GST_TYPE_MPEGTS_ATSC_VCT (gst_mpegts_atsc_vct_get_type ())
+#define GST_TYPE_MPEGTS_ATSC_VCT_SOURCE (gst_mpegts_atsc_vct_source_get_type ())
-typedef struct _GstMpegTsAtscTVCTSource GstMpegTsAtscTVCTSource;
-typedef struct _GstMpegTsAtscTVCT GstMpegTsAtscTVCT;
+typedef struct _GstMpegTsAtscVCTSource GstMpegTsAtscVCTSource;
+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 minor_channel_number;
guint8 modulation_mode;
guint8 ETM_location;
gboolean access_controlled;
gboolean hidden;
+ gboolean path_select; /* CVCT only - reserved bit in TVCT */
+ gboolean out_of_band; /* CVCT only - reserved bit in TVCT */
gboolean hide_guide;
/* FIXME: */
guint8 service_type;
};
/**
- * 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;
guint8 protocol_version;
GPtrArray *descriptors;
};
-GType gst_mpegts_atsc_tvct_get_type (void);
-GType gst_mpegts_atsc_tvct_source_get_type (void);
+GType gst_mpegts_atsc_vct_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