]> git.sesse.net Git - vlc/commitdiff
* all: a few changes in access2 (added a info field to access_t, remove
authorLaurent Aimar <fenrir@videolan.org>
Tue, 1 Jun 2004 22:12:10 +0000 (22:12 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 1 Jun 2004 22:12:10 +0000 (22:12 +0000)
ACCESS_GET_EOF/SIZE/POS, prepared title/seekpoint support).

include/ninput.h
modules/access/ftp.c
modules/access/http.c
modules/access/pvr/pvr.c
modules/access/tcp.c

index 4563a7cdc997bbdc197316eacabccbf43b9c5050..1a37ce2492ea2b8bad83b862cc844b6a4993a5cd 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * ninput.h
  *****************************************************************************
- * Copyright (C) 1999-2001 VideoLAN
+ * Copyright (C) 1999-2004 VideoLAN
  * $Id$
  *
  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
 
 #include "vlc_es.h"
 
+/* Seek point */
+struct seekpoint_t
+{
+    int64_t i_byte_offset;
+    int64_t i_time_offset;
+    char    *psz_name;
+};
+
+static inline seekpoint_t *vlc_seekpoint_New( void )
+{
+    seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
+    point->i_byte_offset =
+    point->i_time_offset = 0;
+    point->psz_name = NULL;
+    return point;
+}
+
+static inline void vlc_seekpoint_Delete( seekpoint_t *point )
+{
+    if( !point ) return;
+    if( point->psz_name ) free( point->psz_name );
+    free( point );
+}
+
+static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src )
+{
+    seekpoint_t *point = vlc_seekpoint_New();
+    if( src->psz_name ) point->psz_name = strdup( src->psz_name );
+    point->i_time_offset = src->i_time_offset;
+    point->i_byte_offset = src->i_byte_offset;
+    return point;
+}
+
+typedef struct
+{
+    vlc_bool_t  b_menu;      /* Is it a menu or a normal entry */
+    int64_t     i_length;    /* length if known, else 0 */
+    int         i_seekpoints;/* How many seekpoint, (0/1 has same meaning)*/
+
+    char        *psz_name;
+} input_title_t;
+
+static inline input_title_t *vlc_input_title_New( )
+{
+    input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) );
+
+    t->b_menu = VLC_FALSE;
+    t->i_length = 0;
+    t->i_seekpoints = 0;
+    t->psz_name = NULL;
+
+    return t;
+}
+static inline void vlc_input_title_Delete( input_title_t *t )
+{
+    if( t )
+    {
+        if( t->psz_name ) free( t->psz_name );
+        free( t );
+    }
+}
+
+static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t )
+{
+    input_title_t *dup = vlc_input_title_New( );
+
+    dup->b_menu      = t->b_menu;
+    dup->i_length    = t->i_length;
+    dup->i_seekpoints= t->i_seekpoints;
+    if( t->psz_name ) dup->psz_name = strdup( t->psz_name );
+
+    return dup;
+}
+
+/**
+ * \defgroup es out Es Out
+ * @{
+ */
+
 enum es_out_mode_e
 {
     ES_OUT_MODE_NONE,   /* don't select anything */
@@ -55,11 +134,6 @@ enum es_out_query_e
     ES_OUT_SET_PCR,             /* arg1=int64_t i_pcr(microsecond!) (using default group 0)*/
     ES_OUT_SET_GROUP_PCR,       /* arg1= int i_group, arg2=int64_t i_pcr(microsecond!)*/
     ES_OUT_RESET_PCR,           /* no arg */
-
-    /* ByBass automatic stream timestamp to absolute timestamp using pcr (and disable the automatic mode XXX:for all groups) */
-    ES_OUT_CONVERT_TIMESTAMP,       /* arg1=int64_t *pi_ts(microsecond!) */
-    ES_OUT_CONVERT_GROUP_TIMESTAMP, /* arg1=int i_group, arg2=int64_t *pi_ts(microsecond!)*/
-
 };
 
 struct es_out_t
@@ -100,6 +174,17 @@ static inline int es_out_Control( es_out_t *out, int i_query, ... )
     va_end( args );
     return i_result;
 }
+
+/**
+ * @}
+ */
+
+/* i_update field of access_t/demux_t */
+#define INPUT_UPDATE_NONE       0x0000
+#define INPUT_UPDATE_SIZE       0x0001
+#define INPUT_UPDATE_TITLE      0x0010
+#define INPUT_UPDATE_SEEKPOINT  0x0020
+
 /**
  * \defgroup access Access
  * @{
@@ -114,14 +199,18 @@ enum access_query_e
     ACCESS_CAN_CONTROL_PACE,/* arg1= vlc_bool_t*    cannot fail */
 
     /* */
