xine-lib 1.2.13-20230125hg15249
rmff.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2002-2021 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
19 *
20 * some functions for real media file headers
21 * adopted from joschkas real tools
22 */
23
24#include <sys/types.h>
25#ifdef HAVE_SYS_SOCKET_H
26#include <sys/socket.h>
27#endif
28#ifdef HAVE_NETINET_IN_H
29#include <netinet/in.h>
30#endif
31#ifdef HAVE_NETDB_H
32#include <netdb.h>
33#endif
34#include <unistd.h>
35#include <stdio.h>
36#include <fcntl.h>
37#include <stdlib.h>
38#include <string.h>
39#include <inttypes.h>
40
41#ifndef HAVE_RMFF_H
42#define HAVE_RMFF_H
43
44#include <xine/attributes.h>
45
46#define RMFF_HEADER_SIZE 0x12
47
48#define RMFF_FILEHEADER_SIZE 18
49#define RMFF_PROPHEADER_SIZE 50
50#define RMFF_MDPRHEADER_SIZE 46
51#define RMFF_CONTHEADER_SIZE 18
52#define RMFF_DATAHEADER_SIZE 18
53
54#define FOURCC_TAG( ch0, ch1, ch2, ch3 ) \
55 (((long)(unsigned char)(ch3) ) | \
56 ( (long)(unsigned char)(ch2) << 8 ) | \
57 ( (long)(unsigned char)(ch1) << 16 ) | \
58 ( (long)(unsigned char)(ch0) << 24 ) )
59
60
61#define RMF_TAG FOURCC_TAG('.', 'R', 'M', 'F')
62#define PROP_TAG FOURCC_TAG('P', 'R', 'O', 'P')
63#define MDPR_TAG FOURCC_TAG('M', 'D', 'P', 'R')
64#define CONT_TAG FOURCC_TAG('C', 'O', 'N', 'T')
65#define DATA_TAG FOURCC_TAG('D', 'A', 'T', 'A')
66#define INDX_TAG FOURCC_TAG('I', 'N', 'D', 'X')
67#define PNA_TAG FOURCC_TAG('P', 'N', 'A', 0 )
68
69#define MLTI_TAG FOURCC_TAG('M', 'L', 'T', 'I')
70
71/* prop flags */
72#define PN_SAVE_ENABLED 0x01
73#define PN_PERFECT_PLAY_ENABLED 0x02
74#define PN_LIVE_BROADCAST 0x04
75
76/*
77 * rm header data structs
78 */
79
80typedef struct {
81
82 uint32_t object_id;
83 uint32_t size;
85
86 uint32_t file_version;
87 uint32_t num_headers;
89
90typedef struct {
91
92 uint32_t object_id;
93 uint32_t size;
95
96 uint32_t max_bit_rate;
97 uint32_t avg_bit_rate;
100 uint32_t num_packets;
101 uint32_t duration;
102 uint32_t preroll;
103 uint32_t index_offset;
104 uint32_t data_offset;
105 uint16_t num_streams;
106 uint16_t flags;
107
109
110typedef struct {
111
112 uint32_t object_id;
113 uint32_t size;
115
117 uint32_t max_bit_rate;
118 uint32_t avg_bit_rate;
121 uint32_t start_time;
122 uint32_t preroll;
123 uint32_t duration;
130
133
135
136typedef struct {
137
138 uint32_t object_id;
139 uint32_t size;
141
142 uint16_t title_len;
143 char *title;
144 uint16_t author_len;
145 char *author;
148 uint16_t comment_len;
149 char *comment;
150
152
153typedef struct {
154
155 uint32_t object_id;
156 uint32_t size;
158
159 uint32_t num_packets;
160 uint32_t next_data_header; /* rarely used */
162
171
172typedef struct {
173
175
176 uint16_t length;
178 uint32_t timestamp;
179 uint8_t reserved;
180 uint8_t flags;
181
183
184/*
185 * constructors for header structs
186 */
187
188rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers);
189
191 uint32_t max_bit_rate,
192 uint32_t avg_bit_rate,
193 uint32_t max_packet_size,
194 uint32_t avg_packet_size,
195 uint32_t num_packets,
196 uint32_t duration,
197 uint32_t preroll,
198 uint32_t index_offset,
199 uint32_t data_offset,
200 uint16_t num_streams,
201 uint16_t flags );
202
204 uint16_t stream_number,
205 uint32_t max_bit_rate,
206 uint32_t avg_bit_rate,
207 uint32_t max_packet_size,
208 uint32_t avg_packet_size,
209 uint32_t start_time,
210 uint32_t preroll,
211 uint32_t duration,
212 const char *stream_name,
213 const char *mime_type,
214 uint32_t type_specific_len,
215 const char *type_specific_data );
216
218 const char *title,
219 const char *author,
220 const char *copyright,
221 const char *comment);
222
224 uint32_t num_packets, uint32_t next_data_header);
225
226#if 0
227/*
228 * reads header infos from data and returns a newly allocated header struct
229 */
230rmff_header_t *rmff_scan_header(const char *data) XINE_MALLOC;
231
232/*
233 * scans a data packet header. Notice, that this function does not allocate
234 * the header struct itself.
235 */
236void rmff_scan_pheader(rmff_pheader_t *h, char *data);
237
238/*
239 * reads header infos from stream and returns a newly allocated header struct
240 */
241rmff_header_t *rmff_scan_header_stream(int fd) XINE_MALLOC;
242
243/*
244 * prints header information in human readible form to stdout
245 */
246void rmff_print_header(rmff_header_t *h);
247#endif
248
249/*
250 * does some checks and fixes header if possible
251 */
253
254#if 0
255/*
256 * returns the size of the header (incl. first data-header)
257 */
258int rmff_get_header_size(rmff_header_t *h);
259#endif
260
261/*
262 * dumps the header <h> to <buffer>. <max> is the size of <buffer>
263 */
264int rmff_dump_header(rmff_header_t *h, void *buffer, int max);
265
266/*
267 * dumps a packet header
268 */
269void rmff_dump_pheader(rmff_pheader_t *h, uint8_t *data);
270
271#if 0
272/*
273 * frees a header struct
274 */
275void rmff_free_header(rmff_header_t *h);
276#endif
277
278#endif
#define XINE_MALLOC
Definition attributes.h:141
int rmff_dump_header(rmff_header_t *h, void *buffer, int max)
Definition rmff.c:243
rmff_cont_t * rmff_new_cont(const char *title, const char *author, const char *copyright, const char *comment)
Definition rmff.c:669
void rmff_dump_pheader(rmff_pheader_t *h, uint8_t *data)
Definition rmff.c:280
rmff_fileheader_t * rmff_new_fileheader(uint32_t num_headers)
Definition rmff.c:576
rmff_prop_t * rmff_new_prop(uint32_t max_bit_rate, uint32_t avg_bit_rate, uint32_t max_packet_size, uint32_t avg_packet_size, uint32_t num_packets, uint32_t duration, uint32_t preroll, uint32_t index_offset, uint32_t data_offset, uint16_t num_streams, uint16_t flags)
Definition rmff.c:589
void rmff_fix_header(rmff_header_t *h)
Definition rmff.c:789
rmff_data_t * rmff_new_dataheader(uint32_t num_packets, uint32_t next_data_header)
Definition rmff.c:707
rmff_mdpr_t * rmff_new_mdpr(uint16_t stream_number, uint32_t max_bit_rate, uint32_t avg_bit_rate, uint32_t max_packet_size, uint32_t avg_packet_size, uint32_t start_time, uint32_t preroll, uint32_t duration, const char *stream_name, const char *mime_type, uint32_t type_specific_len, const char *type_specific_data)
Definition rmff.c:623
Definition rmff.h:136
uint16_t comment_len
Definition rmff.h:148
char * comment
Definition rmff.h:149
uint16_t object_version
Definition rmff.h:140
uint16_t copyright_len
Definition rmff.h:146
uint16_t title_len
Definition rmff.h:142
uint32_t size
Definition rmff.h:139
char * author
Definition rmff.h:145
char * title
Definition rmff.h:143
uint16_t author_len
Definition rmff.h:144
char * copyright
Definition rmff.h:147
uint32_t object_id
Definition rmff.h:138
Definition rmff.h:153
uint32_t object_id
Definition rmff.h:155
uint16_t object_version
Definition rmff.h:157
uint32_t num_packets
Definition rmff.h:159
uint32_t size
Definition rmff.h:156
uint32_t next_data_header
Definition rmff.h:160
Definition rmff.h:80
uint16_t object_version
Definition rmff.h:84
uint32_t file_version
Definition rmff.h:86
uint32_t size
Definition rmff.h:83
uint32_t num_headers
Definition rmff.h:87
uint32_t object_id
Definition rmff.h:82
Definition rmff.h:163
rmff_prop_t * prop
Definition rmff.h:166
rmff_mdpr_t ** streams
Definition rmff.h:167
rmff_data_t * data
Definition rmff.h:169
rmff_cont_t * cont
Definition rmff.h:168
rmff_fileheader_t * fileheader
Definition rmff.h:165
Definition rmff.h:110
uint16_t object_version
Definition rmff.h:114
uint32_t avg_bit_rate
Definition rmff.h:118
uint32_t max_packet_size
Definition rmff.h:119
uint32_t avg_packet_size
Definition rmff.h:120
uint32_t duration
Definition rmff.h:123
uint32_t max_bit_rate
Definition rmff.h:117
char * stream_name
Definition rmff.h:125
uint16_t stream_number
Definition rmff.h:116
char * type_specific_data
Definition rmff.h:129
uint32_t size
Definition rmff.h:113
uint32_t start_time
Definition rmff.h:121
char * mime_type
Definition rmff.h:127
uint32_t type_specific_len
Definition rmff.h:128
uint32_t preroll
Definition rmff.h:122
uint32_t object_id
Definition rmff.h:112
uint8_t mime_type_size
Definition rmff.h:126
char * mlti_data
Definition rmff.h:132
int mlti_data_size
Definition rmff.h:131
uint8_t stream_name_size
Definition rmff.h:124
Definition rmff.h:172
uint8_t reserved
Definition rmff.h:179
uint16_t length
Definition rmff.h:176
uint16_t stream_number
Definition rmff.h:177
uint16_t object_version
Definition rmff.h:174
uint8_t flags
Definition rmff.h:180
uint32_t timestamp
Definition rmff.h:178
Definition rmff.h:90
uint32_t size
Definition rmff.h:93
uint32_t object_id
Definition rmff.h:92
uint32_t data_offset
Definition rmff.h:104
uint32_t duration
Definition rmff.h:101
uint32_t num_packets
Definition rmff.h:100
uint32_t avg_packet_size
Definition rmff.h:99
uint16_t object_version
Definition rmff.h:94
uint32_t max_packet_size
Definition rmff.h:98
uint16_t num_streams
Definition rmff.h:105
uint16_t flags
Definition rmff.h:106
uint32_t avg_bit_rate
Definition rmff.h:97
uint32_t max_bit_rate
Definition rmff.h:96
uint32_t index_offset
Definition rmff.h:103
uint32_t preroll
Definition rmff.h:102