]> git.sesse.net Git - vlc/blobdiff - modules/stream_out/mosaic_bridge.c
Fix Windows case which implements fd_set differently:
[vlc] / modules / stream_out / mosaic_bridge.c
index ee491c252d559035bb4f0be712530eabf85cddd1..17c396ec4db114be80f1b376e5deee827fc9ae23 100644 (file)
@@ -26,8 +26,6 @@
  * Preamble
  *****************************************************************************/
 #include <errno.h>                                                 /* ENOMEM */
-#include <stdlib.h>                                                /* free() */
-#include <string.h>                                            /* strerror() */
 
 #include <vlc/vlc.h>
 #include <vlc_sout.h>
@@ -132,12 +130,12 @@ static int MosaicBridgeCallback( vlc_object_t *, char const *,
 
 #define VFILTER_TEXT N_("Video filter")
 #define VFILTER_LONGTEXT N_( \
-    "Video filters will be applied to the video stream." );
+    "Video filters will be applied to the video stream." )
 
 #define CHROMA_TEXT N_("Image chroma")
 #define CHROMA_LONGTEXT N_( \
     "Force the use of a specific chroma. Use YUVA if you're planning " \
-    "to use the Alphamask or Bluescreen video filter." );
+    "to use the Alphamask or Bluescreen video filter." )
 
 #define CFG_PREFIX "sout-mosaic-bridge-"
 
@@ -162,8 +160,6 @@ vlc_module_begin();
                      NULL, NULL, VFILTER_TEXT, VFILTER_LONGTEXT, VLC_FALSE );
 
     set_callbacks( Open, Close );
-
-    var_Create( p_module->p_libvlc_global, "mosaic-lock", VLC_VAR_MUTEX );
 vlc_module_end();
 
 static const char *ppsz_sout_options[] = {
@@ -177,7 +173,7 @@ static int Open( vlc_object_t *p_this )
 {
     sout_stream_t        *p_stream = (sout_stream_t *)p_this;
     sout_stream_sys_t    *p_sys;
-    libvlc_global_data_t *p_libvlc_global = p_this->p_libvlc_global;
+    vlc_object_t         *p_libvlc = VLC_OBJECT( p_this->p_libvlc );
     vlc_value_t           val;
 
     config_ChainParse( p_stream, CFG_PREFIX, ppsz_sout_options,
@@ -192,7 +188,8 @@ static int Open( vlc_object_t *p_this )
     p_stream->p_sys = p_sys;
     p_sys->b_inited = VLC_FALSE;
 
-    var_Get( p_libvlc_global, "mosaic-lock", &val );
+    var_Create( p_libvlc, "mosaic-lock", VLC_VAR_MUTEX );
+    var_Get( p_libvlc, "mosaic-lock", &val );
     p_sys->p_lock = val.p_address;
 
     var_Get( p_stream, CFG_PREFIX "id", &val );
@@ -317,14 +314,14 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
     p_bridge = GetBridge( p_stream );
     if ( p_bridge == NULL )
     {
-        libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global;
+        vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->p_libvlc );
         vlc_value_t val;
 
         p_bridge = malloc( sizeof( bridge_t ) );
 
-        var_Create( p_libvlc_global, "mosaic-struct", VLC_VAR_ADDRESS );
+        var_Create( p_libvlc, "mosaic-struct", VLC_VAR_ADDRESS );
         val.p_address = p_bridge;
-        var_Set( p_libvlc_global, "mosaic-struct", val );
+        var_Set( p_libvlc, "mosaic-struct", val );
 
         p_bridge->i_es_num = 0;
         p_bridge->pp_es = NULL;
@@ -368,12 +365,12 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
 
     /* Create user specified video filters */
     psz_chain = var_GetNonEmptyString( p_stream, CFG_PREFIX "vfilter" );
-    printf("psz_chain: \e[33;1m%s\e[0m\n", psz_chain );
+    msg_Dbg( p_stream, "psz_chain: %s\n", psz_chain );
     {
         config_chain_t *p_cfg;
         for( p_cfg = p_stream->p_cfg; p_cfg != NULL; p_cfg = p_cfg->p_next )
         {
-            printf(" - %s\n", p_cfg->psz_value );
+            msg_Dbg( p_stream, " - %s\n", p_cfg->psz_value );
         }
     }
     p_sys->i_vfilters = 0;
@@ -419,8 +416,6 @@ static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
             vlc_object_destroy( *pp_vfilter );
             p_sys->i_vfilters--;
         }
-        //if( psz_parser && *psz_parser ) psz_parser++;
-        printf("\n\npsz_parser: %s\n\n", psz_parser );
     }
     free( psz_chain );
 
@@ -498,12 +493,12 @@ static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
 
     if ( b_last_es )
     {
-        libvlc_global_data_t *p_libvlc_global = p_stream->p_libvlc_global;
+        vlc_object_t *p_libvlc = VLC_OBJECT( p_stream->p_libvlc );
         for ( i = 0; i < p_bridge->i_es_num; i++ )
             free( p_bridge->pp_es[i] );
         free( p_bridge->pp_es );
         free( p_bridge );
-        var_Destroy( p_libvlc_global, "mosaic-struct" );
+        var_Destroy( p_libvlc, "mosaic-struct" );
     }
 
     vlc_mutex_unlock( p_sys->p_lock );
@@ -598,11 +593,25 @@ static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
         }
         else
         {
-            p_new_pic = (picture_t*)malloc( sizeof(picture_t) );
             /* TODO: chroma conversion if needed */
-            vout_AllocatePicture( p_stream, p_new_pic, p_pic->format.i_chroma,
+
+            p_new_pic = (picture_t*)malloc( sizeof(picture_t) );
+            if( p_new_pic == NULL )
+            {
+                msg_Err( p_stream, "image conversion failed" );
+                continue;
+            }
+
+            if( vout_AllocatePicture(
+                                  p_stream, p_new_pic, p_pic->format.i_chroma,
                                   p_pic->format.i_width, p_pic->format.i_height,
-                                  p_sys->p_decoder->fmt_out.video.i_aspect );
+                                  p_sys->p_decoder->fmt_out.video.i_aspect )
+                != VLC_SUCCESS )
+            {
+                free( p_new_pic );
+                msg_Err( p_stream, "image allocation failed" );
+                continue;
+            }
 
             vout_CopyPicture( p_stream, p_new_pic, p_pic );
         }