1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199
|
/*****************************************************************************
* clone.c : Clone video plugin for vlc
*****************************************************************************
* Copyright (C) 2002-2009 VLC authors and VideoLAN
* $Id$
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
* 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 Lesser General Public License for more details.
*
* 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.
*****************************************************************************/
/*****************************************************************************
* Preamble
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_video_splitter.h>
/*****************************************************************************
* Module descriptor
*****************************************************************************/
#define COUNT_TEXT N_("Number of clones")
#define COUNT_LONGTEXT N_("Number of video windows in which to "\
"clone the video.")
#define VOUTLIST_TEXT N_("Video output modules")
#define VOUTLIST_LONGTEXT N_("You can use specific video output modules " \
"for the clones. Use a comma-separated list of modules." )
#define CLONE_HELP N_("Duplicate your video to multiple windows " \
"and/or video output modules")
#define CFG_PREFIX "clone-"
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
vlc_module_begin ()
set_description( N_("Clone video filter") )
set_capability( "video splitter", 0 )
set_shortname( N_("Clone" ))
set_help(CLONE_HELP)
set_category( CAT_VIDEO )
set_subcategory( SUBCAT_VIDEO_SPLITTER )
add_integer( CFG_PREFIX "count", 2, COUNT_TEXT, COUNT_LONGTEXT, false )
add_module_list( CFG_PREFIX "vout-list", "vout display", NULL,
VOUTLIST_TEXT, VOUTLIST_LONGTEXT, true )
add_shortcut( "clone" )
set_callbacks( Open, Close )
vlc_module_end ()
/*****************************************************************************
* Local prototypes
*****************************************************************************/
static const char *const ppsz_filter_options[] = {
"count", "vout-list", NULL
};
#define VOUTSEPARATOR ':'
static int Filter( video_splitter_t *, picture_t *pp_dst[], picture_t * );
/**
* This function allocates and initializes a Clone splitter module
*/
static int Open( vlc_object_t *p_this )
{
video_splitter_t *p_splitter = (video_splitter_t*)p_this;
config_ChainParse( p_splitter, CFG_PREFIX, ppsz_filter_options,
p_splitter->p_cfg );
char *psz_clonelist = var_CreateGetNonEmptyString( p_splitter,
CFG_PREFIX "vout-list" );
if( psz_clonelist )
{
/* Count the number of defined vout */
p_splitter->i_output = 1;
for( int i = 0; psz_clonelist[i]; i++ )
{
if( psz_clonelist[i] == VOUTSEPARATOR )
p_splitter->i_output++;
}
/* */
p_splitter->p_output = calloc( p_splitter->i_output,
sizeof(*p_splitter->p_output) );
if( !p_splitter->p_output )
{
free( psz_clonelist );
return VLC_EGENERIC;
}
/* Tokenize the list */
char *psz_tmp = psz_clonelist;
for( int i = 0; psz_tmp && *psz_tmp; i++ )
{
char *psz_new = strchr( psz_tmp, VOUTSEPARATOR );
if( psz_new )
*psz_new++ = '\0';
p_splitter->p_output[i].psz_module = strdup( psz_tmp );
psz_tmp = psz_new;
}
free( psz_clonelist );
}
else
{
/* No list was specified. We will use the default vout, and get
* the number of clones from clone-count */
p_splitter->i_output = var_CreateGetInteger( p_splitter, CFG_PREFIX "count" );
if( p_splitter->i_output <= 0 )
p_splitter->i_output = 1;
p_splitter->p_output = calloc( p_splitter->i_output,
sizeof(*p_splitter->p_output) );
if( !p_splitter->p_output )
return VLC_EGENERIC;
for( int i = 0; i < p_splitter->i_output; i++ )
p_splitter->p_output[i].psz_module = NULL;
}
/* */
for( int i = 0; i < p_splitter->i_output; i++ )
{
video_splitter_output_t *p_cfg = &p_splitter->p_output[i];
video_format_Copy( &p_cfg->fmt, &p_splitter->fmt );
p_cfg->window.i_x = 0;
p_cfg->window.i_y = 0;
p_cfg->window.i_align = 0;
}
/* */
p_splitter->pf_filter = Filter;
p_splitter->pf_mouse = NULL;
msg_Dbg( p_splitter, "spawning %i clone(s)", p_splitter->i_output );
return VLC_SUCCESS;
}
/**
* This function closes a clone video splitter module
*/
static void Close( vlc_object_t *p_this )
{
video_splitter_t *p_splitter = (video_splitter_t*)p_this;
for( int i = 0; i < p_splitter->i_output; i++ )
{
video_splitter_output_t *p_cfg = &p_splitter->p_output[i];
free( p_cfg->psz_module );
video_format_Clean( &p_cfg->fmt );
}
free( p_splitter->p_output );
}
/**
* This function filter a picture
*/
static int Filter( video_splitter_t *p_splitter,
picture_t *pp_dst[], picture_t *p_src )
{
if( video_splitter_NewPicture( p_splitter, pp_dst ) )
{
picture_Release( p_src );
return VLC_EGENERIC;
}
for( int i = 0; i < p_splitter->i_output; i++ )
picture_Copy( pp_dst[i], p_src );
picture_Release( p_src );
return VLC_SUCCESS;
}
|