* sub.c
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
- * $Id: sub.c,v 1.10 2003/03/16 23:35:39 fenrir Exp $
+ * $Id: sub.c,v 1.15 2003/05/13 22:33:33 gbazin Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
+/* define USE_FREETYPE to use freetype for subtitles */
+
/*****************************************************************************
* Preamble
*****************************************************************************/
#include <vlc/vlc.h>
#include <vlc/input.h>
-
+#if defined(USE_FREETYPE)
+#include <osd.h>
+#endif
#include "video.h"
#include "sub.h"
/*****************************************************************************
* Module descriptor
*****************************************************************************/
-
+#define SUB_DELAY_LONGTEXT \
+ "Delay subtitles (in 1/10s)"
#define SUB_FPS_LONGTEXT \
"Override frames per second. " \
- "It will work only with MicroDVD"
+ "It will only work with MicroDVD subtitles."
#define SUB_TYPE_LONGTEXT \
- "One from \"microdvd\", \"subrip\", \"ssa1\", \"ssa2-4\", \"vplayer\" \"sami\"" \
- "(nothing for autodetection, it should always work)"
+ "One from \"microdvd\", \"subrip\", \"ssa1\", \"ssa2-4\", \"vplayer\" " \
+ "\"sami\" (nothing for autodetection, it should always work)."
vlc_module_begin();
- set_description( _("text subtitle demux") );
+ set_description( _("Text subtitles demux") );
set_capability( "subtitle demux", 12 );
- add_category_hint( "subtitle", NULL, VLC_TRUE );
- add_string( "sub-file", NULL, NULL,
- "subtitle file name", "subtitle file name", VLC_TRUE );
+ add_category_hint( "Subtitles", NULL, VLC_TRUE );
+ add_file( "sub-file", NULL, NULL,
+ "Subtitles file name", "Subtitles file name", VLC_TRUE );
add_float( "sub-fps", 0.0, NULL,
- "override frames per second",
+ "Frames per second",
SUB_FPS_LONGTEXT, VLC_TRUE );
add_integer( "sub-delay", 0, NULL,
- "delay subtitles (in 1/10s)",
- "delay subtitles (in 1/10s)", VLC_TRUE );
+ "Delay subtitles (in 1/10s)",
+ SUB_DELAY_LONGTEXT, VLC_TRUE );
add_string_from_list( "sub-type", NULL, ppsz_sub_type, NULL,
- "subtitle type",
+ "subtitles type",
SUB_TYPE_LONGTEXT, VLC_TRUE );
set_callbacks( Open, NULL );
vlc_module_end();
/* *** add subtitle ES *** */
vlc_mutex_lock( &p_input->stream.stream_lock );
- p_sub->p_es = input_AddES( p_input,
- p_input->stream.p_selected_program,
+ p_sub->p_es = input_AddES( p_input, p_input->stream.p_selected_program,
0xff, // FIXME
- 0 );
+ SPU_ES, NULL, 0 );
vlc_mutex_unlock( &p_input->stream.stream_lock );
p_sub->p_es->i_stream_id = 0xff; // FIXME
p_sub->p_es->i_fourcc = VLC_FOURCC( 's','u','b','t' );
- p_sub->p_es->i_cat = SPU_ES;
p_sub->i_previously_selected = 0;
return VLC_SUCCESS;
*****************************************************************************/
static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate )
{
-
+#if defined(USE_FREETYPE)
+ vlc_object_t *p_vout = NULL;
+#endif
if( p_sub->p_es->p_decoder_fifo && !p_sub->i_previously_selected )
{
p_sub->i_previously_selected = 1;
data_packet_t *p_data;
int i_len;
+#if defined(USE_FREETYPE)
+ p_vout = vlc_object_find( p_sub, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+#endif
i_len = strlen( p_sub->subtitle[p_sub->i_subtitle].psz_text ) + 1;
p_sub->i_subtitle++;
continue;
}
+ p_data->p_payload_end = p_data->p_payload_start + i_len;
p_pes->i_pts =
input_ClockGetTS( p_sub->p_input,
{
p_pes->i_dts = 0;
}
+#if defined(USE_FREETYPE)
+ if( p_vout )
+ {
+ vlc_value_t val, lockval;
+ if( var_Get( p_vout, "lock", &lockval ) == VLC_SUCCESS )
+ {
+ int64_t i_tmp;
+ vlc_mutex_lock( lockval.p_address );
+ msg_Dbg( p_sub, "pts "I64Fd" dts " I64Fd, p_pes->i_pts,
+ p_pes->i_dts );
+ i_tmp = p_pes->i_dts - p_pes->i_pts;
+ val.i_int = OSD_ALIGN_LEFT|OSD_ALIGN_BOTTOM;
+ var_Set( p_vout, "flags", val );
+ val.time.i_low = (int)(p_pes->i_pts+p_sub->p_input->i_pts_delay);
+ val.time.i_high = (int)( p_pes->i_pts >> 32 );
+ var_Set( p_vout, "start-date", val );
+ val.time.i_low = (int)(p_pes->i_dts + p_sub->p_input->i_pts_delay);
+ val.time.i_high = (int)( p_pes->i_dts >> 32 );
+ var_Set( p_vout, "stop-date", val );
+ val.i_int = 20;
+ var_Set( p_vout, "x-margin", val );
+ val.i_int = 20;
+ var_Set( p_vout, "y-margin", val );
+ val.psz_string = p_sub->subtitle[p_sub->i_subtitle].psz_text;
+ var_Set( p_vout, "string", val );
+ vlc_mutex_unlock( lockval.p_address );
+ }
+ }
+#endif
p_pes->i_nb_data = 1;
p_pes->p_first =
p_pes->p_last = p_data;
p_sub->i_subtitle++;
}
+#if defined(USE_FREETYPE)
+ if ( p_vout )
+ {
+ vlc_object_release( p_vout );
+ }
+#endif
return( 0 );
}