]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtp.c
vlc_plugin: fix non-LGPL plugins meta infos
[vlc] / modules / stream_out / rtp.c
index 958470d357588b1ff108f8c6c113c85e50c6c266..7a03ba0ce0d23865c3ec815ca2ee2a64c430868c 100644 (file)
@@ -30,6 +30,7 @@
 # include "config.h"
 #endif
 
+#define VLC_MODULE_LICENSE VLC_LICENSE_GPL_2_PLUS
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 
 #include "rtp.h"
 
-#ifdef HAVE_UNISTD_H
-#   include <sys/types.h>
-#   include <unistd.h>
-#endif
+#include <sys/types.h>
+#include <unistd.h>
 #ifdef HAVE_ARPA_INET_H
 #   include <arpa/inet.h>
 #endif
@@ -65,8 +64,8 @@
 # define IPPROTO_UDPLITE 136
 #endif
 
+#include <ctype.h>
 #include <errno.h>
-
 #include <assert.h>
 
 /*****************************************************************************
 #define NAME_LONGTEXT N_( \
     "This is the name of the session that will be announced in the SDP " \
     "(Session Descriptor)." )
+#define CAT_TEXT N_("Session category")
+#define CAT_LONGTEXT N_( \
+  "This allows you to specify a category for the session, " \
+  "that will be announced if you choose to use SAP." )
 #define DESC_TEXT N_("Session description")
 #define DESC_LONGTEXT N_( \
     "This allows you to give a short description with details about the stream, " \
 #define SRTP_KEY_TEXT N_("SRTP key (hexadecimal)")
 #define SRTP_KEY_LONGTEXT N_( \
     "RTP packets will be integrity-protected and ciphered "\
-    "with this Secure RTP master shared secret key.")
+    "with this Secure RTP master shared secret key. "\
+    "This must be a 32-character-long hexadecimal string.")
 
 #define SRTP_SALT_TEXT N_("SRTP salt (hexadecimal)")
 #define SRTP_SALT_LONGTEXT N_( \
-    "Secure RTP requires a (non-secret) master salt value.")
+    "Secure RTP requires a (non-secret) master salt value. " \
+    "This must be a 28-character-long hexadecimal string.")
 
 static const char *const ppsz_protos[] = {
     "dccp", "sctp", "tcp", "udp", "udplite",
@@ -162,19 +167,19 @@ static const char *const ppsz_protocols[] = {
 #define RFC3016_LONGTEXT N_( \
     "This allows you to stream MPEG4 LATM audio streams (see RFC3016)." )
 
-#define RTSP_HOST_TEXT N_( "RTSP host address" )
-#define RTSP_HOST_LONGTEXT N_( \
-    "This defines the address, port and path the RTSP VOD server will listen " \
-    "on.\nSyntax is address:port/path. The default is to listen on all "\
-    "interfaces (address 0.0.0.0), on port 554, with no path.\nTo listen " \
-    "only on the local interface, use \"localhost\" as address." )
-
 #define RTSP_TIMEOUT_TEXT N_( "RTSP session timeout (s)" )
 #define RTSP_TIMEOUT_LONGTEXT N_( "RTSP sessions will be closed after " \
     "not receiving any RTSP request for this long. Setting it to a " \
     "negative value or zero disables timeouts. The default is 60 (one " \
     "minute)." )
 
+#define RTSP_USER_TEXT N_("Username")
+#define RTSP_USER_LONGTEXT N_("Username that will be " \
+                              "requested to access the stream." )
+#define RTSP_PASS_TEXT N_("Password")
+#define RTSP_PASS_LONGTEXT N_("Password that will be " \
+                              "requested to access the stream." )
+
 static int  Open ( vlc_object_t * );
 static void Close( vlc_object_t * );
 
@@ -200,6 +205,7 @@ vlc_module_begin ()
 
     add_string( SOUT_CFG_PREFIX "name", "", NAME_TEXT,
                 NAME_LONGTEXT, true )
+    add_string( SOUT_CFG_PREFIX "cat", "", CAT_TEXT, CAT_LONGTEXT, true )
     add_string( SOUT_CFG_PREFIX "description", "", DESC_TEXT,
                 DESC_LONGTEXT, true )
     add_string( SOUT_CFG_PREFIX "url", "", URL_TEXT,
@@ -211,7 +217,7 @@ vlc_module_begin ()
 
     add_string( SOUT_CFG_PREFIX "proto", "udp", PROTO_TEXT,
                 PROTO_LONGTEXT, false )
-        change_string_list( ppsz_protos, ppsz_protocols, NULL )
+        change_string_list( ppsz_protos, ppsz_protocols )
     add_integer( SOUT_CFG_PREFIX "port", 5004, PORT_TEXT,
                  PORT_LONGTEXT, true )
     add_integer( SOUT_CFG_PREFIX "port-audio", 0, PORT_AUDIO_TEXT,
@@ -246,10 +252,12 @@ vlc_module_begin ()
     set_capability( "vod server", 10 )
     set_callbacks( OpenVoD, CloseVoD )
     add_shortcut( "rtsp" )
-    add_string ( "rtsp-host", NULL, RTSP_HOST_TEXT,
-                 RTSP_HOST_LONGTEXT, true )
     add_integer( "rtsp-timeout", 60, RTSP_TIMEOUT_TEXT,
                  RTSP_TIMEOUT_LONGTEXT, true )
+    add_string( "sout-rtsp-user", "",
+                RTSP_USER_TEXT, RTSP_USER_LONGTEXT, true )
+    add_password( "sout-rtsp-pwd", "",
+                  RTSP_PASS_TEXT, RTSP_PASS_LONGTEXT, true )
 
 vlc_module_end ()
 
@@ -257,19 +265,22 @@ vlc_module_end ()
  * Exported prototypes
  *****************************************************************************/
 static const char *const ppsz_sout_options[] = {
-    "dst", "name", "port", "port-audio", "port-video", "*sdp", "ttl", "mux",
-    "sap", "description", "url", "email", "phone",
-    "proto", "rtcp-mux", "caching", "key", "salt",
+    "dst", "name", "cat", "port", "port-audio", "port-video", "*sdp", "ttl",
+    "mux", "sap", "description", "url", "email", "phone",
+    "proto", "rtcp-mux", "caching",
+#ifdef HAVE_SRTP
+    "key", "salt",
+#endif
     "mp4a-latm", NULL
 };
 
