Mercurial > mplayer.hg
annotate libmpdemux/realrtsp/rmff.h @ 10068:b3ce60d238c4
Updates and a small patch provided by Bohdan Horst.
author | diego |
---|---|
date | Mon, 05 May 2003 02:33:49 +0000 |
parents | 7a51e10ceef4 |
children | 54bcbf28698a |
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 /* | |
70 * rm header data structs | |
71 */ | |
72 | |
73 typedef struct { | |
74 | |
75 uint32_t object_id; | |
76 uint32_t size; | |
77 uint16_t object_version; | |
78 | |
79 uint32_t file_version; | |
80 uint32_t num_headers; | |
81 } rmff_fileheader_t; | |
82 | |
83 typedef struct { | |
84 | |
85 uint32_t object_id; | |
86 uint32_t size; | |
87 uint16_t object_version; | |
88 | |
89 uint32_t max_bit_rate; | |
90 uint32_t avg_bit_rate; | |
91 uint32_t max_packet_size; | |
92 uint32_t avg_packet_size; | |
93 uint32_t num_packets; | |
94 uint32_t duration; | |
95 uint32_t preroll; | |
96 uint32_t index_offset; | |
97 uint32_t data_offset; | |
98 uint16_t num_streams; | |
99 uint16_t flags; | |
100 | |
101 } rmff_prop_t; | |
102 | |
103 typedef struct { | |
104 | |
105 uint32_t object_id; | |
106 uint32_t size; | |
107 uint16_t object_version; | |
108 | |
109 uint16_t stream_number; | |
110 uint32_t max_bit_rate; | |
111 uint32_t avg_bit_rate; | |
112 uint32_t max_packet_size; | |
113 uint32_t avg_packet_size; | |
114 uint32_t start_time; | |
115 uint32_t preroll; | |
116 uint32_t duration; | |
117 uint8_t stream_name_size; | |
118 char *stream_name; | |
119 uint8_t mime_type_size; | |
120 char *mime_type; | |
121 uint32_t type_specific_len; | |
122 char *type_specific_data; | |
123 | |
124 int mlti_data_size; | |
125 char *mlti_data; | |
126 | |
127 } rmff_mdpr_t; | |
128 | |
129 typedef struct { | |
130 | |
131 uint32_t object_id; | |
132 uint32_t size; | |
133 uint16_t object_version; | |
134 | |
135 uint16_t title_len; | |
136 char *title; | |
137 uint16_t author_len; | |
138 char *author; | |
139 uint16_t copyright_len; | |
140 char *copyright; | |
141 uint16_t comment_len; | |
142 char *comment; | |
143 | |
144 } rmff_cont_t; | |
145 | |
146 typedef struct { | |
147 | |
148 uint32_t object_id; | |
149 uint32_t size; | |
150 uint16_t object_version; | |
151 | |
152 uint32_t num_packets; | |
153 uint32_t next_data_header; /* rarely used */ | |
154 } rmff_data_t; | |
155 | |
156 typedef struct { | |
157 | |
158 rmff_fileheader_t *fileheader; | |
159 rmff_prop_t *prop; | |
160 rmff_mdpr_t **streams; | |
161 rmff_cont_t *cont; | |
162 rmff_data_t *data; | |
163 } rmff_header_t; | |
164 | |
165 typedef struct { | |
166 | |
167 uint16_t object_version; | |
168 | |
169 uint16_t length; | |
170 uint16_t stream_number; | |
171 uint32_t timestamp; | |
172 uint8_t reserved; | |
173 uint8_t flags; | |
174 | |
175 } rmff_pheader_t; | |
176 | |
177 /* | |
178 * constructors for header structs | |
179 */ | |
180 | |
181 rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers); | |
182 | |
183 rmff_prop_t *rmff_new_prop ( | |
184 uint32_t max_bit_rate, | |
185 uint32_t avg_bit_rate, | |
186 uint32_t max_packet_size, | |
187 uint32_t avg_packet_size, | |
188 uint32_t num_packets, | |
189 uint32_t duration, | |
190 uint32_t preroll, | |
191 uint32_t index_offset, | |
192 uint32_t data_offset, | |
193 uint16_t num_streams, | |
194 uint16_t flags ); | |
195 | |
196 rmff_mdpr_t *rmff_new_mdpr( | |
197 uint16_t stream_number, | |
198 uint32_t max_bit_rate, | |
199 uint32_t avg_bit_rate, | |
200 uint32_t max_packet_size, | |
201 uint32_t avg_packet_size, | |
202 uint32_t start_time, | |
203 uint32_t preroll, | |
204 uint32_t duration, | |
205 const char *stream_name, | |
206 const char *mime_type, | |
207 uint32_t type_specific_len, | |
208 const char *type_specific_data ); | |
209 | |
210 rmff_cont_t *rmff_new_cont( | |
211 const char *title, | |
212 const char *author, | |
213 const char *copyright, | |
214 const char *comment); | |
215 | |
216 rmff_data_t *rmff_new_dataheader( | |
217 uint32_t num_packets, uint32_t next_data_header); | |
218 | |
219 /* | |
220 * reads header infos from data and returns a newly allocated header struct | |
221 */ | |
222 rmff_header_t *rmff_scan_header(const char *data); | |
223 | |
224 /* | |
225 * scans a data packet header. Notice, that this function does not allocate | |
226 * the header struct itself. | |
227 */ | |
228 void rmff_scan_pheader(rmff_pheader_t *h, char *data); | |
229 | |
230 /* | |
231 * reads header infos from stream and returns a newly allocated header struct | |
232 */ | |
233 rmff_header_t *rmff_scan_header_stream(int fd); | |
234 | |
235 /* | |
236 * prints header information in human readible form to stdout | |
237 */ | |
238 void rmff_print_header(rmff_header_t *h); | |
239 | |
240 /* | |
241 * does some checks and fixes header if possible | |
242 */ | |
243 void rmff_fix_header(rmff_header_t *h); | |
244 | |
245 /* | |
246 * returns the size of the header (incl. first data-header) | |
247 */ | |
248 int rmff_get_header_size(rmff_header_t *h); | |
249 | |
250 /* | |
251 * dumps the header <h> to <buffer>. <max> is the size of <buffer> | |
252 */ | |
253 int rmff_dump_header(rmff_header_t *h, char *buffer, int max); | |
254 | |
255 /* | |
256 * dumps a packet header | |
257 */ | |
258 void rmff_dump_pheader(rmff_pheader_t *h, char *data); | |
259 | |
260 /* | |
261 * frees a header struct | |
262 */ | |
263 void rmff_free_header(rmff_header_t *h); | |
264 | |
265 #endif |