VLC  4.0.0-dev
vlc_input.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_input.h: Core input structures
3  *****************************************************************************
4  * Copyright (C) 1999-2015 VLC authors and VideoLAN
5  *
6  * Authors: Christophe Massiot <massiot@via.ecp.fr>
7  * Laurent Aimar <fenrir@via.ecp.fr>
8  *
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.
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 Lesser General Public License for more details.
18  *
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  *****************************************************************************/
23 
24 #ifndef VLC_INPUT_H
25 #define VLC_INPUT_H 1
26 
27 /**
28  * \defgroup input Input
29  * \ingroup vlc
30  * Input thread
31  * @{
32  * \file
33  * Input thread interface
34  */
35 
36 #include <vlc_es.h>
37 #include <vlc_meta.h>
38 #include <vlc_epg.h>
39 #include <vlc_events.h>
40 #include <vlc_input_item.h>
41 #include <vlc_vout.h>
42 #include <vlc_vout_osd.h>
43 
44 #include <string.h>
45 
46 typedef struct input_resource_t input_resource_t;
47 
48 /*****************************************************************************
49  * Seek point: (generalisation of chapters)
50  *****************************************************************************/
51 struct seekpoint_t
52 {
54  char *psz_name;
55 };
56 
57 static inline seekpoint_t *vlc_seekpoint_New( void )
58 {
59  seekpoint_t *point = (seekpoint_t*)malloc( sizeof( seekpoint_t ) );
60  if( !point )
61  return NULL;
62  point->i_time_offset = -1;
63  point->psz_name = NULL;
64  return point;
65 }
66 
67 static inline void vlc_seekpoint_Delete( seekpoint_t *point )
68 {
69  if( !point ) return;
70  free( point->psz_name );
71  free( point );
72 }
73 
74 static inline seekpoint_t *vlc_seekpoint_Duplicate( const seekpoint_t *src )
75 {
76  seekpoint_t *point = vlc_seekpoint_New();
77  if( likely(point) )
78  {
79  if( src->psz_name ) point->psz_name = strdup( src->psz_name );
80  point->i_time_offset = src->i_time_offset;
81  }
82  return point;
83 }
84 
85 /*****************************************************************************
86  * Title:
87  *****************************************************************************/
88 
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. */
92 
93 typedef struct input_title_t
94 {
95  char *psz_name;
96 
97  vlc_tick_t i_length; /* Length(microsecond) if known, else 0 */
98 
99  unsigned i_flags; /* Is it a menu or a normal entry */
101  /* Title seekpoint */
102  int i_seekpoint;
103  seekpoint_t **seekpoint;
105 
106 static inline input_title_t *vlc_input_title_New(void)
107 {
108  input_title_t *t = (input_title_t*)malloc( sizeof( input_title_t ) );
109  if( !t )
110  return NULL;
111 
112  t->psz_name = NULL;
113  t->i_flags = 0;
114  t->i_length = 0;
115  t->i_seekpoint = 0;
116  t->seekpoint = NULL;
117 
118  return t;
119 }
120 
121 static inline void vlc_input_title_Delete( input_title_t *t )
122 {
123  int i;
124  if( t == NULL )
125  return;
126 
127  free( t->psz_name );
128  for( i = 0; i < t->i_seekpoint; i++ )
130  free( t->seekpoint );
131  free( t );
132 }
133 
134 static inline input_title_t *vlc_input_title_Duplicate( const input_title_t *t )
135 {
137  if( dup == NULL) return NULL;
138 
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 )
143  {
144  dup->seekpoint = (seekpoint_t**)vlc_alloc( t->i_seekpoint, sizeof(seekpoint_t*) );
145  if( likely(dup->seekpoint) )
146  {
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;
150  }
151  }
152 
153  return dup;
154 }
155 
156 /*****************************************************************************
157  * Attachments
158  *****************************************************************************/
159 struct input_attachment_t
160 {
161  char *psz_name;
162  char *psz_mime;
163  char *psz_description;
165  size_t i_data;
166  void *p_data;
167 };
168 
169 static inline void vlc_input_attachment_Delete( input_attachment_t *a )
170 {
171  if( !a )
172  return;
173 
174  free( a->p_data );
175  free( a->psz_description );
176  free( a->psz_mime );
177  free( a->psz_name );
178  free( a );
179 }
180 
181 static inline input_attachment_t *vlc_input_attachment_New( const char *psz_name,
182  const char *psz_mime,
183  const char *psz_description,
184  const void *p_data,
185  size_t i_data )
186 {
187  input_attachment_t *a = (input_attachment_t *)malloc( sizeof (*a) );
188  if( unlikely(a == NULL) )
189  return NULL;
190 
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 : "" );
194  a->i_data = i_data;
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 );
198 
199  if( unlikely(a->psz_name == NULL || a->psz_mime == NULL
200  || a->psz_description == NULL || (i_data > 0 && a->p_data == NULL)) )
201  {
203  a = NULL;
204  }
205  return a;
206 }
207 
209 {
211  a->p_data, a->i_data );
212 }
213 
214 /**
215  * Input rate.
216  *
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).
221  */
222 
223 /**
224  * Minimal rate value
225  */
226 #define INPUT_RATE_MIN 0.03125f
227 /**
228  * Maximal rate value
229  */
230 #define INPUT_RATE_MAX 31.25f
232 /** @} */
233 #endif
Definition: vlc_input.h:160
Definition: resource.c:47
Overlay text and widgets.
char * strdup(const char *)
vlc_tick_t i_length
Definition: vlc_input.h:98
static seekpoint_t * vlc_seekpoint_New(void)
Definition: vlc_input.h:58
This file defines functions and structures for stream meta-data in vlc.
char * psz_name
Definition: vlc_input.h:96
unsigned i_flags
Definition: vlc_input.h:100
int i_seekpoint
Definition: vlc_input.h:103
static seekpoint_t * vlc_seekpoint_Duplicate(const seekpoint_t *src)
Definition: vlc_input.h:75
char * psz_mime
Definition: vlc_input.h:163
vlc_tick_t i_time_offset
Definition: vlc_input.h:54
Video output thread interface.
Definition: vlc_input.h:52
static input_title_t * vlc_input_title_New(void)
Definition: vlc_input.h:107
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45
static void vlc_input_title_Delete(input_title_t *t)
Definition: vlc_input.h:122
static void vlc_seekpoint_Delete(seekpoint_t *point)
Definition: vlc_input.h:68
struct input_title_t input_title_t
#define unlikely(p)
Predicted false condition.
Definition: vlc_common.h:223
#define likely(p)
Predicted true condition.
Definition: vlc_common.h:214
static input_attachment_t * vlc_input_attachment_New(const char *psz_name, const char *psz_mime, const char *psz_description, const void *p_data, size_t i_data)
Definition: vlc_input.h:182
This file defines functions and structures for storing dvb epg information.
static input_title_t * vlc_input_title_Duplicate(const input_title_t *t)
Definition: vlc_input.h:135
static input_attachment_t * vlc_input_attachment_Duplicate(const input_attachment_t *a)
Definition: vlc_input.h:209
void * p_data
Definition: vlc_input.h:167
This file defines functions, structures and enums for input items in vlc.
const char * psz_mime
Definition: image.c:628
static void * vlc_alloc(size_t count, size_t size)
Definition: vlc_common.h:1141
char * psz_name
Definition: vlc_input.h:162
This file defines the elementary streams format types.
char * psz_name
Definition: vlc_input.h:55
size_t i_data
Definition: vlc_input.h:166
char * psz_description
Definition: vlc_input.h:164
static void vlc_input_attachment_Delete(input_attachment_t *a)
Definition: vlc_input.h:170
Definition: vlc_input.h:94
seekpoint_t ** seekpoint
Definition: vlc_input.h:104
This file is the interface definition for events (implementation in src/misc/events.c)