X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fdemux%2Fcdg.c;h=ebb18eef47685324b21bdaaea5986e10d3a6a265;hb=9702039ef7a8fd77807d1b4a3ee5d9405574d5fd;hp=b67af9bd9959ab85f2c7c06c79196769f793b42e;hpb=c366075e5b2e88e59ea84e64968d28cd94fb4030;p=vlc diff --git a/modules/demux/cdg.c b/modules/demux/cdg.c index b67af9bd99..ebb18eef47 100644 --- a/modules/demux/cdg.c +++ b/modules/demux/cdg.c @@ -2,33 +2,36 @@ * cdg.c : cdg file demux module for vlc ***************************************************************************** * Copyright (C) 2007 Laurent Aimar - * $Id: $ + * $Id$ * * Authors: Laurent Aimar * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ /***************************************************************************** * Preamble *****************************************************************************/ -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include +#include +#include +#include /***************************************************************************** * Module descriptor @@ -36,15 +39,14 @@ static int Open ( vlc_object_t * ); static void Close( vlc_object_t * ); -vlc_module_begin(); - set_description( _("CDG demuxer") ); - set_category( CAT_INPUT ); - set_subcategory( SUBCAT_INPUT_DEMUX ); - set_capability( "demux2", 3 ); - set_callbacks( Open, Close ); - add_shortcut( "cdg" ); - add_shortcut( "subtitle" ); -vlc_module_end(); +vlc_module_begin () + set_description( N_("CDG demuxer") ) + set_category( CAT_INPUT ) + set_subcategory( SUBCAT_INPUT_DEMUX ) + set_capability( "demux", 3 ) + set_callbacks( Open, Close ) + add_shortcut( "cdg", "subtitle" ) +vlc_module_end () /***************************************************************************** * Local prototypes @@ -73,7 +75,7 @@ static int Open( vlc_object_t * p_this ) /* Identify cdg file by extension, as there is no simple way to * detect it */ - if( !demux2_IsPathExtension( p_demux, ".cdg" ) && !demux2_IsForced( p_demux, "cdg" ) ) + if( !demux_IsPathExtension( p_demux, ".cdg" ) && !demux_IsForced( p_demux, "cdg" ) ) return VLC_EGENERIC; /* CDG file size has to be multiple of CDG_FRAME_SIZE (it works even @@ -84,12 +86,16 @@ static int Open( vlc_object_t * p_this ) // return VLC_EGENERIC; // } + p_sys = malloc( sizeof( demux_sys_t ) ); + if( unlikely(p_sys == NULL) ) + return VLC_ENOMEM; + p_demux->pf_demux = Demux; p_demux->pf_control = Control; - p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); + p_demux->p_sys = p_sys; /* */ - es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_FOURCC('C','D','G', ' ' ) ); + es_format_Init( &p_sys->fmt, VIDEO_ES, VLC_CODEC_CDG ); p_sys->fmt.video.i_width = 300-2*6; p_sys->fmt.video.i_height = 216-2*12 ; @@ -97,7 +103,7 @@ static int Open( vlc_object_t * p_this ) /* There is CDG_FRAME_RATE frames per second */ date_Init( &p_sys->pts, CDG_FRAME_RATE, 1 ); - date_Set( &p_sys->pts, 1 ); + date_Set( &p_sys->pts, 0 ); return VLC_SUCCESS; } @@ -120,11 +126,14 @@ static int Demux( demux_t *p_demux ) } p_block->i_dts = - p_block->i_pts = date_Increment( &p_sys->pts, 1 ); + p_block->i_pts = VLC_TS_0 + date_Get( &p_sys->pts ); es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts ); es_out_Send( p_demux->out, p_sys->p_es, p_block ); + + date_Increment( &p_sys->pts, 1 ); + return 1; } @@ -144,11 +153,14 @@ static void Close ( vlc_object_t * p_this ) *****************************************************************************/ static int Control( demux_t *p_demux, int i_query, va_list args ) { - switch( i_query ) - { - default: - return demux2_vaControlHelper( p_demux->s, 0, -1, - 8*CDG_FRAME_SIZE*CDG_FRAME_RATE, CDG_FRAME_SIZE, i_query, args ); - } + int i_ret = demux_vaControlHelper( p_demux->s, 0, -1, + 8*CDG_FRAME_SIZE*CDG_FRAME_RATE, CDG_FRAME_SIZE, + i_query, args ); + if( !i_ret && ( i_query == DEMUX_SET_POSITION || i_query == DEMUX_SET_TIME ) ) + date_Set( &p_demux->p_sys->pts, + stream_Tell( p_demux->s ) / CDG_FRAME_SIZE * + INT64_C(1000000) / CDG_FRAME_RATE ); + + return i_ret; }