]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/rtp.c
TS mux: reduce indentation
[vlc] / modules / stream_out / rtp.c
index f414d641be1778ad8207b036e2c2eaa0a15cee2d..cd8d363010fc958f8724a03b30efd7ad7d9b3331 100644 (file)
 #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,13 +164,6 @@ 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 " \
@@ -253,13 +248,11 @@ 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_CFG_PREFIX "user", "",
+    add_string( "sout-rtsp-user", "",
                 RTSP_USER_TEXT, RTSP_USER_LONGTEXT, true )
-    add_password( SOUT_CFG_PREFIX "pwd", "",
+    add_password( "sout-rtsp-pwd", "",
                   RTSP_PASS_TEXT, RTSP_PASS_LONGTEXT, true )
 
 vlc_module_end ()
@@ -270,7 +263,10 @@ vlc_module_end ()
 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",
+    "proto", "rtcp-mux", "caching",
+#ifdef HAVE_SRTP
+    "key", "salt",
+#endif
     "mp4a-latm", NULL
 };
 
@@ -730,23 +726,23 @@ static void SDPHandleUrl( sout_stream_t *p_stream, const char *psz_url )
 
         if( url.psz_host != NULL && *url.psz_host )
         {
-            /* msg_Err( p_stream, "\"%s\" RTSP host ignored", url.psz_host );
-            msg_Info( p_stream, "Pass --rtsp-host=%s on the command line "
-                      "instead.", 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 )
+        if( url.i_port != 0 )
         {
-            msg_Err( p_stream, "\"%u\" RTSP port ignored", url.i_port );
-            msg_Info( p_stream, "Pass --rtsp-port=%u on the command line "
-                      "instead.", url.i_port );
-        } */
+            /* msg_Info( p_stream, "Consider passing --rtsp-port=%u on "
+                      "the command line instead.", url.i_port ); */
 
-        if( url.i_port <= 0 ) url.i_port = 554;
-        var_Create( p_stream, "rtsp-port", VLC_VAR_INTEGER );
-        var_SetInteger( p_stream, "rtsp-port", 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 )
@@ -950,9 +946,14 @@ 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 */
@@ -1575,7 +1576,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;