]> git.sesse.net Git - vlc/blobdiff - src/stream_output/stream_output.c
Merge commit 'origin/1.0-bugfix'
[vlc] / src / stream_output / stream_output.c
index e85323581575e803be0a34dba12f5708332a57b0..a6672dede5784847466da56805d9bda44a0beec1 100644 (file)
 #include "stream_output.h"
 
 #include <vlc_meta.h>
+#include <vlc_block.h>
+#include <vlc_codec.h>
 
-#include "input/input_internal.h"
+#include "input/input_interface.h"
+
+#define VLC_CODEC_NULL VLC_FOURCC( 'n', 'u', 'l', 'l' )
 
 #undef DEBUG_BUFFER
 /*****************************************************************************
@@ -154,52 +158,43 @@ void sout_DeleteInstance( sout_instance_t * p_sout )
  *****************************************************************************/
 void sout_UpdateStatistic( sout_instance_t *p_sout, sout_statistic_t i_type, int i_delta )
 {
-    input_thread_t *p_input;
-    int i_bytes; /* That's pretty stupid to define it as an integer, it will overflow
-                    really fast ... */
-
-    if( !libvlc_stats (p_sout) )
+    if( !libvlc_stats( p_sout ) )
         return;
 
-    /* FIXME that's ugly
-     * TODO add a private (ie not VLC_EXPORTed) input_UpdateStatistic for that */
-    p_input = vlc_object_find( p_sout, VLC_OBJECT_INPUT, FIND_PARENT );
-    if( !p_input || p_input->i_state == INIT_S || p_input->i_state == ERROR_S )
+    /* */
+    input_thread_t *p_input = vlc_object_find( p_sout, VLC_OBJECT_INPUT, FIND_PARENT );
+    if( !p_input )
         return;
 
+    int i_input_type;
     switch( i_type )
     {
-#define I(c) stats_UpdateInteger( p_input, p_input->p->counters.c, i_delta, NULL )
     case SOUT_STATISTIC_DECODED_VIDEO:
-        I(p_decoded_video);
+        i_input_type = SOUT_STATISTIC_DECODED_VIDEO;
         break;
     case SOUT_STATISTIC_DECODED_AUDIO:
-        I(p_decoded_audio);
+        i_input_type = SOUT_STATISTIC_DECODED_AUDIO;
         break;
     case SOUT_STATISTIC_DECODED_SUBTITLE:
-        I(p_decoded_sub);
+        i_input_type = SOUT_STATISTIC_DECODED_SUBTITLE;
         break;
-#if 0
-    case SOUT_STATISTIC_ENCODED_VIDEO:
-    case SOUT_STATISTIC_ENCODED_AUDIO:
-    case SOUT_STATISTIC_ENCODED_SUBTITLE:
-        msg_Warn( p_sout, "Not yet supported statistic type %d", i_type );
-        break;
-#endif
 
     case SOUT_STATISTIC_SENT_PACKET:
-        I(p_sout_sent_packets);
+        i_input_type = SOUT_STATISTIC_SENT_PACKET;
         break;
-#undef I
+
     case SOUT_STATISTIC_SENT_BYTE:
-        if( !stats_UpdateInteger( p_input, p_input->p->counters.p_sout_sent_bytes, i_delta, &i_bytes ) )
-            stats_UpdateFloat( p_input, p_input->p->counters.p_sout_send_bitrate, i_bytes, NULL );
+        i_input_type = SOUT_STATISTIC_SENT_BYTE;
         break;
 
     default:
-        msg_Err( p_sout, "Invalid statistic type %d (internal error)", i_type );
-        break;
+        msg_Err( p_sout, "Not yet supported statistic type %d", i_type );
+        vlc_object_release( p_input );
+        return;
     }
+
+    input_UpdateStatistic( p_input, i_input_type, i_delta );
+
     vlc_object_release( p_input );
 }
 /*****************************************************************************
@@ -218,7 +213,7 @@ sout_packetizer_input_t *sout_InputNew( sout_instance_t *p_sout,
 
     msg_Dbg( p_sout, "adding a new sout input (sout_input:%p)", p_input );
 
-    if( p_fmt->i_codec == VLC_FOURCC( 'n', 'u', 'l', 'l' ) )
+    if( p_fmt->i_codec == VLC_CODEC_NULL )
     {
         vlc_object_release( p_sout );
         return p_input;
@@ -247,7 +242,7 @@ int sout_InputDelete( sout_packetizer_input_t *p_input )
 
     msg_Dbg( p_sout, "removing a sout input (sout_input:%p)", p_input );
 
-    if( p_input->p_fmt->i_codec != VLC_FOURCC( 'n', 'u', 'l', 'l' ) )
+    if( p_input->p_fmt->i_codec != VLC_CODEC_NULL )
     {
         vlc_mutex_lock( &p_sout->lock );
         p_sout->p_stream->pf_del( p_sout->p_stream, p_input->id );
@@ -268,7 +263,7 @@ int sout_InputSendBuffer( sout_packetizer_input_t *p_input,
     sout_instance_t     *p_sout = p_input->p_sout;
     int                 i_ret;
 
-    if( p_input->p_fmt->i_codec == VLC_FOURCC( 'n', 'u', 'l', 'l' ) )
+    if( p_input->p_fmt->i_codec == VLC_CODEC_NULL )
     {
         block_Release( p_buffer );
         return VLC_SUCCESS;
@@ -321,7 +316,7 @@ sout_access_out_t *sout_AccessOutNew( vlc_object_t *p_sout,
     vlc_object_attach( p_access, p_sout );
 
     p_access->p_module   =
-        module_Need( p_access, "sout access", p_access->psz_access, true );
+        module_need( p_access, "sout access", p_access->psz_access, true );
 
     if( !p_access->p_module )
     {
@@ -342,7 +337,7 @@ void sout_AccessOutDelete( sout_access_out_t *p_access )
     vlc_object_detach( p_access );
     if( p_access->p_module )
     {
-        module_Unneed( p_access, p_access->p_module );
+        module_unneed( p_access, p_access->p_module );
     }
     free( p_access->psz_access );
 
@@ -443,7 +438,7 @@ sout_mux_t * sout_MuxNew( sout_instance_t *p_sout, char *psz_mux,
     vlc_object_attach( p_mux, p_sout );
 
     p_mux->p_module =
-        module_Need( p_mux, "sout mux", p_mux->psz_mux, true );
+        module_need( p_mux, "sout mux", p_mux->psz_mux, true );
 
     if( p_mux->p_module == NULL )
     {
@@ -503,7 +498,7 @@ void sout_MuxDelete( sout_mux_t *p_mux )
     vlc_object_detach( p_mux );
     if( p_mux->p_module )
     {
-        module_Unneed( p_mux, p_mux->p_module );
+        module_unneed( p_mux, p_mux->p_module );
     }
     free( p_mux->psz_mux );
 
@@ -796,7 +791,7 @@ sout_stream_t *sout_StreamNew( sout_instance_t *p_sout, char *psz_chain )
     vlc_object_attach( p_stream, p_sout );
 
     p_stream->p_module =
-        module_Need( p_stream, "sout stream", p_stream->psz_name, true );
+        module_need( p_stream, "sout stream", p_stream->psz_name, true );
 
     if( !p_stream->p_module )
     {
@@ -812,7 +807,7 @@ void sout_StreamDelete( sout_stream_t *p_stream )
     msg_Dbg( p_stream, "destroying chain... (name=%s)", p_stream->psz_name );
 
     vlc_object_detach( p_stream );
-    if( p_stream->p_module ) module_Unneed( p_stream, p_stream->p_module );
+    if( p_stream->p_module ) module_unneed( p_stream, p_stream->p_module );
 
     FREENULL( p_stream->psz_name );
     FREENULL( p_stream->psz_next );
@@ -882,3 +877,11 @@ rtp:
     mrl_Clean( &mrl );
     return psz_chain;
 }
+
+#undef sout_EncoderCreate
+encoder_t *sout_EncoderCreate( vlc_object_t *p_this )
+{
+    static const char type[] = "encoder";
+    return vlc_custom_create( p_this, sizeof( encoder_t ), VLC_OBJECT_GENERIC,
+                              type );
+}