]> git.sesse.net Git - vlc/blobdiff - src/stream_output/stream_output.c
sout-standard-url is deprecated
[vlc] / src / stream_output / stream_output.c
index 8cfcd7b5aabded20936a7c28528c4a24631ae5bb..4f768d57b269bdc36ccdda0b0067b50d9e62b10f 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * stream_output.c : stream output module
  *****************************************************************************
- * Copyright (C) 2002-2004 VideoLAN
+ * Copyright (C) 2002-2004 the VideoLAN team
  * $Id$
  *
  * Authors: Christophe Massiot <massiot@via.ecp.fr>
@@ -20,7 +20,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
 /*****************************************************************************
@@ -32,6 +32,7 @@
 
 #include <vlc/vlc.h>
 #include <vlc/sout.h>
+#include <vlc/input.h>
 
 #include "vlc_meta.h"
 
@@ -71,22 +72,22 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
 {
     sout_instance_t *p_sout;
     vlc_value_t keep;
+    counter_t *p_counter;
 
     if( var_Get( p_parent, "sout-keep", &keep ) < 0 )
     {
         msg_Warn( p_parent, "cannot get sout-keep value" );
         keep.b_bool = VLC_FALSE;
     }
-    else if( keep.b_bool )
+    if( keep.b_bool )
     {
-        msg_Warn( p_parent, "sout-keep true" );
         if( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT,
-                                        FIND_ANYWHERE ) ) )
+                                        FIND_ANYWHERE ) ) != NULL )
         {
             if( !strcmp( p_sout->psz_sout, psz_dest ) )
             {
-                msg_Warn( p_parent, "sout keep : reusing sout" );
-                msg_Warn( p_parent, "sout keep : you probably want to use "
+                msg_Dbg( p_parent, "sout keep : reusing sout" );
+                msg_Dbg( p_parent, "sout keep : you probably want to use "
                           "gather stream_out" );
                 vlc_object_detach( p_sout );
                 vlc_object_attach( p_sout, p_parent );
@@ -95,7 +96,8 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
             }
             else
             {
-                msg_Warn( p_parent, "sout keep : destroying unusable sout" );
+                msg_Dbg( p_parent, "sout keep : destroying unusable sout" );
+                vlc_object_release( p_sout );
                 sout_DeleteInstance( p_sout );
             }
         }
@@ -103,9 +105,10 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
     else if( !keep.b_bool )
     {
         while( ( p_sout = vlc_object_find( p_parent, VLC_OBJECT_SOUT,
-                                           FIND_PARENT ) ) )
+                                           FIND_PARENT ) ) != NULL )
         {
-            msg_Warn( p_parent, "sout keep : destroying old sout" );
+            msg_Dbg( p_parent, "sout keep : destroying old sout" );
+            vlc_object_release( p_sout );
             sout_DeleteInstance( p_sout );
         }
     }
@@ -139,6 +142,17 @@ sout_instance_t *__sout_NewInstance( vlc_object_t *p_parent, char * psz_dest )
     /* attach it for inherit */
     vlc_object_attach( p_sout, p_parent );
 
+    /* Create statistics */
+    stats_Create( p_parent, "sout_sent_packets", STATS_SOUT_SENT_PACKETS,
+                  VLC_VAR_INTEGER, STATS_COUNTER );
+    stats_Create( p_parent, "sout_sent_bytes", STATS_SOUT_SENT_BYTES,
+                  VLC_VAR_INTEGER, STATS_COUNTER );
+    stats_Create( p_parent, "sout_send_bitrate", STATS_SOUT_SEND_BITRATE,
+                  VLC_VAR_FLOAT, STATS_DERIVATIVE );
+    p_counter = stats_CounterGet( p_parent, p_parent->i_object_id,
+                                  STATS_SOUT_SEND_BITRATE );
+    if( p_counter) p_counter->update_interval = 1000000;
+
     p_sout->p_stream = sout_StreamNew( p_sout, p_sout->psz_chain );
 
     if( p_sout->p_stream == NULL )
