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">&lt;<a href="mailto:ahaczewski@gmail.com">ahaczewski@gmail.com</a>&gt;</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 &lt;<a href="mailto:ahaczewski@gmail.com">ahaczewski@gmail.com</a>&gt;<br>
---<br>
 gst/typefind/gsttypefindfunctions.c |   54 +++++++++++++++++++++++++++++++++-<br>
 1 files changed, 52 insertions(+), 2 deletions(-)<br>
<br>
Hello all,<br>
<br>
Here&#39;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, &amp;c, 6)))<br>
       break;<br>
@@ -756,6 +758,54 @@ aac_type_find (GstTypeFind * tf, gpointer unused)<br>
       }<br>
<br>
       GST_DEBUG (&quot;No next frame found... (should have been at 0x%x)&quot;, len);<br>
+    } else if (G_UNLIKELY (((snc &amp; 0xffe0) == 0x56e0) || (snc == 0x4de1))) {<br>
+      /* LOAS frame */<br>
+<br>
+      GST_DEBUG (&quot;Found one LOAS syncword at offset 0x%&quot; G_GINT64_MODIFIER<br>
+          &quot;x, tracing next...&quot;, 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] &amp; 0x0f) &lt;&lt; 9) | (c.data[3] &lt;&lt; 1) |<br>
+            ((c.data[4] &amp; 0x80) &gt;&gt; 7);<br>
+        /* add size of EP sync stream header */<br>
+        len += 7;<br>
+      } else {<br>
+        /* AudioSyncStream */<br>
+        len = ((c.data[1] &amp; 0x1f) &lt;&lt; 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, &amp;c, len + 2)) {<br>
+        GST_DEBUG (&quot;Wrong sync or next frame not within reach, len=%u&quot;, len);<br>
+        goto next;<br>
+      }<br>
+<br>
+      /* check if there&#39;s a second LOAS frame */<br>
+      snc = GST_READ_UINT16_BE (c.data + len);<br>
+      if (((snc &amp; 0xffe0) == 0x56e0) || (snc == 0x4de1)) {<br>
+        GstCaps *caps;<br>
+<br>
+        GST_DEBUG (&quot;Found second LOAS syncword at offset 0x%&quot;<br>
+            G_GINT64_MODIFIER &quot;x, framelen %u&quot;, 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 (&quot;audio/mpeg&quot;,<br>
+            &quot;framed&quot;, G_TYPE_BOOLEAN, FALSE,<br>
+            &quot;mpegversion&quot;, G_TYPE_INT, 4,<br>
+            &quot;stream-type&quot;, G_TYPE_STRING, &quot;loas&quot;,<br>
+            &quot;error-resilient&quot;, 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 (&quot;No next frame found... (should have been at 0x%x)&quot;, len);<br>
     } else if (!memcmp (c.data, &quot;ADIF&quot;, 4)) {<br>
       /* ADIF header */<br>
       gst_type_find_suggest_simple (tf, GST_TYPE_FIND_LIKELY, &quot;audio/mpeg&quot;,<br>
@@ -3923,7 +3973,7 @@ plugin_init (GstPlugin * plugin)<br>
   static const gchar *compress_exts[] = { &quot;Z&quot;, NULL };<br>
   static const gchar *m4a_exts[] = { &quot;m4a&quot;, NULL };<br>
   static const gchar *q3gp_exts[] = { &quot;3gp&quot;, NULL };<br>
-  static const gchar *aac_exts[] = { &quot;aac&quot;, NULL };<br>
+  static const gchar *aac_exts[] = { &quot;aac&quot;, &quot;adts&quot;, &quot;adif&quot;, &quot;loas&quot;, NULL };<br>
   static const gchar *spc_exts[] = { &quot;spc&quot;, NULL };<br>
   static const gchar *wavpack_exts[] = { &quot;wv&quot;, &quot;wvp&quot;, NULL };<br>
   static const gchar *wavpack_correction_exts[] = { &quot;wvc&quot;, NULL };<br>
@@ -4156,7 +4206,7 @@ plugin_init (GstPlugin * plugin)<br>
       NULL, CMML_CAPS, NULL, NULL);<br>
   TYPE_FIND_REGISTER_START_WITH (plugin, &quot;application/x-executable&quot;,<br>
       GST_RANK_MARGINAL, NULL, &quot;\177ELF&quot;, 4, GST_TYPE_FIND_MAXIMUM);<br>
-  TYPE_FIND_REGISTER (plugin, &quot;adts_mpeg_stream&quot;, GST_RANK_SECONDARY,<br>
+  TYPE_FIND_REGISTER (plugin, &quot;audio/aac&quot;, GST_RANK_SECONDARY,<br>
       aac_type_find, aac_exts, AAC_CAPS, NULL, NULL);<br>
   TYPE_FIND_REGISTER_START_WITH (plugin, &quot;audio/x-spc&quot;, GST_RANK_SECONDARY,<br>
       spc_exts, &quot;SNES-SPC700 Sound File Data&quot;, 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>