-    ACCESS_GET_MTU,         /* arg1= int*           cannot fail (0 if no sense) */
-    ACCESS_GET_SIZE,        /* arg1= int64_t*       cannot fail (0 if unknown) */
-    ACCESS_GET_POS,         /* arg1= int64_t*       cannot fail */
-    ACCESS_GET_EOF,         /* arg1= vlc_bool_t*    cannot fail */
+    ACCESS_GET_MTU,         /* arg1= int*           cannot fail(0 if no sense)*/
     ACCESS_GET_PTS_DELAY,   /* arg1= int64_t*       cannot fail */
+    /* */
+    ACCESS_GET_TITLE_INFO,      /* arg1=input_title_t*** arg2=int* can fail */
+    ACCESS_GET_SEEKPOINT_INFO,  /* arg1=seekpoint_t ***  arg2=int* can fail */
 
     /* */
-    ACCESS_SET_PAUSE_STATE  /* arg1= vlc_bool_t     can fail if unsuported */
+    ACCESS_SET_PAUSE_STATE, /* arg1= vlc_bool_t     can fail */
+
+    /* */
+    ACCESS_SET_TITLE,       /* arg1= int            can fail */
+    ACCESS_SET_SEEKPOINT,   /* arg1= int            can fail */
 };
 
 struct access_t
@@ -143,6 +232,20 @@ struct access_t
     int         (*pf_seek) ( access_t *, int64_t );         /* can be null if can't seek */
 
     int         (*pf_control)( access_t *, int i_query, va_list args);  /* mandatory */
+
+    /* access has to maintain them uptodate */
+    struct
+    {
+        unsigned int i_update;  /* Access sets them on change,
+                                   Input removes them once take into account*/
+
+        int64_t      i_size;    /* Write only for access, read only for input */
+        int64_t      i_pos;     /* idem */
+        vlc_bool_t   b_eof;     /* idem */
+
+        int          i_title;    /* idem, start from 0 (could be menu) */
+        int          i_seekpoint;/* idem, start from 0 */
+    } info;
     access_sys_t *p_sys;
 };
 
@@ -347,6 +450,17 @@ struct demux_t
     /* set by demuxer */
     int (*pf_demux)  ( demux_t * );   /* demux one frame only */
     int (*pf_control)( demux_t *, int i_query, va_list args);
+
+    /* Demux has to maintain them uptodate
+     * when it is responsible of seekpoint/title*/
+    struct
+    {
+        unsigned int i_update;  /* Demux sets them on change,
+                                   Input removes them once take into account*/
+        /* Seekpoint/Title at demux level */
+        int          i_title;       /* idem, start from 0 (could be menu) */
+        int          i_seekpoint;   /* idem, start from 0 */
+    } info;
     demux_sys_t *p_sys;
 };
 
@@ -355,45 +469,19 @@ enum demux_query_e
     DEMUX_GET_POSITION,         /* arg1= double *       res=    */
     DEMUX_SET_POSITION,         /* arg1= double         res=can fail    */
 
+    DEMUX_GET_LENGTH,           /* arg1= int64_t *      res=    */
     DEMUX_GET_TIME,             /* arg1= int64_t *      res=    */
     DEMUX_SET_TIME,             /* arg1= int64_t        res=can fail    */
 
-    DEMUX_GET_LENGTH,           /* arg1= int64_t *      res=can fail    */
-
     DEMUX_GET_FPS,              /* arg1= float *        res=can fail    */
-    DEMUX_GET_META              /* arg1= vlc_meta_t **  res=can fail    */
-};
+    DEMUX_GET_META,             /* arg1= vlc_meta_t **  res=can fail    */
 
-struct seekpoint_t
-{
-    int64_t i_byte_offset;
-    int64_t i_time_offset;
-    char    *psz_name;
-};
-
-static inline seekpoint_t *vlc_seekpoint_New( void )
-{
-    seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
-    point->i_byte_offset = point->i_time_offset;
-    point->psz_name = NULL;
-    return point;
-}
-
-static inline void vlc_seekpoint_Delete( seekpoint_t *point )
-{
-    if( !point ) return;
-    if( point->psz_name ) free( point->psz_name );
-    free( point );
-}
+    DEMUX_GET_TITLE_INFO,       /* arg1=input_title_t*** arg2=int* can fail */
+    DEMUX_GET_SEEKPOINT_INFO,   /* arg1=seekpoint_t ***  arg2=int* can fail */
 
-static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src )
-{
-    seekpoint_t *point = vlc_seekpoint_New();
-    if( src->psz_name ) point->psz_name = strdup( src->psz_name );
-    point->i_time_offset = src->i_time_offset;
-    point->i_byte_offset = src->i_byte_offset;
-    return point;
-}
+    DEMUX_SET_TITLE,            /* arg1= int            can fail */
+    DEMUX_SET_SEEKPOINT,        /* arg1= int            can fail */
+};
 
 /* Demux */
 VLC_EXPORT( int, demux_vaControl,        ( input_thread_t *, int i_query, va_list  ) );
