* sub.c
*****************************************************************************
* Copyright (C) 1999-2003 VideoLAN
- * $Id: sub.c,v 1.35 2003/11/05 00:39:16 gbazin Exp $
+ * $Id: sub.c,v 1.36 2003/11/13 13:31:12 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
while (*p_pos)
{
- if (toupper(*p_pos) == toupper(*psz_little))
+ if (toupper(*p_pos) == toupper(*psz_little))
{
- char * psz_cur1 = p_pos + 1;
- char * psz_cur2 = psz_little + 1;
- while (*psz_cur1 && *psz_cur2 && toupper(*psz_cur1) == toupper(*psz_cur2))
+ char * psz_cur1 = p_pos + 1;
+ char * psz_cur2 = psz_little + 1;
+ while (*psz_cur1 && *psz_cur2 && toupper(*psz_cur1) == toupper(*psz_cur2))
{
- psz_cur1++;
- psz_cur2++;
- }
- if (!*psz_cur2) return p_pos;
- }
- p_pos++;
+ psz_cur1++;
+ psz_cur2++;
+ }
+ if (!*psz_cur2) return p_pos;
+ }
+ p_pos++;
}
return NULL;
}
{
text_t txt;
vlc_value_t val;
+ es_format_t fmt;
int i;
int i_sub_type;
}
/* *** 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,
- 0xff - i_track_id, /* FIXME */
- SPU_ES, NULL, 0 );
- vlc_mutex_unlock( &p_input->stream.stream_lock );
-
- p_sub->p_es->i_stream_id = 0xff - i_track_id; /* FIXME */
-
- if( p_sub->psz_header != NULL )
- {
- p_sub->p_es->p_demux_data = malloc( sizeof( subtitle_data_t ) );
- p_sub->p_es->p_demux_data->psz_header = strdup( p_sub->psz_header );
- free( p_sub->psz_header );
- }
-
if( p_sub->i_sub_type == SUB_TYPE_VOBSUB )
{
- p_sub->p_es->i_fourcc = VLC_FOURCC( 's','p','u',' ' );
- /* open vobsub file */
+ 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 )
{
- p_sub->p_es->i_fourcc = VLC_FOURCC( 's','s','a',' ' );
+ es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','s','a',' ' ) );
}
else
{
- p_sub->p_es->i_fourcc = VLC_FOURCC( 's','u','b','t' );
+ es_format_Init( &fmt, SPU_ES, VLC_FOURCC( 's','u','b','t' ) );
}
+ if( p_sub->psz_header != NULL )
+ {
+ fmt.i_extra_type = ES_EXTRA_TYPE_SUBHEADER;
+ fmt.i_extra = strlen( p_sub->psz_header ) + 1;
+ fmt.p_extra = strdup( p_sub->psz_header );
+ }
+ p_sub->p_es = es_out_Add( p_input->p_es_out, &fmt );
p_sub->i_previously_selected = 0;
return VLC_SUCCESS;
*****************************************************************************/
static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate )
{
- if( p_sub->p_es->p_decoder_fifo && !p_sub->i_previously_selected )
+ input_thread_t *p_input = p_sub->p_input;
+ vlc_bool_t b;
+
+ es_out_Control( p_input->p_es_out, ES_OUT_GET_SELECT, p_sub->p_es, &b );
+ if( b && !p_sub->i_previously_selected )
{
p_sub->i_previously_selected = 1;
p_sub->pf_seek( p_sub, i_maxdate );
return VLC_SUCCESS;
}
- else if( !p_sub->p_es->p_decoder_fifo && p_sub->i_previously_selected )
+ else if( !b && p_sub->i_previously_selected )
{
p_sub->i_previously_selected = 0;
return VLC_SUCCESS;
p_pes->i_nb_data = 1;
p_pes->p_first =
- p_pes->p_last = p_data;
+ p_pes->p_last = p_data;
p_pes->i_pes_size = i_len;
memcpy( p_data->p_payload_start,
p_sub->subtitle[p_sub->i_subtitle].psz_text,
i_len );
- if( p_sub->p_es->p_decoder_fifo && p_pes->i_pts > 0 )
- {
- input_DecodePES( p_sub->p_es->p_decoder_fifo, p_pes );
+ if( p_pes->i_pts > 0 )
+ {
+ es_out_Send( p_input->p_es_out, p_sub->p_es, p_pes );
}
else
{
p_sub->i_subtitle++;
}
- return( 0 );
+ return VLC_SUCCESS;
}
/*****************************************************************************
{
p_sub->i_subtitle++;
}
-
return( 0 );
}
* sub.h
*****************************************************************************
* Copyright (C) 2001-2003 VideoLAN
- * $Id: sub.h,v 1.10 2003/11/05 00:17:50 hartman Exp $
+ * $Id: sub.h,v 1.11 2003/11/13 13:31:12 fenrir Exp $
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
- *
+ *
* 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
* (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
} subtitle_t;
-typedef struct subtitle_track_s
+#if 0
+typedef struct
{
int i_track_id;
char *psz_header;
int i_previously_selected; /* to make pf_seek */
es_descriptor_t *p_es;
-
+
} subtitle_track_t;
+#endif
typedef struct subtitle_demux_s
{
VLC_COMMON_MEMBERS
-
+
module_t *p_module;
-
- int (*pf_open) ( struct subtitle_demux_s *p_sub,
- input_thread_t*p_input,
+
+ int (*pf_open) ( struct subtitle_demux_s *p_sub,
+ input_thread_t*p_input,
char *psz_name,
mtime_t i_microsecperframe,
int i_track_id );
int (*pf_demux)( struct subtitle_demux_s *p_sub, mtime_t i_maxdate );
int (*pf_seek) ( struct subtitle_demux_s *p_sub, mtime_t i_date );
void (*pf_close)( struct subtitle_demux_s *p_sub );
-
/* *** private *** */
input_thread_t *p_input;
int i_subtitle;
int i_subtitles;
subtitle_t *subtitle;
- es_descriptor_t *p_es;
+ es_out_id_t *p_es;
int i_previously_selected; /* to make pf_seek */
- /*unsigned int i_tracks;
- subtitle_track_t *p_tracks
+ /*unsigned int i_tracks;
+ subtitle_track_t *p_tracks
*/
-
} subtitle_demux_t;
/*****************************************************************************
- *
- * I made somes wrappers : So use them !
- * I think you shouldn't need access to subtitle_demux_t members else said
- * it to me.
- *
- *****************************************************************************/
-
-
-/*****************************************************************************
- * subtitle_New: Start a new subtitle demux instance (but subtitle ES isn't
+ * subtitle_New: Start a new subtitle demux instance (but subtitle ES isn't
* selected by default.
*****************************************************************************
* Return: NULL if failed, else a pointer on a new subtitle_demux_t.
static inline subtitle_demux_t *subtitle_New( input_thread_t *p_input,
char *psz_name,
mtime_t i_microsecperframe,
- int i_track_id );
-/*****************************************************************************
- * subtitle_Select: Select the related subtitle ES.
- *****************************************************************************/
-static inline void subtitle_Select( subtitle_demux_t *p_sub );
-
-/*****************************************************************************
- * subtitle_Unselect: Unselect the related subtitle ES.
- *****************************************************************************/
-static inline void subtitle_Unselect( subtitle_demux_t *p_sub );
-
-/*****************************************************************************
- * subtitle_Demux: send subtitle to decoder from last date to i_max
- *****************************************************************************/
-static inline int subtitle_Demux( subtitle_demux_t *p_sub, mtime_t i_max );
-
-/*****************************************************************************
- * subtitle_Seek: Seek to i_date
- *****************************************************************************/
-static inline int subtitle_Seek( subtitle_demux_t *p_sub, mtime_t i_date );
-
-/*****************************************************************************
- * subtitle_Close: Stop ES decoder and free all memory included p_sub.
- *****************************************************************************/
-static inline void subtitle_Close( subtitle_demux_t *p_sub );
-
-
-
-
-
-/*****************************************************************************/
-/*****************************************************************************/
-/*****************************************************************************/
-
-
-static inline
- subtitle_demux_t *subtitle_New( input_thread_t *p_input,
- char *psz_name,
- mtime_t i_microsecperframe,
- int i_track_id )
+ int i_track_id )
{
subtitle_demux_t *p_sub;
return( p_sub );
}
-static inline void subtitle_Select( subtitle_demux_t *p_sub )
-{
- if( p_sub && p_sub->p_es )
- {
- vlc_mutex_lock( &p_sub->p_input->stream.stream_lock );
- input_SelectES( p_sub->p_input, p_sub->p_es );
- vlc_mutex_unlock( &p_sub->p_input->stream.stream_lock );
- p_sub->i_previously_selected = 0;
- }
-}
-static inline void subtitle_Unselect( subtitle_demux_t *p_sub )
-{
- if( p_sub && p_sub->p_es )
- {
- vlc_mutex_lock( &p_sub->p_input->stream.stream_lock );
- input_UnselectES( p_sub->p_input, p_sub->p_es );
- vlc_mutex_unlock( &p_sub->p_input->stream.stream_lock );
- p_sub->i_previously_selected = 0;
- }
-}
-
+/*****************************************************************************
+ * subtitle_Demux: send subtitle to decoder from last date to i_max
+ *****************************************************************************/
static inline int subtitle_Demux( subtitle_demux_t *p_sub, mtime_t i_max )
{
return( p_sub->pf_demux( p_sub, i_max ) );
}
+/*****************************************************************************
+ * subtitle_Seek: Seek to i_date
+ *****************************************************************************/
static inline int subtitle_Seek( subtitle_demux_t *p_sub, mtime_t i_date )
{
- return( p_sub->pf_demux( p_sub, i_date ) );
+ return( p_sub->pf_seek( p_sub, i_date ) );
}
+/*****************************************************************************
+ * subtitle_Close: Stop ES decoder and free all memory included p_sub.
+ *****************************************************************************/
static inline void subtitle_Close( subtitle_demux_t *p_sub )
{
msg_Info( p_sub, "subtitle stopped" );
vlc_object_destroy( p_sub );
}
}
+
* decoders.
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
- * $Id: input.c,v 1.253 2003/11/13 12:28:34 fenrir Exp $
+ * $Id: input.c,v 1.254 2003/11/13 13:31:12 fenrir Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
*
{
if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string), i_microsecondperframe, 0 ) ) )
{
+ /* Select this ES by default */
+ es_out_Control( p_input->p_es_out, ES_OUT_SET_SELECT, p_sub->p_es, VLC_TRUE );
+
TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub );
- subtitle_Select( p_sub );
}
}
if( val.psz_string ) free( val.psz_string );
-
+
var_Get( p_input, "sub-autodetect-file", &val );
if( val.b_bool )
{
id->p_es->p_bitmapinfoheader = p_bih;
break;
}
+ case SPU_ES:
+ {
+ subtitle_data_t *p_sub = malloc( sizeof( subtitle_data_t ) );
+ memset( p_sub, 0, sizeof( subtitle_data_t ) );
+ if( fmt->i_extra > 0 )
+ {
+ if( fmt->i_extra_type == ES_EXTRA_TYPE_SUBHEADER )
+ {
+ p_sub->psz_header = malloc( fmt->i_extra );
+ memcpy( p_sub->psz_header, fmt->p_extra , fmt->i_extra );
+ }
+ }
+ /* FIXME beuuuuuurk */
+ id->p_es->p_demux_data = p_sub;
+ break;
+ }
default:
break;
}
switch( i_query )
{
case ES_OUT_SET_SELECT:
+ vlc_mutex_lock( &p_sys->p_input->stream.stream_lock );
id = (es_out_id_t*) va_arg( args, es_out_id_t * );
b = (vlc_bool_t) va_arg( args, vlc_bool_t );
if( b && id->p_es->p_decoder_fifo == NULL )
{
input_SelectES( p_sys->p_input, id->p_es );
+ vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock );
return id->p_es->p_decoder_fifo ? VLC_SUCCESS : VLC_EGENERIC;
}
else if( !b && id->p_es->p_decoder_fifo )
{
input_UnselectES( p_sys->p_input, id->p_es );
+ vlc_mutex_unlock( &p_sys->p_input->stream.stream_lock );
+ return VLC_SUCCESS;
}
- return VLC_SUCCESS;
-
case ES_OUT_GET_SELECT:
id = (es_out_id_t*) va_arg( args, es_out_id_t * );
pb = (vlc_bool_t*) va_arg( args, vlc_bool_t * );