1 /*****************************************************************************
2 * input_ts.c: TS demux and netlist management
3 *****************************************************************************
4 * Copyright (C) 1998, 1999, 2000 VideoLAN
5 * $Id: input_ts.c,v 1.1 2001/02/08 04:43:27 sam Exp $
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.
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.
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 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
42 #include "stream_control.h"
43 #include "input_ext-intf.h"
44 #include "input_ext-dec.h"
48 #include "mpeg_system.h"
49 #include "input_netlist.h"
51 /*****************************************************************************
53 *****************************************************************************/
54 static int TSProbe ( probedata_t * );
55 static int TSRead ( struct input_thread_s *,
56 data_packet_t * p_packets[INPUT_READ_ONCE] );
57 static void TSInit ( struct input_thread_s * );
58 static void TSEnd ( struct input_thread_s * );
60 /*****************************************************************************
61 * Functions exported as capabilities. They are declared as static so that
62 * we don't pollute the namespace too much.
63 *****************************************************************************/
64 void input_getfunctions( function_list_t * p_function_list )
66 #define input p_function_list->functions.input
67 p_function_list->pf_probe = TSProbe;
68 input.pf_init = TSInit;
69 input.pf_open = input_FileOpen;
70 input.pf_close = input_FileClose;
72 input.pf_read = TSRead;
73 input.pf_demux = input_DemuxTS;
74 input.pf_new_packet = input_NetlistNewPacket;
75 input.pf_new_pes = input_NetlistNewPES;
76 input.pf_delete_packet = input_NetlistDeletePacket;
77 input.pf_delete_pes = input_NetlistDeletePES;
78 input.pf_rewind = NULL;
83 /*****************************************************************************
84 * TSProbe: verifies that the stream is a TS stream
85 *****************************************************************************/
86 static int TSProbe( probedata_t * p_data )
88 if( TestMethod( INPUT_METHOD_VAR, "ts" ) )
93 /* verify that the first byte is 0x47 */
97 /*****************************************************************************
98 * TSInit: initializes TS structures
99 *****************************************************************************/
100 static void TSInit( input_thread_t * p_input )
102 /* Initialize netlist and TS structures */
105 /*****************************************************************************
106 * TSEnd: frees unused data
107 *****************************************************************************/
108 static void TSEnd( input_thread_t * p_input )
113 /*****************************************************************************
114 * TSRead: reads data packets
115 *****************************************************************************
116 * Returns -1 in case of error, 0 if everything went well, and 1 in case of
118 *****************************************************************************/
119 static int TSRead( input_thread_t * p_input,
120 data_packet_t * pp_packets[INPUT_READ_ONCE] )