[vlc-commits] rtp: fix Opus packetization and use zero copy

Rémi Denis-Courmont git at videolan.org
Thu Sep 25 21:31:27 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Sep 25 21:25:12 2014 +0300| [81400d7e8916a7b44a1a54138a9f54becf642a76] | committer: Rémi Denis-Courmont

rtp: fix Opus packetization and use zero copy

Opus cannot be fragmented, there must be one frame per RTP packet.

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

 modules/stream_out/rtpfmt.c |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/modules/stream_out/rtpfmt.c b/modules/stream_out/rtpfmt.c
index ffd99bc..97fdf21 100644
--- a/modules/stream_out/rtpfmt.c
+++ b/modules/stream_out/rtpfmt.c
@@ -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 */



More information about the vlc-commits mailing list