index e0c0a6e2bdf9e43b1c2224c096446a6b4dffda01..f68ffc16d3c3d12a2d2e5b31a7c116ffd214955c 100644 (file)
@@ -79,12 +79,6 @@ struct access_sys_t
 
     int       fd_cmd;
     int       fd_data;
-
-    int64_t   i_size;
-
-    int64_t   i_tell;
-
-    vlc_bool_t b_eof;
 };
 
 static int  ftp_SendCommand( access_t *, char *, ... );
@@ -105,12 +99,21 @@ static int Open( vlc_object_t *p_this )
     int          i_answer;
     char         *psz_arg;
 
-    /* *** allocate access_sys_t *** */
-    p_sys = malloc( sizeof( access_sys_t ) );
+    /* Init p_access */
+    p_access->pf_read = Read;
+    p_access->pf_block = NULL;
+    p_access->pf_seek = Seek;
+    p_access->pf_control = Control;
+    p_access->info.i_update = 0;
+    p_access->info.i_size = 0;
+    p_access->info.i_pos = 0;
+    p_access->info.b_eof = VLC_FALSE;
+    p_access->info.i_title = 0;
+    p_access->info.i_seekpoint = 0;
+    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
     memset( p_sys, 0, sizeof( access_sys_t ) );
     p_sys->fd_cmd = -1;
     p_sys->fd_data = -1;
-    p_sys->i_tell = 0;
 
     /* *** Parse URL and get server addr/port and path *** */
     psz = p_access->psz_path;
@@ -140,9 +143,6 @@ static int Open( vlc_object_t *p_this )
         goto exit_error;
     }
 
-    /* set p_access->p_sys */
-    p_access->p_sys = p_sys;
-
     for( ;; )
     {
         if( ftp_ReadCommand( p_access, &i_answer, NULL ) != 1 )
@@ -237,9 +237,9 @@ static int Open( vlc_object_t *p_this )
         msg_Err( p_access, "cannot get file size" );
         goto exit_error;
     }
-    p_sys->i_size = atoll( &psz_arg[4] );
+    p_access->info.i_size = atoll( &psz_arg[4] );
     free( psz_arg );
-    msg_Dbg( p_access, "file size: "I64Fd, p_sys->i_size );
+    msg_Dbg( p_access, "file size: "I64Fd, p_access->info.i_size );
 
     /* Start the 'stream' */
     if( ftp_StartStream( p_access, 0 ) < 0 )
@@ -251,11 +251,6 @@ static int Open( vlc_object_t *p_this )
     /* Update default_pts to a suitable value for ftp access */
     var_Create( p_access, "ftp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
 
-    /* *** set exported functions *** */
-    p_access->pf_read = Read;
-    p_access->pf_block = NULL;
-    p_access->pf_seek = Seek;
-    p_access->pf_control = Control;
     return VLC_SUCCESS;
 
 exit_error:
@@ -299,7 +294,6 @@ static void Close( vlc_object_t *p_this )
  *****************************************************************************/
 static int Seek( access_t *p_access, int64_t i_pos )
 {
-    access_sys_t *p_sys = p_access->p_sys;
     if( i_pos < 0 )
     {
         return VLC_EGENERIC;
@@ -309,11 +303,12 @@ static int Seek( access_t *p_access, int64_t i_pos )
     ftp_StopStream( p_access );
     if( ftp_StartStream( p_access, i_pos ) < 0 )
     {
-        p_sys->b_eof = VLC_TRUE;
+        p_access->info.b_eof = VLC_TRUE;
         return VLC_EGENERIC;
     }
 
-    p_sys->i_tell = i_pos;
+    p_access->info.b_eof = VLC_FALSE;
+    p_access->info.i_pos = i_pos;
 
     return VLC_SUCCESS;
 }
@@ -326,14 +321,14 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
     access_sys_t *p_sys = p_access->p_sys;
     int i_read;
 
-    if( p_sys->b_eof )
+    if( p_access->info.b_eof )
         return 0;
 
     i_read = net_Read( p_access, p_sys->fd_data, p_buffer, i_len, VLC_FALSE );
     if( i_read == 0 )
-        p_sys->b_eof = VLC_TRUE;
+        p_access->info.b_eof = VLC_TRUE;
     else if( i_read > 0 )
-        p_sys->i_tell += i_read;
+        p_access->info.i_pos += i_read;
 
     return i_read;
 }
@@ -343,7 +338,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
  *****************************************************************************/
 static int Control( access_t *p_access, int i_query, va_list args )
 {
-    access_sys_t *p_sys = p_access->p_sys;
     vlc_bool_t   *pb_bool;
     int          *pi_int;
     int64_t      *pi_64;
@@ -374,18 +368,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
             pi_int = (int*)va_arg( args, int * );
             *pi_int = 0;
             break;
-        case ACCESS_GET_SIZE:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = p_sys->i_size > 0 ? p_sys->i_size : 0;
-            break;
-        case ACCESS_GET_POS:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = p_sys->i_tell;
-            break;
-        case ACCESS_GET_EOF:
-            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
-            *pb_bool = p_sys->b_eof;
-            break;
 
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
@@ -398,6 +380,12 @@ static int Control( access_t *p_access, int i_query, va_list args )
             /* Nothing to do */
             break;
 
+        case ACCESS_GET_TITLE_INFO:
+        case ACCESS_GET_SEEKPOINT_INFO:
+        case ACCESS_SET_TITLE:
+        case ACCESS_SET_SEEKPOINT:
+            return VLC_EGENERIC;
+
         default:
             msg_Err( p_access, "unimplemented query in control" );
             return VLC_EGENERIC;
index fe0c80ff6d4f2607245f2dd905d5c3b807ee0bcf..f16c9a4cf5adeb5c74b28a2e857be8aa8090941c 100644 (file)
@@ -108,11 +108,8 @@ struct access_sys_t
 
     vlc_bool_t b_chunked;
     int64_t    i_chunk;
-    int64_t    i_tell;
-    int64_t    i_size;
 
     vlc_bool_t b_seekable;
-    vlc_bool_t b_eof;
 };
 
 /* */
@@ -134,18 +131,6 @@ static int  Open ( vlc_object_t *p_this )
     access_sys_t *p_sys;
     vlc_value_t   val;
 
-    /* Create private struct */
-    p_sys = malloc( sizeof( access_sys_t ) );
-    memset( p_sys, 0, sizeof( access_sys_t ) );
-    p_sys->fd = -1;
-    p_sys->b_proxy = VLC_FALSE;
-    p_sys->i_version = 1;
-    p_sys->b_seekable = VLC_TRUE;
-    p_sys->psz_mime = NULL;
-    p_sys->psz_location = NULL;
-    p_sys->psz_user_agent = NULL;
-    p_sys->b_eof = VLC_FALSE;
-
     /* First set ipv4/ipv6 */
     var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
     var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
@@ -171,8 +156,27 @@ static int  Open ( vlc_object_t *p_this )
         }
     }
 
