Mercurial > mplayer.hg
annotate stream/realrtsp/rmff.h @ 36447:740a60d26cc0
Only detect a file as MPEG-PS if we can find at least 2 packets.
author | reimar |
---|---|
date | Wed, 11 Dec 2013 20:03:03 +0000 |
parents | 0f1b5b68af32 |
children |
rev | line source |
---|---|
9922 | 1 /* |
2 * This file was ported to MPlayer from xine CVS rmff.h,v 1.3 2003/02/10 22:11:10 | |
3 */ | |
4 | |
5 /* | |
6 * Copyright (C) 2002 the xine project | |
7 * | |
8 * This file is part of xine, a free video player. | |
9 * | |
10 * xine 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 * xine 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-1307, USA | |
23 * | |
24 * | |
25 * some functions for real media file headers | |
26 * adopted from joschkas real tools | |
27 */ | |
28 | |
26029 | 29 #ifndef MPLAYER_RMFF_H |
30 #define MPLAYER_RMFF_H | |
31 | |
9922 | 32 #include <sys/types.h> |
10281 | 33 #include "config.h" |
28402 | 34 #if !HAVE_WINSOCK2_H |
9922 | 35 #include <sys/socket.h> |
36 #include <netinet/in.h> | |
37 #include <netdb.h> | |
10281 | 38 #else |
39 #include <winsock2.h> | |
40 #endif | |
9922 | 41 #include <unistd.h> |
42 #include <stdio.h> | |
43 #include <fcntl.h> | |
44 #include <stdlib.h> | |
45 #include <string.h> | |
9939
6b88f67564ce
Fix compilation for *BSD, Mac OS X and maybe others (info by Steven M. Schultz and Dan Christiansen)
rtognimp
parents:
9922
diff
changeset
|
46 #include <inttypes.h> |
9922 | 47 |
48 | |
49 #define RMFF_HEADER_SIZE 0x12 | |
50 | |
22803 | 51 #define RMFF_FILEHEADER_SIZE 18 |
52 #define RMFF_PROPHEADER_SIZE 50 | |
53 #define RMFF_MDPRHEADER_SIZE 46 | |
54 #define RMFF_CONTHEADER_SIZE 18 | |
55 #define RMFF_DATAHEADER_SIZE 18 | |
56 | |
9922 | 57 #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \ |
58 (((long)(unsigned char)(ch3) ) | \ | |
59 ( (long)(unsigned char)(ch2) << 8 ) | \ | |
60 ( (long)(unsigned char)(ch1) << 16 ) | \ | |
61 ( (long)(unsigned char)(ch0) << 24 ) ) | |
62 | |
63 | |
64 #define RMF_TAG FOURCC_TAG('.', 'R', 'M', 'F') | |
65 #define PROP_TAG FOURCC_TAG('P', 'R', 'O', 'P') | |
66 #define MDPR_TAG FOURCC_TAG('M', 'D', 'P', 'R') | |
67 #define CONT_TAG FOURCC_TAG('C', 'O', 'N', 'T') | |
68 #define DATA_TAG FOURCC_TAG('D', 'A', 'T', 'A') | |
69 #define INDX_TAG FOURCC_TAG('I', 'N', 'D', 'X') | |
70 #define PNA_TAG FOURCC_TAG('P', 'N', 'A', 0 ) | |
71 | |
72 #define MLTI_TAG FOURCC_TAG('M', 'L', 'T', 'I') | |
73 | |
74 /* prop flags */ | |
75 #define PN_SAVE_ENABLED 0x01 | |
76 #define PN_PERFECT_PLAY_ENABLED 0x02 | |
77 #define PN_LIVE_BROADCAST 0x04 | |
78 | |
79 /* | |
80 * rm header data structs | |
81 */ | |
82 | |
83 typedef struct { | |
84 | |
85 uint32_t object_id; | |
86 uint32_t size; | |
87 uint16_t object_version; | |
88 | |
89 uint32_t file_version; | |
90 uint32_t num_headers; | |
91 } rmff_fileheader_t; | |
92 | |
93 typedef struct { | |
94 | |
95 uint32_t object_id; | |
96 uint32_t size; | |
97 uint16_t object_version; | |
98 | |
99 uint32_t max_bit_rate; | |
100 uint32_t avg_bit_rate; | |
101 uint32_t max_packet_size; | |
102 uint32_t avg_packet_size; | |
103 uint32_t num_packets; | |
104 uint32_t duration; | |
105 uint32_t preroll; | |
106 uint32_t index_offset; | |
107 uint32_t data_offset; | |
108 uint16_t num_streams; | |
109 uint16_t flags; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
110 |
9922 | 111 } rmff_prop_t; |
112 | |
113 typedef struct { | |
114 | |
115 uint32_t object_id; | |
116 uint32_t size; | |
117 uint16_t object_version; | |
118 | |
119 uint16_t stream_number; | |
120 uint32_t max_bit_rate; | |
121 uint32_t avg_bit_rate; | |
122 uint32_t max_packet_size; | |
123 uint32_t avg_packet_size; | |
124 uint32_t start_time; | |
125 uint32_t preroll; | |
126 uint32_t duration; | |
127 uint8_t stream_name_size; | |
128 char *stream_name; | |
129 uint8_t mime_type_size; | |
130 char *mime_type; | |
131 uint32_t type_specific_len; | |
132 char *type_specific_data; | |
133 | |
134 int mlti_data_size; | |
135 char *mlti_data; | |
136 | |
137 } rmff_mdpr_t; | |
138 | |
139 typedef struct { | |
140 | |
141 uint32_t object_id; | |
142 uint32_t size; | |
143 uint16_t object_version; | |
144 | |
145 uint16_t title_len; | |
146 char *title; | |
147 uint16_t author_len; | |
148 char *author; | |
149 uint16_t copyright_len; | |
150 char *copyright; | |
151 uint16_t comment_len; | |
152 char *comment; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
153 |
9922 | 154 } rmff_cont_t; |
155 | |
156 typedef struct { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
157 |
9922 | 158 uint32_t object_id; |
159 uint32_t size; | |
160 uint16_t object_version; | |
161 | |
162 uint32_t num_packets; | |
163 uint32_t next_data_header; /* rarely used */ | |
164 } rmff_data_t; | |
165 | |
166 typedef struct { | |
167 | |
168 rmff_fileheader_t *fileheader; | |
169 rmff_prop_t *prop; | |
170 rmff_mdpr_t **streams; | |
171 rmff_cont_t *cont; | |
172 rmff_data_t *data; | |
173 } rmff_header_t; | |
174 | |
175 typedef struct { | |
176 | |
177 uint16_t object_version; | |
178 | |
179 uint16_t length; | |
180 uint16_t stream_number; | |
181 uint32_t timestamp; | |
182 uint8_t reserved; | |
183 uint8_t flags; | |
184 | |
185 } rmff_pheader_t; | |
186 | |
187 /* | |
188 * constructors for header structs | |
189 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
190 |
9922 | 191 rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers); |
192 | |
193 rmff_prop_t *rmff_new_prop ( | |
194 uint32_t max_bit_rate, | |
195 uint32_t avg_bit_rate, | |
196 uint32_t max_packet_size, | |
197 uint32_t avg_packet_size, | |
198 uint32_t num_packets, | |
199 uint32_t duration, | |
200 uint32_t preroll, | |
201 uint32_t index_offset, | |
202 uint32_t data_offset, | |
203 uint16_t num_streams, | |
204 uint16_t flags ); | |
205 | |
206 rmff_mdpr_t *rmff_new_mdpr( | |
207 uint16_t stream_number, | |
208 uint32_t max_bit_rate, | |
209 uint32_t avg_bit_rate, | |
210 uint32_t max_packet_size, | |
211 uint32_t avg_packet_size, | |
212 uint32_t start_time, | |
213 uint32_t preroll, | |
214 uint32_t duration, | |
215 const char *stream_name, | |
216 const char *mime_type, | |
217 uint32_t type_specific_len, | |
218 const char *type_specific_data ); | |
219 | |
220 rmff_cont_t *rmff_new_cont( | |
221 const char *title, | |
222 const char *author, | |
223 const char *copyright, | |
224 const char *comment); | |
225 | |
226 rmff_data_t *rmff_new_dataheader( | |
227 uint32_t num_packets, uint32_t next_data_header); | |
228 | |
229 /* | |
230 * reads header infos from data and returns a newly allocated header struct | |
231 */ | |
232 rmff_header_t *rmff_scan_header(const char *data); | |
233 | |
234 /* | |
235 * scans a data packet header. Notice, that this function does not allocate | |
236 * the header struct itself. | |
237 */ | |
238 void rmff_scan_pheader(rmff_pheader_t *h, char *data); | |
239 | |
240 /* | |
241 * reads header infos from stream and returns a newly allocated header struct | |
242 */ | |
243 rmff_header_t *rmff_scan_header_stream(int fd); | |
244 | |
245 /* | |
246 * prints header information in human readible form to stdout | |
247 */ | |
248 void rmff_print_header(rmff_header_t *h); | |
249 | |
250 /* | |
251 * does some checks and fixes header if possible | |
252 */ | |
253 void rmff_fix_header(rmff_header_t *h); | |
254 | |
255 /* | |
256 * returns the size of the header (incl. first data-header) | |
257 */ | |
258 int rmff_get_header_size(rmff_header_t *h); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28402
diff
changeset
|
259 |
9922 | 260 /* |
261 * dumps the header <h> to <buffer>. <max> is the size of <buffer> | |
262 */ | |
263 int rmff_dump_header(rmff_header_t *h, char *buffer, int max); | |
264 | |
265 /* | |
266 * dumps a packet header | |
267 */ | |
268 void rmff_dump_pheader(rmff_pheader_t *h, char *data); | |
269 | |
270 /* | |
271 * frees a header struct | |
272 */ | |
273 void rmff_free_header(rmff_header_t *h); | |
274 | |
26029 | 275 #endif /* MPLAYER_RMFF_H */ |