Update translations from 2.2.x branch
[vlc.git] / modules / video_splitter / clone.c
blob58a45b309ba36012cd615d37b4d0e94acac206d0
1 /*****************************************************************************
2 * clone.c : Clone video plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2002-2009 VLC authors and VideoLAN
5 * $Id$
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
25 * Preamble
26 *****************************************************************************/
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_video_splitter.h>
36 /*****************************************************************************
37 * Module descriptor
38 *****************************************************************************/
39 #define COUNT_TEXT N_("Number of clones")
40 #define COUNT_LONGTEXT N_("Number of video windows in which to "\
41 "clone the video.")
43 #define VOUTLIST_TEXT N_("Video output modules")
44 #define VOUTLIST_LONGTEXT N_("You can use specific video output modules " \
45 "for the clones. Use a comma-separated list of modules." )
47 #define CLONE_HELP N_("Duplicate your video to multiple windows " \
48 "and/or video output modules")
49 #define CFG_PREFIX "clone-"
51 static int Open ( vlc_object_t * );
52 static void Close( vlc_object_t * );
54 vlc_module_begin ()
55 set_description( N_("Clone video filter") )
56 set_capability( "video splitter", 0 )
57 set_shortname( N_("Clone" ))
58 set_help(CLONE_HELP)
59 set_category( CAT_VIDEO )
60 set_subcategory( SUBCAT_VIDEO_SPLITTER )
62 add_integer( CFG_PREFIX "count", 2, COUNT_TEXT, COUNT_LONGTEXT, false )
63 add_module_list( CFG_PREFIX "vout-list", "vout display", NULL,
64 VOUTLIST_TEXT, VOUTLIST_LONGTEXT, true )
66 add_shortcut( "clone" )
67 set_callbacks( Open, Close )
68 vlc_module_end ()
70 /*****************************************************************************
71 * Local prototypes
72 *****************************************************************************/
73 static const char *const ppsz_filter_options[] = {
74 "count", "vout-list", NULL
77 #define VOUTSEPARATOR ':'
79 static int Filter( video_splitter_t *, picture_t *pp_dst[], picture_t * );
81 /**
82 * This function allocates and initializes a Clone splitter module
84 static int Open( vlc_object_t *p_this )
86 video_splitter_t *p_splitter = (video_splitter_t*)p_this;
88 config_ChainParse( p_splitter, CFG_PREFIX, ppsz_filter_options,
89 p_splitter->p_cfg );
91 char *psz_clonelist = var_CreateGetNonEmptyString( p_splitter,
92 CFG_PREFIX "vout-list" );
93 if( psz_clonelist )
95 /* Count the number of defined vout */
96 p_splitter->i_output = 1;
97 for( int i = 0; psz_clonelist[i]; i++ )
99 if( psz_clonelist[i] == VOUTSEPARATOR )
100 p_splitter->i_output++;
103 /* */
104 p_splitter->p_output = calloc( p_splitter->i_output,
105 sizeof(*p_splitter->p_output) );
106 if( !p_splitter->p_output )
108 free( psz_clonelist );
109 return VLC_EGENERIC;
112 /* Tokenize the list */
113 char *psz_tmp = psz_clonelist;
114 for( int i = 0; psz_tmp && *psz_tmp; i++ )
116 char *psz_new = strchr( psz_tmp, VOUTSEPARATOR );
117 if( psz_new )
118 *psz_new++ = '\0';
120 p_splitter->p_output[i].psz_module = strdup( psz_tmp );
122 psz_tmp = psz_new;
125 free( psz_clonelist );
127 else
129 /* No list was specified. We will use the default vout, and get
130 * the number of clones from clone-count */
131 p_splitter->i_output = var_CreateGetInteger( p_splitter, CFG_PREFIX "count" );
132 if( p_splitter->i_output <= 0 )
133 p_splitter->i_output = 1;
135 p_splitter->p_output = calloc( p_splitter->i_output,
136 sizeof(*p_splitter->p_output) );
138 if( !p_splitter->p_output )
139 return VLC_EGENERIC;
141 for( int i = 0; i < p_splitter->i_output; i++ )
142 p_splitter->p_output[i].psz_module = NULL;
145 /* */
146 for( int i = 0; i < p_splitter->i_output; i++ )
148 video_splitter_output_t *p_cfg = &p_splitter->p_output[i];
149 video_format_Copy( &p_cfg->fmt, &p_splitter->fmt );
150 p_cfg->window.i_x = 0;
151 p_cfg->window.i_y = 0;
152 p_cfg->window.i_align = 0;
155 /* */
156 p_splitter->pf_filter = Filter;
157 p_splitter->pf_mouse = NULL;
159 msg_Dbg( p_splitter, "spawning %i clone(s)", p_splitter->i_output );
161 return VLC_SUCCESS;
165 * This function closes a clone video splitter module
167 static void Close( vlc_object_t *p_this )
169 video_splitter_t *p_splitter = (video_splitter_t*)p_this;
171 for( int i = 0; i < p_splitter->i_output; i++ )
173 video_splitter_output_t *p_cfg = &p_splitter->p_output[i];
175 free( p_cfg->psz_module );
176 video_format_Clean( &p_cfg->fmt );
178 free( p_splitter->p_output );
182 * This function filter a picture
184 static int Filter( video_splitter_t *p_splitter,
185 picture_t *pp_dst[], picture_t *p_src )
187 if( video_splitter_NewPicture( p_splitter, pp_dst ) )
189 picture_Release( p_src );
190 return VLC_EGENERIC;
193 for( int i = 0; i < p_splitter->i_output; i++ )
194 picture_Copy( pp_dst[i], p_src );
196 picture_Release( p_src );
197 return VLC_SUCCESS;