-    /* Pts delay */
-    var_Create( p_access, "http-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+    /* Set up p_access */
+    p_access->pf_read = Read;
+    p_access->pf_block = NULL;
+    p_access->pf_control = Control;
+    p_access->pf_seek = Seek;
+    p_access->info.i_update = 0;
+    p_access->info.i_size = 0;
+    p_access->info.i_pos = 0;
+    p_access->info.b_eof = VLC_FALSE;
+    p_access->info.i_title = 0;
+    p_access->info.i_seekpoint = 0;
+    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
+    memset( p_sys, 0, sizeof( access_sys_t ) );
+    p_sys->fd = -1;
+    p_sys->b_proxy = VLC_FALSE;
+    p_sys->i_version = 1;
+    p_sys->b_seekable = VLC_TRUE;
+    p_sys->psz_mime = NULL;
+    p_sys->psz_location = NULL;
+    p_sys->psz_user_agent = NULL;
+
 
     /* Parse URI */
     ParseURL( p_sys, p_access->psz_path );
@@ -254,7 +258,6 @@ static int  Open ( vlc_object_t *p_this )
     }
 
     /* Connect */
-    p_access->p_sys = p_sys;
     if( Connect( p_access, 0 ) )
     {
         /* Retry with http 1.0 */
@@ -287,15 +290,9 @@ static int  Open ( vlc_object_t *p_this )
                       p_playlist->i_index + 1 );
         vlc_object_release( p_playlist );
 
-        p_sys->i_size = 0;  /* Force to stop reading */
+        p_access->info.i_size = 0;  /* Force to stop reading */
     }
 
-    /* Set up p_access */
-    p_access->pf_read = Read;
-    p_access->pf_block = NULL;
-    p_access->pf_control = Control;
-    p_access->pf_seek = Seek;
-    p_access->p_sys = p_sys;
     if( !strcmp( p_sys->psz_protocol, "ICY" ) )
     {
         if( p_sys->psz_mime && !strcasecmp( p_sys->psz_mime, "video/nsv" ) )
@@ -306,6 +303,10 @@ static int  Open ( vlc_object_t *p_this )
         msg_Info( p_access, "ICY server found, %s demuxer selected",
                   p_access->psz_demux );
     }
