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