Hello,<div><br></div><div>You might be interested in this thread: <a href="https://bugzilla.gnome.org/show_bug.cgi?id=615740">https://bugzilla.gnome.org/show_bug.cgi?id=615740</a><br><br><div class="gmail_quote">On Thu, Jul 8, 2010 at 10:43 AM, Andrzej K. Haczewski <span dir="ltr"><<a href="mailto:ahaczewski@gmail.com">ahaczewski@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><br>
Signed-off-by: Andrzej K. Haczewski <<a href="mailto:ahaczewski@gmail.com">ahaczewski@gmail.com</a>><br>
---<br>
gst/typefind/gsttypefindfunctions.c | 54 +++++++++++++++++++++++++++++++++-<br>
1 files changed, 52 insertions(+), 2 deletions(-)<br>
<br>
Hello all,<br>
<br>
Here's a little patch to detect LOAS MPEG-4 streams that carry AAC. I also<br>
included additional file extensions for AAC. As the original typefind name<br>
did not reflect the new capability, I also altered it to better reflect its<br>
purpose, as it is currently capable of detecting any type of stream that<br>
AAC can be natively transported in. Feel free to review and comment.<br>
<br>
Regards,<br>
Andrzej K. Haczewski<br>
<br>
diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c<br>
index 07d8747..25c08fc 100644<br>
--- a/gst/typefind/gsttypefindfunctions.c<br>
+++ b/gst/typefind/gsttypefindfunctions.c<br>
@@ -679,6 +679,8 @@ aac_type_find (GstTypeFind * tf, gpointer unused)<br>
* again a valid syncpoint on the next one (28 bits) for certainty. We<br>
* require 4 kB, which is quite a lot, since frames are generally 200-400<br>
* bytes.<br>
+ * LOAS has 2 possible syncwords, which are 11 bits and 16 bits long.<br>
+ * The following stream syntax depends on which one is found.<br>
*/<br>
if (G_UNLIKELY (!data_scan_ctx_ensure_data (tf, &c, 6)))<br>
break;<br>
@@ -756,6 +758,54 @@ aac_type_find (GstTypeFind * tf, gpointer unused)<br>
}<br>
<br>
GST_DEBUG ("No next frame found... (should have been at 0x%x)", len);<br>
+ } else if (G_UNLIKELY (((snc & 0xffe0) == 0x56e0) || (snc == 0x4de1))) {<br>
+ /* LOAS frame */<br>
+<br>
+ GST_DEBUG ("Found one LOAS syncword at offset 0x%" G_GINT64_MODIFIER<br>
+ "x, tracing next...", c.offset);<br>
+<br>
+ /* check length of frame for each type of detectable LOAS streams */<br>
+ if (snc == 0x4de1) {<br>
+ /* EPAudioSyncStream */<br>
+ len = ((c.data[2] & 0x0f) << 9) | (c.data[3] << 1) |<br>
+ ((c.data[4] & 0x80) >> 7);<br>
+ /* add size of EP sync stream header */<br>
+ len += 7;<br>
+ } else {<br>
+ /* AudioSyncStream */<br>
+ len = ((c.data[1] & 0x1f) << 8) | c.data[2];<br>
+ /* add size of sync stream header */<br>
+ len += 3;<br>
+ }<br>
+<br>
+ if (len == 0 || !data_scan_ctx_ensure_data (tf, &c, len + 2)) {<br>
+ GST_DEBUG ("Wrong sync or next frame not within reach, len=%u", len);<br>
+ goto next;<br>
+ }<br>
+<br>
+ /* check if there's a second LOAS frame */<br>
+ snc = GST_READ_UINT16_BE (c.data + len);<br>
+ if (((snc & 0xffe0) == 0x56e0) || (snc == 0x4de1)) {<br>
+ GstCaps *caps;<br>
+<br>
+ GST_DEBUG ("Found second LOAS syncword at offset 0x%"<br>
+ G_GINT64_MODIFIER "x, framelen %u", c.offset, len);<br>
+<br>
+ /* Set additional field to indicate which type of LOAS stream is found.<br>
+ * It is purely informational field as receiving element have to parse<br>
+ * the stream anyway. */<br>
+ caps = gst_caps_new_simple ("audio/mpeg",<br>
+ "framed", G_TYPE_BOOLEAN, FALSE,<br>
+ "mpegversion", G_TYPE_INT, 4,<br>
+ "stream-type", G_TYPE_STRING, "loas",<br>
+ "error-resilient", G_TYPE_BOOLEAN, (snc == 0x4de1), NULL);<br>
+<br>
+ gst_type_find_suggest (tf, GST_TYPE_FIND_LIKELY, caps);<br>
+ gst_caps_unref (caps);<br>
+ break;<br>
+ }<br>
+<br>
+ GST_DEBUG ("No next frame found... (should have been at 0x%x)", len);<br>
} else if (!memcmp (c.data, "ADIF", 4)) {<br>
/* ADIF header */<br>
gst_type_find_suggest_simple (tf, GST_TYPE_FIND_LIKELY, "audio/mpeg",<br>
@@ -3923,7 +3973,7 @@ plugin_init (GstPlugin * plugin)<br>
static const gchar *compress_exts[] = { "Z", NULL };<br>
static const gchar *m4a_exts[] = { "m4a", NULL };<br>
static const gchar *q3gp_exts[] = { "3gp", NULL };<br>
- static const gchar *aac_exts[] = { "aac", NULL };<br>
+ static const gchar *aac_exts[] = { "aac", "adts", "adif", "loas", NULL };<br>
static const gchar *spc_exts[] = { "spc", NULL };<br>
static const gchar *wavpack_exts[] = { "wv", "wvp", NULL };<br>
static const gchar *wavpack_correction_exts[] = { "wvc", NULL };<br>
@@ -4156,7 +4206,7 @@ plugin_init (GstPlugin * plugin)<br>
NULL, CMML_CAPS, NULL, NULL);<br>
TYPE_FIND_REGISTER_START_WITH (plugin, "application/x-executable",<br>
GST_RANK_MARGINAL, NULL, "\177ELF", 4, GST_TYPE_FIND_MAXIMUM);<br>
- TYPE_FIND_REGISTER (plugin, "adts_mpeg_stream", GST_RANK_SECONDARY,<br>
+ TYPE_FIND_REGISTER (plugin, "audio/aac", GST_RANK_SECONDARY,<br>
aac_type_find, aac_exts, AAC_CAPS, NULL, NULL);<br>
TYPE_FIND_REGISTER_START_WITH (plugin, "audio/x-spc", GST_RANK_SECONDARY,<br>
spc_exts, "SNES-SPC700 Sound File Data", 27, GST_TYPE_FIND_MAXIMUM);<br>
--<br>
1.7.1<br>
<br>
<br>
------------------------------------------------------------------------------<br>
This SF.net email is sponsored by Sprint<br>
What will you do first with EVO, the first 4G phone?<br>
Visit <a href="http://sprint.com/first" target="_blank">sprint.com/first</a> -- <a href="http://p.sf.net/sfu/sprint-com-first" target="_blank">http://p.sf.net/sfu/sprint-com-first</a><br>
_______________________________________________<br>
gstreamer-devel mailing list<br>
<a href="mailto:gstreamer-devel@lists.sourceforge.net">gstreamer-devel@lists.sourceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gstreamer-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gstreamer-devel</a><br>
</blockquote></div><br><br clear="all"><br>-- <br>André Dieb Martins<br>
</div>