]> git.sesse.net Git - vlc/blob - src/input/input.h
. correction d'un poliotage de copier-coller
[vlc] / src / input / input.h
1 /*****************************************************************************
2  * input.h: structures of the input not exported to other modules
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: input.h,v 1.9 2001/01/15 06:56:30 sam Exp $
6  *
7  * Authors:
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*
25  * Communication plugin -> input
26  */
27
28 /* FIXME: you've gotta move this move this, you've gotta move this move this */
29 #define INPUT_READ_ONCE     7   /* We live in a world dominated by Ethernet. *
30                                  * Ethernet MTU is 1500 bytes, so in a UDP   *
31                                  * packet we can put : 1500/188 = 7 TS       *
32                                  * packets. Have a nice day and merry Xmas.  */
33 #define PADDING_PACKET_SIZE 100 /* Size of the NULL packet inserted in case
34                                  * of data loss (this should be < 188).      */
35
36 /*****************************************************************************
37  * input_capabilities_t
38  *****************************************************************************
39  * This structure gives pointers to the useful methods of the plugin
40  *****************************************************************************/
41 typedef struct input_capabilities_s
42 {
43     /* Plugin properties */
44     int                     i_weight; /* for a given stream type, the plugin *
45                                        * with higher weight will be used     */
46
47     /* Init/End */
48     int                  (* pf_probe)( struct input_thread_s * );
49     void                 (* pf_init)( struct input_thread_s * );
50     void                 (* pf_end)( struct input_thread_s * );
51
52     /* Read & Demultiplex */
53     int                  (* pf_read)( struct input_thread_s *,
54                           struct data_packet_s * pp_packets[INPUT_READ_ONCE] );
55     void                 (* pf_demux)( struct input_thread_s *,
56                                        struct data_packet_s * );
57
58     /* Packet management facilities */
59     struct data_packet_s *(* pf_new_packet)( void *, size_t );
60     struct pes_packet_s *(* pf_new_pes)( void * );
61     void                 (* pf_delete_packet)( void *,
62                                                struct data_packet_s * );
63     void                 (* pf_delete_pes)( void *, struct pes_packet_s * );
64
65     /* Stream control capabilities */
66     int                  (* pf_rewind)( struct input_thread_s * );
67                                            /* NULL if we don't support going *
68                                             * backwards (it's gonna be fun)  */
69     int                  (* pf_seek)( struct input_thread_s *, off_t );
70 } input_capabilities_t;
71
72 /*****************************************************************************
73  * Prototypes from input_ext-dec.c
74  *****************************************************************************/
75 void InitBitstream  ( struct bit_stream_s *, struct decoder_fifo_s * );
76 void NextDataPacket ( struct bit_stream_s * );
77
78 /*****************************************************************************
79  * Prototypes from input_programs.c
80  *****************************************************************************/
81 void input_InitStream( struct input_thread_s *, size_t );
82 void input_EndStream( struct input_thread_s * );
83 struct pgrm_descriptor_s * input_FindProgram( struct input_thread_s *, u16 );
84 struct pgrm_descriptor_s * input_AddProgram( struct input_thread_s *,
85                                              u16, size_t );
86 void input_DelProgram( struct input_thread_s *, struct pgrm_descriptor_s * );
87 void input_DumpStream( struct input_thread_s * );
88 struct es_descriptor_s * input_FindES( struct input_thread_s *, u16 );
89 struct es_descriptor_s * input_AddES( struct input_thread_s *,
90                                       struct pgrm_descriptor_s *, u16,
91                                       size_t );
92 void input_DelES( struct input_thread_s *, struct es_descriptor_s * );
93 int input_SelectES( struct input_thread_s *, struct es_descriptor_s * );
94
95 /*****************************************************************************
96  * Prototypes from input_dec.c
97  *****************************************************************************/
98 //decoder_capabilities_s * input_ProbeDecoder( void );
99 vlc_thread_t input_RunDecoder( struct decoder_capabilities_s *, void * );
100 void input_EndDecoder( struct input_thread_s *, struct es_descriptor_s * );
101 void input_DecodePES( struct decoder_fifo_s *, struct pes_packet_s * );
102
103 /*****************************************************************************
104  * Create a NULL packet for padding in case of a data loss
105  *****************************************************************************/
106 static __inline__ void input_NullPacket( input_thread_t * p_input,
107                                          es_descriptor_t * p_es )
108 {
109     data_packet_t *             p_pad_data;
110     pes_packet_t *              p_pes;
111
112     if( (p_pad_data = p_input->p_plugin->pf_new_packet(
113                     p_input->p_method_data,
114                     PADDING_PACKET_SIZE )) == NULL )
115     {
116         intf_ErrMsg("Out of memory");
117         p_input->b_error = 1;
118         return;
119     }
120
121     /* XXX FIXME SARASS TODO: remove the following one-liner kludge when
122      * we have bitstream IV, we won't need it anymore */
123     ((WORD_TYPE *)p_pad_data->p_buffer)++;
124
125     memset( p_pad_data->p_buffer, 0, PADDING_PACKET_SIZE );
126     p_pad_data->b_discard_payload = 1;
127     p_pes = p_es->p_pes;
128
129     if( p_pes != NULL )
130     {
131         p_pes->b_messed_up = 1;
132         p_es->p_last->p_next = p_pad_data;
133         p_es->p_last = p_pad_data;
134     }
135     else
136     {
137         if( (p_pes = p_input->p_plugin->pf_new_pes(
138                                         p_input->p_method_data )) == NULL )
139         {
140             intf_ErrMsg("Out of memory");
141             p_input->b_error = 1;
142             return;
143         }
144
145         p_pes->p_first = p_pad_data;
146         p_pes->b_messed_up = p_pes->b_discontinuity = 1;
147         input_DecodePES( p_es->p_decoder_fifo, p_pes );
148     }
149
150     p_es->b_discontinuity = 0;
151 }
152