]> git.sesse.net Git - vlc/blobdiff - plugins/mpeg/input_ts.c
* Ported Glide and MGA plugins to the new module API. MGA never worked,
[vlc] / plugins / mpeg / input_ts.c
index 71681617817a2966b88915a7567502ee45e0772b..d664906d08155c2f44910fb1a2ff2e98dc7b518b 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.2 2001/02/14 15:58:29 henri Exp $
+ * $Id: input_ts.c,v 1.5 2001/02/20 07:49:13 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
  *****************************************************************************/
 #include <errno.h>
 #include <sys/uio.h>
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
 
 #include "config.h"
 #include "common.h"
@@ -64,7 +71,7 @@ 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;
@@ -72,6 +79,7 @@ void input_getfunctions( function_list_t * p_function_list )
     input.pf_open             = input_FileOpen;
     input.pf_close            = input_FileClose;
     input.pf_end              = TSEnd;
+    input.pf_set_area         = NULL;
     input.pf_read             = TSRead;
     input.pf_demux            = input_DemuxTS;
     input.pf_new_packet       = input_NetlistNewPacket;
@@ -88,13 +96,31 @@ void input_getfunctions( function_list_t * p_function_list )
  *****************************************************************************/
 static int TSProbe( probedata_t * p_data )
 {
+    input_thread_t * p_input = (input_thread_t *)p_data;
+
+    char * psz_name = p_input->p_source;
+    int i_handle;
+    int i_score = 1;
+
     if( TestMethod( INPUT_METHOD_VAR, "ts" ) )
     {
         return( 999 );
     }
 
-    /* verify that the first byte is 0x47 */
-    return 0;
+    if( ( strlen(psz_name) > 5 ) && !strncasecmp( psz_name, "file:", 5 ) )
+    {
+        /* If the user specified "file:" then it's probably a file */
+        psz_name += 5;
+    }
+
+    i_handle = open( psz_name, 0 );
+    if( i_handle == -1 )
+    {
+        return( 0 );
+    }
+    close( i_handle );
+
+    return( i_score );
 }
 
 /*****************************************************************************