]> git.sesse.net Git - vlc/blob - modules/access/rtsp/real_rmff.h
Use var_InheritString for --decklink-video-connection.
[vlc] / modules / access / rtsp / real_rmff.h
1 /*
2  * Copyright (C) 2002-2003 the xine project
3  *
4  * This file is part of xine, a free video player.
5  *
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.
10  *
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.
15  *
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
19  *
20  * $Id$
21  *
22  * some functions for real media file headers
23  * adopted from joschkas real tools
24  */
25
26 #ifndef HAVE_RMFF_H
27 #define HAVE_RMFF_H
28
29
30 #define RMFF_HEADER_SIZE 0x12
31
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
37
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 ) )
43
44
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 )
52
53 #define MLTI_TAG  FOURCC_TAG('M', 'L', 'T', 'I')
54
55 /* prop flags */
56 #define PN_SAVE_ENABLED         0x01
57 #define PN_PERFECT_PLAY_ENABLED 0x02
58 #define PN_LIVE_BROADCAST       0x04
59
60 /*
61  * rm header data structs
62  */
63
64 typedef struct {
65
66   uint32_t object_id;
67   uint32_t size;
68   uint16_t object_version;
69
70   uint32_t file_version;
71   uint32_t num_headers;
72 } rmff_fileheader_t;
73
74 typedef struct {
75
76   uint32_t object_id;
77   uint32_t size;
78   uint16_t object_version;
79
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;
92
93 typedef struct {
94
95   uint32_t  object_id;
96   uint32_t  size;
97   uint16_t  object_version;
98
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;
113
114   int       mlti_data_size;
115   char      *mlti_data;
116
117 } rmff_mdpr_t;
118
119 typedef struct {
120
121   uint32_t  object_id;
122   uint32_t  size;
123   uint16_t  object_version;
124
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;
133
134 } rmff_cont_t;
135
136 typedef struct {
137
138   uint32_t object_id;
139   uint32_t size;
140   uint16_t object_version;
141
142   uint32_t num_packets;
143   uint32_t next_data_header; /* rarely used */
144 } rmff_data_t;
145
146 typedef struct {
147
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;
154
155 typedef struct {
156
157   uint16_t object_version;
158
159   uint16_t length;
160   uint16_t stream_number;
161   uint32_t timestamp;
162   uint8_t reserved;
163   uint8_t flags;
164
165 } rmff_pheader_t;
166
167 /*
168  * constructors for header structs
169  */
170
171 rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers);
172
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 );
185
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 );
199
200 rmff_cont_t *rmff_new_cont(
201     const char *title,
202     const char *author,
203     const char *copyright,
204     const char *comment);
205
206 rmff_data_t *rmff_new_dataheader(
207     uint32_t num_packets, uint32_t next_data_header);
208
209 /*
210  * reads header infos from data and returns a newly allocated header struct
211  */
212 rmff_header_t *rmff_scan_header(const char *data);
213
214 /*
215  * scans a data packet header. Notice, that this function does not allocate
216  * the header struct itself.
217  */
218 void rmff_scan_pheader(rmff_pheader_t *h, char *data);
219
220 /*
221  * reads header infos from stream and returns a newly allocated header struct
222  */
223 rmff_header_t *rmff_scan_header_stream(int fd);
224
225 /*
226  * prints header information in human readible form to stdout
227  */
228 void rmff_print_header(rmff_header_t *h);
229
230 /*
231  * does some checks and fixes header if possible
232  */
233 void rmff_fix_header(rmff_header_t *h);
234
235 /*
236  * returns the size of the header (incl. first data-header)
237  */
238 int rmff_get_header_size(rmff_header_t *h);
239  
240 /*
241  * dumps the header <h> to <buffer>. <max> is the size of <buffer>
242  */
243 int rmff_dump_header(rmff_header_t *h, void *buffer, int max);
244
245 /*
246  * dumps a packet header
247  */
248 void rmff_dump_pheader(rmff_pheader_t *h, char *data);
249
250 /*
251  * frees a header struct
252  */
253 void rmff_free_header(rmff_header_t *h);
254
255 #endif