]> git.sesse.net Git - vlc/blob - include/input_ext-plugins.h
3ae2f927a05fa1c6ebc1f8b126b3195c16d90d87
[vlc] / include / input_ext-plugins.h
1 /*****************************************************************************
2  * input_ext-plugins.h: structures of the input not exported to other modules,
3  *                      but exported to plug-ins
4  *****************************************************************************
5  * Copyright (C) 1999-2002 VideoLAN
6  * $Id: input_ext-plugins.h,v 1.35 2002/08/08 00:35:10 sam Exp $
7  *
8  * Authors: Christophe Massiot <massiot@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 /*
26  * Communication plugin -> input
27  */
28
29 /* FIXME: you've gotta move this move this, you've gotta move this move this */
30 #define PADDING_PACKET_SIZE 188 /* Size of the NULL packet inserted in case
31                                  * of data loss (this should be < 188).      */
32 #define PADDING_PACKET_NUMBER 10 /* Number of padding packets top insert to
33                                   * escape a decoder.                        */
34 #define INPUT_DEFAULT_BUFSIZE 65536 /* Default buffer size to use when none
35                                      * is natural.                           */
36 #define NO_SEEK             -1
37
38 /*****************************************************************************
39  * Prototypes from input_programs.c
40  *****************************************************************************/
41 VLC_EXPORT( int,  input_InitStream,( input_thread_t *, size_t ) );
42 VLC_EXPORT( void, input_EndStream, ( input_thread_t * ) );
43 VLC_EXPORT( pgrm_descriptor_t *, input_FindProgram,( input_thread_t *, u16 ) );
44 VLC_EXPORT( pgrm_descriptor_t *, input_AddProgram, ( input_thread_t *, u16, size_t ) );
45 VLC_EXPORT( void, input_DelProgram,( input_thread_t *, pgrm_descriptor_t * ) );
46 VLC_EXPORT( int, input_SetProgram,( input_thread_t *, pgrm_descriptor_t * ) );
47 VLC_EXPORT( input_area_t *, input_AddArea,( input_thread_t * ) );
48 VLC_EXPORT( void, input_DelArea,   ( input_thread_t *, input_area_t * ) );
49 VLC_EXPORT( es_descriptor_t *, input_FindES,( input_thread_t *, u16 ) );
50 VLC_EXPORT( es_descriptor_t *, input_AddES, ( input_thread_t *, pgrm_descriptor_t *, u16, size_t ) );
51 VLC_EXPORT( void, input_DelES,     ( input_thread_t *, es_descriptor_t * ) );
52 VLC_EXPORT( int,  input_SelectES,  ( input_thread_t *, es_descriptor_t * ) );
53 VLC_EXPORT( int,  input_UnselectES,( input_thread_t *, es_descriptor_t * ) );
54
55 /*****************************************************************************
56  * Prototypes from input_dec.c
57  *****************************************************************************/
58 decoder_fifo_t * input_RunDecoder( input_thread_t *, es_descriptor_t * );
59 void input_EndDecoder( input_thread_t *, es_descriptor_t * );
60 VLC_EXPORT( void, input_DecodePES, ( decoder_fifo_t *, pes_packet_t * ) );
61 void input_EscapeDiscontinuity( input_thread_t * );
62 void input_EscapeAudioDiscontinuity( input_thread_t * );
63
64 /*****************************************************************************
65  * Prototypes from input_clock.c
66  *****************************************************************************/
67 void input_ClockInit( pgrm_descriptor_t * );
68 VLC_EXPORT( int,  input_ClockManageControl, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) );
69 VLC_EXPORT( void, input_ClockManageRef, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) );
70 VLC_EXPORT( mtime_t, input_ClockGetTS, ( input_thread_t *, pgrm_descriptor_t *, mtime_t ) );
71
72 /*****************************************************************************
73  * Prototypes from input_info.c
74  *****************************************************************************/
75 VLC_EXPORT( input_info_category_t *, input_InfoCategory, ( input_thread_t *, char * ) );
76 VLC_EXPORT( int, input_AddInfo, ( input_info_category_t *, char *, char *, ... ) );
77 int input_DelInfo( input_thread_t * p_input ); /* no need to export this */
78 /*****************************************************************************
79  * Prototypes from input_ext-plugins.h (buffers management)
80  *****************************************************************************/
81 #define input_BuffersInit(a) __input_BuffersInit(VLC_OBJECT(a))
82 void * __input_BuffersInit( vlc_object_t * );
83 VLC_EXPORT( void, input_BuffersEnd, ( input_thread_t *, input_buffers_t * ) );
84
85 VLC_EXPORT( data_buffer_t *, input_NewBuffer,   ( input_buffers_t *, size_t ) );
86 VLC_EXPORT( void, input_ReleaseBuffer,          ( input_buffers_t *, data_buffer_t * ) );
87 VLC_EXPORT( data_packet_t *, input_ShareBuffer, ( input_buffers_t *, data_buffer_t * ) );
88 VLC_EXPORT( data_packet_t *, input_NewPacket,   ( input_buffers_t *, size_t ) );
89 VLC_EXPORT( void, input_DeletePacket,           ( input_buffers_t *, data_packet_t * ) );
90 VLC_EXPORT( pes_packet_t *, input_NewPES, ( input_buffers_t * ) );
91 VLC_EXPORT( void, input_DeletePES,        ( input_buffers_t *, pes_packet_t * ) );
92 VLC_EXPORT( ssize_t, input_FillBuffer,  ( input_thread_t * ) );
93 VLC_EXPORT( ssize_t, input_Peek,        ( input_thread_t *, byte_t **, size_t ) );
94 VLC_EXPORT( ssize_t, input_SplitBuffer, ( input_thread_t *, data_packet_t **, size_t ) );
95 VLC_EXPORT( int, input_AccessInit,      ( input_thread_t * ) );
96 VLC_EXPORT( void, input_AccessReinit,   ( input_thread_t * ) );
97 VLC_EXPORT( void, input_AccessEnd,      ( input_thread_t * ) );
98
99 /*****************************************************************************
100  * Create a NULL packet for padding in case of a data loss
101  *****************************************************************************/
102 static inline void input_NullPacket( input_thread_t * p_input,
103                                      es_descriptor_t * p_es )
104 {
105     data_packet_t *             p_pad_data;
106     pes_packet_t *              p_pes;
107
108     if( (p_pad_data = input_NewPacket( p_input->p_method_data,
109                     PADDING_PACKET_SIZE )) == NULL )
110     {
111         msg_Err( p_input, "no new packet" );
112         p_input->b_error = 1;
113         return;
114     }
115
116     memset( p_pad_data->p_payload_start, 0, PADDING_PACKET_SIZE );
117     p_pad_data->b_discard_payload = 1;
118     p_pes = p_es->p_pes;
119
120     if( p_pes != NULL )
121     {
122         p_pes->b_discontinuity = 1;
123         p_pes->p_last->p_next = p_pad_data;
124         p_pes->p_last = p_pad_data;
125         p_pes->i_nb_data++;
126     }
127     else
128     {
129         if( (p_pes = input_NewPES( p_input->p_method_data )) == NULL )
130         {
131             msg_Err( p_input, "no PES packet" );
132             p_input->b_error = 1;
133             return;
134         }
135
136         p_pes->i_rate = p_input->stream.control.i_rate;
137         p_pes->p_first = p_pes->p_last = p_pad_data;
138         p_pes->i_nb_data = 1;
139         p_pes->b_discontinuity = 1;
140         input_DecodePES( p_es->p_decoder_fifo, p_pes );
141     }
142 }
143
144 /*
145  * Optional standard file descriptor operations (input_ext-plugins.h)
146  */
147
148 /*****************************************************************************
149  * input_socket_t: private access plug-in data
150  *****************************************************************************/
151 struct input_socket_t
152 {
153     /* Unbuffered file descriptor */
154     int i_handle;
155 };
156
157 /*****************************************************************************
158  * Prototypes
159  *****************************************************************************/
160 VLC_EXPORT( void, __input_FDClose, ( vlc_object_t * ) );
161 #define input_FDClose(a) __input_FDClose(VLC_OBJECT(a))
162 VLC_EXPORT( void, __input_FDNetworkClose, ( vlc_object_t * ) );
163 #define input_FDNetworkClose(a) __input_FDNetworkClose(VLC_OBJECT(a))
164 VLC_EXPORT( ssize_t, input_FDRead, ( input_thread_t *, byte_t *, size_t ) );
165 VLC_EXPORT( ssize_t, input_FDNetworkRead, ( input_thread_t *, byte_t *, size_t ) );
166 VLC_EXPORT( void, input_FDSeek, ( input_thread_t *, off_t ) );
167