@@ -296,6 +310,10 @@ sout_access_out_t *sout_AccessOutNew( sout_instance_t *p_sout,
     p_access->pf_read    = NULL;
     p_access->pf_write   = NULL;
     p_access->p_module   = NULL;
+
+    p_access->i_writes = 0;
+    p_access->i_sent_bytes = 0;
+
     vlc_object_attach( p_access, p_sout );
 
     p_access->p_module   =
@@ -353,6 +371,26 @@ int sout_AccessOutRead( sout_access_out_t *p_access, block_t *p_buffer )
  *****************************************************************************/
 int sout_AccessOutWrite( sout_access_out_t *p_access, block_t *p_buffer )
 {
+    int i_total;
+    p_access->i_writes++;
+    p_access->i_sent_bytes += p_buffer->i_buffer;
+    if( p_access->p_libvlc->b_stats && p_access->i_writes % 30 == 0 )
+    {
+        /* Access_out -> sout_instance -> input_thread_t */
+        input_thread_t *p_input =
+            (input_thread_t *)vlc_object_find( p_access, VLC_OBJECT_INPUT,
+                                               FIND_PARENT );
+        if( p_input )
+        {
+            stats_UpdateInteger( p_input, STATS_SOUT_SENT_PACKETS, 30, NULL );
+            stats_UpdateInteger( p_input, STATS_SOUT_SENT_BYTES,
+                                 p_access->i_sent_bytes, &i_total );
+            stats_UpdateFloat( p_input, STATS_SOUT_SEND_BITRATE, (float)i_total,
+                               NULL );
+            p_access->i_sent_bytes = 0;
+            vlc_object_release( p_input );
+        }
+    }
     return p_access->pf_write( p_access, p_buffer );
 }
 
@@ -472,7 +510,7 @@ sout_input_t *sout_MuxAddStream( sout_mux_t *p_mux, es_format_t *p_fmt )
 
     if( !p_mux->b_add_stream_any_time && !p_mux->b_waiting_stream )
     {
-        msg_Err( p_mux, "cannot add a new stream (unsuported while muxing "
+        msg_Err( p_mux, "cannot add a new stream (unsupported while muxing "
                         "for this format)" );
         return NULL;
     }
@@ -543,6 +581,14 @@ void sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
 {
     block_FifoPut( p_input->p_fifo, p_buffer );
 
+    if( p_mux->p_sout->i_out_pace_nocontrol )
+    {
+        mtime_t current_date = mdate();
+        if ( current_date > p_buffer->i_dts )
+            msg_Warn( p_mux, "late buffer for mux input ("I64Fd")",
+                      current_date - p_buffer->i_dts );
+    }
+
     if( p_mux->b_waiting_stream )
     {
         if( p_mux->i_add_stream_start < 0 )
@@ -551,7 +597,7 @@ void sout_MuxSendBuffer( sout_mux_t *p_mux, sout_input_t *p_input,
         }
 
         if( p_mux->i_add_stream_start >= 0 &&
-            p_mux->i_add_stream_start + I64C(15000000) < p_buffer->i_dts )
+            p_mux->i_add_stream_start + I64C(1500000) < p_buffer->i_dts )
         {
             /* Wait until we have more than 1.5 seconds worth of data
              * before start muxing */
@@ -922,6 +968,7 @@ void __sout_CfgParse( vlc_object_t *p_this, char *psz_prefix,
         vlc_value_t val;
         vlc_bool_t b_yes = VLC_TRUE;
         vlc_bool_t b_once = VLC_FALSE;
+        module_config_t *p_conf;
 
         if( cfg->psz_name == NULL || *cfg->psz_name == '\0' )
         {
@@ -961,6 +1008,42 @@ void __sout_CfgParse( vlc_object_t *p_this, char *psz_prefix,
         /* create name */
         asprintf( &psz_name, "%s%s", psz_prefix, b_once ? &ppsz_options[i][1] : ppsz_options[i] );
 
+
+        /* Check if the option is deprecated */
+
+        p_conf = config_FindConfig( p_this, psz_name );
+
+        /* This is basically cut and paste from src/misc/configuration.c
+         * with slight changes */
+        if( p_conf && p_conf->psz_current )
+        {
+            if( !strcmp( p_conf->psz_current, "SUPPRESSED" ) )
+            {
+                msg_Err( p_this, "Option %s is no longer used.",
+                         p_conf->psz_name );
+                goto next;
+            }
+            else if( p_conf->b_strict )
+            {
+                msg_Err( p_this, "Option %s is deprecated. Use %s instead.",
+                         p_conf->psz_name, p_conf->psz_current );
+                /* TODO: this should return an error and end option parsing
+                 * ... but doing this would change the VLC API and all the
+                 * modules so i'll do it later */
+                goto next;
+            }
+            else
+            {
+                msg_Warn( p_this, "Option %s is deprecated. You should use "
+                        "%s instead.", p_conf->psz_name, p_conf->psz_current );
+                i_type = config_GetType( p_this, psz_name );
+                free( psz_name );
+                psz_name = strdup( p_conf->psz_current );
+                var_Create( p_this, psz_name, i_type | VLC_VAR_DOINHERIT );
+            }
+        }
+        /* </Check if the option is deprecated> */
+
         /* get the type of the variable */
         i_type = config_GetType( p_this, psz_name );
         if( !i_type )
@@ -993,6 +1076,7 @@ void __sout_CfgParse( vlc_object_t *p_this, char *psz_prefix,
                 val.f_float = atof( cfg->psz_value ? cfg->psz_value : "0" );
                 break;
             case VLC_VAR_STRING:
+            case VLC_VAR_MODULE:
                 val.psz_string = cfg->psz_value;
                 break;
             default:
@@ -1096,12 +1180,12 @@ static char *_sout_stream_url_to_chain( vlc_object_t *p_this, char *psz_url )
     if( config_GetInt( p_this, "sout-display" ) )
     {
         p += sprintf( p, "duplicate{dst=display,dst=std{mux=\"%s\","
-                      "access=\"%s\",url=\"%s\"}}",
+                      "access=\"%s\",dst=\"%s\"}}",
                       mrl.psz_way, mrl.psz_access, mrl.psz_name );
     }
     else
     {
-        p += sprintf( p, "std{mux=\"%s\",access=\"%s\",url=\"%s\"}",
+        p += sprintf( p, "std{mux=\"%s\",access=\"%s\",dst=\"%s\"}",
                       mrl.psz_way, mrl.psz_access, mrl.psz_name );
     }