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
20 * $Id: rmff.h,v 1.5 2004/04/06 19:20:16 valtri Exp $
22 * some functions for real media file headers
23 * adopted from joschkas real tools
30 #define RMFF_HEADER_SIZE 0x12
32 #define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
33 (((long)(unsigned char)(ch3) ) | \
34 ( (long)(unsigned char)(ch2) << 8 ) | \
35 ( (long)(unsigned char)(ch1) << 16 ) | \
36 ( (long)(unsigned char)(ch0) << 24 ) )
39 #define RMF_TAG FOURCC_TAG('.', 'R', 'M', 'F')
40 #define PROP_TAG FOURCC_TAG('P', 'R', 'O', 'P')
41 #define MDPR_TAG FOURCC_TAG('M', 'D', 'P', 'R')
42 #define CONT_TAG FOURCC_TAG('C', 'O', 'N', 'T')
43 #define DATA_TAG FOURCC_TAG('D', 'A', 'T', 'A')
44 #define INDX_TAG FOURCC_TAG('I', 'N', 'D', 'X')
45 #define PNA_TAG FOURCC_TAG('P', 'N', 'A', 0 )
47 #define MLTI_TAG FOURCC_TAG('M', 'L', 'T', 'I')
50 #define PN_SAVE_ENABLED 0x01
51 #define PN_PERFECT_PLAY_ENABLED 0x02
52 #define PN_LIVE_BROADCAST 0x04
55 * rm header data structs
62 uint16_t object_version;
64 uint32_t file_version;
72 uint16_t object_version;
74 uint32_t max_bit_rate;
75 uint32_t avg_bit_rate;
76 uint32_t max_packet_size;
77 uint32_t avg_packet_size;
81 uint32_t index_offset;
91 uint16_t object_version;
93 uint16_t stream_number;
94 uint32_t max_bit_rate;
95 uint32_t avg_bit_rate;
96 uint32_t max_packet_size;
97 uint32_t avg_packet_size;
101 uint8_t stream_name_size;
103 uint8_t mime_type_size;
105 uint32_t type_specific_len;
106 char *type_specific_data;
117 uint16_t object_version;
123 uint16_t copyright_len;
125 uint16_t comment_len;
134 uint16_t object_version;
136 uint32_t num_packets;
137 uint32_t next_data_header; /* rarely used */
142 rmff_fileheader_t *fileheader;
144 rmff_mdpr_t **streams;
151 uint16_t object_version;
154 uint16_t stream_number;
162 * constructors for header structs
165 rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers);
167 rmff_prop_t *rmff_new_prop (
168 uint32_t max_bit_rate,
169 uint32_t avg_bit_rate,
170 uint32_t max_packet_size,
171 uint32_t avg_packet_size,
172 uint32_t num_packets,
175 uint32_t index_offset,
176 uint32_t data_offset,
177 uint16_t num_streams,
180 rmff_mdpr_t *rmff_new_mdpr(
181 uint16_t stream_number,
182 uint32_t max_bit_rate,
183 uint32_t avg_bit_rate,
184 uint32_t max_packet_size,
185 uint32_t avg_packet_size,
189 const char *stream_name,
190 const char *mime_type,
191 uint32_t type_specific_len,
192 const char *type_specific_data );
194 rmff_cont_t *rmff_new_cont(
197 const char *copyright,
198 const char *comment);
200 rmff_data_t *rmff_new_dataheader(
201 uint32_t num_packets, uint32_t next_data_header);
204 * reads header infos from data and returns a newly allocated header struct
206 rmff_header_t *rmff_scan_header(const char *data);
209 * scans a data packet header. Notice, that this function does not allocate
210 * the header struct itself.
212 void rmff_scan_pheader(rmff_pheader_t *h, char *data);
215 * reads header infos from stream and returns a newly allocated header struct
217 rmff_header_t *rmff_scan_header_stream(int fd);
220 * prints header information in human readible form to stdout
222 void rmff_print_header(rmff_header_t *h);
225 * does some checks and fixes header if possible
227 void rmff_fix_header(rmff_header_t *h);
230 * returns the size of the header (incl. first data-header)
232 int rmff_get_header_size(rmff_header_t *h);
235 * dumps the header <h> to <buffer>. <max> is the size of <buffer>
237 int rmff_dump_header(rmff_header_t *h, char *buffer, int max);
240 * dumps a packet header
242 void rmff_dump_pheader(rmff_pheader_t *h, char *data);
245 * frees a header struct
247 void rmff_free_header(rmff_header_t *h);