/*****************************************************************************
* mosaic_bridge.c:
*****************************************************************************
- * Copyright (C) 2004-2007 the VideoLAN team
+ * Copyright (C) 2004-2007 VLC authors and VideoLAN
* $Id$
*
* Authors: Antoine Cellerier <dionoea@videolan.org>
* Christophe Massiot <massiot@via.ecp.fr>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
#include <vlc_image.h>
#include <vlc_filter.h>
+#include <vlc_modules.h>
#include "../video_filter/mosaic.h"
struct sout_stream_sys_t
{
bridged_es_t *p_es;
- vlc_mutex_t *p_lock;
decoder_t *p_decoder;
image_handler_t *p_image; /* filter for resizing */
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * );
-static sout_stream_id_t *Add ( sout_stream_t *, es_format_t * );
-static int Del ( sout_stream_t *, sout_stream_id_t * );
-static int Send( sout_stream_t *, sout_stream_id_t *, block_t * );
+static sout_stream_id_sys_t *Add ( sout_stream_t *, es_format_t * );
+static int Del ( sout_stream_t *, sout_stream_id_sys_t * );
+static int Send( sout_stream_t *, sout_stream_id_sys_t *, block_t * );
inline static void video_del_buffer_decoder( decoder_t *, picture_t * );
inline static void video_del_buffer_filter( filter_t *, picture_t * );
set_capability( "sout stream", 0 )
add_shortcut( "mosaic-bridge" )
- add_string( CFG_PREFIX "id", "Id", NULL, ID_TEXT, ID_LONGTEXT,
+ add_string( CFG_PREFIX "id", "Id", ID_TEXT, ID_LONGTEXT,
false )
- add_integer( CFG_PREFIX "width", 0, NULL, WIDTH_TEXT,
+ add_integer( CFG_PREFIX "width", 0, WIDTH_TEXT,
WIDTH_LONGTEXT, true )
- add_integer( CFG_PREFIX "height", 0, NULL, HEIGHT_TEXT,
+ add_integer( CFG_PREFIX "height", 0, HEIGHT_TEXT,
HEIGHT_LONGTEXT, true )
- add_string( CFG_PREFIX "sar", "1:1", NULL, RATIO_TEXT,
+ add_string( CFG_PREFIX "sar", "1:1", RATIO_TEXT,
RATIO_LONGTEXT, false )
- add_string( CFG_PREFIX "chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
+ add_string( CFG_PREFIX "chroma", NULL, CHROMA_TEXT, CHROMA_LONGTEXT,
false )
add_module_list( CFG_PREFIX "vfilter", "video filter2",
- NULL, NULL, VFILTER_TEXT, VFILTER_LONGTEXT, false )
+ NULL, VFILTER_TEXT, VFILTER_LONGTEXT, false )
- add_integer_with_range( CFG_PREFIX "alpha", 255, 0, 255, NULL,
+ add_integer_with_range( CFG_PREFIX "alpha", 255, 0, 255,
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 )
+ add_integer( CFG_PREFIX "x", -1, X_TEXT, X_LONGTEXT, false )
+ add_integer( CFG_PREFIX "y", -1, Y_TEXT, Y_LONGTEXT, false )
set_callbacks( Open, Close )
vlc_module_end ()
{
sout_stream_t *p_stream = (sout_stream_t *)p_this;
sout_stream_sys_t *p_sys;
- 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 = false;
- var_Create( p_libvlc, "mosaic-lock", VLC_VAR_MUTEX );
- var_Get( p_libvlc, "mosaic-lock", &val );
- p_sys->p_lock = val.p_address;
-
p_sys->psz_id = var_CreateGetString( p_stream, CFG_PREFIX "id" );
p_sys->i_height =
p_stream->pf_add = Add;
p_stream->pf_del = Del;
p_stream->pf_send = Send;
-
- p_stream->p_sout->i_out_pace_nocontrol++;
+ p_stream->pace_nocontrol = true;
return VLC_SUCCESS;
}
var_DelCallback( p_stream, CFG_PREFIX "x", xCallback, p_stream );
var_DelCallback( p_stream, CFG_PREFIX "y", yCallback, p_stream );
- p_stream->p_sout->i_out_pace_nocontrol--;
-
free( p_sys->psz_id );
free( p_sys );
}
-static int video_filter_buffer_allocation_init( filter_t *p_filter, void *p_data )
-{
- p_filter->pf_vout_buffer_new = video_new_buffer_filter;
- p_filter->pf_vout_buffer_del = video_del_buffer_filter;
- p_filter->p_owner = p_data;
- return VLC_SUCCESS;
-}
-
-static sout_stream_id_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
+static sout_stream_id_sys_t * Add( sout_stream_t *p_stream, es_format_t *p_fmt )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
bridge_t *p_bridge;
return NULL;
/* Create decoder object */
- p_sys->p_decoder = vlc_object_create( p_stream, VLC_OBJECT_DECODER );
+ p_sys->p_decoder = vlc_object_create( p_stream, sizeof( decoder_t ) );
if( !p_sys->p_decoder )
return NULL;
- 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 = false;
p_sys->p_decoder->p_owner = malloc( sizeof(decoder_owner_sys_t) );
if( !p_sys->p_decoder->p_owner )
{
- vlc_object_detach( p_sys->p_decoder );
vlc_object_release( p_sys->p_decoder );
return NULL;
}
msg_Err( p_stream, "cannot find decoder" );
}
free( p_sys->p_decoder->p_owner );
- vlc_object_detach( p_sys->p_decoder );
vlc_object_release( p_sys->p_decoder );
return NULL;
}
p_sys->b_inited = true;
- vlc_mutex_lock( p_sys->p_lock );
+ vlc_global_lock( VLC_MOSAIC_MUTEX );
p_bridge = GetBridge( p_stream );
if ( p_bridge == NULL )
p_es->pp_last = &p_es->p_picture;
p_es->b_empty = false;
- vlc_mutex_unlock( p_sys->p_lock );
+ vlc_global_unlock( VLC_MOSAIC_MUTEX );
if ( p_sys->i_height || p_sys->i_width )
{
msg_Dbg( p_stream, "psz_chain: %s", psz_chain );
if( psz_chain )
{
- p_sys->p_vf2 = filter_chain_New( p_stream, "video filter2", false,
- video_filter_buffer_allocation_init,
- NULL, p_sys->p_decoder->p_owner );
+ filter_owner_t owner = {
+ .sys = p_sys->p_decoder->p_owner,
+ .video = {
+ .buffer_new = video_new_buffer_filter,
+ .buffer_del = video_del_buffer_filter,
+ },
+ };
+
+ p_sys->p_vf2 = filter_chain_NewVideo( p_stream, false, &owner );
es_format_t fmt;
es_format_Copy( &fmt, &p_sys->p_decoder->fmt_out );
if( p_sys->i_chroma )
p_sys->p_vf2 = NULL;
}
- return (sout_stream_id_t *)p_sys;
+ return (sout_stream_id_sys_t *)p_sys;
}
-static int Del( sout_stream_t *p_stream, sout_stream_id_t *id )
+static int Del( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
{
VLC_UNUSED(id);
sout_stream_sys_t *p_sys = p_stream->p_sys;
if( p_sys->p_decoder->p_description )
vlc_meta_Delete( p_sys->p_decoder->p_description );
- vlc_object_detach( p_sys->p_decoder );
vlc_object_release( p_sys->p_decoder );
free( p_owner );
if( p_sys->p_vf2 )
filter_chain_Delete( p_sys->p_vf2 );
- vlc_mutex_lock( p_sys->p_lock );
+ vlc_global_lock( VLC_MOSAIC_MUTEX );
p_bridge = GetBridge( p_stream );
p_es = p_sys->p_es;
var_Destroy( p_libvlc, "mosaic-struct" );
}
- vlc_mutex_unlock( p_sys->p_lock );
+ vlc_global_unlock( VLC_MOSAIC_MUTEX );
if ( p_sys->p_image )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
bridged_es_t *p_es = p_sys->p_es;
- vlc_mutex_lock( p_sys->p_lock );
+ vlc_global_lock( VLC_MOSAIC_MUTEX );
*p_es->pp_last = p_picture;
p_picture->p_next = NULL;
p_es->pp_last = &p_picture->p_next;
- vlc_mutex_unlock( p_sys->p_lock );
+ vlc_global_unlock( VLC_MOSAIC_MUTEX );
}
-static int Send( sout_stream_t *p_stream, sout_stream_id_t *id,
+static int Send( sout_stream_t *p_stream, sout_stream_id_sys_t *id,
block_t *p_buffer )
{
sout_stream_sys_t *p_sys = p_stream->p_sys;
inline static picture_t *video_new_buffer_filter( filter_t *p_filter )
{
return video_new_buffer( VLC_OBJECT( p_filter ),
- (decoder_owner_sys_t *)p_filter->p_owner,
+ (decoder_owner_sys_t *)p_filter->owner.sys,
&p_filter->fmt_out );
}