annotate stream/realrtsp/rmff.c @ 26386:cf87699fba0b

Indentation fix for r26417
author zuxy
date Sat, 12 Apr 2008 18:24:25 +0000
parents 4401909aac98
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
1 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
2 * This file was ported to MPlayer from xine CVS rmff.c,v 1.3 2002/12/24 01:30:22
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
3 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
4
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
5 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
6 * Copyright (C) 2002 the xine project
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
7 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
8 * This file is part of xine, a free video player.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
9 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
10 * xine is free software; you can redistribute it and/or modify
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
13 * (at your option) any later version.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
14 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
15 * xine is distributed in the hope that it will be useful,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
18 * GNU General Public License for more details.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
19 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
23 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
24 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
25 * functions for real media file format
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
26 * adopted from joschkas real tools
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
27 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
28
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
29 #include "rmff.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
30 #include "xbuffer.h"
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
31 #include "mp_msg.h"
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
32 #include "libavutil/intreadwrite.h"
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
33
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
34 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
35 #define LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
36 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
37
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
38 static void hexdump (const char *buf, int length) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
39
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
40 int i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
41
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
42 printf ("rmff: ascii>");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
43 for (i = 0; i < length; i++) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
44 unsigned char c = buf[i];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
45
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
46 if ((c >= 32) && (c <= 128))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
47 printf ("%c", c);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
48 else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
49 printf (".");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
50 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
51 printf ("\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
52
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
53 printf ("rmff: hexdump> ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
54 for (i = 0; i < length; i++) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
55 unsigned char c = buf[i];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
56
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
57 printf ("%02x", c);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
58
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
59 if ((i % 16) == 15)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
60 printf ("\nrmff: ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
61
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
62 if ((i % 2) == 1)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
63 printf (" ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
64
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
65 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
66 printf ("\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
67 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
68
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
69 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
70 * writes header data to a buffer
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
71 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
72
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
73 static int rmff_dump_fileheader(rmff_fileheader_t *fileheader, char *buffer, int bufsize) {
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
74
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
75 if (!fileheader) return 0;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
76
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
77 if (bufsize < RMFF_FILEHEADER_SIZE)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
78 return -1;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
79
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
80 AV_WB32(buffer, fileheader->object_id);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
81 AV_WB32(buffer+4, fileheader->size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
82 AV_WB16(buffer+8, fileheader->object_version);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
83 AV_WB32(buffer+10, fileheader->file_version);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
84 AV_WB32(buffer+14, fileheader->num_headers);
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
85
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
86 return RMFF_FILEHEADER_SIZE;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
87 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
88
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
89 static int rmff_dump_prop(rmff_prop_t *prop, char *buffer, int bufsize) {
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
90
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
91 if (!prop) return 0;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
92
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
93 if (bufsize < RMFF_PROPHEADER_SIZE)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
94 return -1;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
95
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
96 AV_WB32(buffer, prop->object_id);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
97 AV_WB32(buffer+4, prop->size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
98 AV_WB16(buffer+8, prop->object_version);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
99 AV_WB32(buffer+10, prop->max_bit_rate);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
100 AV_WB32(buffer+14, prop->avg_bit_rate);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
101 AV_WB32(buffer+18, prop->max_packet_size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
102 AV_WB32(buffer+22, prop->avg_packet_size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
103 AV_WB32(buffer+26, prop->num_packets);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
104 AV_WB32(buffer+30, prop->duration);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
105 AV_WB32(buffer+34, prop->preroll);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
106 AV_WB32(buffer+38, prop->index_offset);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
107 AV_WB32(buffer+42, prop->data_offset);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
108 AV_WB16(buffer+46, prop->num_streams);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
109 AV_WB16(buffer+48, prop->flags);
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
110
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
111 return RMFF_PROPHEADER_SIZE;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
112 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
113
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
114 static int rmff_dump_mdpr(rmff_mdpr_t *mdpr, char *buffer, int bufsize) {
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
115
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
116 int s1, s2, s3;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
117
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
118 if (!mdpr) return 0;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
119
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
120 if (!(bufsize > RMFF_MDPRHEADER_SIZE + mdpr->stream_name_size + mdpr->mime_type_size &&
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
121 (unsigned)bufsize - RMFF_MDPRHEADER_SIZE - mdpr->stream_name_size - mdpr->mime_type_size > mdpr->type_specific_len))
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
122 return -1;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
123
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
124 AV_WB32(buffer, mdpr->object_id);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
125 AV_WB32(buffer+4, mdpr->size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
126 AV_WB16(buffer+8, mdpr->object_version);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
127 AV_WB16(buffer+10, mdpr->stream_number);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
128 AV_WB32(buffer+12, mdpr->max_bit_rate);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
129 AV_WB32(buffer+16, mdpr->avg_bit_rate);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
130 AV_WB32(buffer+20, mdpr->max_packet_size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
131 AV_WB32(buffer+24, mdpr->avg_packet_size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
132 AV_WB32(buffer+28, mdpr->start_time);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
133 AV_WB32(buffer+32, mdpr->preroll);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
134 AV_WB32(buffer+36, mdpr->duration);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
135
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
136 buffer[40] = mdpr->stream_name_size;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
137 s1=mdpr->stream_name_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
138 memcpy(&buffer[41], mdpr->stream_name, s1);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
139
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
140 buffer[41+s1] = mdpr->mime_type_size;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
141 s2=mdpr->mime_type_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
142 memcpy(&buffer[42+s1], mdpr->mime_type, s2);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
143
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
144 AV_WB32(buffer+42+s1+s2, mdpr->type_specific_len);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
145 s3=mdpr->type_specific_len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
146 memcpy(&buffer[46+s1+s2], mdpr->type_specific_data, s3);
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
147
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
148 return RMFF_MDPRHEADER_SIZE + s1 + s2 + s3;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
149 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
150
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
151 static int rmff_dump_cont(rmff_cont_t *cont, char *buffer, int bufsize) {
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
152
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
153 int p;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
154
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
155 if (!cont) return 0;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
156
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
157 if (bufsize < RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len +
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
158 cont->copyright_len + cont->comment_len)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
159 return -1;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
160
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
161 AV_WB32(buffer, cont->object_id);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
162 AV_WB32(buffer+4, cont->size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
163 AV_WB16(buffer+8, cont->object_version);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
164
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
165 AV_WB16(buffer+10, cont->title_len);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
166 memcpy(&buffer[12], cont->title, cont->title_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
167 p=12+cont->title_len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
168
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
169 AV_WB16(buffer+p, cont->author_len);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
170 memcpy(&buffer[p+2], cont->author, cont->author_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
171 p+=2+cont->author_len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
172
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
173 AV_WB16(buffer+p, cont->copyright_len);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
174 memcpy(&buffer[p+2], cont->copyright, cont->copyright_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
175 p+=2+cont->copyright_len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
176
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
177 AV_WB16(buffer+p, cont->comment_len);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
178 memcpy(&buffer[p+2], cont->comment, cont->comment_len);
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
179
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
180 return RMFF_CONTHEADER_SIZE + cont->title_len + cont->author_len +
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
181 cont->copyright_len + cont->comment_len;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
182 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
183
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
184 static int rmff_dump_dataheader(rmff_data_t *data, char *buffer, int bufsize) {
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
185
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
186 if (!data) return 0;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
187
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
188 if (bufsize < RMFF_DATAHEADER_SIZE)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
189 return -1;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
190
22783
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
191 AV_WB32(buffer, data->object_id);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
192 AV_WB32(buffer+4, data->size);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
193 AV_WB16(buffer+8, data->object_version);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
194 AV_WB32(buffer+10, data->num_packets);
96f0c2cd4538 Use AV_WB* instead of swap+memcpy+swap
rtogni
parents: 22376
diff changeset
195 AV_WB32(buffer+14, data->next_data_header);
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
196
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
197 return RMFF_DATAHEADER_SIZE;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
198 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
199
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
200 int rmff_dump_header(rmff_header_t *h, char *buffer, int max) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
201
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
202 int written=0, size;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
203 rmff_mdpr_t **stream=h->streams;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
204
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
205 if ((size=rmff_dump_fileheader(h->fileheader, &buffer[written], max)) < 0)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
206 goto buftoosmall;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
207 written+=size;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
208 max -= size;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
209 if ((size=rmff_dump_prop(h->prop, &buffer[written], max)) < 0)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
210 goto buftoosmall;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
211 written+=size;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
212 max -= size;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
213 if ((size=rmff_dump_cont(h->cont, &buffer[written], max)) < 0)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
214 goto buftoosmall;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
215 written+=size;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
216 max -= size;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
217 if (stream)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
218 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
219 while(*stream)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
220 {
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
221 if ((size=rmff_dump_mdpr(*stream, &buffer[written], max)) < 0)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
222 goto buftoosmall;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
223 written+=size;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
224 max -= size;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
225 stream++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
226 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
227 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
228
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
229 if ((size=rmff_dump_dataheader(h->data, &buffer[written], max)) < 0)
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
230 goto buftoosmall;
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
231 written+=size;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
232
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
233 return written;
22803
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
234
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
235 buftoosmall:
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
236 mp_msg(MSGT_STREAM, MSGL_ERR, "rmff_dumpheader: buffer too small, aborting. Please report\n");
4401909aac98 Check buffer size in header dump functions
rtogni
parents: 22783
diff changeset
237 return -1;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
238 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
239
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
240 void rmff_dump_pheader(rmff_pheader_t *h, char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
241
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
242 data[0]=(h->object_version>>8) & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
243 data[1]=h->object_version & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
244 data[2]=(h->length>>8) & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
245 data[3]=h->length & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
246 data[4]=(h->stream_number>>8) & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
247 data[5]=h->stream_number & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
248 data[6]=(h->timestamp>>24) & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
249 data[7]=(h->timestamp>>16) & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
250 data[8]=(h->timestamp>>8) & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
251 data[9]=h->timestamp & 0xff;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
252 data[10]=h->reserved;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
253 data[11]=h->flags;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
254 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
255
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
256 static rmff_fileheader_t *rmff_scan_fileheader(const char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
257
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
258 rmff_fileheader_t *fileheader=malloc(sizeof(rmff_fileheader_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
259
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
260 fileheader->object_id=AV_RB32(data);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
261 fileheader->size=AV_RB32(&data[4]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
262 fileheader->object_version=AV_RB16(&data[8]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
263 if (fileheader->object_version != 0)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
264 {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
265 mp_msg(MSGT_STREAM, MSGL_WARN, "warning: unknown object version in .RMF: 0x%04x\n",
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
266 fileheader->object_version);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
267 }
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
268 fileheader->file_version=AV_RB32(&data[10]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
269 fileheader->num_headers=AV_RB32(&data[14]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
270
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
271 return fileheader;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
272 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
273
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
274 static rmff_prop_t *rmff_scan_prop(const char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
275
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
276 rmff_prop_t *prop=malloc(sizeof(rmff_prop_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
277
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
278 prop->object_id=AV_RB32(data);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
279 prop->size=AV_RB32(&data[4]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
280 prop->object_version=AV_RB16(&data[8]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
281 if (prop->object_version != 0)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
282 {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
283 mp_msg(MSGT_STREAM, MSGL_WARN, "warning: unknown object version in PROP: 0x%04x\n",
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
284 prop->object_version);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
285 }
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
286 prop->max_bit_rate=AV_RB32(&data[10]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
287 prop->avg_bit_rate=AV_RB32(&data[14]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
288 prop->max_packet_size=AV_RB32(&data[18]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
289 prop->avg_packet_size=AV_RB32(&data[22]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
290 prop->num_packets=AV_RB32(&data[26]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
291 prop->duration=AV_RB32(&data[30]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
292 prop->preroll=AV_RB32(&data[34]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
293 prop->index_offset=AV_RB32(&data[38]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
294 prop->data_offset=AV_RB32(&data[42]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
295 prop->num_streams=AV_RB16(&data[46]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
296 prop->flags=AV_RB16(&data[48]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
297
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
298 return prop;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
299 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
300
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
301 static rmff_mdpr_t *rmff_scan_mdpr(const char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
302
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
303 rmff_mdpr_t *mdpr=malloc(sizeof(rmff_mdpr_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
304
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
305 mdpr->object_id=AV_RB32(data);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
306 mdpr->size=AV_RB32(&data[4]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
307 mdpr->object_version=AV_RB16(&data[8]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
308 if (mdpr->object_version != 0)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
309 {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
310 mp_msg(MSGT_STREAM, MSGL_WARN, "warning: unknown object version in MDPR: 0x%04x\n",
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
311 mdpr->object_version);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
312 }
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
313 mdpr->stream_number=AV_RB16(&data[10]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
314 mdpr->max_bit_rate=AV_RB32(&data[12]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
315 mdpr->avg_bit_rate=AV_RB32(&data[16]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
316 mdpr->max_packet_size=AV_RB32(&data[20]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
317 mdpr->avg_packet_size=AV_RB32(&data[24]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
318 mdpr->start_time=AV_RB32(&data[28]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
319 mdpr->preroll=AV_RB32(&data[32]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
320 mdpr->duration=AV_RB32(&data[36]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
321
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
322 mdpr->stream_name_size=data[40];
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
323 mdpr->stream_name=malloc(mdpr->stream_name_size+1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
324 memcpy(mdpr->stream_name, &data[41], mdpr->stream_name_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
325 mdpr->stream_name[mdpr->stream_name_size]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
326
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
327 mdpr->mime_type_size=data[41+mdpr->stream_name_size];
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
328 mdpr->mime_type=malloc(mdpr->mime_type_size+1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
329 memcpy(mdpr->mime_type, &data[42+mdpr->stream_name_size], mdpr->mime_type_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
330 mdpr->mime_type[mdpr->mime_type_size]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
331
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
332 mdpr->type_specific_len=AV_RB32(&data[42+mdpr->stream_name_size+mdpr->mime_type_size]);
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
333 mdpr->type_specific_data=malloc(mdpr->type_specific_len);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
334 memcpy(mdpr->type_specific_data,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
335 &data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
336
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
337 return mdpr;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
338 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
339
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
340 static rmff_cont_t *rmff_scan_cont(const char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
341
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
342 rmff_cont_t *cont=malloc(sizeof(rmff_cont_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
343 int pos;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
344
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
345 cont->object_id=AV_RB32(data);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
346 cont->size=AV_RB32(&data[4]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
347 cont->object_version=AV_RB16(&data[8]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
348 if (cont->object_version != 0)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
349 {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
350 mp_msg(MSGT_STREAM, MSGL_WARN, "warning: unknown object version in CONT: 0x%04x\n",
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
351 cont->object_version);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
352 }
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
353 cont->title_len=AV_RB16(&data[10]);
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
354 cont->title=malloc(cont->title_len+1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
355 memcpy(cont->title, &data[12], cont->title_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
356 cont->title[cont->title_len]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
357 pos=cont->title_len+12;
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
358 cont->author_len=AV_RB16(&data[pos]);
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
359 cont->author=malloc(cont->author_len+1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
360 memcpy(cont->author, &data[pos+2], cont->author_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
361 cont->author[cont->author_len]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
362 pos=pos+2+cont->author_len;
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
363 cont->copyright_len=AV_RB16(&data[pos]);
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
364 cont->copyright=malloc(cont->copyright_len+1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
365 memcpy(cont->copyright, &data[pos+2], cont->copyright_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
366 cont->copyright[cont->copyright_len]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
367 pos=pos+2+cont->copyright_len;
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
368 cont->comment_len=AV_RB16(&data[pos]);
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
369 cont->comment=malloc(cont->comment_len+1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
370 memcpy(cont->comment, &data[pos+2], cont->comment_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
371 cont->comment[cont->comment_len]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
372
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
373 return cont;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
374 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
375
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
376 static rmff_data_t *rmff_scan_dataheader(const char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
377
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
378 rmff_data_t *dh=malloc(sizeof(rmff_data_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
379
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
380 dh->object_id=AV_RB32(data);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
381 dh->size=AV_RB32(&data[4]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
382 dh->object_version=AV_RB16(&data[8]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
383 if (dh->object_version != 0)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
384 {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
385 mp_msg(MSGT_STREAM, MSGL_WARN, "warning: unknown object version in DATA: 0x%04x\n",
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
386 dh->object_version);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
387 }
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
388 dh->num_packets=AV_RB32(&data[10]);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
389 dh->next_data_header=AV_RB32(&data[14]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
390
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
391 return dh;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
392 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
393
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
394 rmff_header_t *rmff_scan_header(const char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
395
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
396 rmff_header_t *header=malloc(sizeof(rmff_header_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
397 rmff_mdpr_t *mdpr=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
398 int chunk_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
399 uint32_t chunk_type;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
400 const char *ptr=data;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
401 int i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
402
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
403 header->fileheader=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
404 header->prop=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
405 header->cont=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
406 header->data=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
407
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
408 chunk_type = AV_RB32(ptr);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
409 if (chunk_type != RMF_TAG)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
410 {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
411 mp_msg(MSGT_STREAM, MSGL_ERR, "rmff: not an real media file header (.RMF tag not found).\n");
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
412 free(header);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
413 return NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
414 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
415 header->fileheader=rmff_scan_fileheader(ptr);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
416 ptr += header->fileheader->size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
417
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
418 header->streams=malloc(sizeof(rmff_mdpr_t*)*(header->fileheader->num_headers));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
419 for (i=0; i<header->fileheader->num_headers; i++) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
420 header->streams[i]=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
421 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
422
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
423 for (i=1; i<header->fileheader->num_headers; i++) {
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
424 chunk_type = AV_RB32(ptr);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
425
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
426 if (ptr[0] == 0)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
427 {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
428 mp_msg(MSGT_STREAM, MSGL_WARN, "rmff: warning: only %d of %d header found.\n", i, header->fileheader->num_headers);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
429 break;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
430 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
431
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
432 chunk_size=1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
433 switch (chunk_type) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
434 case PROP_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
435 header->prop=rmff_scan_prop(ptr);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
436 chunk_size=header->prop->size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
437 break;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
438 case MDPR_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
439 mdpr=rmff_scan_mdpr(ptr);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
440 chunk_size=mdpr->size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
441 header->streams[mdpr->stream_number]=mdpr;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
442 break;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
443 case CONT_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
444 header->cont=rmff_scan_cont(ptr);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
445 chunk_size=header->cont->size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
446 break;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
447 case DATA_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
448 header->data=rmff_scan_dataheader(ptr);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
449 chunk_size=34; /* hard coded header size */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
450 break;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
451 default:
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
452 mp_msg(MSGT_STREAM, MSGL_WARN, "unknown chunk\n");
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
453 hexdump(ptr,10);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
454 chunk_size=1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
455 break;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
456 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
457 ptr+=chunk_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
458 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
459
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
460 return header;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
461 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
462
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
463 rmff_header_t *rmff_scan_header_stream(int fd) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
464
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
465 rmff_header_t *header;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
466 char *buf=xbuffer_init(1024);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
467 int index=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
468 uint32_t chunk_type;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
469 uint32_t chunk_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
470
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
471 do {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
472 buf = xbuffer_ensure_size(buf, index+8);
10206
35e306346e59 Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
alex
parents: 9922
diff changeset
473 recv(fd, buf+index, 8, 0);
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
474 chunk_type=AV_RB32(buf+index); index+=4;
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
475 chunk_size=AV_RB32(buf+index); index+=4;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
476
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
477 switch (chunk_type) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
478 case DATA_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
479 chunk_size=18;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
480 case MDPR_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
481 case CONT_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
482 case RMF_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
483 case PROP_TAG:
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
484 buf = xbuffer_ensure_size(buf, index+chunk_size-8);
10206
35e306346e59 Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
alex
parents: 9922
diff changeset
485 recv(fd, buf+index, (chunk_size-8), 0);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
486 index+=(chunk_size-8);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
487 break;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
488 default:
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
489 mp_msg(MSGT_STREAM, MSGL_WARN, "rmff_scan_header_stream: unknown chunk");
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
490 hexdump(buf+index-8, 8);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
491 chunk_type=DATA_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
492 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
493 } while (chunk_type != DATA_TAG);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
494
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
495 header = rmff_scan_header(buf);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
496
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
497 xbuffer_free(buf);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
498
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
499 return header;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
500 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
501
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
502 void rmff_scan_pheader(rmff_pheader_t *h, char *data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
503
22376
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
504 h->object_version=AV_RB16(data);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
505 h->length=AV_RB16(data+2);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
506 h->stream_number=AV_RB16(data+4);
6c1fe779b704 Use libavutil AV_RB/AV_WB macros instead of defining out own variants.
reimar
parents: 20711
diff changeset
507 h->timestamp=AV_RB32(data+6);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
508 h->reserved=(uint8_t)data[10];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
509 h->flags=(uint8_t)data[11];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
510 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
511
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
512 rmff_fileheader_t *rmff_new_fileheader(uint32_t num_headers) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
513
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
514 rmff_fileheader_t *fileheader=malloc(sizeof(rmff_fileheader_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
515
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
516 fileheader->object_id=RMF_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
517 fileheader->size=18;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
518 fileheader->object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
519 fileheader->file_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
520 fileheader->num_headers=num_headers;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
521
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
522 return fileheader;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
523 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
524
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
525 rmff_prop_t *rmff_new_prop (
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
526 uint32_t max_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
527 uint32_t avg_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
528 uint32_t max_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
529 uint32_t avg_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
530 uint32_t num_packets,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
531 uint32_t duration,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
532 uint32_t preroll,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
533 uint32_t index_offset,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
534 uint32_t data_offset,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
535 uint16_t num_streams,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
536 uint16_t flags ) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
537
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
538 rmff_prop_t *prop=malloc(sizeof(rmff_prop_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
539
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
540 prop->object_id=PROP_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
541 prop->size=50;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
542 prop->object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
543
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
544 prop->max_bit_rate=max_bit_rate;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
545 prop->avg_bit_rate=avg_bit_rate;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
546 prop->max_packet_size=max_packet_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
547 prop->avg_packet_size=avg_packet_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
548 prop->num_packets=num_packets;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
549 prop->duration=duration;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
550 prop->preroll=preroll;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
551 prop->index_offset=index_offset;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
552 prop->data_offset=data_offset;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
553 prop->num_streams=num_streams;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
554 prop->flags=flags;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
555
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
556 return prop;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
557 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
558
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
559 rmff_mdpr_t *rmff_new_mdpr(
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
560 uint16_t stream_number,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
561 uint32_t max_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
562 uint32_t avg_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
563 uint32_t max_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
564 uint32_t avg_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
565 uint32_t start_time,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
566 uint32_t preroll,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
567 uint32_t duration,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
568 const char *stream_name,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
569 const char *mime_type,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
570 uint32_t type_specific_len,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
571 const char *type_specific_data ) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
572
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
573 rmff_mdpr_t *mdpr=malloc(sizeof(rmff_mdpr_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
574
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
575 mdpr->object_id=MDPR_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
576 mdpr->object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
577
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
578 mdpr->stream_number=stream_number;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
579 mdpr->max_bit_rate=max_bit_rate;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
580 mdpr->avg_bit_rate=avg_bit_rate;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
581 mdpr->max_packet_size=max_packet_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
582 mdpr->avg_packet_size=avg_packet_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
583 mdpr->start_time=start_time;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
584 mdpr->preroll=preroll;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
585 mdpr->duration=duration;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
586 mdpr->stream_name_size=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
587 if (stream_name) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
588 mdpr->stream_name=strdup(stream_name);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
589 mdpr->stream_name_size=strlen(stream_name);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
590 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
591 mdpr->mime_type_size=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
592 if (mime_type) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
593 mdpr->mime_type=strdup(mime_type);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
594 mdpr->mime_type_size=strlen(mime_type);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
595 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
596 mdpr->type_specific_len=type_specific_len;
19070
16990c298b7b more sizeof(char) fun
reynaldo
parents: 10206
diff changeset
597 mdpr->type_specific_data=malloc(type_specific_len);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
598 memcpy(mdpr->type_specific_data,type_specific_data,type_specific_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
599 mdpr->mlti_data=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
600
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
601 mdpr->size=mdpr->stream_name_size+mdpr->mime_type_size+mdpr->type_specific_len+46;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
602
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
603 return mdpr;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
604 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
605
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
606 rmff_cont_t *rmff_new_cont(const char *title, const char *author, const char *copyright, const char *comment) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
607
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
608 rmff_cont_t *cont=malloc(sizeof(rmff_cont_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
609
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
610 cont->object_id=CONT_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
611 cont->object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
612
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
613 cont->title=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
614 cont->author=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
615 cont->copyright=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
616 cont->comment=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
617
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
618 cont->title_len=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
619 cont->author_len=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
620 cont->copyright_len=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
621 cont->comment_len=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
622
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
623 if (title) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
624 cont->title_len=strlen(title);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
625 cont->title=strdup(title);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
626 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
627 if (author) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
628 cont->author_len=strlen(author);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
629 cont->author=strdup(author);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
630 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
631 if (copyright) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
632 cont->copyright_len=strlen(copyright);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
633 cont->copyright=strdup(copyright);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
634 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
635 if (comment) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
636 cont->comment_len=strlen(comment);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
637 cont->comment=strdup(comment);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
638 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
639 cont->size=cont->title_len+cont->author_len+cont->copyright_len+cont->comment_len+18;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
640
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
641 return cont;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
642 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
643
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
644 rmff_data_t *rmff_new_dataheader(uint32_t num_packets, uint32_t next_data_header) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
645
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
646 rmff_data_t *data=malloc(sizeof(rmff_data_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
647
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
648 data->object_id=DATA_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
649 data->size=18;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
650 data->object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
651 data->num_packets=num_packets;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
652 data->next_data_header=next_data_header;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
653
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
654 return data;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
655 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
656
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
657 void rmff_print_header(rmff_header_t *h) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
658
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
659 rmff_mdpr_t **stream;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
660
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
661 if(!h) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
662 printf("rmff_print_header: NULL given\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
663 return;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
664 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
665 if(h->fileheader)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
666 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
667 printf("\nFILE:\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
668 printf("file version : %d\n", h->fileheader->file_version);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
669 printf("number of headers : %d\n", h->fileheader->num_headers);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
670 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
671 if(h->cont)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
672 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
673 printf("\nCONTENT:\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
674 printf("title : %s\n", h->cont->title);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
675 printf("author : %s\n", h->cont->author);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
676 printf("copyright : %s\n", h->cont->copyright);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
677 printf("comment : %s\n", h->cont->comment);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
678 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
679 if(h->prop)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
680 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
681 printf("\nSTREAM PROPERTIES:\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
682 printf("bit rate (max/avg) : %i/%i\n", h->prop->max_bit_rate, h->prop->avg_bit_rate);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
683 printf("packet size (max/avg) : %i/%i bytes\n", h->prop->max_packet_size, h->prop->avg_packet_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
684 printf("packets : %i\n", h->prop->num_packets);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
685 printf("duration : %i ms\n", h->prop->duration);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
686 printf("pre-buffer : %i ms\n", h->prop->preroll);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
687 printf("index offset : %i bytes\n", h->prop->index_offset);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
688 printf("data offset : %i bytes\n", h->prop->data_offset);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
689 printf("media streams : %i\n", h->prop->num_streams);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
690 printf("flags : ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
691 if (h->prop->flags & PN_SAVE_ENABLED) printf("save_enabled ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
692 if (h->prop->flags & PN_PERFECT_PLAY_ENABLED) printf("perfect_play_enabled ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
693 if (h->prop->flags & PN_LIVE_BROADCAST) printf("live_broadcast ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
694 printf("\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
695 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
696 stream=h->streams;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
697 if(stream)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
698 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
699 while (*stream)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
700 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
701 printf("\nSTREAM %i:\n", (*stream)->stream_number);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
702 printf("stream name [mime type] : %s [%s]\n", (*stream)->stream_name, (*stream)->mime_type);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
703 printf("bit rate (max/avg) : %i/%i\n", (*stream)->max_bit_rate, (*stream)->avg_bit_rate);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
704 printf("packet size (max/avg) : %i/%i bytes\n", (*stream)->max_packet_size, (*stream)->avg_packet_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
705 printf("start time : %i\n", (*stream)->start_time);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
706 printf("pre-buffer : %i ms\n", (*stream)->preroll);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
707 printf("duration : %i ms\n", (*stream)->duration);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
708 printf("type specific data:\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
709 hexdump((*stream)->type_specific_data, (*stream)->type_specific_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
710 stream++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
711 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
712 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
713 if(h->data)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
714 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
715 printf("\nDATA:\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
716 printf("size : %i\n", h->data->size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
717 printf("packets : %i\n", h->data->num_packets);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
718 printf("next DATA : 0x%08x\n", h->data->next_data_header);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
719 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
720 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
721
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
722 void rmff_fix_header(rmff_header_t *h) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
723
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
724 int num_headers=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
725 int header_size=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
726 rmff_mdpr_t **streams;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
727 int num_streams=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
728
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
729 if (!h) {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
730 mp_msg(MSGT_STREAM, MSGL_ERR, "rmff_fix_header: fatal: no header given.\n");
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
731 return;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
732 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
733
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
734 if (!h->streams) {
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
735 mp_msg(MSGT_STREAM, MSGL_WARN, "rmff_fix_header: warning: no MDPR chunks\n");
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
736 } else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
737 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
738 streams=h->streams;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
739 while (*streams)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
740 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
741 num_streams++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
742 num_headers++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
743 header_size+=(*streams)->size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
744 streams++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
745 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
746 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
747
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
748 if (h->prop) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
749 if (h->prop->size != 50)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
750 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
751 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
752 printf("rmff_fix_header: correcting prop.size from %i to %i\n", h->prop->size, 50);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
753 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
754 h->prop->size=50;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
755 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
756 if (h->prop->num_streams != num_streams)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
757 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
758 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
759 printf("rmff_fix_header: correcting prop.num_streams from %i to %i\n", h->prop->num_streams, num_streams);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
760 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
761 h->prop->num_streams=num_streams;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
762 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
763 num_headers++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
764 header_size+=50;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
765 } else
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
766 mp_msg(MSGT_STREAM, MSGL_WARN, "rmff_fix_header: warning: no PROP chunk.\n");
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
767
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
768 if (h->cont) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
769 num_headers++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
770 header_size+=h->cont->size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
771 } else
20711
de8bbed6c79e printf->mp_msg
rtogni
parents: 19271
diff changeset
772 mp_msg(MSGT_STREAM, MSGL_WARN, "rmff_fix_header: warning: no CONT chunk.\n");
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
773
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
774 if (!h->data) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
775 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
776 printf("rmff_fix_header: no DATA chunk, creating one\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
777 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
778 h->data=malloc(sizeof(rmff_data_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
779 h->data->object_id=DATA_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
780 h->data->object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
781 h->data->size=34;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
782 h->data->num_packets=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
783 h->data->next_data_header=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
784 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
785 num_headers++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
786
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
787
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
788 if (!h->fileheader) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
789 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
790 printf("rmff_fix_header: no fileheader, creating one");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
791 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
792 h->fileheader=malloc(sizeof(rmff_fileheader_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
793 h->fileheader->object_id=RMF_TAG;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
794 h->fileheader->size=34;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
795 h->fileheader->object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
796 h->fileheader->file_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
797 h->fileheader->num_headers=num_headers+1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
798 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
799 header_size+=h->fileheader->size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
800 num_headers++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
801
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
802 if(h->fileheader->num_headers != num_headers) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
803 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
804 printf("rmff_fix_header: setting num_headers from %i to %i\n", h->fileheader->num_headers, num_headers);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
805 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
806 h->fileheader->num_headers=num_headers;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
807 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
808
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
809 if(h->prop) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
810 if (h->prop->data_offset != header_size) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
811 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
812 printf("rmff_fix_header: setting prop.data_offset from %i to %i\n", h->prop->data_offset, header_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
813 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
814 h->prop->data_offset=header_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
815 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
816 if (h->prop->num_packets == 0) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
817 int p=(int)(h->prop->avg_bit_rate/8.0*(h->prop->duration/1000.0)/h->prop->avg_packet_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
818 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
819 printf("rmff_fix_header: assuming prop.num_packets=%i\n", p);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
820 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
821 h->prop->num_packets=p;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
822 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
823 if (h->data->num_packets == 0) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
824 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
825 printf("rmff_fix_header: assuming data.num_packets=%i\n", h->prop->num_packets);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
826 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
827 h->data->num_packets=h->prop->num_packets;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
828 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
829
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
830 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
831 printf("rmff_fix_header: assuming data.size=%i\n", h->prop->num_packets*h->prop->avg_packet_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
832 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
833 h->data->size=h->prop->num_packets*h->prop->avg_packet_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
834 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
835 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
836
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
837 int rmff_get_header_size(rmff_header_t *h) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
838
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
839 if (!h) return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
840 if (!h->prop) return -1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
841
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
842 return h->prop->data_offset+18;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
843
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
844 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
845
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
846 void rmff_free_header(rmff_header_t *h) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
847
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
848 if (!h) return;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
849
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
850 if (h->fileheader) free(h->fileheader);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
851 if (h->prop) free(h->prop);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
852 if (h->data) free(h->data);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
853 if (h->cont)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
854 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
855 free(h->cont->title);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
856 free(h->cont->author);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
857 free(h->cont->copyright);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
858 free(h->cont->comment);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
859 free(h->cont);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
860 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
861 if (h->streams)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
862 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
863 rmff_mdpr_t **s=h->streams;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
864
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
865 while(*s) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
866 free((*s)->stream_name);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
867 free((*s)->mime_type);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
868 free((*s)->type_specific_data);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
869 free(*s);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
870 s++;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
871 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
872 free(h->streams);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
873 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
874 free(h);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
875 }