]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtp.c
#include order
[vlc] / modules / stream_out / rtp.c
index df2eda69ca7039ee0f41fc7f269a00db6cedb7f7..bfc554c6ba211def17ef7c1a849fdab26bb34731 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include "config.h"
-#ifdef HAVE_UNISTD_H
-#   include <unistd.h>
-#endif
-
-#include <errno.h>
 
 #include <vlc/vlc.h>
 #include <vlc_sout.h>
 
 #include "rtp.h"
 
+#ifdef HAVE_UNISTD_H
+#   include <unistd.h>
+#endif
+
+#include <errno.h>
+
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
 
-#define MTU_REDUCE 50
-
 #define DST_TEXT N_("Destination")
 #define DST_LONGTEXT N_( \
     "This is the output URL that will be used." )
@@ -429,7 +427,7 @@ static int Open( vlc_object_t *p_this )
             if( p_sys->i_ttl > 0 )
                 sprintf( access, "udp{raw,rtcp,ttl=%d}", p_sys->i_ttl );
             else
-                strcat( access, "udp{raw,rtcp}" );
+                strcpy( access, "udp{raw,rtcp}" );
 
             /* IPv6 needs brackets if not already present */
             if (strchr( p_sys->psz_destination, ':' ) != NULL )
@@ -451,12 +449,11 @@ static int Open( vlc_object_t *p_this )
         }
 
         id->i_mtu = config_GetInt( p_stream, "mtu" );  /* XXX beurk */
-        if( id->i_mtu <= 16 + MTU_REDUCE )
+        if( id->i_mtu <= 12 + 16 )
         {
             /* better than nothing */
-            id->i_mtu = 1500;
+            id->i_mtu = 576 - 20 - 8;
         }
-        id->i_mtu -= MTU_REDUCE;
 
         /* the access out grabber TODO export it as sout_AccessOutGrabberNew */
         p_grab = p_sys->p_grab =
@@ -1149,13 +1146,12 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     id->i_timestamp_start = rand()&0xffffffff;
     id->i_bitrate = p_fmt->i_bitrate/1000; /* Stream bitrate in kbps */
 
-    id->i_mtu    = config_GetInt( p_stream, "mtu" );  /* XXX beuk */
-    if( id->i_mtu <= 16 + MTU_REDUCE )
+    id->i_mtu = config_GetInt( p_stream, "mtu" );  /* XXX beuk */
+    if( id->i_mtu <= 12 + 16 )
     {
         /* better than nothing */
-        id->i_mtu = 1500;
+        id->i_mtu = 576 - 20 - 8;
     }
-    id->i_mtu -= MTU_REDUCE;
     msg_Dbg( p_stream, "maximum RTP packet size: %d bytes", id->i_mtu );
 
     if( p_sys->rtsp != NULL )
@@ -2050,13 +2046,12 @@ static int MuxDel( sout_stream_t *p_stream, sout_stream_id_t *id )
 
 
 static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
-                                        block_t *p_buffer )
+                                        const block_t *p_buffer )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     sout_stream_id_t *id = p_sys->es[0];
 
     int64_t  i_dts = p_buffer->i_dts;
-    uint32_t i_timestamp = i_dts * 9 / 100;
 
     uint8_t         *p_data = p_buffer->p_buffer;
     unsigned int    i_data  = p_buffer->i_buffer;
@@ -2080,22 +2075,10 @@ static int AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
         {
             /* allocate a new packet */
             p_sys->packet = block_New( p_stream, id->i_mtu );
-            p_sys->packet->p_buffer[ 0] = 0x80;
-            p_sys->packet->p_buffer[ 1] = 0x80|id->i_payload_type;
-            p_sys->packet->p_buffer[ 2] = ( id->i_sequence >> 8)&0xff;
-            p_sys->packet->p_buffer[ 3] = ( id->i_sequence     )&0xff;
-            p_sys->packet->p_buffer[ 4] = ( i_timestamp >> 24 )&0xff;
-            p_sys->packet->p_buffer[ 5] = ( i_timestamp >> 16 )&0xff;
-            p_sys->packet->p_buffer[ 6] = ( i_timestamp >>  8 )&0xff;
-            p_sys->packet->p_buffer[ 7] = ( i_timestamp       )&0xff;
-            memcpy( p_sys->packet->p_buffer + 8, id->ssrc, 4 );
-            p_sys->packet->i_buffer = 12;
-
+            rtp_packetize_common( id, p_sys->packet, 1, i_dts );
             p_sys->packet->i_dts = i_dts;
             p_sys->packet->i_length = p_buffer->i_length / i_packet;
             i_dts += p_sys->packet->i_length;
-
-            id->i_sequence++;
         }
 
         i_size = __MIN( i_data,