]> git.sesse.net Git - vlc/blobdiff - modules/access/rtp/xiph.c
Use var_InheritString for --decklink-video-connection.
[vlc] / modules / access / rtp / xiph.c
index 8a98bd624a469143fea0a81130942b6607be4465..c99280a21c89951aa0386157b2011ca6ad954c02 100644 (file)
@@ -7,7 +7,7 @@
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2.0
+ * as published by the Free Software Foundation; either version 2
  * of the License, or (at your option) any later version.
  *
  * This library is distributed in the hope that it will be useful,
@@ -15,7 +15,7 @@
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
- * You should have received a copy of the GNU Lesser General Public
+ * You should have received a copy of the GNU General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  ****************************************************************************/
 #endif
 #include <vlc_plugin.h>
 
-#include <vlc_codecs.h>
+#include "../../demux/xiph.h"
 
 #include "rtp.h"
-#include <srtp.h>
 
 /* PT=dynamic
  * vorbis: Xiph Vorbis audio (draft-ietf-avt-rtp-vorbis-09, RFC FIXME)
@@ -113,28 +112,20 @@ static ssize_t vorbis_header (void **pextra, const uint8_t *buf, size_t len)
     setuplen = len - (idlen + cmtlen);
 
     /* Create the VLC extra format header */
-    uint8_t *extra = malloc ((size_t)6 + idlen + cmtlen + setuplen);
-    if (extra == NULL)
-        return -1;
-    uint8_t *ptr = *pextra = extra;
-    /* Identification header */
-    *ptr++ = idlen >> 8;
-    *ptr++ = idlen & 0xff;
-    memcpy (ptr, buf, idlen);
-    buf += idlen;
-    ptr += idlen;
-    /* Comments header */
-    *ptr++ = cmtlen >> 8;
-    *ptr++ = cmtlen & 0xff;
-    memcpy (ptr, buf, cmtlen);
-    buf += cmtlen;
-    ptr += cmtlen;
-    /* Setup header */
-    *ptr++ = setuplen >> 8;
-    *ptr++ = setuplen & 0xff;
-    memcpy (ptr, buf, setuplen);
-    ptr += setuplen;
-    return ptr - extra;
+    unsigned sizes[3] = {
+        idlen, cmtlen, setuplen
+    };
+    void *payloads[3] = {
+        buf + 0,
+        buf + idlen,
+        buf + cmtlen
+    };
+    void *extra;
+    int  extra_size;
+    if (xiph_PackHeaders (&extra_size, &extra, sizes, payloads, 3))
+        return -1;;
+    *pextra = extra;
+    return extra_size;
 }