Fix non-ASCII comment
[vlc/asuraparaju-public.git] / modules / misc / stats / demux.c
blob20105b6d0761bdcec99d9d9ac728cd5ff0a02fe1
1 /*****************************************************************************
2 * demux.c: stats demux plugin
3 *****************************************************************************
4 * Copyright (C) 2001-2008 the VideoLAN team
6 * Authors: Samuel Hocevar <sam@zoy.org>
7 * Pierre d'Herbemont <pdherbemont@videolan.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 /*****************************************************************************
25 * Preamble
26 *****************************************************************************/
28 #ifdef HAVE_CONFIG_H
29 # include "config.h"
30 #endif
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_access.h>
35 #include <vlc_demux.h>
37 #include "stats.h"
40 /*****************************************************************************
41 * Demux
42 *****************************************************************************/
45 struct demux_sys_t
47 es_format_t fmt;
48 es_out_id_t *p_es;
50 date_t pts;
53 static int Demux( demux_t * );
54 static int DemuxControl( demux_t *, int, va_list );
57 /*****************************************************************************
58 * OpenDemux
59 *****************************************************************************/
60 int OpenDemux ( vlc_object_t *p_this )
62 demux_t *p_demux = (demux_t*)p_this;
63 demux_sys_t *p_sys;
65 p_demux->p_sys = NULL;
67 /* Only when selected */
68 if( *p_demux->psz_demux == '\0' )
69 return VLC_EGENERIC;
71 msg_Dbg( p_demux, "Init Stat demux" );
73 p_demux->pf_demux = Demux;
74 p_demux->pf_control = DemuxControl;
76 p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
77 if( !p_demux->p_sys )
78 return VLC_ENOMEM;
80 date_Init( &p_sys->pts, 1, 1 );
81 date_Set( &p_sys->pts, 1 );
83 es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_FOURCC('s','t','a','t') );
84 p_sys->fmt.video.i_width = 720;
85 p_sys->fmt.video.i_height= 480;
87 p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt );
89 return VLC_SUCCESS;
92 /*****************************************************************************
93 * CloseDemux
94 *****************************************************************************/
95 void CloseDemux ( vlc_object_t *p_this )
97 demux_t *p_demux = (demux_t*)p_this;
99 msg_Dbg( p_demux, "Closing Stat demux" );
101 free( p_demux->p_sys );
104 /*****************************************************************************
105 * Demux
106 *****************************************************************************/
107 static int Demux( demux_t *p_demux )
109 demux_sys_t *p_sys = p_demux->p_sys;
111 block_t * p_block = stream_Block( p_demux->s, kBufferSize );
113 if( !p_block ) return 1;
115 p_block->i_dts = p_block->i_pts =
116 date_Increment( &p_sys->pts, kBufferSize );
118 msg_Dbg( p_demux, "demux got %d ms offset", (int)(mdate() - *(mtime_t *)p_block->p_buffer) / 1000 );
120 //es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts );
122 es_out_Send( p_demux->out, p_sys->p_es, p_block );
124 return 1;
127 static int DemuxControl( demux_t *p_demux, int i_query, va_list args )
129 return demux_vaControlHelper( p_demux->s,
130 0, 0, 0, 1,
131 i_query, args );