* Preamble
*****************************************************************************/
#include <errno.h> /* ENOMEM */
-#include <stdlib.h> /* free() */
-#include <string.h> /* strerror() */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
#include <vlc/vlc.h>
+#include <vlc_plugin.h>
#include <vlc_sout.h>
#include <vlc_block.h>
#include <vlc_codec.h>
int i_height, i_width;
unsigned int i_sar_num, i_sar_den;
char *psz_id;
- vlc_bool_t b_inited;
+ bool b_inited;
int i_chroma; /* force image format chroma */
}
else
{
- if( p_pic && p_pic->p_data_orig ) free( p_pic->p_data_orig );
- if( p_pic ) free( p_pic );
+ if( p_pic )
+ {
+ free( p_pic->p_data_orig );
+ free( p_pic );
+ }
}
}
}
inline static void video_del_buffer_decoder( decoder_t *, picture_t * );
inline static void video_del_buffer_filter( filter_t *, picture_t * );
-static void video_del_buffer( vlc_object_t *, picture_t * );
+static void video_del_buffer( picture_t * );
inline static picture_t *video_new_buffer_decoder( decoder_t * );
inline static picture_t *video_new_buffer_filter( filter_t * );
static void video_link_picture_decoder( decoder_t *, picture_t * );
static void video_unlink_picture_decoder( decoder_t *, picture_t * );
-static int MosaicBridgeCallback( vlc_object_t *, char const *,
- vlc_value_t, vlc_value_t, void * );
+
+static int HeightCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+static int WidthCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+static int alphaCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+static int xCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
+static int yCallback( vlc_object_t *, char const *,
+ vlc_value_t, vlc_value_t, void * );
/*****************************************************************************
* Module descriptor
#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 ALPHA_TEXT N_("Transparency")
+#define ALPHA_LONGTEXT N_( \
+ "Transparency of the mosaic picture." )
+
+#define X_TEXT N_("X offset")
+#define X_LONGTEXT N_( \
+ "X coordinate of the upper left corner in the mosaic if non negative." )
+
+#define Y_TEXT N_("Y offset")
+#define Y_LONGTEXT N_( \
+ "Y coordinate of the upper left corner in the mosaic if non negative." )
#define CFG_PREFIX "sout-mosaic-bridge-"
add_shortcut( "mosaic-bridge" );
add_string( CFG_PREFIX "id", "Id", NULL, ID_TEXT, ID_LONGTEXT,
- VLC_FALSE );
+ false );
add_integer( CFG_PREFIX "width", 0, NULL, WIDTH_TEXT,
- WIDTH_LONGTEXT, VLC_TRUE );
+ WIDTH_LONGTEXT, true );
add_integer( CFG_PREFIX "height", 0, NULL, HEIGHT_TEXT,
- HEIGHT_LONGTEXT, VLC_TRUE );
+ HEIGHT_LONGTEXT, true );
add_string( CFG_PREFIX "sar", "1:1", NULL, RATIO_TEXT,
- RATIO_LONGTEXT, VLC_FALSE );
+ RATIO_LONGTEXT, false );
add_string( CFG_PREFIX "chroma", 0, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
- VLC_FALSE );
+ false );
add_module_list( CFG_PREFIX "vfilter", "video filter2",
- NULL, NULL, VFILTER_TEXT, VFILTER_LONGTEXT, VLC_FALSE );
+ NULL, NULL, VFILTER_TEXT, VFILTER_LONGTEXT, false );
+
+ add_integer_with_range( CFG_PREFIX "alpha", 255, 0, 255, NULL,
+ ALPHA_TEXT, ALPHA_LONGTEXT, false );
+ add_integer( CFG_PREFIX "x", -1, NULL, X_TEXT, X_LONGTEXT, false );
+ add_integer( CFG_PREFIX "y", -1, NULL, Y_TEXT, Y_LONGTEXT, false );
set_callbacks( Open, Close );
vlc_module_end();
static const char *ppsz_sout_options[] = {
- "id", "width", "height", "sar", "vfilter", "chroma", NULL
+ "id", "width", "height", "sar", "vfilter", "chroma", "alpha", "x", "y", NULL
};
/*****************************************************************************
{
sout_stream_t *p_stream = (sout_stream_t *)p_this;
sout_stream_sys_t *p_sys;
- vlc_object_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,
}
p_stream->p_sys = p_sys;
- p_sys->b_inited = VLC_FALSE;
+ p_sys->b_inited = false;
- var_Create( p_libvlc_global, "mosaic-lock", VLC_VAR_MUTEX );
- 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 );
p_sys->i_height =
var_CreateGetIntegerCommand( p_stream, CFG_PREFIX "height" );
- var_AddCallback( p_stream, CFG_PREFIX "height", MosaicBridgeCallback,
- p_stream );
+ var_AddCallback( p_stream, CFG_PREFIX "height", HeightCallback, p_stream );
p_sys->i_width =
var_CreateGetIntegerCommand( p_stream, CFG_PREFIX "width" );
- var_AddCallback( p_stream, CFG_PREFIX "width", MosaicBridgeCallback,
- p_stream );
+ var_AddCallback( p_stream, CFG_PREFIX "width", WidthCallback, p_stream );
var_Get( p_stream, CFG_PREFIX "sar", &val );
if ( val.psz_string )
msg_Dbg( p_stream, "Forcing image chroma to 0x%.8x (%4.4s)", p_sys->i_chroma, (char*)&p_sys->i_chroma );
}
+#define INT_COMMAND( a ) \
+ var_Create( p_stream, CFG_PREFIX #a, \
+ VLC_VAR_INTEGER | VLC_VAR_DOINHERIT | VLC_VAR_ISCOMMAND ); \
+ var_AddCallback( p_stream, CFG_PREFIX #a, a ## Callback, \
+ p_stream );
+ INT_COMMAND( alpha )
+ INT_COMMAND( x )
+ INT_COMMAND( y )
+
p_stream->pf_add = Add;
p_stream->pf_del = Del;
p_stream->pf_send = Send;
p_stream->p_sout->i_out_pace_nocontrol--;
- if ( p_sys->psz_id )
- free( p_sys->psz_id );
+ free( p_sys->psz_id );
free( p_sys );
}
vlc_object_attach( p_sys->p_decoder, p_stream );
p_sys->p_decoder->p_module = NULL;
p_sys->p_decoder->fmt_in = *p_fmt;
- p_sys->p_decoder->b_pace_control = VLC_FALSE;
+ p_sys->p_decoder->b_pace_control = false;
p_sys->p_decoder->fmt_out = p_sys->p_decoder->fmt_in;
p_sys->p_decoder->fmt_out.i_extra = 0;
p_sys->p_decoder->fmt_out.p_extra = 0;
{
msg_Err( p_stream, "cannot find decoder" );
vlc_object_detach( p_sys->p_decoder );
- vlc_object_destroy( p_sys->p_decoder );
+ vlc_object_release( p_sys->p_decoder );
return NULL;
}
- p_sys->b_inited = VLC_TRUE;
+ p_sys->b_inited = true;
vlc_mutex_lock( p_sys->p_lock );
p_bridge = GetBridge( p_stream );
if ( p_bridge == NULL )
{
- vlc_object_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;
p_sys->p_es = p_es = p_bridge->pp_es[i];
+ p_es->i_alpha = var_GetInteger( p_stream, CFG_PREFIX "alpha" );
+ p_es->i_x = var_GetInteger( p_stream, CFG_PREFIX "x" );
+ p_es->i_y = var_GetInteger( p_stream, CFG_PREFIX "y" );
+
//p_es->fmt = *p_fmt;
p_es->psz_id = p_sys->psz_id;
p_es->p_picture = NULL;
p_es->pp_last = &p_es->p_picture;
- p_es->b_empty = VLC_FALSE;
+ p_es->b_empty = false;
vlc_mutex_unlock( p_sys->p_lock );
(*pp_vfilter)->fmt_out = (*pp_vfilter)->fmt_in;
(*pp_vfilter)->p_cfg = p_cfg;
(*pp_vfilter)->p_module =
- module_Need( *pp_vfilter, "video filter2", psz_name, VLC_TRUE );
+ module_Need( *pp_vfilter, "video filter2", psz_name, true );
if( (*pp_vfilter)->p_module )
{
/* It worked! */
"no video filter matching name \"%s\" found",
psz_name );
vlc_object_detach( *pp_vfilter );
- vlc_object_destroy( *pp_vfilter );
+ vlc_object_release( *pp_vfilter );
p_sys->i_vfilters--;
}
}
static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
{
+ VLC_UNUSED(id);
sout_stream_sys_t *p_sys = p_stream->p_sys;
bridge_t *p_bridge;
bridged_es_t *p_es;
- vlc_bool_t b_last_es = VLC_TRUE;
+ bool b_last_es = true;
filter_t **pp_vfilter, **pp_end;
int i;
if( p_sys->p_decoder->p_module )
module_Unneed( p_sys->p_decoder, p_sys->p_decoder->p_module );
vlc_object_detach( p_sys->p_decoder );
- vlc_object_destroy( p_sys->p_decoder );
+ vlc_object_release( p_sys->p_decoder );
for( i = 0; i < PICTURE_RING_SIZE; i++ )
{
if ( pp_ring[i] != NULL )
{
- if ( pp_ring[i]->p_data_orig != NULL )
- free( pp_ring[i]->p_data_orig );
+ free( pp_ring[i]->p_data_orig );
free( pp_ring[i]->p_sys );
free( pp_ring[i] );
}
vlc_object_detach( *pp_vfilter );
if( (*pp_vfilter)->p_module )
module_Unneed( *pp_vfilter, (*pp_vfilter)->p_module );
- vlc_object_destroy( *pp_vfilter );
+ vlc_object_release( *pp_vfilter );
}
free( p_sys->pp_vfilters );
p_bridge = GetBridge( p_stream );
p_es = p_sys->p_es;
- p_es->b_empty = VLC_TRUE;
+ p_es->b_empty = true;
while ( p_es->p_picture )
{
picture_t *p_next = p_es->p_picture->p_next;
{
if ( !p_bridge->pp_es[i]->b_empty )
{
- b_last_es = VLC_FALSE;
+ b_last_es = false;
break;
}
}
if ( b_last_es )
{
- vlc_object_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 );
image_HandlerDelete( p_sys->p_image );
}
- p_sys->b_inited = VLC_FALSE;
+ p_sys->b_inited = false;
return VLC_SUCCESS;
}
struct picture_sys_t
{
vlc_object_t *p_owner;
- vlc_bool_t b_dead;
+ bool b_dead;
};
static void video_release_buffer_decoder( picture_t *p_pic )
{
if ( pp_ring[i]->i_status == DESTROYED_PICTURE )
{
- if ( pp_ring[i]->p_data_orig != NULL )
- free( pp_ring[i]->p_data_orig );
+ free( pp_ring[i]->p_data_orig );
free( pp_ring[i]->p_sys );
free( pp_ring[i] );
}
else
{
- pp_ring[i]->p_sys->b_dead = VLC_TRUE;
+ pp_ring[i]->p_sys->b_dead = true;
}
pp_ring[i] = NULL;
}
}
p_pic = malloc( sizeof(picture_t) );
+ if( !p_pic ) return NULL;
fmt_out->video.i_chroma = fmt_out->i_codec;
vout_AllocatePicture( p_this, p_pic,
fmt_out->video.i_chroma,
p_pic->pf_release = pf_release;
p_pic->p_sys = malloc( sizeof(picture_sys_t) );
p_pic->p_sys->p_owner = p_this;
- p_pic->p_sys->b_dead = VLC_FALSE;
+ p_pic->p_sys->b_dead = false;
p_pic->i_status = RESERVED_PICTURE;
pp_ring[i] = p_pic;
inline static void video_del_buffer_decoder( decoder_t *p_this,
picture_t *p_pic )
{
- video_del_buffer( VLC_OBJECT( p_this ), p_pic );
+ VLC_UNUSED(p_this);
+ video_del_buffer( p_pic );
}
inline static void video_del_buffer_filter( filter_t *p_this,
picture_t *p_pic )
{
- video_del_buffer( VLC_OBJECT( p_this ), p_pic );
+ VLC_UNUSED(p_this);
+ video_del_buffer( p_pic );
}
-static void video_del_buffer( vlc_object_t *p_this, picture_t *p_pic )
+static void video_del_buffer( picture_t *p_pic )
{
p_pic->i_refcount = 0;
p_pic->i_status = DESTROYED_PICTURE;
if ( p_pic->p_sys->b_dead )
{
- if ( p_pic->p_data_orig != NULL )
- free( p_pic->p_data_orig );
+ free( p_pic->p_data_orig );
free( p_pic->p_sys );
free( p_pic );
}
static void video_link_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
{
+ VLC_UNUSED(p_dec);
p_pic->i_refcount++;
}
static void video_unlink_picture_decoder( decoder_t *p_dec, picture_t *p_pic )
{
+ VLC_UNUSED(p_dec);
video_release_buffer_decoder( p_pic );
}
/**********************************************************************
* Callback to update (some) params on the fly
**********************************************************************/
-static int MosaicBridgeCallback( vlc_object_t *p_this, char const *psz_var,
- vlc_value_t oldval, vlc_value_t newval,
- void *p_data )
+static int HeightCallback( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
sout_stream_t *p_stream = (sout_stream_t *)p_data;
sout_stream_sys_t *p_sys = p_stream->p_sys;
- int i_ret = VLC_SUCCESS;
-#define VAR_IS( a ) !strcmp( psz_var, CFG_PREFIX a )
- if( VAR_IS( "height" ) )
- {
- /* We create the handler before updating the value in p_sys
- * so we don't have to worry about locking */
- if( !p_sys->p_image && newval.i_int )
- p_sys->p_image = image_HandlerCreate( p_stream );
- p_sys->i_height = newval.i_int;
- }
- else if( VAR_IS( "width" ) )
- {
- /* We create the handler before updating the value in p_sys
- * so we don't have to worry about locking */
- if( !p_sys->p_image && newval.i_int )
- p_sys->p_image = image_HandlerCreate( p_stream );
- p_sys->i_width = newval.i_int;
- }
-#undef VAR_IS
+ /* We create the handler before updating the value in p_sys
+ * so we don't have to worry about locking */
+ if( !p_sys->p_image && newval.i_int )
+ p_sys->p_image = image_HandlerCreate( p_stream );
+ p_sys->i_height = newval.i_int;
+
+ return VLC_SUCCESS;
+}
+
+static int WidthCallback( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+ sout_stream_t *p_stream = (sout_stream_t *)p_data;
+ sout_stream_sys_t *p_sys = p_stream->p_sys;
- return i_ret;
+ /* We create the handler before updating the value in p_sys
+ * so we don't have to worry about locking */
+ if( !p_sys->p_image && newval.i_int )
+ p_sys->p_image = image_HandlerCreate( p_stream );
+ p_sys->i_width = newval.i_int;
+
+ return VLC_SUCCESS;
+}
+
+static int alphaCallback( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+ sout_stream_t *p_stream = (sout_stream_t *)p_data;
+ sout_stream_sys_t *p_sys = p_stream->p_sys;
+
+ if( p_sys->p_es )
+ p_sys->p_es->i_alpha = newval.i_int;
+
+ return VLC_SUCCESS;
+}
+
+static int xCallback( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+ sout_stream_t *p_stream = (sout_stream_t *)p_data;
+ sout_stream_sys_t *p_sys = p_stream->p_sys;
+
+ if( p_sys->p_es )
+ p_sys->p_es->i_x = newval.i_int;
+
+ return VLC_SUCCESS;
+}
+
+static int yCallback( vlc_object_t *p_this, char const *psz_var,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(p_this); VLC_UNUSED(oldval);
+ sout_stream_t *p_stream = (sout_stream_t *)p_data;
+ sout_stream_sys_t *p_sys = p_stream->p_sys;
+
+ if( p_sys->p_es )
+ p_sys->p_es->i_y = newval.i_int;
+
+ return VLC_SUCCESS;
}