+
+    /* Pts delay */
+    var_Create( p_access, "http-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+
     return VLC_SUCCESS;
 
 error:
@@ -362,15 +363,16 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
 
     if( p_sys->fd < 0 )
     {
-        p_sys->b_eof = VLC_TRUE;
+        p_access->info.b_eof = VLC_TRUE;
         return 0;
     }
 
-    if( p_sys->i_size > 0 && i_len + p_sys->i_tell > p_sys->i_size )
+    if( p_access->info.i_size > 0 &&
+        i_len + p_access->info.i_pos > p_access->info.i_size )
     {
-        if( ( i_len = p_sys->i_size - p_sys->i_tell ) == 0 )
+        if( ( i_len = p_access->info.i_size - p_access->info.i_pos ) == 0 )
         {
-            p_sys->b_eof = VLC_TRUE;
+            p_access->info.b_eof = VLC_TRUE;
             return 0;
         }
     }
@@ -378,7 +380,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
     {
         if( p_sys->i_chunk < 0 )
         {
-            p_sys->b_eof = VLC_TRUE;
+            p_access->info.b_eof = VLC_TRUE;
             return 0;
         }
 
@@ -397,7 +399,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
             if( p_sys->i_chunk <= 0 )   /* eof */
             {
                 p_sys->i_chunk = -1;
-                p_sys->b_eof = VLC_TRUE;
+                p_access->info.b_eof = VLC_TRUE;
                 return 0;
             }
         }
@@ -412,7 +414,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
     i_read = net_Read( p_access, p_sys->fd, p_buffer, i_len, VLC_FALSE );
     if( i_read > 0 )
     {
-        p_sys->i_tell += i_read;
+        p_access->info.i_pos += i_read;
 
         if( p_sys->b_chunked )
         {
@@ -430,7 +432,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
     }
     else if( i_read == 0 )
     {
-        p_sys->b_eof = VLC_TRUE;
+        p_access->info.b_eof = VLC_TRUE;
     }
     return i_read;
 }
@@ -449,7 +451,7 @@ static int Seek( access_t *p_access, int64_t i_pos )
     if( Connect( p_access, i_pos ) )
     {
         msg_Err( p_access, "seek failed" );
-        p_sys->b_eof = VLC_TRUE;
+        p_access->info.b_eof = VLC_TRUE;
         return VLC_EGENERIC;
     }
     return VLC_SUCCESS;
@@ -491,18 +493,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
             pi_int = (int*)va_arg( args, int * );
             *pi_int = 0;
             break;
-        case ACCESS_GET_SIZE:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = p_sys->i_size > 0 ? p_sys->i_size : 0;
-            break;
-        case ACCESS_GET_POS:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = p_sys->i_tell;
-            break;
-        case ACCESS_GET_EOF:
-            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
-            *pb_bool = p_sys->b_eof;
-            break;
 
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
@@ -512,9 +502,14 @@ static int Control( access_t *p_access, int i_query, va_list args )
 
         /* */
         case ACCESS_SET_PAUSE_STATE:
-            /* Nothing to do */
             break;
 
+        case ACCESS_GET_TITLE_INFO:
+        case ACCESS_GET_SEEKPOINT_INFO:
+        case ACCESS_SET_TITLE:
+        case ACCESS_SET_SEEKPOINT:
+            return VLC_EGENERIC;
+
         default:
             msg_Err( p_access, "unimplemented query in control" );
             return VLC_EGENERIC;
@@ -588,8 +583,10 @@ static int Connect( access_t *p_access, int64_t i_tell )
     p_sys->psz_mime = NULL;
     p_sys->b_chunked = VLC_FALSE;
     p_sys->i_chunk = 0;
-    p_sys->i_size = -1;
-    p_sys->i_tell = i_tell;
+
+    p_access->info.i_size = 0;
+    p_access->info.i_pos  = i_tell;
+    p_access->info.b_eof  = VLC_FALSE;
 
 
     /* Open connection */
@@ -721,8 +718,8 @@ static int Connect( access_t *p_access, int64_t i_tell )
 
         if( !strcasecmp( psz, "Content-Length" ) )
         {
-            p_sys->i_size = i_tell + atoll( p );
-            msg_Dbg( p_access, "stream size="I64Fd, p_sys->i_size );
+            p_access->info.i_size = i_tell + atoll( p );
+            msg_Dbg( p_access, "stream size="I64Fd, p_access->info.i_size );
         }
         else if( !strcasecmp( psz, "Location" ) )
         {
index 2a57f98e958f18898bf82526e54df100684cd6ae..f21647b59ab386c48acc6c12d7348322c3897ea1 100644 (file)
@@ -10,7 +10,7 @@
  * 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
 #include <sys/ioctl.h>
 #include "videodev2.h"
 
-/* ivtv specific ioctls */
-#define IVTV_IOC_G_CODEC    0xFFEE7703
-#define IVTV_IOC_S_CODEC    0xFFEE7704
-
-
-/* for use with IVTV_IOC_G_CODEC and IVTV_IOC_S_CODEC */
-
-struct ivtv_ioctl_codec {
-        uint32_t aspect;
-        uint32_t audio_bitmask;
-        uint32_t bframes;
-        uint32_t bitrate_mode;
-        uint32_t bitrate;
-        uint32_t bitrate_peak;
-        uint32_t dnr_mode;
-        uint32_t dnr_spatial;
-        uint32_t dnr_temporal;
-        uint32_t dnr_type;
-        uint32_t framerate;
-        uint32_t framespergop;
-        uint32_t gop_closure;
-        uint32_t pulldown;
-        uint32_t stream_type;
-};
-
-/*****************************************************************************
- * Prototypes
- *****************************************************************************/
-static int     Open   ( vlc_object_t * );
-static void    Close  ( vlc_object_t * );
-
-static int Read   ( access_t *, uint8_t *, int );
-static int Control   ( access_t *, int, va_list );
-
 /*****************************************************************************
  * Module descriptor
  *****************************************************************************/
+static int  Open ( vlc_object_t * );
+static void Close( vlc_object_t * );
 
 #define DEVICE_TEXT N_( "Device" )
 #define DEVICE_LONGTEXT N_( "PVR video device" )
 
 #define NORM_TEXT N_( "Norm" )
 #define NORM_LONGTEXT N_( "Defines the norm of the stream (Automatic, SECAM, PAL, or NTSC)" )
-static int i_norm_list[] = { V4L2_STD_UNKNOWN, V4L2_STD_SECAM, V4L2_STD_PAL, 
+static int i_norm_list[] = { V4L2_STD_UNKNOWN, V4L2_STD_SECAM, V4L2_STD_PAL,
                              V4L2_STD_NTSC };
 static char *psz_norm_list_text[] = { N_("Automatic"), N_("SECAM"),
                                       N_("PAL"),  N_("NSTC") };
@@ -93,7 +61,7 @@ static char *psz_norm_list_text[] = { N_("Automatic"), N_("SECAM"),
                            "autodetect)" )
 #define FREQUENCY_TEXT N_( "Frequency" )
 #define FREQUENCY_LONGTEXT N_( "Frequency to capture (in kHz), if applicable" )
-#define FRAMERATE_TEXT N_( "Framerate" ) 
+#define FRAMERATE_TEXT N_( "Framerate" )
 #define FRAMERATE_LONGTEXT N_( "Framerate to capture, if applicable (-1 for " \
                                "auto" )
 #define KEYINT_TEXT N_( "Key interval" )
@@ -103,13 +71,13 @@ static char *psz_norm_list_text[] = { N_("Automatic"), N_("SECAM"),
 #define BFRAMES_LONGTEXT N_("If this option is set, B-Frames will be used." \
                             "Use this option to set the number of B-Frames")
 #define BITRATE_TEXT N_( "Bitrate" )
-#define BITRATE_LONGTEXT N_( "Bitrate to use (-1 for default)" ) 
+#define BITRATE_LONGTEXT N_( "Bitrate to use (-1 for default)" )
 #define BITRATE_PEAK_TEXT N_( "Bitrate peak" )
 #define BITRATE_PEAK_LONGTEXT N_( "Peak bitrate in VBR mode" )
 #define BITRATE_MODE_TEXT N_( "Bitrate mode (vbr or cbr)" )
 #define BITRATE_MODE_LONGTEXT N_( "Bitrate mode to use" )
 #define BITMASK_TEXT N_( "Audio bitmask" )
-#define BITMASK_LONGTEXT N_("FIXME FIXME FIXME FIXME" ) 
+#define BITMASK_LONGTEXT N_("FIXME FIXME FIXME FIXME" )
 #define CHAN_TEXT N_( "Channel" )
 #define CHAN_LONGTEXT N_( "Channel of the card to use (Usually, 0 = tuner, " \
                           "1 = composite, 2 = svideo )" )
@@ -130,23 +98,23 @@ vlc_module_begin();
                              NORM_LONGTEXT, VLC_FALSE );
        change_integer_list( i_norm_list, psz_norm_list_text, 0 );
 
