mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-07 06:52:41 +00:00
typefind: add typefinder for Apple/iTunes itc artwork files
Avoids audio/mpeg false-positive described at: https://bugzilla.gnome.org/show_bug.cgi?id=773172
This commit is contained in:
parent
90b24d34b3
commit
7e14875458
1 changed files with 63 additions and 0 deletions
|
@ -422,6 +422,67 @@ uri_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*** application/itc ***/
|
||||||
|
static GstStaticCaps itc_caps = GST_STATIC_CAPS ("application/itc");
|
||||||
|
#define ITC_CAPS (gst_static_caps_get(&itc_caps))
|
||||||
|
|
||||||
|
static void
|
||||||
|
itc_type_find (GstTypeFind * tf, gpointer unused)
|
||||||
|
{
|
||||||
|
DataScanCtx c = { 0, NULL, 0 };
|
||||||
|
guint8 magic[8] = { 0x00, 0x00, 0x01, 0x1C, 0x69, 0x74, 0x63, 0x68 };
|
||||||
|
guint8 preamble[4] = { 0x00, 0x00, 0x00, 0x02 };
|
||||||
|
guint8 artwork_marker[8] = { 0x00, 0x00, 0x00, 0x00, 0x61, 0x72, 0x74, 0x77 };
|
||||||
|
GstTypeFindProbability itc_prob = GST_TYPE_FIND_NONE;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 8)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (memcmp (c.data, magic, 8))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* At least we found the right magic */
|
||||||
|
itc_prob = GST_TYPE_FIND_MINIMUM;
|
||||||
|
data_scan_ctx_advance (tf, &c, 8);
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 12)))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* Check preamble 3 consecutive times */
|
||||||
|
for (i = 0; i < 3; i++) {
|
||||||
|
if (memcmp (c.data, preamble, 4))
|
||||||
|
goto done;
|
||||||
|
data_scan_ctx_advance (tf, &c, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
itc_prob = GST_TYPE_FIND_POSSIBLE;
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 8)))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* Look for "artw" marker */
|
||||||
|
if (memcmp (c.data, artwork_marker, 8))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
itc_prob = GST_TYPE_FIND_LIKELY;
|
||||||
|
data_scan_ctx_advance (tf, &c, 8);
|
||||||
|
|
||||||
|
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 256)))
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
/* ...and 256 0x00 padding bytes on what looks like the header's end */
|
||||||
|
for (i = 0; i < 256; i++) {
|
||||||
|
if (c.data[i])
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
|
itc_prob = GST_TYPE_FIND_NEARLY_CERTAIN;
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_type_find_suggest (tf, itc_prob, ITC_CAPS);
|
||||||
|
}
|
||||||
|
|
||||||
/*** application/x-hls ***/
|
/*** application/x-hls ***/
|
||||||
|
|
||||||
static GstStaticCaps hls_caps = GST_STATIC_CAPS ("application/x-hls");
|
static GstStaticCaps hls_caps = GST_STATIC_CAPS ("application/x-hls");
|
||||||
|
@ -5683,6 +5744,8 @@ plugin_init (GstPlugin * plugin)
|
||||||
"txt", UTF32_CAPS, NULL, NULL);
|
"txt", UTF32_CAPS, NULL, NULL);
|
||||||
TYPE_FIND_REGISTER (plugin, "text/uri-list", GST_RANK_MARGINAL, uri_type_find,
|
TYPE_FIND_REGISTER (plugin, "text/uri-list", GST_RANK_MARGINAL, uri_type_find,
|
||||||
"ram", URI_CAPS, NULL, NULL);
|
"ram", URI_CAPS, NULL, NULL);
|
||||||
|
TYPE_FIND_REGISTER (plugin, "application/itc", GST_RANK_SECONDARY,
|
||||||
|
itc_type_find, "itc", ITC_CAPS, NULL, NULL);
|
||||||
TYPE_FIND_REGISTER (plugin, "application/x-hls", GST_RANK_MARGINAL,
|
TYPE_FIND_REGISTER (plugin, "application/x-hls", GST_RANK_MARGINAL,
|
||||||
hls_type_find, "m3u8", HLS_CAPS, NULL, NULL);
|
hls_type_find, "m3u8", HLS_CAPS, NULL, NULL);
|
||||||
TYPE_FIND_REGISTER (plugin, "application/sdp", GST_RANK_SECONDARY,
|
TYPE_FIND_REGISTER (plugin, "application/sdp", GST_RANK_SECONDARY,
|
||||||
|
|
Loading…
Reference in a new issue