]> git.sesse.net Git - vlc/blobdiff - modules/demux/util/sub.h
* Implement INPUT_GET_SUBDELAY and INPUT_SET_SUBDELAY
[vlc] / modules / demux / util / sub.h
index 45966f2a84c1af0c376da1d7b22dca26d9d8b18f..f153c293e1b67fee5654a8700a810c57b156ea67 100644 (file)
@@ -1,16 +1,16 @@
 /*****************************************************************************
  * sub.h
  *****************************************************************************
- * Copyright (C) 2001-2003 VideoLAN
- * $Id: sub.h,v 1.10 2003/11/05 00:17:50 hartman Exp $
+ * Copyright (C) 2001-2004 VideoLAN
+ * $Id$
  *
  * 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
@@ -21,6 +21,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#include "../ps.h"
+
 #define SUB_TYPE_MICRODVD   0x00
 #define SUB_TYPE_SUBRIP     0x01
 #define SUB_TYPE_SSA1       0x02
@@ -40,35 +42,19 @@ typedef struct subtitle_s
 
 } subtitle_t;
 
-typedef struct subtitle_track_s
-{
-    int             i_track_id;
-    char            *psz_header;
-    int             i_subtitle;
-    int             i_subtitles;
-    subtitle_t      *subtitle;
-    char            *psz_language;
-
-    int             i_previously_selected; /* to make pf_seek */
-    es_descriptor_t *p_es;
-    
-} subtitle_track_t;
-
 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 );
+                         mtime_t i_microsecperframe );
     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;
@@ -78,27 +64,15 @@ typedef struct subtitle_demux_s
     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
-    */
-    
+    FILE                *p_vobsub_file;
+    mtime_t             i_original_mspf;
 
 } 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.
@@ -111,61 +85,17 @@ typedef struct subtitle_demux_s
  *****************************************************************************/
 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 )
+                                              mtime_t i_microsecperframe )
 {
     subtitle_demux_t *p_sub;
 
     p_sub = vlc_object_create( p_input, sizeof( subtitle_demux_t ) );
     p_sub->psz_object_name = "subtitle demux";
     vlc_object_attach( p_sub, p_input );
-    p_sub->p_module = module_Need( p_sub, "subtitle demux", "" );
+    p_sub->p_module = module_Need( p_sub, "subtitle demux", NULL, 0 );
 
     if( p_sub->p_module &&
-        p_sub->pf_open( p_sub,
-                        p_input,
-                        psz_name,
-                        i_microsecperframe,
-                        i_track_id ) >=0 )
+        p_sub->pf_open( p_sub, p_input, psz_name, i_microsecperframe ) >=0 )
     {
         msg_Info( p_input, "subtitle started" );
 
@@ -185,42 +115,31 @@ static inline
     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" );
     if( p_sub )
     {
+        p_sub->pf_close( p_sub );
         vlc_object_detach( p_sub );
         if( p_sub->p_module )
         {
@@ -229,3 +148,4 @@ static inline void subtitle_Close( subtitle_demux_t *p_sub )
         vlc_object_destroy( p_sub );
     }
 }
+