Commit 03ed4ccc authored by Laurent Aimar's avatar Laurent Aimar

 * sub ->subtitle : converted sub.c to a 'real' demux2.
 * input.c: added basic multi-input support for subtitle.
 * avi, mp4: don't exit anymore when no es selected.
parent 4a6468f3
......@@ -900,7 +900,7 @@ VLC_ADD_PLUGINS([aout_file])
VLC_ADD_PLUGINS([i420_rgb i420_yuy2 i422_yuy2 i420_ymga])
VLC_ADD_PLUGINS([m3u playlist export sgimb])
VLC_ADD_PLUGINS([rawvideo])
VLC_ADD_PLUGINS([wav araw demuxsub adpcm a52sys dtssys au])
VLC_ADD_PLUGINS([wav araw subtitle adpcm a52sys dtssys au])
VLC_ADD_PLUGINS([access_file access_udp access_tcp access_http ipv4 access_mms])
VLC_ADD_PLUGINS([access_ftp access_directory sap http])
......
......@@ -20,3 +20,4 @@ SOURCES_pva = pva.c
SOURCES_aiff = aiff.c
SOURCES_sgimb = sgimb.c
SOURCES_mjpeg = mjpeg.c
SOURCES_subtitle = subtitle.c
......@@ -610,8 +610,17 @@ static int Demux_Seekable( demux_t *p_demux )
if( i_track_count <= 0 )
{
int64_t i_length = p_sys->i_length * (mtime_t)1000000;
p_sys->i_time += 25*1000; /* read 25ms */
if( i_length > 0 )
{
if( p_sys->i_time >= i_length )
return 0;
return 1;
}
msg_Warn( p_demux, "no track selected, exiting..." );
return( 0 );
return 0;
}
/* wait for the good time */
......
......@@ -528,6 +528,17 @@ static int Demux( demux_t *p_demux )
if( i_track_selected <= 0 )
{
p_sys->i_time += __MAX( p_sys->i_timescale / 10 , 1 );
if( p_sys->i_timescale > 0 )
{
int64_t i_length = (mtime_t)1000000 *
(mtime_t)p_sys->i_duration /
(mtime_t)p_sys->i_timescale;
if( MP4_GetMoviePTS( p_sys ) >= i_length )
return 0;
return 1;
}
msg_Warn( p_demux, "no track selected, exiting..." );
return 0;
}
......
/*****************************************************************************
* sub.c: subtitle demux for external subtitle files
* subtitle.c: Demux for text and vobsub files.
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
* $Id$
......@@ -26,6 +26,7 @@
* Preamble
*****************************************************************************/
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <ctype.h>
......@@ -33,34 +34,19 @@
#include <vlc/vlc.h>
#include <vlc/input.h>
#include "vlc_video.h"
#include <codecs.h>
#include "sub.h"
#include "../ps.h"
#if (!defined( WIN32 ) || defined(__MINGW32__))
# include <dirent.h>
#endif
#define DVD_VIDEO_LB_LEN 2048
static int Open ( vlc_object_t *p_this );
static int sub_open ( subtitle_demux_t *p_sub,
input_thread_t *p_input,
char *psz_name,
mtime_t i_microsecperframe );
static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate );
static int sub_seek ( subtitle_demux_t *p_sub, mtime_t i_date );
static void sub_close( subtitle_demux_t *p_sub );
static void sub_fix( subtitle_demux_t *p_sub );
static char *ppsz_sub_type[] = { "auto", "microdvd", "subrip", "subviewer", "ssa1",
"ssa2-4", "vplayer", "sami", "vobsub" };
/*****************************************************************************
* Module descriptor
*****************************************************************************/
static int Open ( vlc_object_t *p_this );
static void Close( vlc_object_t *p_this );
#define SUB_DELAY_LONGTEXT \
"Delay subtitles (in 1/10s)"
#define SUB_FPS_LONGTEXT \
......@@ -69,42 +55,42 @@ static char *ppsz_sub_type[] = { "auto", "microdvd", "subrip", "subviewer", "ssa
#define SUB_TYPE_LONGTEXT \
"One from \"microdvd\", \"subrip\", \"ssa1\", \"ssa2-4\", \"vplayer\" " \
"\"sami\" (auto for autodetection, it should always work)."
static char *ppsz_sub_type[] =
{
"auto", "microdvd", "subrip", "subviewer", "ssa1",
"ssa2-4", "vplayer", "sami", "vobsub"
};
vlc_module_begin();
set_description( _("Text subtitles demux") );
set_capability( "subtitle demux", 12 );
set_capability( "demux2", 0 );
add_float( "sub-fps", 0.0, NULL,
N_("Frames per second"),
SUB_FPS_LONGTEXT, VLC_TRUE );
add_string( "sub-type", "auto", NULL, "Subtitles fileformat",
SUB_TYPE_LONGTEXT, VLC_TRUE );
change_string_list( ppsz_sub_type, 0, 0 );
set_callbacks( Open, NULL );
set_callbacks( Open, Close );
add_shortcut( "subtitle" );
add_shortcut( "vobsub" );
vlc_module_end();
/*****************************************************************************
* Module initializer
* Prototypes:
*****************************************************************************/
static int Open ( vlc_object_t *p_this )
enum
{
subtitle_demux_t *p_sub = (subtitle_demux_t*)p_this;
p_sub->pf_open = sub_open;
p_sub->pf_demux = sub_demux;
p_sub->pf_seek = sub_seek;
p_sub->pf_close = sub_close;
/* Initialize the variables */
var_Create( p_this, "sub-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Create( p_this, "sub-delay", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_this, "sub-type", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
return VLC_SUCCESS;
}
#define MAX_TRY 256
#define MAX_LINE 2048
#define FREE( p ) if( p ) { free( p); (p) = NULL; }
SUB_TYPE_UNKNOWN = -1,
SUB_TYPE_MICRODVD,
SUB_TYPE_SUBRIP,
SUB_TYPE_SSA1,
SUB_TYPE_SSA2_4,
SUB_TYPE_VPLAYER,
SUB_TYPE_SAMI,
SUB_TYPE_SUBVIEWER,
SUB_TYPE_VOBSUB,
};
typedef struct
{
......@@ -112,228 +98,159 @@ typedef struct
int i_line;
char **line;
} text_t;
static int TextLoad( text_t *, stream_t *s );
static void TextUnload( text_t * );
static int text_load( text_t *txt, char *psz_name )
typedef struct
{
FILE *f;
int i_line_max;
mtime_t i_start;
mtime_t i_stop;
/* init txt */
i_line_max = 100;
txt->i_line_count = 0;
txt->i_line = 0;
txt->line = calloc( i_line_max, sizeof( char * ) );
char *psz_text;
int i_vobsub_location;
} subtitle_t;
/* open file */
if( !( f = fopen( psz_name, "rb" ) ) )
{
return VLC_EGENERIC;
}
/* load the complete file */
for( ;; )
{
char buffer[8096];
char *p;
if( fgets( buffer, 8096, f ) <= 0)
{
break;
}
while( ( p = strchr( buffer, '\r' ) ) )
{
*p = '\0';
}
while( ( p = strchr( buffer, '\n' ) ) )
{
*p = '\0';
}
txt->line[txt->i_line_count++] = strdup( buffer );
if( txt->i_line_count >= i_line_max )
{
i_line_max += 100;
txt->line = realloc( txt->line, i_line_max * sizeof( char*) );
}
}
fclose( f );
if( txt->i_line_count <= 0 )
{
FREE( txt->line );
return( VLC_EGENERIC );
}
return( VLC_SUCCESS );
}
static void text_unload( text_t *txt )
struct demux_sys_t
{
int i;
int i_type;
text_t txt;
es_out_id_t *es;
for( i = 0; i < txt->i_line_count; i++ )
{
FREE( txt->line[i] );
}
FREE( txt->line );
txt->i_line = 0;
txt->i_line_count = 0;
}
int64_t i_next_demux_date;
static char *text_get_line( text_t *txt )
{
if( txt->i_line >= txt->i_line_count )
{
return( NULL );
}
int64_t i_microsecperframe;
return( txt->line[txt->i_line++] );
}
static void text_previous_line( text_t *txt )
{
if( txt->i_line > 0 )
{
txt->i_line--;
}
}
static void text_rewind( text_t *txt )
{
txt->i_line = 0;
}
char *psz_header;
int i_subtitle;
int i_subtitles;
subtitle_t *subtitle;
FILE *p_vobsub_file;
mtime_t i_original_mspf;
static int sub_MicroDvdRead( subtitle_demux_t *p_sub, text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsecperframe );
static int sub_SubRipRead ( subtitle_demux_t *p_sub, text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsecperframe );
static int sub_SubViewer ( subtitle_demux_t *p_sub, text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsecperframe );
static int sub_SSARead ( subtitle_demux_t *p_sub, text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsecperframe );
static int sub_Vplayer ( subtitle_demux_t *p_sub, text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsecperframe );
static int sub_Sami ( subtitle_demux_t *p_sub, text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsecperframe );
static int sub_VobSubIDX ( subtitle_demux_t *p_sub, text_t *txt, subtitle_t *p_subtitle, mtime_t i_microsecperframe );
int64_t i_length;
};
static int ParseMicroDvd ( demux_t *, subtitle_t * );
static int ParseSubRip ( demux_t *, subtitle_t * );
static int ParseSubViewer( demux_t *, subtitle_t * );
static int ParseSSA ( demux_t *, subtitle_t * );
static int ParseVplayer ( demux_t *, subtitle_t * );
static int ParseSami ( demux_t *, subtitle_t * );
static int ParseVobSubIDX( demux_t *, subtitle_t * );
static int DemuxVobSub ( subtitle_demux_t *, block_t * );
static int DemuxVobSub( demux_t *, block_t * );
static struct
{
char *psz_type_name;
int i_type;
char *psz_name;
int (*pf_read_subtitle) ( subtitle_demux_t *, text_t *, subtitle_t*, mtime_t );
int (*pf_read)( demux_t *, subtitle_t* );
} sub_read_subtitle_function [] =
{
{ "microdvd", SUB_TYPE_MICRODVD, "MicroDVD", sub_MicroDvdRead },
{ "subrip", SUB_TYPE_SUBRIP, "SubRIP", sub_SubRipRead },
{ "subviewer", SUB_TYPE_SUBVIEWER, "SubViewer",sub_SubViewer },
{ "ssa1", SUB_TYPE_SSA1, "SSA-1", sub_SSARead },
{ "ssa2-4", SUB_TYPE_SSA2_4, "SSA-2/3/4",sub_SSARead },
{ "vplayer", SUB_TYPE_VPLAYER, "VPlayer", sub_Vplayer },
{ "sami", SUB_TYPE_SAMI, "SAMI", sub_Sami },
{ "vobsub", SUB_TYPE_VOBSUB, "VobSub", sub_VobSubIDX },
{ "microdvd", SUB_TYPE_MICRODVD, "MicroDVD", ParseMicroDvd },
{ "subrip", SUB_TYPE_SUBRIP, "SubRIP", ParseSubRip },
{ "subviewer", SUB_TYPE_SUBVIEWER, "SubViewer",ParseSubViewer },
{ "ssa1", SUB_TYPE_SSA1, "SSA-1", ParseSSA },
{ "ssa2-4", SUB_TYPE_SSA2_4, "SSA-2/3/4",ParseSSA },
{ "vplayer", SUB_TYPE_VPLAYER, "VPlayer", ParseVplayer },
{ "sami", SUB_TYPE_SAMI, "SAMI", ParseSami },
{ "vobsub", SUB_TYPE_VOBSUB, "VobSub", ParseVobSubIDX },
{ NULL, SUB_TYPE_UNKNOWN, "Unknown", NULL }
};
static int Demux( demux_t * );
static int Control( demux_t *, int, va_list );
static void Fix( demux_t * );
#define DVD_VIDEO_LB_LEN 2048
/*****************************************************************************
* sub_open: Open a subtitle file and add subtitle ES
* Module initializer
*****************************************************************************/
static int sub_open( subtitle_demux_t *p_sub, input_thread_t *p_input,
char *psz_name, mtime_t i_microsecperframe )
static int Open ( vlc_object_t *p_this )
{
text_t txt;
vlc_value_t val;
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
es_format_t fmt;
int i, i_sub_type, i_max;
int (*pf_read_subtitle)( subtitle_demux_t *, text_t *, subtitle_t *,
mtime_t ) = NULL;
p_sub->i_sub_type = SUB_TYPE_UNKNOWN;
p_sub->p_es = NULL;
p_sub->i_subtitles = 0;
p_sub->subtitle = NULL;
p_sub->p_vobsub_file = 0;
p_sub->i_original_mspf = i_microsecperframe;
p_sub->p_input = p_input;
if( !psz_name || !*psz_name )
{
msg_Err( p_sub, "no subtitle file specified" );
return VLC_EGENERIC;
}
float f_fps;
char *psz_type;
int (*pf_read)( demux_t *, subtitle_t* );
int i, i_max;
/* *** load the file *** */
if( text_load( &txt, psz_name ) )
if( strcmp( p_demux->psz_demux, "subtitle" ) &&
strcmp( p_demux->psz_demux, "vobsub" ) )
{
msg_Err( p_sub, "cannot open `%s' subtitle file", psz_name );
msg_Dbg( p_demux, "subtitle demux discarded" );
return VLC_EGENERIC;
}
msg_Dbg( p_sub, "opened `%s'", psz_name );
var_Get( p_sub, "sub-fps", &val );
if( val.i_int >= 1.0 )
{
i_microsecperframe = (mtime_t)( (float)1000000 / val.f_float );
}
else if( val.f_float == 0 )
{
/* No value given */
i_microsecperframe = 0;
}
else if( val.f_float <= 0 )
p_demux->pf_demux = Demux;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
p_sys->psz_header = NULL;
p_sys->i_subtitle = 0;
p_sys->i_subtitles= 0;
p_sys->subtitle = NULL;
p_sys->p_vobsub_file = NULL;
p_sys->i_original_mspf = 0;
/* Get the FPS */
p_sys->i_microsecperframe = 40000; /* default to 25 fps */
f_fps = var_CreateGetFloat( p_demux, "sub-fps" );
if( f_fps >= 1.0 )
{
/* invalid value, default = 25fps */
i_microsecperframe = 40000;
p_sys->i_microsecperframe = (mtime_t)( (float)1000000 / f_fps );
}
var_Get( p_sub, "sub-type", &val);
if( val.psz_string && *val.psz_string )
/* Get or probe the type */
p_sys->i_type = SUB_TYPE_UNKNOWN;
psz_type = var_CreateGetString( p_demux, "sub-type" );
if( *psz_type )
{
int i;
for( i = 0; ; i++ )
{
if( sub_read_subtitle_function[i].psz_type_name == NULL )
{
i_sub_type = SUB_TYPE_UNKNOWN;
break;
}
if( !strcmp( sub_read_subtitle_function[i].psz_type_name,
val.psz_string ) )
psz_type ) )
{
i_sub_type = sub_read_subtitle_function[i].i_type;
p_sys->i_type = sub_read_subtitle_function[i].i_type;
break;
}
}
}
else
{
i_sub_type = SUB_TYPE_UNKNOWN;
}
FREE( val.psz_string );
free( psz_type );
/* *** Now try to autodetect subtitle format *** */
if( i_sub_type == SUB_TYPE_UNKNOWN )
/* Probe if unknown type */
if( p_sys->i_type == SUB_TYPE_UNKNOWN )
{
int i_try;
char *s;
msg_Dbg( p_input, "trying to autodetect file format" );
for( i_try = 0; i_try < MAX_TRY; i_try++ )
msg_Dbg( p_demux, "autodetecting subtitle format" );
for( i_try = 0; i_try < 256; i_try++ )
{
int i_dummy;
if( ( s = text_get_line( &txt ) ) == NULL )
{
if( ( s = stream_ReadLine( p_demux->s ) ) == NULL )
break;
}
if( strcasestr( s, "<SAMI>" ) )
{
i_sub_type = SUB_TYPE_SAMI;
p_sys->i_type = SUB_TYPE_SAMI;
break;
}
else if( sscanf( s, "{%d}{%d}", &i_dummy, &i_dummy ) == 2 ||
sscanf( s, "{%d}{}", &i_dummy ) == 1)
{
i_sub_type = SUB_TYPE_MICRODVD;
p_sys->i_type = SUB_TYPE_MICRODVD;
break;
}
else if( sscanf( s,
......@@ -341,7 +258,7 @@ static int sub_open( subtitle_demux_t *p_sub, input_thread_t *p_input,
&i_dummy,&i_dummy,&i_dummy,&i_dummy,
&i_dummy,&i_dummy,&i_dummy,&i_dummy ) == 8 )
{
i_sub_type = SUB_TYPE_SUBRIP;
p_sys->i_type = SUB_TYPE_SUBRIP;
break;
}
else if( sscanf( s,
......@@ -350,117 +267,130 @@ static int sub_open( subtitle_demux_t *p_sub, input_thread_t *p_input,
{
if( i_dummy <= 1 )
{
i_sub_type = SUB_TYPE_SSA1;
p_sys->i_type = SUB_TYPE_SSA1;
}
else
{
i_sub_type = SUB_TYPE_SSA2_4; /* I hope this will work */
p_sys->i_type = SUB_TYPE_SSA2_4; /* I hope this will work */
}
break;
}
else if( strcasestr( s, "This is a Sub Station Alpha v4 script" ) )
{
i_sub_type = SUB_TYPE_SSA2_4; /* I hope this will work */
p_sys->i_type = SUB_TYPE_SSA2_4; /* I hope this will work */
break;
}
else if( !strncasecmp( s, "Dialogue: Marked", 16 ) )
{
i_sub_type = SUB_TYPE_SSA2_4; /* could be wrong */
p_sys->i_type = SUB_TYPE_SSA2_4; /* could be wrong */
break;
}
else if( strcasestr( s, "[INFORMATION]" ) )
{
i_sub_type = SUB_TYPE_SUBVIEWER; /* I hope this will work */
p_sys->i_type = SUB_TYPE_SUBVIEWER; /* I hope this will work */
break;
}
else if( sscanf( s, "%d:%d:%d:", &i_dummy, &i_dummy, &i_dummy ) == 3 ||
sscanf( s, "%d:%d:%d ", &i_dummy, &i_dummy, &i_dummy ) == 3 )
{
i_sub_type = SUB_TYPE_VPLAYER;
p_sys->i_type = SUB_TYPE_VPLAYER;
break;
}
else if( strcasestr( s, "# VobSub index file" ) )
{
i_sub_type = SUB_TYPE_VOBSUB;
p_sys->i_type = SUB_TYPE_VOBSUB;
break;
}
}
text_rewind( &txt );
/* It will nearly always work even for non seekable stream thanks the
* caching system, and if it fails we loose just a few sub */
if( stream_Seek( p_demux->s, 0 ) )
{
msg_Warn( p_demux, "failed to rewind" );
}
}
if( p_sys->i_type == SUB_TYPE_UNKNOWN )
{
msg_Err( p_demux, "failed to recognize subtitle type" );
return VLC_EGENERIC;
}
/* *** Load this file in memory *** */
for( i = 0; ; i++ )
{
if( sub_read_subtitle_function[i].i_type == SUB_TYPE_UNKNOWN )
{
msg_Dbg( p_input, "unknown subtitle file" );
text_unload( &txt );
return VLC_EGENERIC;
}
if( sub_read_subtitle_function[i].i_type == i_sub_type )
if( sub_read_subtitle_function[i].i_type == p_sys->i_type )
{
msg_Dbg( p_input, "detected %s format",
sub_read_subtitle_function[i].psz_name );
p_sub->i_sub_type = i_sub_type;
pf_read_subtitle = sub_read_subtitle_function[i].pf_read_subtitle;
msg_Dbg( p_demux, "detected %s format",
sub_read_subtitle_function[i].psz_name );
pf_read = sub_read_subtitle_function[i].pf_read;
break;
}
}
msg_Dbg( p_demux, "loading all subtitles..." );
/* Load the whole file */
TextLoad( &p_sys->txt, p_demux->s );
/* Parse it */
for( i_max = 0;; )
{
if( p_sub->i_subtitles >= i_max )
if( p_sys->i_subtitles >= i_max )
{
i_max += 128;
if( !( p_sub->subtitle = realloc( p_sub->subtitle,
i_max += 500;
if( !( p_sys->subtitle = realloc( p_sys->subtitle,
sizeof(subtitle_t) * i_max ) ) )
{
msg_Err( p_sub, "out of memory");
msg_Err( p_demux, "out of memory");
return VLC_ENOMEM;
}
}
if( pf_read_subtitle( p_sub, &txt,
p_sub->subtitle + p_sub->i_subtitles,
i_microsecperframe ) < 0 )
{
if( pf_read( p_demux, &p_sys->subtitle[p_sys->i_subtitles] ) )
break;
}
p_sub->i_subtitles++;
p_sys->i_subtitles++;
}
msg_Dbg( p_sub, "loaded %d subtitles", p_sub->i_subtitles );
/* Unload */
TextUnload( &p_sys->txt );
/* *** Close the file *** */
text_unload( &txt );
msg_Dbg(p_demux, "loaded %d subtitles", p_sys->i_subtitles );
/* *** fix subtitle (order and time) *** */
p_sub->i_subtitle = 0; /* will be modified by sub_fix */
if( p_sub->i_sub_type != SUB_TYPE_VOBSUB )
/* Fix subtitle (order and time) *** */
p_sys->i_subtitle = 0;
if( p_sys->i_type != SUB_TYPE_VOBSUB )
{
Fix( p_demux );
}
p_sys->i_length = 0;
if( p_sys->i_subtitles > 0 )
{
sub_fix( p_sub );
p_sys->i_length = p_sys->subtitle[p_sys->i_subtitles-1].i_stop;
/* +1 to avoid 0 */
if( p_sys->i_length <= 0 )
p_sys->i_length = p_sys->subtitle[p_sys->i_subtitles-1].i_start+1;
}
/* *** add subtitle ES *** */
if( p_sub->i_sub_type == SUB_TYPE_VOBSUB )
if( p_sys->i_type == SUB_TYPE_VOBSUB )
{
int i_len = strlen( psz_name );
char *psz_vobname = strdup(psz_name);
int i_len = strlen( p_demux->psz_path );
char *psz_vobname = strdup( p_demux->psz_path );
strcpy( psz_vobname + i_len - 4, ".sub" );
/* open file */
if( !( p_sub->p_vobsub_file = fopen( psz_vobname, "rb" ) ) )
if( !( p_sys->p_vobsub_file = fopen( psz_vobname, "rb" ) ) )
{
msg_Err( p_sub, "couldn't open .sub Vobsub file: %s", psz_vobname );
msg_Err( p_demux, "couldn't open .sub Vobsub file: %s",
psz_vobname );
}
free( psz_vobname );
es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','p','u',' ' ) );
}
else if( p_sub->i_sub_type == SUB_TYPE_SSA1 ||
p_sub->i_sub_type == SUB_TYPE_SSA2_4 )
else if( p_sys->i_type == SUB_TYPE_SSA1 ||
p_sys->i_type == SUB_TYPE_SSA2_4 )
{
es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','s','a',' ' ) );
}
......@@ -468,184 +398,256 @@ static int sub_open( subtitle_demux_t *p_sub, input_thread_t *p_input,
{
es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','u','b','t' ) );
}
if( p_sub->psz_header != NULL )
if( p_sys->psz_header != NULL )
{
fmt.i_extra = strlen( p_sub->psz_header ) + 1;
fmt.p_extra = strdup( p_sub->psz_header );
fmt.i_extra = strlen( p_sys->psz_header ) + 1;
fmt.p_extra = strdup( p_sys->psz_header );
}
p_sub->p_es = es_out_Add( p_input->p_es_out, &fmt );
p_sub->i_previously_selected = 0;
p_sys->es = es_out_Add( p_demux->out, &fmt );
return VLC_SUCCESS;
}
/*****************************************************************************
* sub_demux: Send subtitle to decoder until i_maxdate
* Close: Close subtitle demux
*****************************************************************************/
static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate )
static void Close( vlc_object_t *p_this )
{
input_thread_t *p_input = p_sub->p_input;
vlc_bool_t b;
vlc_value_t val;
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys = p_demux->p_sys;
int i;
es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, p_sub->p_es, &b );
if( b && !p_sub->i_previously_selected )
for( i = 0; i < p_sys->i_subtitles; i++ )
{
p_sub->i_previously_selected = 1;
p_sub->pf_seek( p_sub, i_maxdate );
return VLC_SUCCESS;
if( p_sys->subtitle[i].psz_text )
free( p_sys->subtitle[i].psz_text );
}
if( p_sys->subtitle )
free( p_sys->subtitle );
if( p_sys->p_vobsub_file )
fclose( p_sys->p_vobsub_file );
free( p_sys );