]> git.sesse.net Git - vlc/blobdiff - modules/access_output/udp.c
cdda/access.c: Fix a warning.
[vlc] / modules / access_output / udp.c
index 22deda05e660d403f3403fb19daaddb227477665..7a0a829d80428371dcce6440d80f912e383bdffd 100644 (file)
@@ -102,8 +102,10 @@ static void Close( vlc_object_t * );
                        "directly, without trying to fill the MTU (ie, " \
                        "without trying to make the biggest possible packets " \
                        "in order to improve streaming)." )
-#define RTCP_TEXT N_("RTCP destination port number")
-#define RTCP_LONGTEXT N_("Sends RTCP packets to this port (0 = auto)")
+#define RTCP_TEXT N_("RTCP Sender Report")
+#define RTCP_LONGTEXT N_("Send RTCP Sender Report packets")
+#define RTCP_PORT_TEXT N_("RTCP destination port number")
+#define RTCP_PORT_LONGTEXT N_("Sends RTCP packets to this port (0 = auto)")
 #define AUTO_MCAST_TEXT N_("Automatic multicast streaming")
 #define AUTO_MCAST_LONGTEXT N_("Allocates an outbound multicast address " \
                                "automatically.")
@@ -120,11 +122,13 @@ vlc_module_begin();
     add_integer( SOUT_CFG_PREFIX "caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE );
     add_integer( SOUT_CFG_PREFIX "group", 1, NULL, GROUP_TEXT, GROUP_LONGTEXT,
                                  VLC_TRUE );
-    add_suppressed_integer( SOUT_CFG_PREFIX "late" );
+    add_obsolete_integer( SOUT_CFG_PREFIX "late" );
     add_bool( SOUT_CFG_PREFIX "raw",  VLC_FALSE, NULL, RAW_TEXT, RAW_LONGTEXT,
                                  VLC_TRUE );
-    add_integer( SOUT_CFG_PREFIX "rtcp",  0, NULL, RTCP_TEXT, RTCP_LONGTEXT,
-                 VLC_TRUE );
+    add_bool( SOUT_CFG_PREFIX "rtcp",  VLC_FALSE, NULL, RAW_TEXT, RAW_LONGTEXT,
+                                 VLC_TRUE );
+    add_integer( SOUT_CFG_PREFIX "rtcp-port",  0, NULL, RTCP_PORT_TEXT,
+                 RTCP_PORT_LONGTEXT, VLC_TRUE );
     add_bool( SOUT_CFG_PREFIX "auto-mcast", VLC_FALSE, NULL, AUTO_MCAST_TEXT,
               AUTO_MCAST_LONGTEXT, VLC_TRUE );
     add_bool( SOUT_CFG_PREFIX "udplite", VLC_FALSE, NULL, UDPLITE_TEXT, UDPLITE_LONGTEXT, VLC_TRUE );
@@ -140,19 +144,20 @@ vlc_module_end();
  * Exported prototypes
  *****************************************************************************/
 
-static const char *ppsz_sout_options[] = {
+static const char *const ppsz_sout_options[] = {
     "auto-mcast",
     "caching",
     "group",
     "raw",
     "rtcp",
+    "rtcp-port",
     "lite",
     "cscov",
     NULL
 };
 
 /* Options handled by the libvlc network core */
-static const char *ppsz_core_options[] = {
+static const char *const ppsz_core_options[] = {
     "dscp",
     "ttl",
     "miface",
@@ -227,8 +232,6 @@ static int Open( vlc_object_t *p_this )
 
     int                 i_handle;
 
-    vlc_value_t         val;
-
     config_ChainParse( p_access, SOUT_CFG_PREFIX,
                        ppsz_sout_options, p_access->p_cfg );
     config_ChainParse( p_access, "",
@@ -275,7 +278,7 @@ static int Open( vlc_object_t *p_this )
         if (psz_parser[0] == '[')
             psz_parser = strchr (psz_parser, ']');
 
-        psz_parser = strchr (psz_parser, ':');
+        psz_parser = strchr (psz_parser ?: psz_dst_addr, ':');
         if (psz_parser != NULL)
         {
             *psz_parser++ = '\0';
@@ -283,13 +286,14 @@ static int Open( vlc_object_t *p_this )
         }
     }
 
-    /* This option is really only meant for the RTP streaming output
-     * plugin. Doing RTCP for raw UDP will yield weird results. */
-    i_rtcp_port = var_GetInteger (p_access, SOUT_CFG_PREFIX"rtcp");
-    /* If RTCP port is not specified, use the default, if we do RTP/MP2 encap,
-     * or do not use RTCP at all otherwise. */
-    if ((i_rtcp_port == 0) && (p_sys->b_rtpts))
-        i_rtcp_port = i_dst_port + 1;
+    if (var_GetBool (p_access, SOUT_CFG_PREFIX"rtcp"))
+    {
+        /* This is really only for the RTP sout plugin.
+         * Doing RTCP for non RTP packet is NOT a good idea. */
+        i_rtcp_port = var_GetInteger (p_access, SOUT_CFG_PREFIX"rtcp-port");
+        if (i_rtcp_port == 0)
+            i_rtcp_port = i_dst_port + 1;
+    }
 
     p_sys->p_thread =
         vlc_object_create( p_access, sizeof( sout_access_thread_t ) );
@@ -398,9 +402,10 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    var_Get( p_access, SOUT_CFG_PREFIX "raw", &val );
-    if( val.b_bool )  p_access->pf_write = WriteRaw;
-    else p_access->pf_write = Write;
+    if (var_GetBool (p_accesss, SOUT_CFG_PREFIX"raw"))
+        p_access->pf_write = WriteRaw;
+    else
+        p_access->pf_write = Write;
 
     p_access->pf_seek = Seek;
 
@@ -419,7 +424,7 @@ static void Close( vlc_object_t * p_this )
     sout_access_out_sys_t *p_sys = p_access->p_sys;
     int i;
 
-    p_sys->p_thread->b_die = 1;
+    vlc_object_kill( p_sys->p_thread );
     for( i = 0; i < 10; i++ )
     {
         block_t *p_dummy = block_New( p_access, p_sys->i_mtu );
@@ -460,6 +465,7 @@ static int Write( sout_access_out_t *p_access, block_t *p_buffer )
     {
         block_t *p_next;
         int i_packets = 0;
+        mtime_t now = mdate();
 
         if( !p_sys->b_mtu_warning && p_buffer->i_buffer > p_sys->i_mtu )
         {
@@ -472,10 +478,10 @@ static int Write( sout_access_out_t *p_access, block_t *p_buffer )
         if( p_sys->p_buffer &&
             p_sys->p_buffer->i_buffer + p_buffer->i_buffer > p_sys->i_mtu )
         {
-            if( p_sys->p_buffer->i_dts + p_sys->p_thread->i_caching < mdate() )
+            if( p_sys->p_buffer->i_dts + p_sys->p_thread->i_caching < now )
             {
                 msg_Dbg( p_access, "late packet for UDP input (" I64Fd ")",
-                         mdate() - p_sys->p_buffer->i_dts
+                         now - p_sys->p_buffer->i_dts
                           - p_sys->p_thread->i_caching );
             }
             block_FifoPut( p_sys->p_thread->p_fifo, p_sys->p_buffer );
@@ -515,8 +521,7 @@ static int Write( sout_access_out_t *p_access, block_t *p_buffer )
             if( p_sys->p_buffer->i_buffer == p_sys->i_mtu || i_packets > 1 )
             {
                 /* Flush */
-                if( p_sys->p_buffer->i_dts + p_sys->p_thread->i_caching
-                      < mdate() )
+                if( p_sys->p_buffer->i_dts + p_sys->p_thread->i_caching < now )
                 {
                     msg_Dbg( p_access, "late packet for udp input (" I64Fd ")",
                              mdate() - p_sys->p_buffer->i_dts