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