-static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
-static int               Del ( sout_stream_t *, sout_stream_id_t * );
-static int               Send( sout_stream_t *, sout_stream_id_t *,
+static sout_stream_id_sys_t *Add( sout_stream_t *, const es_format_t * );
+static void              Del ( sout_stream_t *, sout_stream_id_sys_t * );
+static int               Send( sout_stream_t *, sout_stream_id_sys_t *,
                                block_t* );
-static sout_stream_id_t *MuxAdd ( sout_stream_t *, es_format_t * );
-static int               MuxDel ( sout_stream_t *, sout_stream_id_t * );
-static int               MuxSend( sout_stream_t *, sout_stream_id_t *,
+static sout_stream_id_sys_t *MuxAdd( sout_stream_t *, const es_format_t * );
+static void              MuxDel ( sout_stream_t *, sout_stream_id_sys_t * );
+static int               MuxSend( sout_stream_t *, sout_stream_id_sys_t *,
                                   block_t* );
 
 static sout_access_out_t *GrabberCreate( sout_stream_t *p_sout );
@@ -332,7 +343,7 @@ struct sout_stream_sys_t
     /* */
     vlc_mutex_t      lock_es;
     int              i_es;
-    sout_stream_id_t **es;
+    sout_stream_id_sys_t **es;
 };
 
 typedef struct rtp_sink_t
@@ -341,11 +352,12 @@ typedef struct rtp_sink_t
     rtcp_sender_t *rtcp;
 } rtp_sink_t;
 