-    add_integer( "pvr-width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE ); 
+    add_integer( "pvr-width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );
     add_integer( "pvr-height", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT,
-                                         VLC_TRUE ); 
+                                         VLC_TRUE );
     add_integer( "pvr-frequency", -1, NULL, FREQUENCY_TEXT, FREQUENCY_LONGTEXT,
-                                         VLC_FALSE ); 
+                                         VLC_FALSE );
     add_integer( "pvr-framerate", -1, NULL, FRAMERATE_TEXT, FRAMERATE_LONGTEXT,
-                                         VLC_TRUE ); 
+                                         VLC_TRUE );
     add_integer( "pvr-keyint", -1, NULL, KEYINT_TEXT, KEYINT_LONGTEXT,
-                                         VLC_TRUE ); 
+                                         VLC_TRUE );
     add_integer( "pvr-bframes", -1, NULL, FRAMERATE_TEXT, FRAMERATE_LONGTEXT,
-                                         VLC_TRUE ); 
+                                         VLC_TRUE );
     add_integer( "pvr-bitrate", -1, NULL, BITRATE_TEXT, BITRATE_LONGTEXT,
-                                         VLC_FALSE ); 
-    add_integer( "pvr-bitrate-peak", -1, NULL, BITRATE_PEAK_TEXT, 
-                                         BITRATE_PEAK_LONGTEXT, VLC_TRUE ); 
-    add_integer( "pvr-bitrate-mode", -1, NULL, BITRATE_MODE_TEXT, 
-                                         BITRATE_MODE_LONGTEXT, VLC_TRUE ); 
+                                         VLC_FALSE );
+    add_integer( "pvr-bitrate-peak", -1, NULL, BITRATE_PEAK_TEXT,
+                                         BITRATE_PEAK_LONGTEXT, VLC_TRUE );
+    add_integer( "pvr-bitrate-mode", -1, NULL, BITRATE_MODE_TEXT,
+                                         BITRATE_MODE_LONGTEXT, VLC_TRUE );
         change_integer_list( i_bitrates, psz_bitrates_list_text, 0 );
     add_integer( "pvr-audio-bitmask", -1, NULL, BITMASK_TEXT,
                                          BITMASK_LONGTEXT, VLC_TRUE );
