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 /*****************************************************************************
26 *****************************************************************************/
32 #include <vlc_common.h>
33 #include <vlc_interface.h>
34 #include <vlc_access.h>
35 #include <vlc_demux.h>
40 /*****************************************************************************
42 *****************************************************************************/
53 static int Demux( demux_t
* );
54 static int DemuxControl( demux_t
*, int, va_list );
57 /*****************************************************************************
59 *****************************************************************************/
60 int OpenDemux ( vlc_object_t
*p_this
)
62 demux_t
*p_demux
= (demux_t
*)p_this
;
65 p_demux
->p_sys
= NULL
;
67 /* Only when selected */
68 if( *p_demux
->psz_demux
== '\0' )
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
) );
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
);
92 /*****************************************************************************
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 /*****************************************************************************
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
);
127 static int DemuxControl( demux_t
*p_demux
, int i_query
, va_list args
)
129 return demux_vaControlHelper( p_demux
->s
,