-struct sout_stream_id_t
+struct sout_stream_id_sys_t
 {
     sout_stream_t *p_stream;
     /* rtp field */
-    uint16_t    i_sequence;
+    /* For RFC 4175, seqnum is extended to 32-bits */
+    uint32_t    i_sequence;
     bool        b_first_packet;
     bool        b_ts_init;
     uint32_t    i_ts_offset;
@@ -385,7 +397,6 @@ struct sout_stream_id_t
 static int Open( vlc_object_t *p_this )
 {
     sout_stream_t       *p_stream = (sout_stream_t*)p_this;
-    sout_instance_t     *p_sout = p_stream->p_sout;
     sout_stream_sys_t   *p_sys = NULL;
     config_chain_t      *p_cfg = NULL;
     char                *psz;
@@ -559,7 +570,7 @@ static int Open( vlc_object_t *p_this )
         }
 
         p_sys->p_grab = GrabberCreate( p_stream );
-        p_sys->p_mux = sout_MuxNew( p_sout, psz, p_sys->p_grab );
+        p_sys->p_mux = sout_MuxNew( p_stream->p_sout, psz, p_sys->p_grab );
         free( psz );
 
         if( p_sys->p_mux == NULL )
@@ -590,6 +601,7 @@ static int Open( vlc_object_t *p_this )
         p_stream->pf_del    = Del;
         p_stream->pf_send   = Send;
     }
+    p_stream->pace_nocontrol = true;
 
     if( var_GetBool( p_stream, SOUT_CFG_PREFIX"sap" ) )
         SDPHandleUrl( p_stream, "sap" );
@@ -618,12 +630,9 @@ static int Open( vlc_object_t *p_this )
         free( psz );
     }
 
