1 /*****************************************************************************
2 * vout.c: Dummy video output display method for testing purposes
3 *****************************************************************************
4 * Copyright (C) 2000-2009 the VideoLAN team
7 * Authors: Samuel Hocevar <sam@zoy.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 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 General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_plugin.h>
34 #include <vlc_vout_display.h>
36 #define CHROMA_TEXT N_("Dummy image chroma format")
37 #define CHROMA_LONGTEXT N_( \
38 "Force the dummy video output to create images using a specific chroma " \
39 "format instead of trying to improve performances by using the most " \
42 static int OpenDummy( vlc_object_t * );
43 static int OpenStats( vlc_object_t * );
44 static void Close( vlc_object_t * );
47 set_shortname( N_("Dummy") )
48 set_description( N_("Dummy video output") )
49 set_capability( "vout display", 0 )
50 set_callbacks( OpenDummy, Close )
51 add_shortcut( "dummy" )
53 set_category( CAT_VIDEO )
54 set_subcategory( SUBCAT_VIDEO_VOUT )
55 add_string( "dummy-chroma", NULL, CHROMA_TEXT, CHROMA_LONGTEXT, true )
58 set_description( N_("Statistics video output") )
59 set_capability( "vout display", 0 )
60 add_shortcut( "stats" )
61 set_callbacks( OpenStats, Close )
65 /*****************************************************************************
67 *****************************************************************************/
68 struct vout_display_sys_t {
71 static picture_pool_t *Pool(vout_display_t *, unsigned count);
72 static void Display(vout_display_t *, picture_t *, subpicture_t *);
73 static void DisplayStat(vout_display_t *, picture_t *, subpicture_t *);
74 static int Control(vout_display_t *, int, va_list);
76 /*****************************************************************************
77 * OpenVideo: activates dummy vout display method
78 *****************************************************************************/
79 static int Open(vlc_object_t *object,
80 void (*display)(vout_display_t *, picture_t *, subpicture_t *))
82 vout_display_t *vd = (vout_display_t *)object;
83 vout_display_sys_t *sys;
85 vd->sys = sys = calloc(1, sizeof(*sys));
90 /* p_vd->info is not modified */
92 char *chroma = var_InheritString(vd, "dummy-chroma");
94 vlc_fourcc_t fcc = vlc_fourcc_GetCodecFromString(VIDEO_ES, chroma);
96 msg_Dbg(vd, "forcing chroma 0x%.8x (%4.4s)", fcc, (char*)&fcc);
97 vd->fmt.i_chroma = fcc;
103 vd->display = display;
104 vd->control = Control;
110 static int OpenDummy(vlc_object_t *object)
112 return Open(object, Display);
115 static int OpenStats(vlc_object_t *object)
117 return Open(object, DisplayStat);
120 static void Close(vlc_object_t *object)
122 vout_display_t *vd = (vout_display_t *)object;
123 vout_display_sys_t *sys = vd->sys;
126 picture_pool_Delete(sys->pool);
130 static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
132 vout_display_sys_t *sys = vd->sys;
134 sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
138 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
141 VLC_UNUSED(subpicture);
142 picture_Release(picture);
145 static void DisplayStat(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
148 VLC_UNUSED(subpicture);
149 if (vd->fmt.i_width*vd->fmt.i_height >= sizeof(mtime_t)) {
151 memcpy(&date, picture->p->p_pixels, sizeof(date));
152 msg_Dbg(vd, "VOUT got %"PRIu64" ms offset",
153 (mdate() - date) / 1000 );
155 picture_Release(picture);
158 static int Control(vout_display_t *vd, int query, va_list args)