2 * Copyright (C) 2002-2003 the xine project
4 * This file is part of xine, a free video player.
6 * xine is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * xine is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
22 * some functions for real media file headers
23 * adopted from joschkas real tools
30 #define RMFF_HEADER_SIZE 0x12
32 #define RMFF_FILEHEADER_SIZE 18
33 #define RMFF_PROPHEADER_SIZE 50
34 #define RMFF_MDPRHEADER_SIZE 46
35 #define RMFF_CONTHEADER_SIZE 18
36 #define RMFF_DATAHEADER_SIZE 18
38 #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
39 (((long)(unsigned char)(ch3) ) | \
40 ( (long)(unsigned char)(ch2) << 8 ) | \
41 ( (long)(unsigned char)(ch1) << 16 ) | \
42 ( (long)(unsigned char)(ch0) << 24 ) )
45 #define RMF_TAG FOURCC_TAG('.', 'R', 'M', 'F')
46 #define PROP_TAG FOURCC_TAG('P', 'R', 'O', 'P')
47 #define MDPR_TAG FOURCC_TAG('M', 'D', 'P', 'R')
48 #define CONT_TAG FOURCC_TAG('C', 'O', 'N', 'T')
49 #define DATA_TAG FOURCC_TAG('D', 'A', 'T', 'A')
50 #define INDX_TAG FOURCC_TAG('I', 'N', 'D', 'X')
51 #define PNA_TAG FOURCC_TAG('P', 'N', 'A', 0 )
53 #define MLTI_TAG FOURCC_TAG('M', 'L', 'T', 'I')
56 #define PN_SAVE_ENABLED 0x01
57 #define PN_PERFECT_PLAY_ENABLED 0x02
58 #define PN_LIVE_BROADCAST 0x04
61 * rm header data structs
68 uint16_t object_version
;
70 uint32_t file_version
;
78 uint16_t object_version
;
80 uint32_t max_bit_rate
;
81 uint32_t avg_bit_rate
;
82 uint32_t max_packet_size
;
83 uint32_t avg_packet_size
;
87 uint32_t index_offset
;
97 uint16_t object_version
;
99 uint16_t stream_number
;
100 uint32_t max_bit_rate
;
101 uint32_t avg_bit_rate
;
102 uint32_t max_packet_size
;
103 uint32_t avg_packet_size
;
107 uint8_t stream_name_size
;
109 uint8_t mime_type_size
;
111 uint32_t type_specific_len
;
112 char *type_specific_data
;
123 uint16_t object_version
;
129 uint16_t copyright_len
;
131 uint16_t comment_len
;
140 uint16_t object_version
;
142 uint32_t num_packets
;
143 uint32_t next_data_header
; /* rarely used */
148 rmff_fileheader_t
*fileheader
;
150 rmff_mdpr_t
**streams
;
157 uint16_t object_version
;
160 uint16_t stream_number
;
168 * constructors for header structs
171 rmff_fileheader_t
*rmff_new_fileheader(uint32_t num_headers
);
173 rmff_prop_t
*rmff_new_prop (
174 uint32_t max_bit_rate
,
175 uint32_t avg_bit_rate
,
176 uint32_t max_packet_size
,
177 uint32_t avg_packet_size
,
178 uint32_t num_packets
,
181 uint32_t index_offset
,
182 uint32_t data_offset
,
183 uint16_t num_streams
,
186 rmff_mdpr_t
*rmff_new_mdpr(
187 uint16_t stream_number
,
188 uint32_t max_bit_rate
,
189 uint32_t avg_bit_rate
,
190 uint32_t max_packet_size
,
191 uint32_t avg_packet_size
,
195 const char *stream_name
,
196 const char *mime_type
,
197 uint32_t type_specific_len
,
198 const char *type_specific_data
);
200 rmff_cont_t
*rmff_new_cont(
203 const char *copyright
,
204 const char *comment
);
206 rmff_data_t
*rmff_new_dataheader(
207 uint32_t num_packets
, uint32_t next_data_header
);
210 * reads header infos from data and returns a newly allocated header struct
212 rmff_header_t
*rmff_scan_header(const char *data
);
215 * scans a data packet header. Notice, that this function does not allocate
216 * the header struct itself.
218 void rmff_scan_pheader(rmff_pheader_t
*h
, char *data
);
221 * reads header infos from stream and returns a newly allocated header struct
223 rmff_header_t
*rmff_scan_header_stream(int fd
);
226 * prints header information in human readible form to stdout
228 void rmff_print_header(rmff_header_t
*h
);
231 * does some checks and fixes header if possible
233 void rmff_fix_header(rmff_header_t
*h
);
236 * returns the size of the header (incl. first data-header)
238 int rmff_get_header_size(rmff_header_t
*h
);
241 * dumps the header <h> to <buffer>. <max> is the size of <buffer>
243 int rmff_dump_header(rmff_header_t
*h
, void *buffer
, int max
);
246 * dumps a packet header
248 void rmff_dump_pheader(rmff_pheader_t
*h
, char *data
);
251 * frees a header struct
253 void rmff_free_header(rmff_header_t
*h
);