[vlc-commits] opus: handle RTP depayloading (fixes #11938)

Tristan Matthews git at videolan.org
Mon Jan 12 23:17:59 CET 2015


vlc | branch: master | Tristan Matthews <tmatth at videolan.org> | Fri Jan  9 21:55:22 2015 +0000| [5c3d4712751ff36425b850b5f287073ad99e9cce] | committer: Tristan Matthews

opus: handle RTP depayloading (fixes #11938)

If no header is given, deduce it from the decoder format.

Tested for mono, stereo and with/without --codec avcodec at
8000, 12000, 16000, 24000 and 48000hz.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5c3d4712751ff36425b850b5f287073ad99e9cce
---

 modules/access/live555.cpp |    4 ++++
 modules/codec/opus.c       |   32 ++++++++++++++++++++++++++++++--
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/modules/access/live555.cpp b/modules/access/live555.cpp
index a86c439..3423f82 100644
--- a/modules/access/live555.cpp
+++ b/modules/access/live555.cpp
@@ -996,6 +996,10 @@ static int SessionsSetup( demux_t *p_demux )
                     else
                         msg_Warn( p_demux,"Missing or unsupported vorbis header." );
                 }
+                else if( !strcmp( sub->codecName(), "OPUS" ) )
+                {
+                    tk->fmt.i_codec = VLC_CODEC_OPUS;
+                }
             }
             else if( !strcmp( sub->mediumName(), "video" ) )
             {
diff --git a/modules/codec/opus.c b/modules/codec/opus.c
index 74bb101..1eb885e 100644
--- a/modules/codec/opus.c
+++ b/modules/codec/opus.c
@@ -238,11 +238,36 @@ static int ProcessHeaders( decoder_t *p_dec )
     void     *pp_data[XIPH_MAX_HEADER_COUNT];
     unsigned i_count;
 
+    int i_extra = p_dec->fmt_in.i_extra;
+    uint8_t *p_extra = p_dec->fmt_in.p_extra;
+
+    /* If we have no header (e.g. from RTP), make one. */
+    bool b_dummy_header = false;
+    if( !i_extra )
+    {
+        OpusHeader header;
+        opus_prepare_header( p_dec->fmt_in.audio.i_channels,
+                             p_dec->fmt_in.audio.i_rate, &header );
+        if( opus_write_header( &p_extra, &i_extra, &header,
+                               opus_get_version_string() ) )
+            return VLC_ENOMEM;
+        b_dummy_header = true;
+    }
+
     if( xiph_SplitHeaders( pi_size, pp_data, &i_count,
-                           p_dec->fmt_in.i_extra, p_dec->fmt_in.p_extra) )
+                           i_extra, p_extra ) )
+    {
+        if( b_dummy_header )
+            free( p_extra );
         return VLC_EGENERIC;
+    }
+
     if( i_count < 2 )
-        return VLC_EGENERIC;;
+    {
+        if( b_dummy_header )
+            free( p_extra );
+        return VLC_EGENERIC;
+    }
 
     oggpacket.granulepos = -1;
     oggpacket.e_o_s = 0;
@@ -257,6 +282,9 @@ static int ProcessHeaders( decoder_t *p_dec )
     if (ret != VLC_SUCCESS)
         msg_Err( p_dec, "initial Opus header is corrupted" );
 
+    if( b_dummy_header )
+        free( p_extra );
+
     return ret;
 }
 



More information about the vlc-commits mailing list