]> git.sesse.net Git - vlc/commitdiff
RTP out: convert s16l to s16b on the fly
authorRémi Denis-Courmont <remi@remlab.net>
Mon, 30 Nov 2009 17:47:28 +0000 (19:47 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Mon, 30 Nov 2009 17:47:28 +0000 (19:47 +0200)
modules/stream_out/rtp.c
modules/stream_out/rtp.h
modules/stream_out/rtpfmt.c

index c019a13c14a52c95b5b04f5e4dbd37be4f542d71..837270b5f04eb713689d9f6c1dc54c11ac2298d3 100644 (file)
@@ -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:
index 4af86cec7f76f208f80ab5cfa94a4806afa93da4..aec9dde9253f84e366015148e8df0792430f8c48 100644 (file)
@@ -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 *);
index 680f7456b18ea969b119696da27f51aaf161bdbb..ccc4bbf500b245337c909a1daf968ce11aa59aad 100644 (file)
@@ -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 )
 {