mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 02:01:12 +00:00
mpegts: Handle when iconv doesn't support ISO 6937
Systems like musl libc don't support ISO 6937 in iconv. This ensures that the MPEG-TS plugin can cope with that. There is existing support in the plugin for other methods, so it seems to have been the original intent anyway. Fixes: #1314 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3245>
This commit is contained in:
parent
6a2a5fd44c
commit
f4bdc79a07
2 changed files with 41 additions and 20 deletions
|
@ -296,7 +296,7 @@ guint8 *
|
|||
dvb_text_from_utf8 (const gchar * text, gsize * out_size)
|
||||
{
|
||||
GError *error = NULL;
|
||||
gchar *out_text;
|
||||
gchar *out_text = NULL;
|
||||
guint8 *out_buffer;
|
||||
guint encoding;
|
||||
GIConv giconv = (GIConv) - 1;
|
||||
|
@ -304,6 +304,7 @@ dvb_text_from_utf8 (const gchar * text, gsize * out_size)
|
|||
/* We test character maps one-by-one. Start with the default */
|
||||
encoding = _ICONV_ISO6937;
|
||||
giconv = _get_iconv (_ICONV_UTF8, encoding);
|
||||
if (giconv != (GIConv) - 1)
|
||||
out_text = g_convert_with_iconv (text, -1, giconv, NULL, out_size, &error);
|
||||
|
||||
if (out_text) {
|
||||
|
|
|
@ -71,6 +71,16 @@ static const guint8 stt_data_check[] = {
|
|||
0xc0, 0x00, 0xc4, 0x86, 0x56, 0xa5
|
||||
};
|
||||
|
||||
static gboolean
|
||||
_has_iso6937_iconv (void)
|
||||
{
|
||||
gboolean supported;
|
||||
GIConv test = g_iconv_open ("iso6937", "utf-8");
|
||||
supported = (test != (GIConv) - 1);
|
||||
g_iconv_close (test);
|
||||
return supported;
|
||||
}
|
||||
|
||||
GST_START_TEST (test_scte_sit)
|
||||
{
|
||||
GstMpegtsSCTESIT *sit;
|
||||
|
@ -397,11 +407,13 @@ GST_START_TEST (test_mpegts_nit)
|
|||
|
||||
fail_if (data == NULL);
|
||||
|
||||
if (_has_iso6937_iconv ()) {
|
||||
for (i = 0; i < data_size; i++) {
|
||||
if (data[i] != nit_data_check[i])
|
||||
fail ("0x%X != 0x%X in byte %d of NIT section", data[i],
|
||||
nit_data_check[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check assertion on bad CRC. Reset parsed data, and make the CRC corrupt */
|
||||
nit_section->data[nit_section->section_length - 1]++;
|
||||
|
@ -486,11 +498,13 @@ GST_START_TEST (test_mpegts_sdt)
|
|||
|
||||
fail_if (data == NULL);
|
||||
|
||||
if (_has_iso6937_iconv ()) {
|
||||
for (i = 0; i < data_size; i++) {
|
||||
if (data[i] != sdt_data_check[i])
|
||||
fail ("0x%X != 0x%X in byte %d of SDT section", data[i],
|
||||
sdt_data_check[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check assertion on bad CRC. Reset parsed data, and make the CRC corrupt */
|
||||
sdt_section->data[sdt_section->section_length - 1]++;
|
||||
|
@ -594,14 +608,17 @@ GST_START_TEST (test_mpegts_dvb_descriptors)
|
|||
/* Check creation of descriptor */
|
||||
desc = gst_mpegts_descriptor_from_dvb_network_name ("Name");
|
||||
fail_if (desc == NULL);
|
||||
if (_has_iso6937_iconv ())
|
||||
fail_unless (desc->length == 4);
|
||||
fail_unless (desc->tag == 0x40);
|
||||
|
||||
if (_has_iso6937_iconv ()) {
|
||||
for (i = 0; i < 6; i++) {
|
||||
if (desc->data[i] != network_name_descriptor[i])
|
||||
fail ("0x%X != 0x%X in byte %d of network name descriptor",
|
||||
desc->data[i], network_name_descriptor[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check parsing of descriptor */
|
||||
ret = gst_mpegts_descriptor_parse_dvb_network_name (desc, &string);
|
||||
|
@ -623,14 +640,17 @@ GST_START_TEST (test_mpegts_dvb_descriptors)
|
|||
desc = gst_mpegts_descriptor_from_dvb_service
|
||||
(GST_DVB_SERVICE_DIGITAL_TELEVISION, "Name", "Provider");
|
||||
fail_if (desc == NULL);
|
||||
if (_has_iso6937_iconv ())
|
||||
fail_unless (desc->length == 15);
|
||||
fail_unless (desc->tag == 0x48);
|
||||
|
||||
if (_has_iso6937_iconv ()) {
|
||||
for (i = 0; i < 17; i++) {
|
||||
if (desc->data[i] != service_descriptor[i])
|
||||
fail ("0x%X != 0x%X in byte %d of service descriptor",
|
||||
desc->data[i], service_descriptor[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
/* Check parsing of descriptor with data */
|
||||
ret = gst_mpegts_descriptor_parse_dvb_service
|
||||
|
|
Loading…
Reference in a new issue