]> git.sesse.net Git - vlc/blob - include/vlc_access.h
Added signal-quality/strength input variables for access signal report.
[vlc] / include / vlc_access.h
1 /*****************************************************************************
2  * vlc_access.h: Access descriptor, queries and methods
3  *****************************************************************************
4  * Copyright (C) 1999-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef VLC_ACCESS_H
25 #define VLC_ACCESS_H 1
26
27 /**
28  * \file
29  * This file defines functions and definitions for access object
30  */
31
32 #include <vlc_block.h>
33
34 /**
35  * \defgroup access Access
36  * @{
37  */
38
39 enum access_query_e
40 {
41     /* capabilities */
42     ACCESS_CAN_SEEK,        /* arg1= bool*    cannot fail */
43     ACCESS_CAN_FASTSEEK,    /* arg1= bool*    cannot fail */
44     ACCESS_CAN_PAUSE,       /* arg1= bool*    cannot fail */
45     ACCESS_CAN_CONTROL_PACE,/* arg1= bool*    cannot fail */
46
47     /* */
48     ACCESS_GET_MTU,         /* arg1= int*           cannot fail(0 if no sense)*/
49     ACCESS_GET_PTS_DELAY,   /* arg1= int64_t*       cannot fail */
50     /* */
51     ACCESS_GET_TITLE_INFO,  /* arg1=input_title_t*** arg2=int*      res=can fail */
52     /* Meta data */
53     ACCESS_GET_META,        /* arg1= vlc_meta_t **                  res=can fail */
54
55     /* */
56     ACCESS_GET_CONTENT_TYPE,/* arg1=char **ppsz_content_type                       res=can fail */
57
58     /* */
59     ACCESS_GET_SIGNAL,      /* arg1=double *pf_quality, arg2=double *pf_strength   res=can fail */
60
61     /* */
62     ACCESS_SET_PAUSE_STATE, /* arg1= bool           can fail */
63
64     /* */
65     ACCESS_SET_TITLE,       /* arg1= int            can fail */
66     ACCESS_SET_SEEKPOINT,   /* arg1= int            can fail */
67
68     /* Special mode for access/demux communication
69      * XXX: avoid to use it unless you can't */
70     ACCESS_SET_PRIVATE_ID_STATE, /* arg1= int i_private_data, bool b_selected    res=can fail */
71     ACCESS_SET_PRIVATE_ID_CA,    /* arg1= int i_program_number, uint16_t i_vpid, uint16_t i_apid1, uint16_t i_apid2, uint16_t i_apid3, uint8_t i_length, uint8_t *p_data */
72     ACCESS_GET_PRIVATE_ID_STATE, /* arg1=int i_private_data arg2=bool *          res=can fail */
73 };
74
75 struct access_t
76 {
77     VLC_COMMON_MEMBERS
78
79     /* Module properties */
80     module_t    *p_module;
81
82     /* Access name (empty if non forced) */
83     char        *psz_access;
84     /* Access path/url/filename/.... */
85     char        *psz_path;
86     /* Access source for access_filter (NULL for regular access) */
87     access_t    *p_source;
88
89     /* Access can fill this entry to force a demuxer
90      * XXX: fill it once you know for sure you will succeed
91      * (if you fail, this value won't be reseted */
92     char        *psz_demux;
93
94     /* pf_read/pf_block is used to read data.
95      * XXX A access should set one and only one of them */
96     ssize_t     (*pf_read) ( access_t *, uint8_t *, size_t );  /* Return -1 if no data yet, 0 if no more data, else real data read */
97     block_t    *(*pf_block)( access_t * );                  /* return a block of data in his 'natural' size, NULL if not yet data or eof */
98
99     /* Called for each seek.
100      * XXX can be null */
101     int         (*pf_seek) ( access_t *, int64_t );         /* can be null if can't seek */
102
103     /* Used to retreive and configure the access
104      * XXX mandatory. look at access_query_e to know what query you *have to* support */
105     int         (*pf_control)( access_t *, int i_query, va_list args);
106
107     /* Access has to maintain them uptodate */
108     struct
109     {
110         unsigned int i_update;  /* Access sets them on change,
111                                    Input removes them once take into account*/
112
113         int64_t      i_size;    /* Write only for access, read only for input */
114         int64_t      i_pos;     /* idem */
115         bool   b_eof;     /* idem */
116
117         int          i_title;    /* idem, start from 0 (could be menu) */
118         int          i_seekpoint;/* idem, start from 0 */
119
120         bool   b_prebuffered; /* Read only for input */
121     } info;
122     access_sys_t *p_sys;
123 };
124
125 static inline int access_vaControl( access_t *p_access, int i_query, va_list args )
126 {
127     if( !p_access ) return VLC_EGENERIC;
128     return p_access->pf_control( p_access, i_query, args );
129 }
130
131 static inline int access_Control( access_t *p_access, int i_query, ... )
132 {
133     va_list args;
134     int     i_result;
135
136     va_start( args, i_query );
137     i_result = access_vaControl( p_access, i_query, args );
138     va_end( args );
139     return i_result;
140 }
141
142 static inline void access_InitFields( access_t *p_a )
143 {
144     p_a->info.i_update = 0;
145     p_a->info.i_size = 0;
146     p_a->info.i_pos = 0;
147     p_a->info.b_eof = false;
148     p_a->info.i_title = 0;
149     p_a->info.i_seekpoint = 0;
150 }
151
152 #define ACCESS_SET_CALLBACKS( read, block, control, seek ) \
153     p_access->pf_read = read;  \
154     p_access->pf_block = block; \
155     p_access->pf_control = control; \
156     p_access->pf_seek = seek; \
157
158 #define STANDARD_READ_ACCESS_INIT \
159     access_InitFields( p_access ); \
160     ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
161     MALLOC_ERR( p_access->p_sys, access_sys_t ); \
162     p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
163
164 #define STANDARD_BLOCK_ACCESS_INIT \
165     access_InitFields( p_access ); \
166     ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek ); \
167     MALLOC_ERR( p_access->p_sys, access_sys_t ); \
168     p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
169
170 #endif