]> git.sesse.net Git - vlc/blobdiff - plugins/mpeg/input_ts.c
* Disabled network input under BeOS so that it compiles again. We'll
[vlc] / plugins / mpeg / input_ts.c
index 4fd9a5e4cf6cce326ebbcf059de87d14127c78ab..56ff82cafff7c02bb99420a5f6cf678ce2e55c84 100644 (file)
@@ -2,7 +2,7 @@
  * input_ts.c: TS demux and netlist management
  *****************************************************************************
  * Copyright (C) 1998, 1999, 2000 VideoLAN
- * $Id: input_ts.c,v 1.4 2001/02/20 02:53:13 stef Exp $
+ * $Id: input_ts.c,v 1.9 2001/03/07 01:36:41 sam Exp $
  *
  * Authors: 
  *
@@ -21,6 +21,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
+#define MODULE_NAME ts
+#include "modules_inner.h"
+
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -29,9 +32,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
-#include <sys/uio.h>
 
 #include <sys/types.h>
+#include <sys/uio.h>
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
@@ -68,13 +71,18 @@ static void TSEnd       ( struct input_thread_s * );
  * Functions exported as capabilities. They are declared as static so that
  * we don't pollute the namespace too much.
  *****************************************************************************/
-void input_getfunctions( function_list_t * p_function_list )
+void _M( input_getfunctions )( function_list_t * p_function_list )
 {
 #define input p_function_list->functions.input
     p_function_list->pf_probe = TSProbe;
     input.pf_init             = TSInit;
+#ifdef SYS_BEOS
     input.pf_open             = input_FileOpen;
     input.pf_close            = input_FileClose;
+#else
+    input.pf_open             = input_NetworkOpen;
+    input.pf_close            = input_NetworkClose;
+#endif
     input.pf_end              = TSEnd;
     input.pf_set_area         = NULL;
     input.pf_read             = TSRead;
@@ -127,8 +135,9 @@ static void TSInit( input_thread_t * p_input )
 {
     /* Initialize netlist and TS structures */
     thread_ts_data_t    * p_method;
-    pgrm_ts_data_t      * p_pgrm_demux;
-    es_descriptor_t     * kludge1;
+    es_descriptor_t     * p_pat_es;
+    es_ts_data_t        * p_demux_data;
+    stream_ts_data_t    * p_stream_data;
 
     /* Initialise structure */
     p_method = malloc( sizeof( thread_ts_data_t ) );
@@ -156,28 +165,21 @@ static void TSInit( input_thread_t * p_input )
     /* Initialize the stream */
     input_InitStream( p_input, sizeof( stream_ts_data_t ) );
 
-    /* FIXME : PSIDemux and PSIDecode */
-    /* Add audio and video programs */
-    /* p_input->stream.pp_programs[0] = */
-    input_AddProgram( p_input, 0, sizeof( pgrm_ts_data_t ) );
-    p_pgrm_demux = 
-        (pgrm_ts_data_t *)p_input->stream.pp_programs[0]->p_demux_data;
-    p_pgrm_demux->i_pcr_pid = 0x78;
-
-    kludge1 = input_AddES( p_input, p_input->stream.pp_programs[0], 
-                           0x78, sizeof( es_ts_data_t ) );
-
-    // kludge
-    kludge1->i_type = MPEG2_VIDEO_ES;
-
-    input_SelectES( p_input, kludge1 );
-
-    vlc_mutex_lock( &(p_input->stream.stream_lock) );
-    p_input->stream.pp_programs[0]->b_is_ok = 1;
-    vlc_mutex_unlock( &(p_input->stream.stream_lock) );
-
-//debug
-intf_ErrMsg("End of TSINIT");    
+    /* Init */
+    p_stream_data = (stream_ts_data_t *)p_input->stream.p_demux_data;
+    p_stream_data->i_pat_version = PAT_UNINITIALIZED ;
+
+    /* We'll have to catch the PAT in order to continue 
+     * Then the input will catch the PMT and then the others ES
+     * The PAT es is indepedent of any program. */
+    p_pat_es = input_AddES( p_input, NULL,
+                           0x00, sizeof( es_ts_data_t ) );
+    p_demux_data=(es_ts_data_t *)p_pat_es->p_demux_data;
+    p_demux_data->b_psi = 1;
+    p_demux_data->i_psi_type = PSI_IS_PAT;
+    p_demux_data->p_psi_section = malloc(sizeof(psi_section_t));
+    p_demux_data->p_psi_section->b_is_complete = 1;
+    
 }
 
 /*****************************************************************************
@@ -185,7 +187,13 @@ intf_ErrMsg("End of TSINIT");
  *****************************************************************************/
 static void TSEnd( input_thread_t * p_input )
 {
+    es_descriptor_t     * p_pat_es;
+    
+    p_pat_es = input_FindES( p_input, 0x00 );
 
+    if( p_pat_es != NULL )
+        input_DelES( p_input, p_pat_es );
+    free(p_input->p_plugin_data);
 }
 
 /*****************************************************************************
@@ -210,7 +218,6 @@ static int TSRead( input_thread_t * p_input,
     } 
 
     i_read = readv( p_input->i_handle, p_iovec, INPUT_READ_ONCE );
-    
     if( i_read == -1 )
     {
         intf_ErrMsg( "Could not readv" );