contrib: theora: do not run autoreconf
[vlc/gmpfix.git] / modules / access / rtsp / real_rmff.h
blobe4fd2d2e719067eb3e499af05fd6cbb84bbaf4e4
1 /*
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$
22 * some functions for real media file headers
23 * adopted from joschkas real tools
26 #ifndef HAVE_RMFF_H
27 #define HAVE_RMFF_H
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')
55 /* prop flags */
56 #define PN_SAVE_ENABLED 0x01
57 #define PN_PERFECT_PLAY_ENABLED 0x02
58 #define PN_LIVE_BROADCAST 0x04
61 * rm header data structs
64 typedef struct {
66 uint32_t object_id;
67 uint32_t size;
68 uint16_t object_version;
70 uint32_t file_version;
71 uint32_t num_headers;
72 } rmff_fileheader_t;
74 typedef struct {
76 uint32_t object_id;
77 uint32_t size;
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;
84 uint32_t num_packets;
85 uint32_t duration;
86 uint32_t preroll;
87 uint32_t index_offset;
88 uint32_t data_offset;
89 uint16_t num_streams;
90 uint16_t flags;
91 } rmff_prop_t;
93 typedef struct {
95 uint32_t object_id;
96 uint32_t size;
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;
104 uint32_t start_time;
105 uint32_t preroll;
106 uint32_t duration;
107 uint8_t stream_name_size;
108 char *stream_name;
109 uint8_t mime_type_size;
110 char *mime_type;
111 uint32_t type_specific_len;
112 char *type_specific_data;
114 int mlti_data_size;
115 char *mlti_data;
117 } rmff_mdpr_t;
119 typedef struct {
121 uint32_t object_id;
122 uint32_t size;
123 uint16_t object_version;
125 uint16_t title_len;
126 char *title;
127 uint16_t author_len;
128 char *author;
129 uint16_t copyright_len;
130 char *copyright;
131 uint16_t comment_len;
132 char *comment;
134 } rmff_cont_t;
136 typedef struct {
138 uint32_t object_id;
139 uint32_t size;
140 uint16_t object_version;
142 uint32_t num_packets;
143 uint32_t next_data_header; /* rarely used */
144 } rmff_data_t;
146 typedef struct {
148 rmff_fileheader_t *fileheader;
149 rmff_prop_t *prop;
150 rmff_mdpr_t **streams;
151 rmff_cont_t *cont;
152 rmff_data_t *data;
153 } rmff_header_t;
155 typedef struct {
157 uint16_t object_version;
159 uint16_t length;
160 uint16_t stream_number;
161 uint32_t timestamp;
162 uint8_t reserved;
163 uint8_t flags;
165 } rmff_pheader_t;
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,
179 uint32_t duration,
180 uint32_t preroll,
181 uint32_t index_offset,
182 uint32_t data_offset,
183 uint16_t num_streams,
184 uint16_t flags );
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,
192 uint32_t start_time,
193 uint32_t preroll,
194 uint32_t duration,
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(
201 const char *title,
202 const char *author,
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);
255 #endif