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