]> git.sesse.net Git - vlc/commitdiff
rtp: fix Opus packetization and use zero copy
authorRémi Denis-Courmont <remi@remlab.net>
Thu, 25 Sep 2014 18:25:12 +0000 (21:25 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Thu, 25 Sep 2014 19:16:44 +0000 (22:16 +0300)
Opus cannot be fragmented, there must be one frame per RTP packet.

modules/stream_out/rtpfmt.c

index ffd99bc96d3666acc1fcddb9ecd629f1cbff3e92..97fdf21bb49f1830841f820ad585c3d3f8aac86f 100644 (file)
@@ -39,6 +39,7 @@
 static int rtp_packetize_mpa  (sout_stream_id_sys_t *, block_t *);
 static int rtp_packetize_mpv  (sout_stream_id_sys_t *, block_t *);
 static int rtp_packetize_ac3  (sout_stream_id_sys_t *, block_t *);
+static int rtp_packetize_simple(sout_stream_id_sys_t *, block_t *);
 static int rtp_packetize_split(sout_stream_id_sys_t *, block_t *);
 static int rtp_packetize_swab (sout_stream_id_sys_t *, block_t *);
 static int rtp_packetize_mp4a (sout_stream_id_sys_t *, block_t *);
@@ -512,7 +513,7 @@ int rtp_get_fmt( vlc_object_t *obj, es_format_t *p_fmt, const char *mux,
                 return VLC_EGENERIC;
             }
             rtp_fmt->ptname = "opus";
-            rtp_fmt->pf_packetize = rtp_packetize_split;
+            rtp_fmt->pf_packetize = rtp_packetize_simple;
             rtp_fmt->clock_rate = 48000;
             rtp_fmt->channels = 2;
             if (p_fmt->audio.i_channels == 2)
@@ -848,6 +849,17 @@ static int rtp_packetize_ac3( sout_stream_id_sys_t *id, block_t *in )
     return VLC_SUCCESS;
 }
 
+static int rtp_packetize_simple(sout_stream_id_sys_t *id, block_t *block)
+{
+    block = block_Realloc(block, 12, block->i_buffer);
+    if (unlikely(block == NULL))
+        return VLC_ENOMEM;
+
+    rtp_packetize_common(id, block, true, block->i_pts);
+    rtp_packetize_send(id, block);
+    return VLC_SUCCESS;
+}
+
 static int rtp_packetize_split( sout_stream_id_sys_t *id, block_t *in )
 {
     int     i_max   = rtp_mtu (id); /* payload max in one packet */