demux: ts: only seek on pcr for current program
[vlc.git] / modules / video_output / vdummy.c
blobf8535ca5360d01a9df95ded454e46384b07f35f7
1 /*****************************************************************************
2 * vdummy.c: Dummy video output display method for testing purposes
3 *****************************************************************************
4 * Copyright (C) 2000-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_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 " \
40 "efficient one.")
42 static int OpenDummy( vlc_object_t * );
43 static int OpenStats( vlc_object_t * );
44 static void Close( vlc_object_t * );
46 vlc_module_begin ()
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 )
57 add_submodule ()
58 set_description( N_("Statistics video output") )
59 set_capability( "vout display", 0 )
60 add_shortcut( "stats" )
61 set_callbacks( OpenStats, Close )
62 vlc_module_end ()
65 /*****************************************************************************
66 * Local prototypes
67 *****************************************************************************/
68 struct vout_display_sys_t {
69 picture_pool_t *pool;
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));
86 if (!sys)
87 return VLC_EGENERIC;
88 sys->pool = NULL;
90 /* p_vd->info is not modified */
92 char *chroma = var_InheritString(vd, "dummy-chroma");
93 if (chroma) {
94 vlc_fourcc_t fcc = vlc_fourcc_GetCodecFromString(VIDEO_ES, chroma);
95 if (fcc != 0) {
96 msg_Dbg(vd, "forcing chroma 0x%.8x (%4.4s)", fcc, (char*)&fcc);
97 vd->fmt.i_chroma = fcc;
99 free(chroma);
101 vd->pool = Pool;
102 vd->prepare = NULL;
103 vd->display = display;
104 vd->control = Control;
106 vout_display_DeleteWindow(vd, NULL);
108 return VLC_SUCCESS;
111 static int OpenDummy(vlc_object_t *object)
113 return Open(object, Display);
116 static int OpenStats(vlc_object_t *object)
118 return Open(object, DisplayStat);
121 static void Close(vlc_object_t *object)
123 vout_display_t *vd = (vout_display_t *)object;
124 vout_display_sys_t *sys = vd->sys;
126 if (sys->pool)
127 picture_pool_Release(sys->pool);
128 free(sys);
131 static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
133 vout_display_sys_t *sys = vd->sys;
134 if (!sys->pool)
135 sys->pool = picture_pool_NewFromFormat(&vd->fmt, count);
136 return sys->pool;
139 static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
141 VLC_UNUSED(vd);
142 VLC_UNUSED(subpicture);
143 picture_Release(picture);
146 static void DisplayStat(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
148 VLC_UNUSED(vd);
149 VLC_UNUSED(subpicture);
150 if ( vd->fmt.i_width*vd->fmt.i_height >= sizeof(mtime_t) &&
151 (picture->p->i_pitch * picture->p->i_lines) >= sizeof(mtime_t) ) {
152 mtime_t date;
153 memcpy(&date, picture->p->p_pixels, sizeof(date));
154 msg_Dbg(vd, "VOUT got %"PRIu64" ms offset",
155 (mdate() - date) / 1000 );
157 picture_Release(picture);
160 static int Control(vout_display_t *vd, int query, va_list args)
162 VLC_UNUSED(vd);
163 VLC_UNUSED(query);
164 VLC_UNUSED(args);
165 return VLC_SUCCESS;