-    /* update p_sout->i_out_pace_nocontrol */
-    p_stream->p_sout->i_out_pace_nocontrol++;
-
     if( p_sys->p_mux != NULL )
     {
-        sout_stream_id_t *id = Add( p_stream, NULL );
+        sout_stream_id_sys_t *id = Add( p_stream, NULL );
         if( id == NULL )
         {
             Close( p_this );
@@ -642,9 +651,6 @@ static void Close( vlc_object_t * p_this )
     sout_stream_t     *p_stream = (sout_stream_t*)p_this;
     sout_stream_sys_t *p_sys = p_stream->p_sys;
 
-    /* update p_sout->i_out_pace_nocontrol */
-    p_stream->p_sout->i_out_pace_nocontrol--;
-
     if( p_sys->p_mux )
     {
         assert( p_sys->i_es <= 1 );
@@ -677,9 +683,7 @@ static void Close( vlc_object_t * p_this )
 
     if( p_sys->psz_sdp_file != NULL )
     {
-#ifdef HAVE_UNISTD_H
         unlink( p_sys->psz_sdp_file );
-#endif
         free( p_sys->psz_sdp_file );
     }
     free( p_sys->psz_vod_session );
@@ -717,6 +721,26 @@ static void SDPHandleUrl( sout_stream_t *p_stream, const char *psz_url )
             goto out;
         }
 
+        if( url.psz_host != NULL && *url.psz_host )
+        {
+            msg_Warn( p_stream, "\"%s\" RTSP host might be ignored in "
+                      "multiple-host configurations, use at your own risks.",
+                      url.psz_host );
+            msg_Info( p_stream, "Consider passing --rtsp-host=IP on the "
+                                "command line instead." );
+
+            var_Create( p_stream, "rtsp-host", VLC_VAR_STRING );
+            var_SetString( p_stream, "rtsp-host", url.psz_host );
+        }
+        if( url.i_port != 0 )
+        {
+            /* msg_Info( p_stream, "Consider passing --rtsp-port=%u on "
+                      "the command line instead.", url.i_port ); */
+
+            var_Create( p_stream, "rtsp-port", VLC_VAR_INTEGER );
+            var_SetInteger( p_stream, "rtsp-port", url.i_port );
+        }
+
         p_sys->rtsp = RtspSetup( VLC_OBJECT(p_stream), NULL, url.psz_path );
         if( p_sys->rtsp == NULL )
             msg_Err( p_stream, "cannot export SDP as RTSP" );
@@ -844,7 +868,7 @@ char *SDPGenerate( sout_stream_t *p_stream, const char *rtsp_url )
 
     for( i = 0; i < p_sys->i_es; i++ )
     {
-        sout_stream_id_t *id = p_sys->es[i];
+        sout_stream_id_sys_t *id = p_sys->es[i];
         rtp_format_t *rtp_fmt = &id->rtp_fmt;
         const char *mime_major; /* major MIME type */
 
@@ -904,7 +928,7 @@ out:
  * Shrink the MTU down to a fixed packetization time (for audio).
  */
 static void
-rtp_set_ptime (sout_stream_id_t *id, unsigned ptime_ms, size_t bytes)
+rtp_set_ptime (sout_stream_id_sys_t *id, unsigned ptime_ms, size_t bytes)
 {
     /* Samples per second */
     size_t spl = (id->rtp_fmt.clock_rate - 1) * ptime_ms / 1000 + 1;
@@ -919,20 +943,26 @@ rtp_set_ptime (sout_stream_id_t *id, unsigned ptime_ms, size_t bytes)
 
 uint32_t rtp_compute_ts( unsigned i_clock_rate, int64_t i_pts )
 {
-    /* NOTE: this plays nice with offsets because the calculations are
-     * linear. */
-    return i_pts * (int64_t)i_clock_rate / CLOCK_FREQ;
+    /* This is an overflow-proof way of doing:
+     * return i_pts * (int64_t)i_clock_rate / CLOCK_FREQ;
+     *
+     * NOTE: this plays nice with offsets because the (equivalent)
+     * calculations are linear. */
+    lldiv_t q = lldiv(i_pts, CLOCK_FREQ);
+    return q.quot * (int64_t)i_clock_rate
+          + q.rem * (int64_t)i_clock_rate / CLOCK_FREQ;
 }
 
 /** Add an ES as a new RTP stream */
-static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
+static sout_stream_id_sys_t *Add( sout_stream_t *p_stream,
+                                  const es_format_t *p_fmt )
 {
     /* NOTE: As a special case, if we use a non-RTP
      * mux (TS/PS), then p_fmt is NULL. */
     sout_stream_sys_t *p_sys = p_stream->p_sys;
     char              *psz_sdp;
 
-    sout_stream_id_t *id = malloc( sizeof( *id ) );
+    sout_stream_id_sys_t *id = malloc( sizeof( *id ) );
     if( unlikely(id == NULL) )
         return NULL;
     id->p_stream   = p_stream;
@@ -1008,12 +1038,13 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         }
 
         char *salt = var_GetNonEmptyString (p_stream, SOUT_CFG_PREFIX"salt");
-        errno = srtp_setkeystring (id->srtp, key, salt ? salt : "");
+        int val = srtp_setkeystring (id->srtp, key, salt ? salt : "");
         free (salt);
         free (key);
-        if (errno)
+        if (val)
         {
-            msg_Err (p_stream, "bad SRTP key/salt combination (%m)");
+            msg_Err (p_stream, "bad SRTP key/salt combination (%s)",
+                     vlc_strerror_c(val));
             goto error;
         }
         id->i_sequence = 0; /* FIXME: awful hack for libvlc_srtp */
@@ -1127,6 +1158,9 @@ static sout_stream_id_t *Add( sout_stream_t *p_stream, es_format_t *p_fmt )
         case VLC_CODEC_S16L:
             rtp_set_ptime (id, 20, 2);
             break;
+        case VLC_CODEC_S24B:
+            rtp_set_ptime (id, 20, 3);
+            break;
         default:
             break;
     }
@@ -1185,7 +1219,7 @@ error:
     return NULL;
 }
 
-static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
+static void Del( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
 
@@ -1228,20 +1262,18 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
     if( p_sys->psz_sdp_file != NULL ) FileSetup( p_stream );
 
     free( id );
-    return VLC_SUCCESS;
 }
 
-static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
+static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
                  block_t *p_buffer )
 {
-    block_t *p_next;
-
     assert( p_stream->p_sys->p_mux == NULL );
     (void)p_stream;
 
     while( p_buffer != NULL )
     {
-        p_next = p_buffer->p_next;
+        block_t *p_next = p_buffer->p_next;
+        p_buffer->p_next = NULL;
 
         /* Send a Vorbis/Theora Packed Configuration packet (RFC 5215 ยง3.1)
          * as the first packet of the stream */
@@ -1257,7 +1289,6 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
         if( id->rtp_fmt.pf_packetize( id, p_buffer ) )
             break;
 
-        block_Release( p_buffer );
         p_buffer = p_next;
     }
     return VLC_SUCCESS;
@@ -1269,17 +1300,16 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
 static int SapSetup( sout_stream_t *p_stream )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
-    sout_instance_t   *p_sout = p_stream->p_sout;
 
     /* Remove the previous session */
     if( p_sys->p_session != NULL)
     {
-        sout_AnnounceUnRegister( p_sout, p_sys->p_session);
+        sout_AnnounceUnRegister( p_stream, p_sys->p_session);
         p_sys->p_session = NULL;
     }
 
     if( p_sys->i_es > 0 && p_sys->psz_sdp && *p_sys->psz_sdp )
-        p_sys->p_session = sout_AnnounceRegisterSDP( p_sout,
+        p_sys->p_session = sout_AnnounceRegisterSDP( p_stream,
                                                      p_sys->psz_sdp,
                                                      p_sys->psz_destination );
 
@@ -1299,8 +1329,8 @@ static int FileSetup( sout_stream_t *p_stream )
 
     if( ( f = vlc_fopen( p_sys->psz_sdp_file, "wt" ) ) == NULL )
     {
-        msg_Err( p_stream, "cannot open file '%s' (%m)",
-                 p_sys->psz_sdp_file );
+        msg_Err( p_stream, "cannot open file '%s' (%s)",
+                 p_sys->psz_sdp_file, vlc_strerror_c(errno) );
         return VLC_EGENERIC;
     }
 
@@ -1327,7 +1357,7 @@ static int HttpSetup( sout_stream_t *p_stream, const vlc_url_t *url)
         p_sys->p_httpd_file = httpd_FileNew( p_sys->p_httpd_host,
                                              url->psz_path ? url->psz_path : "/",
                                              "application/sdp",
-                                             NULL, NULL, NULL,
+                                             NULL, NULL,
                                              HttpCallback, (void*)p_sys );
     }
     if( p_sys->p_httpd_file == NULL )
@@ -1366,17 +1396,12 @@ static int  HttpCallback( httpd_file_sys_t *p_args,
  ****************************************************************************/
 static void* ThreadSend( void *data )
 {
-#ifdef WIN32
-# define ECONNREFUSED WSAECONNREFUSED
-# define ENOPROTOOPT  WSAENOPROTOOPT
-# define EHOSTUNREACH WSAEHOSTUNREACH
-# define ENETUNREACH  WSAENETUNREACH
-# define ENETDOWN     WSAENETDOWN
+#ifdef _WIN32
 # define ENOBUFS      WSAENOBUFS
 # define EAGAIN       WSAEWOULDBLOCK
 # define EWOULDBLOCK  WSAEWOULDBLOCK
 #endif
-    sout_stream_id_t *id = data;
+    sout_stream_id_sys_t *id = data;
     unsigned i_caching = id->i_caching;
 
     for (;;)
@@ -1396,8 +1421,8 @@ static void* ThreadSend( void *data )
             vlc_restorecancel (canc);
             if( val )
             {
-                errno = val;
-                msg_Dbg( id->p_stream, "SRTP sending error: %m" );
+                msg_Dbg( id->p_stream, "SRTP sending error: %s",
+                         vlc_strerror_c(val) );
                 block_Release( out );
                 out = NULL;
             }
@@ -1461,7 +1486,7 @@ static void* ThreadSend( void *data )
 /* This thread dequeues incoming connections (DCCP streaming) */
 static void *rtp_listen_thread( void *data )
 {
-    sout_stream_id_t *id = data;
+    sout_stream_id_sys_t *id = data;
 
     assert( id->listen.fd != NULL );
 
@@ -1475,11 +1500,11 @@ static void *rtp_listen_thread( void *data )
         vlc_restorecancel( canc );
     }
 
-    assert( 0 );
+    vlc_assert_unreachable();
 }
 
 
-int rtp_add_sink( sout_stream_id_t *id, int fd, bool rtcp_mux, uint16_t *seq )
+int rtp_add_sink( sout_stream_id_sys_t *id, int fd, bool rtcp_mux, uint16_t *seq )
 {
     rtp_sink_t sink = { fd, NULL };
     sink.rtcp = OpenRTCP( VLC_OBJECT( id->p_stream ), fd, IPPROTO_UDP,
@@ -1495,7 +1520,7 @@ int rtp_add_sink( sout_stream_id_t *id, int fd, bool rtcp_mux, uint16_t *seq )
     return VLC_SUCCESS;
 }
 
-void rtp_del_sink( sout_stream_id_t *id, int fd )
+void rtp_del_sink( sout_stream_id_sys_t *id, int fd )
 {
     rtp_sink_t sink = { fd, NULL };
 
@@ -1516,7 +1541,7 @@ void rtp_del_sink( sout_stream_id_t *id, int fd )
     net_Close( sink.rtp_fd );
 }
 
-uint16_t rtp_get_seq( sout_stream_id_t *id )
+uint16_t rtp_get_seq( sout_stream_id_sys_t *id )
 {
     /* This will return values for the next packet. */
     uint16_t seq;
@@ -1544,7 +1569,7 @@ static int64_t rtp_init_ts( const vod_media_t *p_media,
     /* As per RFC 2326, session identifiers are at least 8 bytes long */
     strncpy((char *)&i_ts_init, psz_vod_session, sizeof(uint64_t));
     i_ts_init ^= (uintptr_t)p_media;
-    /* Limit the timestamp to 48 bytes, this is enough and allows us
+    /* Limit the timestamp to 48 bits, this is enough and allows us
      * to stay away from overflows */
     i_ts_init &= 0xFFFFFFFFFFFF;
     return i_ts_init;
@@ -1555,7 +1580,7 @@ static int64_t rtp_init_ts( const vod_media_t *p_media,
  * Also return the NPT corresponding to this timestamp. If the stream
  * output is not started, the initial timestamp that will be used with
  * the first packets for NPT=0 is returned instead. */
-int64_t rtp_get_ts( const sout_stream_t *p_stream, const sout_stream_id_t *id,
+int64_t rtp_get_ts( const sout_stream_t *p_stream, const sout_stream_id_sys_t *id,
                     const vod_media_t *p_media, const char *psz_vod_session,
                     int64_t *p_npt )
 {
@@ -1588,7 +1613,7 @@ int64_t rtp_get_ts( const sout_stream_t *p_stream, const sout_stream_id_t *id,
     return p_sys->i_pts_zero + npt; 
 }
 
-void rtp_packetize_common( sout_stream_id_t *id, block_t *out,
+void rtp_packetize_common( sout_stream_id_sys_t *id, block_t *out,
                            int b_marker, int64_t i_pts )
 {
     if( !id->b_ts_init )
@@ -1626,11 +1651,15 @@ void rtp_packetize_common( sout_stream_id_t *id, block_t *out,
 
     memcpy( out->p_buffer + 8, id->ssrc, 4 );
 
-    out->i_buffer = 12;
     id->i_sequence++;
 }
 
-void rtp_packetize_send( sout_stream_id_t *id, block_t *out )
+uint16_t rtp_get_extended_sequence( sout_stream_id_sys_t *id )
+{
+    return id->i_sequence >> 16;
+}
+
+void rtp_packetize_send( sout_stream_id_sys_t *id, block_t *out )
 {
     block_FifoPut( id->p_fifo, out );
 }
@@ -1639,7 +1668,7 @@ void rtp_packetize_send( sout_stream_id_t *id, block_t *out )
  * @return configured max RTP payload size (including payload type-specific
  * headers, excluding RTP and transport headers)
  */
-size_t rtp_mtu (const sout_stream_id_t *id)
+size_t rtp_mtu (const sout_stream_id_sys_t *id)
 {
     return id->i_mtu - 12;
 }
@@ -1649,7 +1678,8 @@ size_t rtp_mtu (const sout_stream_id_t *id)
  *****************************************************************************/
 
 /** Add an ES to a non-RTP muxed stream */
-static sout_stream_id_t *MuxAdd( sout_stream_t *p_stream, es_format_t *p_fmt )
+static sout_stream_id_sys_t *MuxAdd( sout_stream_t *p_stream,
+                                     const es_format_t *p_fmt )
 {
     sout_input_t      *p_input;
     sout_mux_t *p_mux = p_stream->p_sys->p_mux;
@@ -1662,29 +1692,27 @@ static sout_stream_id_t *MuxAdd( sout_stream_t *p_stream, es_format_t *p_fmt )
         return NULL;
     }
 
-    return (sout_stream_id_t *)p_input;
+    return (sout_stream_id_sys_t *)p_input;
 }
 
 
-static int MuxSend( sout_stream_t *p_stream, sout_stream_id_t *id,
+static int MuxSend( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
                     block_t *p_buffer )
 {
     sout_mux_t *p_mux = p_stream->p_sys->p_mux;
     assert( p_mux != NULL );
 
-    sout_MuxSendBuffer( p_mux, (sout_input_t *)id, p_buffer );
-    return VLC_SUCCESS;
+    return sout_MuxSendBuffer( p_mux, (sout_input_t *)id, p_buffer );
 }
 
 
 /** Remove an ES from a non-RTP muxed stream */
-static int MuxDel( sout_stream_t *p_stream, sout_stream_id_t *id )
+static void MuxDel( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
 {
     sout_mux_t *p_mux = p_stream->p_sys->p_mux;
     assert( p_mux != NULL );
 
     sout_MuxDeleteStream( p_mux, (sout_input_t *)id );
-    return VLC_SUCCESS;
 }
 
 
@@ -1692,7 +1720,7 @@ static ssize_t AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
                                             const block_t *p_buffer )
 {
     sout_stream_sys_t *p_sys = p_stream->p_sys;
-    sout_stream_id_t *id = p_sys->es[0];
+    sout_stream_id_sys_t *id = p_sys->es[0];
 
     int64_t  i_dts = p_buffer->i_dts;
 
@@ -1717,7 +1745,7 @@ static ssize_t AccessOutGrabberWriteBuffer( sout_stream_t *p_stream,
         if( p_sys->packet == NULL )
         {
             /* allocate a new packet */
-            p_sys->packet = block_New( p_stream, id->i_mtu );
+            p_sys->packet = block_Alloc( id->i_mtu );
             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;
@@ -1776,3 +1804,9 @@ static sout_access_out_t *GrabberCreate( sout_stream_t *p_stream )
     p_grab->pf_write    = AccessOutGrabberWrite;
     return p_grab;
 }
+
+void rtp_get_video_geometry( sout_stream_id_sys_t *id, int *width, int *height )
+{
+    int ret = sscanf( id->rtp_fmt.fmtp, "%*s width=%d; height=%d; ", width, height );
+    assert( ret == 2 );
+}