Changeset 5c276c93dc4adddcc82c0da88901f320e3def217

Show
Ignore:
Timestamp:
02/06/04 00:12:10 (5 years ago)
Author:
Laurent Aimar <fenrir@videolan.org>
git-committer:
Laurent Aimar <fenrir@videolan.org> 1086127930 +0000
git-parent:

[0cd04434ba018611c8327592d02724063baf8386]

git-author:
Laurent Aimar <fenrir@videolan.org> 1086127930 +0000
Message:
  • all: a few changes in access2 (added a info field to access_t, remove

ACCESS_GET_EOF/SIZE/POS, prepared title/seekpoint support).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/ninput.h

    r4ac573f r5c276c9  
    22 * ninput.h 
    33 ***************************************************************************** 
    4  * Copyright (C) 1999-2001 VideoLAN 
     4 * Copyright (C) 1999-2004 VideoLAN 
    55 * $Id$ 
    66 * 
     
    2727#include "vlc_es.h" 
    2828 
     29/* Seek point */ 
     30struct seekpoint_t 
     31{ 
     32    int64_t i_byte_offset; 
     33    int64_t i_time_offset; 
     34    char    *psz_name; 
     35}; 
     36 
     37static inline seekpoint_t *vlc_seekpoint_New( void ) 
     38{ 
     39    seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) ); 
     40    point->i_byte_offset = 
     41    point->i_time_offset = 0; 
     42    point->psz_name = NULL; 
     43    return point; 
     44} 
     45 
     46static inline void vlc_seekpoint_Delete( seekpoint_t *point ) 
     47{ 
     48    if( !point ) return; 
     49    if( point->psz_name ) free( point->psz_name ); 
     50    free( point ); 
     51} 
     52 
     53static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src ) 
     54{ 
     55    seekpoint_t *point = vlc_seekpoint_New(); 
     56    if( src->psz_name ) point->psz_name = strdup( src->psz_name ); 
     57    point->i_time_offset = src->i_time_offset; 
     58    point->i_byte_offset = src->i_byte_offset; 
     59    return point; 
     60} 
     61 
     62typedef struct 
     63{ 
     64    vlc_bool_t  b_menu;      /* Is it a menu or a normal entry */ 
     65    int64_t     i_length;    /* length if known, else 0 */ 
     66    int         i_seekpoints;/* How many seekpoint, (0/1 has same meaning)*/ 
     67 
     68    char        *psz_name; 
     69} input_title_t; 
     70 
     71static inline input_title_t *vlc_input_title_New( ) 
     72{ 
     73    input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) ); 
     74 
     75    t->b_menu = VLC_FALSE; 
     76    t->i_length = 0; 
     77    t->i_seekpoints = 0; 
     78    t->psz_name = NULL; 
     79 
     80    return t; 
     81} 
     82static inline void vlc_input_title_Delete( input_title_t *t ) 
     83{ 
     84    if( t ) 
     85    { 
     86        if( t->psz_name ) free( t->psz_name ); 
     87        free( t ); 
     88    } 
     89} 
     90 
     91static inline input_title_t *vlc_input_title_Duplicate( input_title_t *t ) 
     92{ 
     93    input_title_t *dup = vlc_input_title_New( ); 
     94 
     95    dup->b_menu      = t->b_menu; 
     96    dup->i_length    = t->i_length; 
     97    dup->i_seekpoints= t->i_seekpoints; 
     98    if( t->psz_name ) dup->psz_name = strdup( t->psz_name ); 
     99 
     100    return dup; 
     101} 
     102 
     103/** 
     104 * \defgroup es out Es Out 
     105 * @{ 
     106 */ 
     107 
    29108enum es_out_mode_e 
    30109{ 
     
    56135    ES_OUT_SET_GROUP_PCR,       /* arg1= int i_group, arg2=int64_t i_pcr(microsecond!)*/ 
    57136    ES_OUT_RESET_PCR,           /* no arg */ 
    58  
    59     /* ByBass automatic stream timestamp to absolute timestamp using pcr (and disable the automatic mode XXX:for all groups) */ 
    60     ES_OUT_CONVERT_TIMESTAMP,       /* arg1=int64_t *pi_ts(microsecond!) */ 
    61     ES_OUT_CONVERT_GROUP_TIMESTAMP, /* arg1=int i_group, arg2=int64_t *pi_ts(microsecond!)*/ 
    62  
    63137}; 
    64138 
     
    101175    return i_result; 
    102176} 
     177 
     178/** 
     179 * @} 
     180 */ 
     181 
     182/* i_update field of access_t/demux_t */ 
     183#define INPUT_UPDATE_NONE       0x0000 
     184#define INPUT_UPDATE_SIZE       0x0001 
     185#define INPUT_UPDATE_TITLE      0x0010 
     186#define INPUT_UPDATE_SEEKPOINT  0x0020 
     187 
    103188/** 
    104189 * \defgroup access Access 
     
    115200 
    116201    /* */ 
    117     ACCESS_GET_MTU,         /* arg1= int*           cannot fail (0 if no sense) */ 
    118     ACCESS_GET_SIZE,        /* arg1= int64_t*       cannot fail (0 if unknown) */ 
    119     ACCESS_GET_POS,         /* arg1= int64_t*       cannot fail */ 
    120     ACCESS_GET_EOF,         /* arg1= vlc_bool_t*    cannot fail */ 
     202    ACCESS_GET_MTU,         /* arg1= int*           cannot fail(0 if no sense)*/ 
    121203    ACCESS_GET_PTS_DELAY,   /* arg1= int64_t*       cannot fail */ 
    122  
    123204    /* */ 
    124     ACCESS_SET_PAUSE_STATE  /* arg1= vlc_bool_t     can fail if unsuported */ 
     205    ACCESS_GET_TITLE_INFO,      /* arg1=input_title_t*** arg2=int* can fail */ 
     206    ACCESS_GET_SEEKPOINT_INFO,  /* arg1=seekpoint_t ***  arg2=int* can fail */ 
     207 
     208    /* */ 
     209    ACCESS_SET_PAUSE_STATE, /* arg1= vlc_bool_t     can fail */ 
     210 
     211    /* */ 
     212    ACCESS_SET_TITLE,       /* arg1= int            can fail */ 
     213    ACCESS_SET_SEEKPOINT,   /* arg1= int            can fail */ 
    125214}; 
    126215 
     
    144233 
    145234    int         (*pf_control)( access_t *, int i_query, va_list args);  /* mandatory */ 
     235 
     236    /* access has to maintain them uptodate */ 
     237    struct 
     238    { 
     239        unsigned int i_update;  /* Access sets them on change, 
     240                                   Input removes them once take into account*/ 
     241 
     242        int64_t      i_size;    /* Write only for access, read only for input */ 
     243        int64_t      i_pos;     /* idem */ 
     244        vlc_bool_t   b_eof;     /* idem */ 
     245 
     246        int          i_title;    /* idem, start from 0 (could be menu) */ 
     247        int          i_seekpoint;/* idem, start from 0 */ 
     248    } info; 
    146249    access_sys_t *p_sys; 
    147250}; 
     
    348451    int (*pf_demux)  ( demux_t * );   /* demux one frame only */ 
    349452    int (*pf_control)( demux_t *, int i_query, va_list args); 
     453 
     454    /* Demux has to maintain them uptodate 
     455     * when it is responsible of seekpoint/title*/ 
     456    struct 
     457    { 
     458        unsigned int i_update;  /* Demux sets them on change, 
     459                                   Input removes them once take into account*/ 
     460        /* Seekpoint/Title at demux level */ 
     461        int          i_title;       /* idem, start from 0 (could be menu) */ 
     462        int          i_seekpoint;   /* idem, start from 0 */ 
     463    } info; 
    350464    demux_sys_t *p_sys; 
    351465}; 
     
    356470    DEMUX_SET_POSITION,         /* arg1= double         res=can fail    */ 
    357471 
     472    DEMUX_GET_LENGTH,           /* arg1= int64_t *      res=    */ 
    358473    DEMUX_GET_TIME,             /* arg1= int64_t *      res=    */ 
    359474    DEMUX_SET_TIME,             /* arg1= int64_t        res=can fail    */ 
    360475 
    361     DEMUX_GET_LENGTH,           /* arg1= int64_t *      res=can fail    */ 
    362  
    363476    DEMUX_GET_FPS,              /* arg1= float *        res=can fail    */ 
    364     DEMUX_GET_META              /* arg1= vlc_meta_t **  res=can fail    */ 
    365 }; 
    366  
    367 struct seekpoint_t 
    368 
    369     int64_t i_byte_offset; 
    370     int64_t i_time_offset; 
    371     char    *psz_name; 
    372 }; 
    373  
    374 static inline seekpoint_t *vlc_seekpoint_New( void ) 
    375 
    376     seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) ); 
    377     point->i_byte_offset = point->i_time_offset; 
    378     point->psz_name = NULL; 
    379     return point; 
    380 
    381  
    382 static inline void vlc_seekpoint_Delete( seekpoint_t *point ) 
    383 
    384     if( !point ) return; 
    385     if( point->psz_name ) free( point->psz_name ); 
    386     free( point ); 
    387 
    388  
    389 static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src ) 
    390 
    391     seekpoint_t *point = vlc_seekpoint_New(); 
    392     if( src->psz_name ) point->psz_name = strdup( src->psz_name ); 
    393     point->i_time_offset = src->i_time_offset; 
    394     point->i_byte_offset = src->i_byte_offset; 
    395     return point; 
    396 
     477    DEMUX_GET_META,             /* arg1= vlc_meta_t **  res=can fail    */ 
     478 
     479    DEMUX_GET_TITLE_INFO,       /* arg1=input_title_t*** arg2=int* can fail */ 
     480    DEMUX_GET_SEEKPOINT_INFO,   /* arg1=seekpoint_t ***  arg2=int* can fail */ 
     481 
     482    DEMUX_SET_TITLE,            /* arg1= int            can fail */ 
     483    DEMUX_SET_SEEKPOINT,        /* arg1= int            can fail */ 
     484}; 
    397485 
    398486/* Demux */ 
  • modules/access/ftp.c

    rdab3b92 r5c276c9  
    8080    int       fd_cmd; 
    8181    int       fd_data; 
    82  
    83     int64_t   i_size; 
    84  
    85     int64_t   i_tell; 
    86  
    87     vlc_bool_t b_eof; 
    8882}; 
    8983 
     
    106100    char         *psz_arg; 
    107101 
    108     /* *** allocate access_sys_t *** */ 
    109     p_sys = malloc( sizeof( access_sys_t ) ); 
     102    /* Init p_access */ 
     103    p_access->pf_read = Read; 
     104    p_access->pf_block = NULL; 
     105    p_access->pf_seek = Seek; 
     106    p_access->pf_control = Control; 
     107    p_access->info.i_update = 0; 
     108    p_access->info.i_size = 0; 
     109    p_access->info.i_pos = 0; 
     110    p_access->info.b_eof = VLC_FALSE; 
     111    p_access->info.i_title = 0; 
     112    p_access->info.i_seekpoint = 0; 
     113    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); 
    110114    memset( p_sys, 0, sizeof( access_sys_t ) ); 
    111115    p_sys->fd_cmd = -1; 
    112116    p_sys->fd_data = -1; 
    113     p_sys->i_tell = 0; 
    114117 
    115118    /* *** Parse URL and get server addr/port and path *** */ 
     
    140143        goto exit_error; 
    141144    } 
    142  
    143     /* set p_access->p_sys */ 
    144     p_access->p_sys = p_sys; 
    145145 
    146146    for( ;; ) 
     
    238238        goto exit_error; 
    239239    } 
    240     p_sys->i_size = atoll( &psz_arg[4] ); 
     240    p_access->info.i_size = atoll( &psz_arg[4] ); 
    241241    free( psz_arg ); 
    242     msg_Dbg( p_access, "file size: "I64Fd, p_sys->i_size ); 
     242    msg_Dbg( p_access, "file size: "I64Fd, p_access->info.i_size ); 
    243243 
    244244    /* Start the 'stream' */ 
     
    252252    var_Create( p_access, "ftp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
    253253 
    254     /* *** set exported functions *** */ 
    255     p_access->pf_read = Read; 
    256     p_access->pf_block = NULL; 
    257     p_access->pf_seek = Seek; 
    258     p_access->pf_control = Control; 
    259254    return VLC_SUCCESS; 
    260255 
     
    300295static int Seek( access_t *p_access, int64_t i_pos ) 
    301296{ 
    302     access_sys_t *p_sys = p_access->p_sys; 
    303297    if( i_pos < 0 ) 
    304298    { 
     
    310304    if( ftp_StartStream( p_access, i_pos ) < 0 ) 
    311305    { 
    312         p_sys->b_eof = VLC_TRUE; 
    313         return VLC_EGENERIC; 
    314     } 
    315  
    316     p_sys->i_tell = i_pos; 
     306        p_access->info.b_eof = VLC_TRUE; 
     307        return VLC_EGENERIC; 
     308    } 
     309 
     310    p_access->info.b_eof = VLC_FALSE; 
     311    p_access->info.i_pos = i_pos; 
    317312 
    318313    return VLC_SUCCESS; 
     
    327322    int i_read; 
    328323 
    329     if( p_sys->b_eof ) 
     324    if( p_access->info.b_eof ) 
    330325        return 0; 
    331326 
    332327    i_read = net_Read( p_access, p_sys->fd_data, p_buffer, i_len, VLC_FALSE ); 
    333328    if( i_read == 0 ) 
    334         p_sys->b_eof = VLC_TRUE; 
     329        p_access->info.b_eof = VLC_TRUE; 
    335330    else if( i_read > 0 ) 
    336         p_sys->i_tell += i_read; 
     331        p_access->info.i_pos += i_read; 
    337332 
    338333    return i_read; 
     
    344339static int Control( access_t *p_access, int i_query, va_list args ) 
    345340{ 
    346     access_sys_t *p_sys = p_access->p_sys; 
    347341    vlc_bool_t   *pb_bool; 
    348342    int          *pi_int; 
     
    375369            *pi_int = 0; 
    376370            break; 
    377         case ACCESS_GET_SIZE: 
    378             pi_64 = (int64_t*)va_arg( args, int64_t * ); 
    379             *pi_64 = p_sys->i_size > 0 ? p_sys->i_size : 0; 
    380             break; 
    381         case ACCESS_GET_POS: 
    382             pi_64 = (int64_t*)va_arg( args, int64_t * ); 
    383             *pi_64 = p_sys->i_tell; 
    384             break; 
    385         case ACCESS_GET_EOF: 
    386             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); 
    387             *pb_bool = p_sys->b_eof; 
    388             break; 
    389371 
    390372        case ACCESS_GET_PTS_DELAY: 
     
    398380            /* Nothing to do */ 
    399381            break; 
     382 
     383        case ACCESS_GET_TITLE_INFO: 
     384        case ACCESS_GET_SEEKPOINT_INFO: 
     385        case ACCESS_SET_TITLE: 
     386        case ACCESS_SET_SEEKPOINT: 
     387            return VLC_EGENERIC; 
    400388 
    401389        default: 
  • modules/access/http.c

    r82e174b r5c276c9  
    109109    vlc_bool_t b_chunked; 
    110110    int64_t    i_chunk; 
    111     int64_t    i_tell; 
    112     int64_t    i_size; 
    113111 
    114112    vlc_bool_t b_seekable; 
    115     vlc_bool_t b_eof; 
    116113}; 
    117114 
     
    135132    vlc_value_t   val; 
    136133 
    137     /* Create private struct */ 
    138     p_sys = malloc( sizeof( access_sys_t ) ); 
     134    /* First set ipv4/ipv6 */ 
     135    var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
     136    var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
     137 
     138    if( *p_access->psz_access ) 
     139    { 
     140        /* Find out which shortcut was used */ 
     141        if( !strncmp( p_access->psz_access, "http4", 6 ) ) 
     142        { 
     143            val.b_bool = VLC_TRUE; 
     144            var_Set( p_access, "ipv4", val ); 
     145 
     146            val.b_bool = VLC_FALSE; 
     147            var_Set( p_access, "ipv6", val ); 
     148        } 
     149        else if( !strncmp( p_access->psz_access, "http6", 6 ) ) 
     150        { 
     151            val.b_bool = VLC_TRUE; 
     152            var_Set( p_access, "ipv6", val ); 
     153 
     154            val.b_bool = VLC_FALSE; 
     155            var_Set( p_access, "ipv4", val ); 
     156        } 
     157    } 
     158 
     159    /* Set up p_access */ 
     160    p_access->pf_read = Read; 
     161    p_access->pf_block = NULL; 
     162    p_access->pf_control = Control; 
     163    p_access->pf_seek = Seek; 
     164    p_access->info.i_update = 0; 
     165    p_access->info.i_size = 0; 
     166    p_access->info.i_pos = 0; 
     167    p_access->info.b_eof = VLC_FALSE; 
     168    p_access->info.i_title = 0; 
     169    p_access->info.i_seekpoint = 0; 
     170    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); 
    139171    memset( p_sys, 0, sizeof( access_sys_t ) ); 
    140172    p_sys->fd = -1; 
     
    145177    p_sys->psz_location = NULL; 
    146178    p_sys->psz_user_agent = NULL; 
    147     p_sys->b_eof = VLC_FALSE; 
    148  
    149     /* First set ipv4/ipv6 */ 
    150     var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
    151     var_Create( p_access, "ipv6", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); 
    152  
    153     if( *p_access->psz_access ) 
    154     { 
    155         /* Find out which shortcut was used */ 
    156         if( !strncmp( p_access->psz_access, "http4", 6 ) ) 
    157         { 
    158             val.b_bool = VLC_TRUE; 
    159             var_Set( p_access, "ipv4", val ); 
    160  
    161             val.b_bool = VLC_FALSE; 
    162             var_Set( p_access, "ipv6", val ); 
    163         } 
    164         else if( !strncmp( p_access->psz_access, "http6", 6 ) ) 
    165         { 
    166             val.b_bool = VLC_TRUE; 
    167             var_Set( p_access, "ipv6", val ); 
    168  
    169             val.b_bool = VLC_FALSE; 
    170             var_Set( p_access, "ipv4", val ); 
    171         } 
    172     } 
    173  
    174     /* Pts delay */ 
    175     var_Create( p_access, "http-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
     179 
    176180 
    177181    /* Parse URI */ 
     
    255259 
    256260    /* Connect */ 
    257     p_access->p_sys = p_sys; 
    258261    if( Connect( p_access, 0 ) ) 
    259262    { 
     
    288291        vlc_object_release( p_playlist ); 
    289292 
    290         p_sys->i_size = 0;  /* Force to stop reading */ 
    291     } 
    292  
    293     /* Set up p_access */ 
    294     p_access->pf_read = Read; 
    295     p_access->pf_block = NULL; 
    296     p_access->pf_control = Control; 
    297     p_access->pf_seek = Seek; 
    298     p_access->p_sys = p_sys; 
     293        p_access->info.i_size = 0;  /* Force to stop reading */ 
     294    } 
     295 
    299296    if( !strcmp( p_sys->psz_protocol, "ICY" ) ) 
    300297    { 
     
    307304                  p_access->psz_demux ); 
    308305    } 
     306 
     307    /* Pts delay */ 
     308    var_Create( p_access, "http-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
     309 
    309310    return VLC_SUCCESS; 
    310311 
     
    363364    if( p_sys->fd < 0 ) 
    364365    { 
    365         p_sys->b_eof = VLC_TRUE; 
     366        p_access->info.b_eof = VLC_TRUE; 
    366367        return 0; 
    367368    } 
    368369 
    369     if( p_sys->i_size > 0 && i_len + p_sys->i_tell > p_sys->i_size ) 
    370     { 
    371         if( ( i_len = p_sys->i_size - p_sys->i_tell ) == 0 ) 
    372         { 
    373             p_sys->b_eof = VLC_TRUE; 
     370    if( p_access->info.i_size > 0 && 
     371        i_len + p_access->info.i_pos > p_access->info.i_size ) 
     372    { 
     373        if( ( i_len = p_access->info.i_size - p_access->info.i_pos ) == 0 ) 
     374        { 
     375            p_access->info.b_eof = VLC_TRUE; 
    374376            return 0; 
    375377        } 
     
    379381        if( p_sys->i_chunk < 0 ) 
    380382        { 
    381             p_sys->b_eof = VLC_TRUE; 
     383            p_access->info.b_eof = VLC_TRUE; 
    382384            return 0; 
    383385        } 
     
    398400            { 
    399401                p_sys->i_chunk = -1; 
    400                 p_sys->b_eof = VLC_TRUE; 
     402                p_access->info.b_eof = VLC_TRUE; 
    401403                return 0; 
    402404            } 
     
    413415    if( i_read > 0 ) 
    414416    { 
    415         p_sys->i_tell += i_read; 
     417        p_access->info.i_pos += i_read; 
    416418 
    417419        if( p_sys->b_chunked ) 
     
    431433    else if( i_read == 0 ) 
    432434    { 
    433         p_sys->b_eof = VLC_TRUE; 
     435        p_access->info.b_eof = VLC_TRUE; 
    434436    } 
    435437    return i_read; 
     
    450452    { 
    451453        msg_Err( p_access, "seek failed" ); 
    452         p_sys->b_eof = VLC_TRUE; 
     454        p_access->info.b_eof = VLC_TRUE; 
    453455        return VLC_EGENERIC; 
    454456    } 
     
    492494            *pi_int = 0; 
    493495            break; 
    494         case ACCESS_GET_SIZE: 
    495             pi_64 = (int64_t*)va_arg( args, int64_t * ); 
    496             *pi_64 = p_sys->i_size > 0 ? p_sys->i_size : 0; 
    497             break; 
    498         case ACCESS_GET_POS: 
    499             pi_64 = (int64_t*)va_arg( args, int64_t * ); 
    500             *pi_64 = p_sys->i_tell; 
    501             break; 
    502         case ACCESS_GET_EOF: 
    503             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); 
    504             *pb_bool = p_sys->b_eof; 
    505             break; 
    506496 
    507497        case ACCESS_GET_PTS_DELAY: 
     
    513503        /* */ 
    514504        case ACCESS_SET_PAUSE_STATE: 
    515             /* Nothing to do */ 
    516             break; 
     505            break; 
     506 
     507        case ACCESS_GET_TITLE_INFO: 
     508        case ACCESS_GET_SEEKPOINT_INFO: 
     509        case ACCESS_SET_TITLE: 
     510        case ACCESS_SET_SEEKPOINT: 
     511            return VLC_EGENERIC; 
    517512 
    518513        default: 
     
    589584    p_sys->b_chunked = VLC_FALSE; 
    590585    p_sys->i_chunk = 0; 
    591     p_sys->i_size = -1; 
    592     p_sys->i_tell = i_tell; 
     586 
     587    p_access->info.i_size = 0; 
     588    p_access->info.i_pos  = i_tell; 
     589    p_access->info.b_eof  = VLC_FALSE; 
    593590 
    594591 
     
    722719        if( !strcasecmp( psz, "Content-Length" ) ) 
    723720        { 
    724             p_sys->i_size = i_tell + atoll( p ); 
    725             msg_Dbg( p_access, "stream size="I64Fd, p_sys->i_size ); 
     721            p_access->info.i_size = i_tell + atoll( p ); 
     722            msg_Dbg( p_access, "stream size="I64Fd, p_access->info.i_size ); 
    726723        } 
    727724        else if( !strcasecmp( psz, "Location" ) ) 
  • modules/access/pvr/pvr.c

    rd2a2e28 r5c276c9  
    1111 * the Free Software Foundation; either version 2 of the License, or 
    1212 * (at your option) any later version. 
    13  *  
     13 * 
    1414 * This program is distributed in the hope that it will be useful, 
    1515 * but WITHOUT ANY WARRANTY; without even the implied warranty of 
     
    3838#include "videodev2.h" 
    3939 
     40/***************************************************************************** 
     41 * Module descriptor 
     42 *****************************************************************************/ 
     43static int  Open ( vlc_object_t * ); 
     44static void Close( vlc_object_t * ); 
     45 
     46#define DEVICE_TEXT N_( "Device" ) 
     47#define DEVICE_LONGTEXT N_( "PVR video device" ) 
     48 
     49#define NORM_TEXT N_( "Norm" ) 
     50#define NORM_LONGTEXT N_( "Defines the norm of the stream (Automatic, SECAM, PAL, or NTSC)" ) 
     51static int i_norm_list[] = { V4L2_STD_UNKNOWN, V4L2_STD_SECAM, V4L2_STD_PAL, 
     52                             V4L2_STD_NTSC }; 
     53static char *psz_norm_list_text[] = { N_("Automatic"), N_("SECAM"), 
     54                                      N_("PAL"),  N_("NSTC") }; 
     55 
     56#define WIDTH_TEXT N_( "Width" ) 
     57#define WIDTH_LONGTEXT N_( "Width of the stream to capture (-1 for " \ 
     58                           "autodetect)" ) 
     59#define HEIGHT_TEXT N_( "Height" ) 
     60#define HEIGHT_LONGTEXT N_( "Height of the stream to capture (-1 for " \ 
     61                           "autodetect)" ) 
     62#define FREQUENCY_TEXT N_( "Frequency" ) 
     63#define FREQUENCY_LONGTEXT N_( "Frequency to capture (in kHz), if applicable" ) 
     64#define FRAMERATE_TEXT N_( "Framerate" ) 
     65#define FRAMERATE_LONGTEXT N_( "Framerate to capture, if applicable (-1 for " \ 
     66                               "auto" ) 
     67#define KEYINT_TEXT N_( "Key interval" ) 
     68#define KEYINT_LONGTEXT N_( "Interval between keyframes, in FIXME (-1 for " \ 
     69                                " auto" ) 
     70#define BFRAMES_TEXT N_( "B Frames" ) 
     71#define BFRAMES_LONGTEXT N_("If this option is set, B-Frames will be used." \ 
     72                            "Use this option to set the number of B-Frames") 
     73#define BITRATE_TEXT N_( "Bitrate" ) 
     74#define BITRATE_LONGTEXT N_( "Bitrate to use (-1 for default)" ) 
     75#define BITRATE_PEAK_TEXT N_( "Bitrate peak" ) 
     76#define BITRATE_PEAK_LONGTEXT N_( "Peak bitrate in VBR mode" ) 
     77#define BITRATE_MODE_TEXT N_( "Bitrate mode (vbr or cbr)" ) 
     78#define BITRATE_MODE_LONGTEXT N_( "Bitrate mode to use" ) 
     79#define BITMASK_TEXT N_( "Audio bitmask" ) 
     80#define BITMASK_LONGTEXT N_("FIXME FIXME FIXME FIXME" ) 
     81#define CHAN_TEXT N_( "Channel" ) 
     82#define CHAN_LONGTEXT N_( "Channel of the card to use (Usually, 0 = tuner, " \ 
     83                          "1 = composite, 2 = svideo )" ) 
     84 
     85static int i_bitrates[] = { 0, 1 }; 
     86static char *psz_bitrates_list_text[] = { N_("vbr"), N_("cbr") }; 
     87 
     88vlc_module_begin(); 
     89    set_shortname( _("PVR") ); 
     90    set_description( _("MPEG Encoding cards input (with ivtv drivers)") ); 
     91    set_capability( "access2", 0 ); 
     92    add_shortcut( "pvr" ); 
     93 
     94    add_string( "pvr-device", "/dev/video0", NULL, DEVICE_TEXT, 
     95                            DEVICE_LONGTEXT, VLC_FALSE ); 
     96 
     97    add_integer( "pvr-norm", V4L2_STD_UNKNOWN , NULL, NORM_TEXT, 
     98                             NORM_LONGTEXT, VLC_FALSE ); 
     99       change_integer_list( i_norm_list, psz_norm_list_text, 0 ); 
     100 
     101    add_integer( "pvr-width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE ); 
     102    add_integer( "pvr-height", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, 
     103                                         VLC_TRUE ); 
     104    add_integer( "pvr-frequency", -1, NULL, FREQUENCY_TEXT, FREQUENCY_LONGTEXT, 
     105                                         VLC_FALSE ); 
     106    add_integer( "pvr-framerate", -1, NULL, FRAMERATE_TEXT, FRAMERATE_LONGTEXT, 
     107                                         VLC_TRUE ); 
     108    add_integer( "pvr-keyint", -1, NULL, KEYINT_TEXT, KEYINT_LONGTEXT, 
     109                                         VLC_TRUE ); 
     110    add_integer( "pvr-bframes", -1, NULL, FRAMERATE_TEXT, FRAMERATE_LONGTEXT, 
     111                                         VLC_TRUE ); 
     112    add_integer( "pvr-bitrate", -1, NULL, BITRATE_TEXT, BITRATE_LONGTEXT, 
     113                                         VLC_FALSE ); 
     114    add_integer( "pvr-bitrate-peak", -1, NULL, BITRATE_PEAK_TEXT, 
     115                                         BITRATE_PEAK_LONGTEXT, VLC_TRUE ); 
     116    add_integer( "pvr-bitrate-mode", -1, NULL, BITRATE_MODE_TEXT, 
     117                                         BITRATE_MODE_LONGTEXT, VLC_TRUE ); 
     118        change_integer_list( i_bitrates, psz_bitrates_list_text, 0 ); 
     119    add_integer( "pvr-audio-bitmask", -1, NULL, BITMASK_TEXT, 
     120                                         BITMASK_LONGTEXT, VLC_TRUE ); 
     121    add_integer( "pvr-channel", -1, NULL, CHAN_TEXT, 
     122                                          CHAN_LONGTEXT, VLC_TRUE ); 
     123 
     124    set_callbacks( Open, Close ); 
     125vlc_module_end(); 
     126 
     127/***************************************************************************** 
     128 * Prototypes 
     129 *****************************************************************************/ 
     130static int Read   ( access_t *, uint8_t *, int ); 
     131static int Control( access_t *, int, va_list ); 
     132 
    40133/* ivtv specific ioctls */ 
    41134#define IVTV_IOC_G_CODEC    0xFFEE7703 
    42135#define IVTV_IOC_S_CODEC    0xFFEE7704 
    43  
    44136 
    45137/* for use with IVTV_IOC_G_CODEC and IVTV_IOC_S_CODEC */ 
     
    63155}; 
    64156 
    65 /***************************************************************************** 
    66  * Prototypes 
    67  *****************************************************************************/ 
    68 static int     Open   ( vlc_object_t * ); 
    69 static void    Close  ( vlc_object_t * ); 
    70  
    71 static int Read   ( access_t *, uint8_t *, int ); 
    72 static int Control   ( access_t *, int, va_list ); 
    73  
    74 /***************************************************************************** 
    75  * Module descriptor 
    76  *****************************************************************************/ 
    77  
    78 #define DEVICE_TEXT N_( "Device" ) 
    79 #define DEVICE_LONGTEXT N_( "PVR video device" ) 
    80  
    81 #define NORM_TEXT N_( "Norm" ) 
    82 #define NORM_LONGTEXT N_( "Defines the norm of the stream (Automatic, SECAM, PAL, or NTSC)" ) 
    83 static int i_norm_list[] = { V4L2_STD_UNKNOWN, V4L2_STD_SECAM, V4L2_STD_PAL,  
    84                              V4L2_STD_NTSC }; 
    85 static char *psz_norm_list_text[] = { N_("Automatic"), N_("SECAM"), 
    86                                       N_("PAL"),  N_("NSTC") }; 
    87  
    88 #define WIDTH_TEXT N_( "Width" ) 
    89 #define WIDTH_LONGTEXT N_( "Width of the stream to capture (-1 for " \ 
    90                            "autodetect)" ) 
    91 #define HEIGHT_TEXT N_( "Height" ) 
    92 #define HEIGHT_LONGTEXT N_( "Height of the stream to capture (-1 for " \ 
    93                            "autodetect)" ) 
    94 #define FREQUENCY_TEXT N_( "Frequency" ) 
    95 #define FREQUENCY_LONGTEXT N_( "Frequency to capture (in kHz), if applicable" ) 
    96 #define FRAMERATE_TEXT N_( "Framerate" )  
    97 #define FRAMERATE_LONGTEXT N_( "Framerate to capture, if applicable (-1 for " \ 
    98                                "auto" ) 
    99 #define KEYINT_TEXT N_( "Key interval" ) 
    100 #define KEYINT_LONGTEXT N_( "Interval between keyframes, in FIXME (-1 for " \ 
    101                                 " auto" ) 
    102 #define BFRAMES_TEXT N_( "B Frames" ) 
    103 #define BFRAMES_LONGTEXT N_("If this option is set, B-Frames will be used." \ 
    104                             "Use this option to set the number of B-Frames") 
    105 #define BITRATE_TEXT N_( "Bitrate" ) 
    106 #define BITRATE_LONGTEXT N_( "Bitrate to use (-1 for default)" )  
    107 #define BITRATE_PEAK_TEXT N_( "Bitrate peak" ) 
    108 #define BITRATE_PEAK_LONGTEXT N_( "Peak bitrate in VBR mode" ) 
    109 #define BITRATE_MODE_TEXT N_( "Bitrate mode (vbr or cbr)" ) 
    110 #define BITRATE_MODE_LONGTEXT N_( "Bitrate mode to use" ) 
    111 #define BITMASK_TEXT N_( "Audio bitmask" ) 
    112 #define BITMASK_LONGTEXT N_("FIXME FIXME FIXME FIXME" )  
    113 #define CHAN_TEXT N_( "Channel" ) 
    114 #define CHAN_LONGTEXT N_( "Channel of the card to use (Usually, 0 = tuner, " \ 
    115                           "1 = composite, 2 = svideo )" ) 
    116  
    117 static int i_bitrates[] = { 0, 1 }; 
    118 static char *psz_bitrates_list_text[] = { N_("vbr"), N_("cbr") }; 
    119  
    120 vlc_module_begin(); 
    121     set_shortname( _("PVR") ); 
    122     set_description( _("MPEG Encoding cards input (with ivtv drivers)") ); 
    123     set_capability( "access2", 0 ); 
    124     add_shortcut( "pvr" ); 
    125  
    126     add_string( "pvr-device", "/dev/video0", NULL, DEVICE_TEXT, 
    127                             DEVICE_LONGTEXT, VLC_FALSE ); 
    128  
    129     add_integer( "pvr-norm", V4L2_STD_UNKNOWN , NULL, NORM_TEXT, 
    130                              NORM_LONGTEXT, VLC_FALSE ); 
    131        change_integer_list( i_norm_list, psz_norm_list_text, 0 ); 
    132  
    133     add_integer( "pvr-width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE );  
    134     add_integer( "pvr-height", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, 
    135                                          VLC_TRUE );  
    136     add_integer( "pvr-frequency", -1, NULL, FREQUENCY_TEXT, FREQUENCY_LONGTEXT, 
    137                                          VLC_FALSE );  
    138     add_integer( "pvr-framerate", -1, NULL, FRAMERATE_TEXT, FRAMERATE_LONGTEXT, 
    139                                          VLC_TRUE );  
    140     add_integer( "pvr-keyint", -1, NULL, KEYINT_TEXT, KEYINT_LONGTEXT, 
    141                                          VLC_TRUE );  
    142     add_integer( "pvr-bframes", -1, NULL, FRAMERATE_TEXT, FRAMERATE_LONGTEXT, 
    143                                          VLC_TRUE );  
    144     add_integer( "pvr-bitrate", -1, NULL, BITRATE_TEXT, BITRATE_LONGTEXT, 
    145                                          VLC_FALSE );  
    146     add_integer( "pvr-bitrate-peak", -1, NULL, BITRATE_PEAK_TEXT,  
    147                                          BITRATE_PEAK_LONGTEXT, VLC_TRUE );  
    148     add_integer( "pvr-bitrate-mode", -1, NULL, BITRATE_MODE_TEXT,  
    149                                          BITRATE_MODE_LONGTEXT, VLC_TRUE );  
    150         change_integer_list( i_bitrates, psz_bitrates_list_text, 0 ); 
    151     add_integer( "pvr-audio-bitmask", -1, NULL, BITMASK_TEXT, 
    152                                          BITMASK_LONGTEXT, VLC_TRUE ); 
    153     add_integer( "pvr-channel", -1, NULL, CHAN_TEXT, 
    154                                           CHAN_LONGTEXT, VLC_TRUE ); 
    155  
    156     set_callbacks( Open, Close ); 
    157 vlc_module_end(); 
    158     vlc_bool_t b_eof; 
    159      
    160 /***************************************************************************** 
    161  * Private access data 
    162  *****************************************************************************/ 
    163157struct access_sys_t 
    164158{ 
     
    166160    int i_fd; 
    167161 
    168     int64_t i_tell; /** Number of read bytes */ 
    169     vlc_bool_t b_eof; 
    170      
    171162    /* options */ 
    172163    int i_standard; 
     
    205196    p_access->pf_seek = NULL; 
    206197    p_access->pf_control = Control; 
     198    p_access->info.i_update = 0; 
     199    p_access->info.i_size = 0; 
     200    p_access->info.i_pos = 0; 
     201    p_access->info.b_eof = VLC_FALSE; 
     202    p_access->info.i_title = 0; 
     203    p_access->info.i_seekpoint = 0; 
    207204 
    208205    /* create private access data */ 
     
    266263    p_sys->i_input = val.i_int; 
    267264 
    268  
    269     p_sys->i_tell = 0; 
    270  
    271265    /* parse command line options */ 
    272266    psz_tofree = strdup( p_access->psz_path ); 
     
    656650 
    657651    int i_ret; 
    658      
     652 
    659653    struct timeval timeout; 
    660654    fd_set fds; 
     
    665659    timeout.tv_usec = 500000; 
    666660 
    667     if( p_sys->b_eof ) 
     661    if( p_access->info.b_eof ) 
    668662        return 0; 
    669663 
    670     while( !( i_ret = select( p_sys->i_fd + 1, &fds, 
    671                               NULL, NULL, &timeout ) ) ) 
     664    while( !( i_ret = select( p_sys->i_fd + 1, &fds, NULL, NULL, &timeout) ) ) 
    672665    { 
    673666        FD_ZERO( &fds ); 
     
    689682    if( i_ret == 0 ) 
    690683    { 
    691         p_sys->b_eof = VLC_TRUE; 
    692     } 
    693     else if ( i_ret > 0 ) 
    694     { 
    695         p_sys->i_tell += i_ret; 
     684        p_access->info.b_eof = VLC_TRUE; 
     685    } 
     686    else if( i_ret > 0 ) 
     687    { 
     688        p_access->info.i_pos += i_ret; 
    696689    } 
    697690 
     
    731724            *pi_int = 0; 
    732725            break; 
    733         case ACCESS_GET_SIZE: 
    734             pi_64 = (int64_t*)va_arg( args, int64_t * );  
    735             *pi_64 = 0; 
    736             break; 
    737         case ACCESS_GET_POS: 
    738             pi_64 = (int64_t*)va_arg( args, int64_t * ); 
    739             *pi_64 = p_sys->i_tell; 
    740             break; 
    741         case ACCESS_GET_EOF: 
    742             pb_bool = (vlc_bool_t*)va_arg( args, vlc_bool_t* ); 
    743             *pb_bool = p_sys->b_eof; 
    744             break; 
     726 
    745727        case ACCESS_GET_PTS_DELAY: 
    746728            pi_64 = (int64_t*)va_arg( args, int64_t * ); 
     
    753735            break; 
    754736 
     737        case ACCESS_GET_TITLE_INFO: 
     738        case ACCESS_GET_SEEKPOINT_INFO: 
     739        case ACCESS_SET_TITLE: 
     740        case ACCESS_SET_SEEKPOINT: 
     741            return VLC_EGENERIC; 
     742 
    755743        default: 
    756744            msg_Err( p_access, "unimplemented query in control" ); 
  • modules/access/tcp.c

    r32618df r5c276c9  
    6060{ 
    6161    int        fd; 
    62     int64_t    i_tell; 
    63     vlc_bool_t b_eof; 
    6462}; 
    6563 
     
    107105    } 
    108106 
    109     /* Connect */ 
     107    /* Init p_access */ 
     108    p_access->pf_read = Read; 
     109    p_access->pf_block = NULL; 
     110    p_access->pf_control = Control; 
     111    p_access->pf_seek = NULL; 
     112    p_access->info.i_update = 0; 
     113    p_access->info.i_size = 0; 
     114    p_access->info.i_pos = 0; 
     115    p_access->info.b_eof = VLC_FALSE; 
     116    p_access->info.i_title = 0; 
     117    p_access->info.i_seekpoint = 0; 
    110118    p_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) ); 
     119 
    111120    p_sys->fd = net_OpenTCP( p_access, psz_dup, atoi( psz_parser ) ); 
    112     p_sys->i_tell = 0; 
    113     p_sys->b_eof = VLC_FALSE; 
    114121    free( psz_dup ); 
    115122 
     
    120127    } 
    121128 
    122     p_access->pf_read    = Read; 
    123     p_access->pf_block   = NULL; 
    124     p_access->pf_seek    = NULL; 
    125     p_access->pf_control = Control; 
    126  
    127129    /* Update default_pts to a suitable value for udp access */ 
    128130    var_Create( p_access, "tcp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 
     
    151153    int i_read; 
    152154 
    153     if( p_sys->b_eof ) 
     155    if( p_access->info.b_eof ) 
    154156        return 0; 
    155157 
    156158    i_read = net_Read( p_access, p_sys->fd, p_buffer, i_len, VLC_FALSE ); 
    157159    if( i_read == 0 ) 
    158         p_sys->b_eof = VLC_TRUE; 
     160        p_access->info.b_eof = VLC_TRUE; 
    159161    else if( i_read > 0 ) 
    160         p_sys->i_tell += i_read; 
     162        p_access->info.i_pos += i_read; 
    161163 
    162164    return i_read; 
     
    168170static int Control( access_t *p_access, int i_query, va_list args ) 
    169171{ 
    170     access_sys_t *p_sys = p_access->p_sys; 
    171172    vlc_bool_t   *pb_bool; 
    172173    int          *pi_int; 
     
    196197            *pi_int = 0; 
    197198            break; 
    198         case ACCESS_GET_SIZE: 
    199