@@ -155,19 +123,42 @@ vlc_module_begin();
 
     set_callbacks( Open, Close );
 vlc_module_end();
-    vlc_bool_t b_eof;
-    
+
 /*****************************************************************************
- * Private access data
+ * Prototypes
  *****************************************************************************/
+static int Read   ( access_t *, uint8_t *, int );
+static int Control( access_t *, int, va_list );
+
+/* ivtv specific ioctls */
+#define IVTV_IOC_G_CODEC    0xFFEE7703
+#define IVTV_IOC_S_CODEC    0xFFEE7704
+
+/* for use with IVTV_IOC_G_CODEC and IVTV_IOC_S_CODEC */
+
+struct ivtv_ioctl_codec {
+        uint32_t aspect;
+        uint32_t audio_bitmask;
+        uint32_t bframes;
+        uint32_t bitrate_mode;
+        uint32_t bitrate;
+        uint32_t bitrate_peak;
+        uint32_t dnr_mode;
+        uint32_t dnr_spatial;
+        uint32_t dnr_temporal;
+        uint32_t dnr_type;
+        uint32_t framerate;
+        uint32_t framespergop;
+        uint32_t gop_closure;
+        uint32_t pulldown;
+        uint32_t stream_type;
+};
+
 struct access_sys_t
 {
     /* file descriptor */
     int i_fd;
 
-    int64_t i_tell; /** Number of read bytes */
-    vlc_bool_t b_eof;
-    
     /* options */
     int i_standard;
     int i_width;
@@ -204,6 +195,12 @@ static int Open( vlc_object_t * p_this )
     p_access->pf_block = NULL;
     p_access->pf_seek = NULL;
     p_access->pf_control = Control;
+    p_access->info.i_update = 0;
+    p_access->info.i_size = 0;
+    p_access->info.i_pos = 0;
+    p_access->info.b_eof = VLC_FALSE;
+    p_access->info.i_title = 0;
+    p_access->info.i_seekpoint = 0;
 
     /* create private access data */
     p_sys = calloc( sizeof( access_sys_t ), 1 );
@@ -265,9 +262,6 @@ static int Open( vlc_object_t * p_this )
     var_Get( p_access, "pvr-channel" , &val);
     p_sys->i_input = val.i_int;
 
-
-    p_sys->i_tell = 0;
-
     /* parse command line options */
     psz_tofree = strdup( p_access->psz_path );
     psz_parser = psz_tofree;
@@ -655,7 +649,7 @@ static int Read( access_t * p_access, uint8_t * p_buffer,
     access_sys_t * p_sys = p_access->p_sys;
 
     int i_ret;
-    
+
     struct timeval timeout;
     fd_set fds;
 
@@ -664,11 +658,10 @@ static int Read( access_t * p_access, uint8_t * p_buffer,
     timeout.tv_sec = 0;
     timeout.tv_usec = 500000;
 
-    if( p_sys->b_eof )
+    if( p_access->info.b_eof )
         return 0;
 
-    while( !( i_ret = select( p_sys->i_fd + 1, &fds,
-                              NULL, NULL, &timeout ) ) )
+    while( !( i_ret = select( p_sys->i_fd + 1, &fds, NULL, NULL, &timeout) ) )
     {
         FD_ZERO( &fds );
         FD_SET( p_sys->i_fd, &fds );
@@ -688,11 +681,11 @@ static int Read( access_t * p_access, uint8_t * p_buffer,
     i_ret = read( p_sys->i_fd, p_buffer, i_len );
     if( i_ret == 0 )
     {
-        p_sys->b_eof = VLC_TRUE;
+        p_access->info.b_eof = VLC_TRUE;
     }
-    else if ( i_ret > 0 )
+    else if( i_ret > 0 )
     {
-        p_sys->i_tell += i_ret;
+        p_access->info.i_pos += i_ret;
     }
 
     return i_ret;
@@ -730,18 +723,7 @@ static int Control( access_t *p_access, int i_query, va_list args )
             pi_int = (int*)va_arg( args, int * );
             *pi_int = 0;
             break;
-        case ACCESS_GET_SIZE:
-            pi_64 = (int64_t*)va_arg( args, int64_t * ); 
-            *pi_64 = 0;
-            break;
-        case ACCESS_GET_POS:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = p_sys->i_tell;
-            break;
-        case ACCESS_GET_EOF:
-            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
-            *pb_bool = p_sys->b_eof;
-            break;
+
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
             *pi_64 = 1000000;
@@ -752,6 +734,12 @@ static int Control( access_t *p_access, int i_query, va_list args )
             /* Nothing to do */
             break;
 
+        case ACCESS_GET_TITLE_INFO:
+        case ACCESS_GET_SEEKPOINT_INFO:
+        case ACCESS_SET_TITLE:
+        case ACCESS_SET_SEEKPOINT:
+            return VLC_EGENERIC;
+
         default:
             msg_Err( p_access, "unimplemented query in control" );
             return VLC_EGENERIC;
index 6fb29430f381fb8f8503d7dedaada3e73eac5e92..cabb157aaef6809d8cf8b6d5d34ee386338181be 100644 (file)
@@ -59,8 +59,6 @@ vlc_module_end();
 struct access_sys_t
 {
     int        fd;
-    int64_t    i_tell;
-    vlc_bool_t b_eof;
 };
 
 
@@ -106,11 +104,20 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    /* Connect */
+    /* Init p_access */
+    p_access->pf_read = Read;
+    p_access->pf_block = NULL;
+    p_access->pf_control = Control;
+    p_access->pf_seek = NULL;
+    p_access->info.i_update = 0;
+    p_access->info.i_size = 0;
+    p_access->info.i_pos = 0;
+    p_access->info.b_eof = VLC_FALSE;
+    p_access->info.i_title = 0;
+    p_access->info.i_seekpoint = 0;
     p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
+
     p_sys->fd = net_OpenTCP( p_access, psz_dup, atoi( psz_parser ) );
-    p_sys->i_tell = 0;
-    p_sys->b_eof = VLC_FALSE;
     free( psz_dup );
 
     if( p_sys->fd < 0 )
@@ -119,11 +126,6 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
     }
 
-    p_access->pf_read    = Read;
-    p_access->pf_block   = NULL;
-    p_access->pf_seek    = NULL;
-    p_access->pf_control = Control;
-
     /* Update default_pts to a suitable value for udp access */
     var_Create( p_access, "tcp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
 
@@ -150,14 +152,14 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
     access_sys_t *p_sys = p_access->p_sys;
     int i_read;
 
-    if( p_sys->b_eof )
+    if( p_access->info.b_eof )
         return 0;
 
     i_read = net_Read( p_access, p_sys->fd, p_buffer, i_len, VLC_FALSE );
     if( i_read == 0 )
-        p_sys->b_eof = VLC_TRUE;
+        p_access->info.b_eof = VLC_TRUE;
     else if( i_read > 0 )
-        p_sys->i_tell += i_read;
+        p_access->info.i_pos += i_read;
 
     return i_read;
 }
@@ -167,7 +169,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
  *****************************************************************************/
 static int Control( access_t *p_access, int i_query, va_list args )
 {
-    access_sys_t *p_sys = p_access->p_sys;
     vlc_bool_t   *pb_bool;
     int          *pi_int;
     int64_t      *pi_64;
@@ -195,18 +196,6 @@ static int Control( access_t *p_access, int i_query, va_list args )
             pi_int = (int*)va_arg( args, int * );
             *pi_int = 0;
             break;
-        case ACCESS_GET_SIZE:
-            pi_64 = (int64_t*)va_arg( args, int64_t * ); 
-            *pi_64 = 0;
-            break;
-        case ACCESS_GET_POS:
-            pi_64 = (int64_t*)va_arg( args, int64_t * );
-            *pi_64 = p_sys->i_tell;
-            break;
-        case ACCESS_GET_EOF:
-            pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* );
-            *pb_bool = p_sys->b_eof;
-            break;
 
         case ACCESS_GET_PTS_DELAY:
             pi_64 = (int64_t*)va_arg( args, int64_t * );
@@ -219,6 +208,12 @@ static int Control( access_t *p_access, int i_query, va_list args )
             /* Nothing to do */
             break;
 
+        case ACCESS_GET_TITLE_INFO:
+        case ACCESS_GET_SEEKPOINT_INFO:
+        case ACCESS_SET_TITLE:
+        case ACCESS_SET_SEEKPOINT:
+            return VLC_EGENERIC;
+
         default:
             msg_Err( p_access, "unimplemented query in control" );
             return VLC_EGENERIC;