Commit 5c276c93 authored by Laurent Aimar's avatar Laurent Aimar

* all: a few changes in access2 (added a info field to access_t, remove

ACCESS_GET_EOF/SIZE/POS, prepared title/seekpoint support).
parent 0cd04434
/***************************************************************************** /*****************************************************************************
* ninput.h * ninput.h
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2004 VideoLAN
* $Id$ * $Id$
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
...@@ -26,6 +26,85 @@ ...@@ -26,6 +26,85 @@
#include "vlc_es.h" #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 enum es_out_mode_e
{ {
ES_OUT_MODE_NONE, /* don't select anything */ ES_OUT_MODE_NONE, /* don't select anything */
...@@ -55,11 +134,6 @@ enum es_out_query_e ...@@ -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_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_SET_GROUP_PCR, /* arg1= int i_group, arg2=int64_t i_pcr(microsecond!)*/
ES_OUT_RESET_PCR, /* no arg */ 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 struct es_out_t
...@@ -100,6 +174,17 @@ static inline int es_out_Control( es_out_t *out, int i_query, ... ) ...@@ -100,6 +174,17 @@ static inline int es_out_Control( es_out_t *out, int i_query, ... )
va_end( args ); va_end( args );
return i_result; 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 * \defgroup access Access
* @{ * @{
...@@ -114,14 +199,18 @@ enum access_query_e ...@@ -114,14 +199,18 @@ enum access_query_e
ACCESS_CAN_CONTROL_PACE,/* arg1= vlc_bool_t* cannot fail */ ACCESS_CAN_CONTROL_PACE,/* arg1= vlc_bool_t* cannot fail */
/* */ /* */
ACCESS_GET_MTU, /* arg1= int* cannot fail (0 if no sense) */ 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_PTS_DELAY, /* arg1= int64_t* cannot fail */ 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 struct access_t
...@@ -143,6 +232,20 @@ 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_seek) ( access_t *, int64_t ); /* can be null if can't seek */
int (*pf_control)( access_t *, int i_query, va_list args); /* mandatory */ 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; access_sys_t *p_sys;
}; };
...@@ -347,6 +450,17 @@ struct demux_t ...@@ -347,6 +450,17 @@ struct demux_t
/* set by demuxer */ /* set by demuxer */
int (*pf_demux) ( demux_t * ); /* demux one frame only */ int (*pf_demux) ( demux_t * ); /* demux one frame only */
int (*pf_control)( demux_t *, int i_query, va_list args); 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; demux_sys_t *p_sys;
}; };
...@@ -355,45 +469,19 @@ enum demux_query_e ...@@ -355,45 +469,19 @@ enum demux_query_e
DEMUX_GET_POSITION, /* arg1= double * res= */ DEMUX_GET_POSITION, /* arg1= double * res= */
DEMUX_SET_POSITION, /* arg1= double res=can fail */ DEMUX_SET_POSITION, /* arg1= double res=can fail */
DEMUX_GET_LENGTH, /* arg1= int64_t * res= */
DEMUX_GET_TIME, /* arg1= int64_t * res= */ DEMUX_GET_TIME, /* arg1= int64_t * res= */
DEMUX_SET_TIME, /* arg1= int64_t res=can fail */ 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_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 DEMUX_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int* can fail */
{ DEMUX_GET_SEEKPOINT_INFO, /* arg1=seekpoint_t *** arg2=int* can fail */
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 );
}
static inline seekpoint_t *vlc_seekpoint_Duplicate( seekpoint_t *src ) DEMUX_SET_TITLE, /* arg1= int can fail */
{ DEMUX_SET_SEEKPOINT, /* arg1= int can fail */
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 */ /* Demux */
VLC_EXPORT( int, demux_vaControl, ( input_thread_t *, int i_query, va_list ) ); VLC_EXPORT( int, demux_vaControl, ( input_thread_t *, int i_query, va_list ) );
......
...@@ -79,12 +79,6 @@ struct access_sys_t ...@@ -79,12 +79,6 @@ struct access_sys_t
int fd_cmd; int fd_cmd;
int fd_data; int fd_data;
int64_t i_size;
int64_t i_tell;
vlc_bool_t b_eof;
}; };
static int ftp_SendCommand( access_t *, char *, ... ); static int ftp_SendCommand( access_t *, char *, ... );
...@@ -105,12 +99,21 @@ static int Open( vlc_object_t *p_this ) ...@@ -105,12 +99,21 @@ static int Open( vlc_object_t *p_this )
int i_answer; int i_answer;
char *psz_arg; char *psz_arg;
/* *** allocate access_sys_t *** */ /* Init p_access */
p_sys = malloc( sizeof( access_sys_t ) ); 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 ) ); memset( p_sys, 0, sizeof( access_sys_t ) );
p_sys->fd_cmd = -1; p_sys->fd_cmd = -1;
p_sys->fd_data = -1; p_sys->fd_data = -1;
p_sys->i_tell = 0;
/* *** Parse URL and get server addr/port and path *** */ /* *** Parse URL and get server addr/port and path *** */
psz = p_access->psz_path; psz = p_access->psz_path;
...@@ -140,9 +143,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -140,9 +143,6 @@ static int Open( vlc_object_t *p_this )
goto exit_error; goto exit_error;
} }
/* set p_access->p_sys */
p_access->p_sys = p_sys;
for( ;; ) for( ;; )
{ {
if( ftp_ReadCommand( p_access, &i_answer, NULL ) != 1 ) if( ftp_ReadCommand( p_access, &i_answer, NULL ) != 1 )
...@@ -237,9 +237,9 @@ static int Open( vlc_object_t *p_this ) ...@@ -237,9 +237,9 @@ static int Open( vlc_object_t *p_this )
msg_Err( p_access, "cannot get file size" ); msg_Err( p_access, "cannot get file size" );
goto exit_error; goto exit_error;
} }
p_sys->i_size = atoll( &psz_arg[4] ); p_access->info.i_size = atoll( &psz_arg[4] );
free( psz_arg ); 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' */ /* Start the 'stream' */
if( ftp_StartStream( p_access, 0 ) < 0 ) if( ftp_StartStream( p_access, 0 ) < 0 )
...@@ -251,11 +251,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -251,11 +251,6 @@ static int Open( vlc_object_t *p_this )
/* Update default_pts to a suitable value for ftp access */ /* Update default_pts to a suitable value for ftp access */
var_Create( p_access, "ftp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 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; return VLC_SUCCESS;
exit_error: exit_error:
...@@ -299,7 +294,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -299,7 +294,6 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static int Seek( access_t *p_access, int64_t i_pos ) static int Seek( access_t *p_access, int64_t i_pos )
{ {
access_sys_t *p_sys = p_access->p_sys;
if( i_pos < 0 ) if( i_pos < 0 )
{ {
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -309,11 +303,12 @@ static int Seek( access_t *p_access, int64_t i_pos ) ...@@ -309,11 +303,12 @@ static int Seek( access_t *p_access, int64_t i_pos )
ftp_StopStream( p_access ); ftp_StopStream( p_access );
if( ftp_StartStream( p_access, i_pos ) < 0 ) if( ftp_StartStream( p_access, i_pos ) < 0 )
{ {
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
return VLC_EGENERIC; 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; return VLC_SUCCESS;
} }
...@@ -326,14 +321,14 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -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; access_sys_t *p_sys = p_access->p_sys;
int i_read; int i_read;
if( p_sys->b_eof ) if( p_access->info.b_eof )
return 0; return 0;
i_read = net_Read( p_access, p_sys->fd_data, p_buffer, i_len, VLC_FALSE ); i_read = net_Read( p_access, p_sys->fd_data, p_buffer, i_len, VLC_FALSE );
if( i_read == 0 ) if( i_read == 0 )
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
else if( i_read > 0 ) else if( i_read > 0 )
p_sys->i_tell += i_read; p_access->info.i_pos += i_read;
return i_read; return i_read;
} }
...@@ -343,7 +338,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -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 ) 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; vlc_bool_t *pb_bool;
int *pi_int; int *pi_int;
int64_t *pi_64; int64_t *pi_64;
...@@ -374,18 +368,6 @@ static int Control( access_t *p_access, int i_query, va_list args ) ...@@ -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 = (int*)va_arg( args, int * );
*pi_int = 0; *pi_int = 0;
break; 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: case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * ); 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 ) ...@@ -398,6 +380,12 @@ static int Control( access_t *p_access, int i_query, va_list args )
/* Nothing to do */ /* Nothing to do */
break; break;
case ACCESS_GET_TITLE_INFO:
case ACCESS_GET_SEEKPOINT_INFO:
case ACCESS_SET_TITLE:
case ACCESS_SET_SEEKPOINT:
return VLC_EGENERIC;
default: default:
msg_Err( p_access, "unimplemented query in control" ); msg_Err( p_access, "unimplemented query in control" );
return VLC_EGENERIC; return VLC_EGENERIC;
......
...@@ -108,11 +108,8 @@ struct access_sys_t ...@@ -108,11 +108,8 @@ struct access_sys_t
vlc_bool_t b_chunked; vlc_bool_t b_chunked;
int64_t i_chunk; int64_t i_chunk;
int64_t i_tell;
int64_t i_size;
vlc_bool_t b_seekable; vlc_bool_t b_seekable;
vlc_bool_t b_eof;
}; };
/* */ /* */
...@@ -134,18 +131,6 @@ static int Open ( vlc_object_t *p_this ) ...@@ -134,18 +131,6 @@ static int Open ( vlc_object_t *p_this )
access_sys_t *p_sys; access_sys_t *p_sys;
vlc_value_t val; 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 */ /* First set ipv4/ipv6 */
var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_access, "ipv4", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_access, "ipv6", 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 ) ...@@ -171,8 +156,27 @@ static int Open ( vlc_object_t *p_this )
} }
} }
/* Pts delay */ /* Set up p_access */
var_Create( p_access, "http-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 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 */ /* Parse URI */
ParseURL( p_sys, p_access->psz_path ); ParseURL( p_sys, p_access->psz_path );
...@@ -254,7 +258,6 @@ static int Open ( vlc_object_t *p_this ) ...@@ -254,7 +258,6 @@ static int Open ( vlc_object_t *p_this )
} }
/* Connect */ /* Connect */
p_access->p_sys = p_sys;
if( Connect( p_access, 0 ) ) if( Connect( p_access, 0 ) )
{ {
/* Retry with http 1.0 */ /* Retry with http 1.0 */
...@@ -287,15 +290,9 @@ static int Open ( vlc_object_t *p_this ) ...@@ -287,15 +290,9 @@ static int Open ( vlc_object_t *p_this )
p_playlist->i_index + 1 ); p_playlist->i_index + 1 );
vlc_object_release( p_playlist ); 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( !strcmp( p_sys->psz_protocol, "ICY" ) )
{ {
if( p_sys->psz_mime && !strcasecmp( p_sys->psz_mime, "video/nsv" ) ) if( p_sys->psz_mime && !strcasecmp( p_sys->psz_mime, "video/nsv" ) )
...@@ -306,6 +303,10 @@ static int Open ( vlc_object_t *p_this ) ...@@ -306,6 +303,10 @@ static int Open ( vlc_object_t *p_this )
msg_Info( p_access, "ICY server found, %s demuxer selected", msg_Info( p_access, "ICY server found, %s demuxer selected",
p_access->psz_demux ); p_access->psz_demux );
} }
/* Pts delay */
var_Create( p_access, "http-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
return VLC_SUCCESS; return VLC_SUCCESS;
error: error:
...@@ -362,15 +363,16 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -362,15 +363,16 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
if( p_sys->fd < 0 ) if( p_sys->fd < 0 )
{ {
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
return 0; 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; return 0;
} }
} }
...@@ -378,7 +380,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -378,7 +380,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
{ {
if( p_sys->i_chunk < 0 ) if( p_sys->i_chunk < 0 )
{ {
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
return 0; return 0;
} }
...@@ -397,7 +399,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -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 */ if( p_sys->i_chunk <= 0 ) /* eof */
{ {
p_sys->i_chunk = -1; p_sys->i_chunk = -1;
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
return 0; return 0;
} }
} }
...@@ -412,7 +414,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -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 ); i_read = net_Read( p_access, p_sys->fd, p_buffer, i_len, VLC_FALSE );
if( i_read > 0 ) if( i_read > 0 )
{ {
p_sys->i_tell += i_read; p_access->info.i_pos += i_read;
if( p_sys->b_chunked ) if( p_sys->b_chunked )
{ {
...@@ -430,7 +432,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -430,7 +432,7 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len )
} }
else if( i_read == 0 ) else if( i_read == 0 )
{ {
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
} }
return i_read; return i_read;
} }
...@@ -449,7 +451,7 @@ static int Seek( access_t *p_access, int64_t i_pos ) ...@@ -449,7 +451,7 @@ static int Seek( access_t *p_access, int64_t i_pos )
if( Connect( p_access, i_pos ) ) if( Connect( p_access, i_pos ) )
{ {
msg_Err( p_access, "seek failed" ); msg_Err( p_access, "seek failed" );
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
return VLC_EGENERIC; return VLC_EGENERIC;
} }
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -491,18 +493,6 @@ static int Control( access_t *p_access, int i_query, va_list args ) ...@@ -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 = (int*)va_arg( args, int * );
*pi_int = 0; *pi_int = 0;
break; 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: case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * ); 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 ) ...@@ -512,9 +502,14 @@ static int Control( access_t *p_access, int i_query, va_list args )
/* */ /* */
case ACCESS_SET_PAUSE_STATE: case ACCESS_SET_PAUSE_STATE:
/* Nothing to do */
break; break;
case ACCESS_GET_TITLE_INFO:
case ACCESS_GET_SEEKPOINT_INFO:
case ACCESS_SET_TITLE:
case ACCESS_SET_SEEKPOINT:
return VLC_EGENERIC;
default: default:
msg_Err( p_access, "unimplemented query in control" ); msg_Err( p_access, "unimplemented query in control" );
return VLC_EGENERIC; return VLC_EGENERIC;
...@@ -588,8 +583,10 @@ static int Connect( access_t *p_access, int64_t i_tell ) ...@@ -588,8 +583,10 @@ static int Connect( access_t *p_access, int64_t i_tell )
p_sys->psz_mime = NULL; p_sys->psz_mime = NULL;
p_sys->b_chunked = VLC_FALSE; p_sys->b_chunked = VLC_FALSE;
p_sys->i_chunk = 0; 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 */ /* Open connection */
...@@ -721,8 +718,8 @@ static int Connect( access_t *p_access, int64_t i_tell ) ...@@ -721,8 +718,8 @@ static int Connect( access_t *p_access, int64_t i_tell )
if( !strcasecmp( psz, "Content-Length" ) ) if( !strcasecmp( psz, "Content-Length" ) )
{ {
p_sys->i_size = i_tell + atoll( p ); p_access->info.i_size = i_tell + atoll( p );
msg_Dbg( p_access, "stream size="I64Fd, p_sys->i_size ); msg_Dbg( p_access, "stream size="I64Fd, p_access->info.i_size );
} }
else if( !strcasecmp( psz, "Location" ) ) else if( !strcasecmp( psz, "Location" ) )
{ {
......
This diff is collapsed.
...@@ -59,8 +59,6 @@ vlc_module_end(); ...@@ -59,8 +59,6 @@ vlc_module_end();
struct access_sys_t struct access_sys_t
{ {
int fd; int fd;
int64_t i_tell;
vlc_bool_t b_eof;
}; };
...@@ -106,11 +104,20 @@ static int Open( vlc_object_t *p_this ) ...@@ -106,11 +104,20 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; 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_access->p_sys = p_sys = malloc( sizeof( access_sys_t ) );
p_sys->fd = net_OpenTCP( p_access, psz_dup, atoi( psz_parser ) ); 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 ); free( psz_dup );
if( p_sys->fd < 0 ) if( p_sys->fd < 0 )
...@@ -119,11 +126,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -119,11 +126,6 @@ static int Open( vlc_object_t *p_this )
return VLC_EGENERIC; 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 */ /* Update default_pts to a suitable value for udp access */
var_Create( p_access, "tcp-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); 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 ) ...@@ -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; access_sys_t *p_sys = p_access->p_sys;
int i_read; int i_read;
if( p_sys->b_eof ) if( p_access->info.b_eof )
return 0; return 0;
i_read = net_Read( p_access, p_sys->fd, p_buffer, i_len, VLC_FALSE ); i_read = net_Read( p_access, p_sys->fd, p_buffer, i_len, VLC_FALSE );
if( i_read == 0 ) if( i_read == 0 )
p_sys->b_eof = VLC_TRUE; p_access->info.b_eof = VLC_TRUE;
else if( i_read > 0 ) else if( i_read > 0 )
p_sys->i_tell += i_read; p_access->info.i_pos += i_read;
return i_read; return i_read;
} }
...@@ -167,7 +169,6 @@ static int Read( access_t *p_access, uint8_t *p_buffer, int i_len ) ...@@ -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 ) 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; vlc_bool_t *pb_bool;
int *pi_int; int *pi_int;
int64_t *pi_64; int64_t *pi_64;
...@@ -195,18 +196,6 @@ static int Control( access_t *p_access, int i_query, va_list args ) ...@@ -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 = (int*)va_arg( args, int * );
*pi_int = 0; *pi_int = 0;
break; 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: case ACCESS_GET_PTS_DELAY:
pi_64 = (int64_t*)va_arg( args, int64_t * ); 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 ) ...@@ -219,6 +208,12 @@ static int Control( access_t *p_access, int i_query, va_list args )
/* Nothing to do */ /* Nothing to do */
break; break;
case ACCESS_GET_TITLE_INFO:
case ACCESS_GET_SEEKPOINT_INFO:
case ACCESS_SET_TITLE:
case ACCESS_SET_SEEKPOINT:
return VLC_EGENERIC;
default: default:
msg_Err( p_access, "unimplemented query in control" ); msg_Err( p_access, "unimplemented query in control" );
return VLC_EGENERIC; return VLC_EGENERIC;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment