[vlc-devel] commit: RTP out: convert s16l to s16b on the fly ( Rémi Denis-Courmont )

git version control git at videolan.org
Mon Nov 30 18:48:21 CET 2009


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Nov 30 19:47:28 2009 +0200| [d381107922c443ffaaa35c81b69910069c816752] | committer: Rémi Denis-Courmont 

RTP out: convert s16l to s16b on the fly

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

 modules/stream_out/rtp.c    |    6 +++++-
 modules/stream_out/rtp.h    |    1 +
 modules/stream_out/rtpfmt.c |   33 +++++++++++++++++++++++++++++++++
 3 files changed, 39 insertions(+), 1 deletions(-)

diff --git a/modules/stream_out/rtp.c b/modules/stream_out/rtp.c
index c019a13..837270b 100644
--- a/modules/stream_out/rtp.c
+++ b/modules/stream_out/rtp.c
@@ -1066,6 +1066,7 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
             rtp_set_ptime (id, 20, 1);
             break;
         case VLC_CODEC_S16B:
+        case VLC_CODEC_S16L:
             if( p_fmt->audio.i_channels == 1 && p_fmt->audio.i_rate == 44100 )
             {
                 id->i_payload_type = 11;
@@ -1076,7 +1077,10 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
                 id->i_payload_type = 10;
             }
             id->psz_enc = "L16";
-            id->pf_packetize = rtp_packetize_split;
+            if( p_fmt->i_codec == VLC_CODEC_S16B )
+                id->pf_packetize = rtp_packetize_split;
+            else
+                id->pf_packetize = rtp_packetize_swab;
             rtp_set_ptime (id, 20, 2);
             break;
         case VLC_CODEC_U8:
diff --git a/modules/stream_out/rtp.h b/modules/stream_out/rtp.h
index 4af86ce..aec9dde 100644
--- a/modules/stream_out/rtp.h
+++ b/modules/stream_out/rtp.h
@@ -51,6 +51,7 @@ int rtp_packetize_mpa  (sout_stream_id_t *, block_t *);
 int rtp_packetize_mpv  (sout_stream_id_t *, block_t *);
 int rtp_packetize_ac3  (sout_stream_id_t *, block_t *);
 int rtp_packetize_split(sout_stream_id_t *, block_t *);
+int rtp_packetize_swab (sout_stream_id_t *, block_t *);
 int rtp_packetize_mp4a (sout_stream_id_t *, block_t *);
 int rtp_packetize_mp4a_latm (sout_stream_id_t *, block_t *);
 int rtp_packetize_h263 (sout_stream_id_t *, block_t *);
diff --git a/modules/stream_out/rtpfmt.c b/modules/stream_out/rtpfmt.c
index 680f745..ccc4bbf 100644
--- a/modules/stream_out/rtpfmt.c
+++ b/modules/stream_out/rtpfmt.c
@@ -240,6 +240,39 @@ int rtp_packetize_split( sout_stream_id_t *id, block_t *in )
     return VLC_SUCCESS;
 }
 
+/* split and convert from little endian to network byte order */
+int rtp_packetize_swab( sout_stream_id_t *id, block_t *in )
+{
+    int     i_max   = rtp_mtu (id); /* payload max in one packet */
+    int     i_count = ( in->i_buffer + i_max - 1 ) / i_max;
+
+    uint8_t *p_data = in->p_buffer;
+    int     i_data  = in->i_buffer;
+    int     i;
+
+    for( i = 0; i < i_count; i++ )
+    {
+        int           i_payload = __MIN( i_max, i_data );
+        block_t *out = block_Alloc( 12 + i_payload );
+
+        /* rtp common header */
+        rtp_packetize_common( id, out, (i == i_count - 1),
+                              (in->i_pts > 0 ? in->i_pts : in->i_dts) );
+        swab( p_data, out->p_buffer + 12, i_payload );
+
+        out->i_buffer = 12 + i_payload;
+        out->i_dts    = in->i_dts + i * in->i_length / i_count;
+        out->i_length = in->i_length / i_count;
+
+        rtp_packetize_send( id, out );
+
+        p_data += i_payload;
+        i_data -= i_payload;
+    }
+
+    return VLC_SUCCESS;
+}
+
 /* rfc3016 */
 int rtp_packetize_mp4a_latm( sout_stream_id_t *id, block_t *in )
 {




More information about the vlc-devel mailing list