1 /*****************************************************************************
2 * vlc_input.h: Core input structures
3 *****************************************************************************
4 * Copyright (C) 1999-2015 VLC authors and VideoLAN
6 * Authors: Christophe Massiot <massiot@via.ecp.fr>
7 * Laurent Aimar <fenrir@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU Lesser General Public License as published by
11 * the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
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 Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this program; if not, write to the Free Software Foundation,
21 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
28 * \defgroup input Input
33 * Input thread interface
39 #include <vlc_events.h>
40 #include <vlc_input_item.h>
42 #include <vlc_vout_osd.h>
46 typedef struct input_resource_t input_resource_t
;
48 /*****************************************************************************
49 * Seek point: (generalisation of chapters)
50 *****************************************************************************/
53 vlc_tick_t i_time_offset
;
57 static inline seekpoint_t
*vlc_seekpoint_New( void )
59 seekpoint_t
*point
= (seekpoint_t
*)malloc( sizeof( seekpoint_t
) );
62 point
->i_time_offset
= -1;
63 point
->psz_name
= NULL
;
67 static inline void vlc_seekpoint_Delete( seekpoint_t
*point
)
70 free( point
->psz_name
);
74 static inline seekpoint_t
*vlc_seekpoint_Duplicate( const seekpoint_t
*src
)
76 seekpoint_t
*point
= vlc_seekpoint_New();
79 if( src
->psz_name
) point
->psz_name
= strdup( src
->psz_name
);
80 point
->i_time_offset
= src
->i_time_offset
;
85 /*****************************************************************************
87 *****************************************************************************/
89 /* input_title_t.i_flags field */
90 #define INPUT_TITLE_MENU 0x01 /* Menu title */
91 #define INPUT_TITLE_INTERACTIVE 0x02 /* Interactive title. Playback position has no meaning. */
93 typedef struct input_title_t
97 vlc_tick_t i_length
; /* Length(microsecond) if known, else 0 */
99 unsigned i_flags
; /* Is it a menu or a normal entry */
101 /* Title seekpoint */
103 seekpoint_t
**seekpoint
;
106 static inline input_title_t
*vlc_input_title_New(void)
108 input_title_t
*t
= (input_title_t
*)malloc( sizeof( input_title_t
) );
121 static inline void vlc_input_title_Delete( input_title_t
*t
)
128 for( i
= 0; i
< t
->i_seekpoint
; i
++ )
129 vlc_seekpoint_Delete( t
->seekpoint
[i
] );
130 free( t
->seekpoint
);
134 static inline input_title_t
*vlc_input_title_Duplicate( const input_title_t
*t
)
136 input_title_t
*dup
= vlc_input_title_New( );
137 if( dup
== NULL
) return NULL
;
139 if( t
->psz_name
) dup
->psz_name
= strdup( t
->psz_name
);
140 dup
->i_flags
= t
->i_flags
;
141 dup
->i_length
= t
->i_length
;
142 if( t
->i_seekpoint
> 0 )
144 dup
->seekpoint
= (seekpoint_t
**)vlc_alloc( t
->i_seekpoint
, sizeof(seekpoint_t
*) );
145 if( likely(dup
->seekpoint
) )
147 for( int i
= 0; i
< t
->i_seekpoint
; i
++ )
148 dup
->seekpoint
[i
] = vlc_seekpoint_Duplicate( t
->seekpoint
[i
] );
149 dup
->i_seekpoint
= t
->i_seekpoint
;
156 /*****************************************************************************
158 *****************************************************************************/
159 struct input_attachment_t
163 char *psz_description
;
169 static inline void vlc_input_attachment_Delete( input_attachment_t
*a
)
175 free( a
->psz_description
);
181 static inline input_attachment_t
*vlc_input_attachment_New( const char *psz_name
,
182 const char *psz_mime
,
183 const char *psz_description
,
187 input_attachment_t
*a
= (input_attachment_t
*)malloc( sizeof (*a
) );
188 if( unlikely(a
== NULL
) )
191 a
->psz_name
= strdup( psz_name
? psz_name
: "" );
192 a
->psz_mime
= strdup( psz_mime
? psz_mime
: "" );
193 a
->psz_description
= strdup( psz_description
? psz_description
: "" );
195 a
->p_data
= malloc( i_data
);
196 if( i_data
> 0 && likely(a
->p_data
!= NULL
) )
197 memcpy( a
->p_data
, p_data
, i_data
);
199 if( unlikely(a
->psz_name
== NULL
|| a
->psz_mime
== NULL
200 || a
->psz_description
== NULL
|| (i_data
> 0 && a
->p_data
== NULL
)) )
202 vlc_input_attachment_Delete( a
);
208 static inline input_attachment_t
*vlc_input_attachment_Duplicate( const input_attachment_t
*a
)
210 return vlc_input_attachment_New( a
->psz_name
, a
->psz_mime
, a
->psz_description
,
211 a
->p_data
, a
->i_data
);
217 * It is an float used by the variable "rate" in the
218 * range [INPUT_RATE_MIN, INPUT_RATE_MAX]
219 * the default value being 1.f. It represents the ratio of playback speed to
220 * nominal speed (bigger is faster).
226 #define INPUT_RATE_MIN 0.03125f
230 #define INPUT_RATE_MAX 31.25f