annotate libmpdemux/realrtsp/real.c @ 19074:d385666efa27

removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
author reynaldo
date Fri, 14 Jul 2006 06:26:31 +0000
parents 16990c298b7b
children ed6ca050bba5
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 real.c,v 1.8 2003/03/30 17:11:50
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 * special functions for real streams.
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
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
30 #include <stdio.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
31 #include <string.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
32
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
33 #include "../config.h"
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
34 #include "../bswap.h"
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
35 #include "real.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
36 #include "asmrp.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
37 #include "sdpplin.h"
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
38 #include "xbuffer.h"
9922
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 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
41 #define LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
42 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
43
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
44 const unsigned char xor_table[] = {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
45 0x05, 0x18, 0x74, 0xd0, 0x0d, 0x09, 0x02, 0x53,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
46 0xc0, 0x01, 0x05, 0x05, 0x67, 0x03, 0x19, 0x70,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
47 0x08, 0x27, 0x66, 0x10, 0x10, 0x72, 0x08, 0x09,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
48 0x63, 0x11, 0x03, 0x71, 0x08, 0x08, 0x70, 0x02,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
49 0x10, 0x57, 0x05, 0x18, 0x54, 0x00, 0x00, 0x00 };
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
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
52 #define BE_32C(x,y) (*((uint32_t*)(x))=be2me_32(y))
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
53
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
54 #define BE_16(x) be2me_16(*(uint16_t*)(x))
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
55
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
56 #define BE_32(x) be2me_32(*(uint32_t*)(x))
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
57
12845
5c83c247bad1 no redefinition, clashes with OpenBSD
alex
parents: 12271
diff changeset
58 #ifndef MAX
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
59 #define MAX(x,y) ((x>y) ? x : y)
12845
5c83c247bad1 no redefinition, clashes with OpenBSD
alex
parents: 12271
diff changeset
60 #endif
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
61
18792
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
62 #define BUF_SIZE 4096
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
63
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
64 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
65 static void hexdump (const char *buf, int length) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
66
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
67 int i;
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 printf (" hexdump> ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
70 for (i = 0; i < length; i++) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
71 unsigned char c = buf[i];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
72
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
73 printf ("%02x", c);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
74
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
75 if ((i % 16) == 15)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
76 printf ("\n ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
77
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
78 if ((i % 2) == 1)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
79 printf (" ");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
80
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
81 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
82 printf ("\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
83 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
84 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
85
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
86
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
87 static void hash(char *field, char *param) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
88
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
89 uint32_t a, b, c, d;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
90
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
91
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
92 /* fill variables */
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
93 a= le2me_32(*(uint32_t*)(field));
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
94 b= le2me_32(*(uint32_t*)(field+4));
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
95 c= le2me_32(*(uint32_t*)(field+8));
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
96 d= le2me_32(*(uint32_t*)(field+12));
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
97
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
98 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
99 printf("real: hash input: %x %x %x %x\n", a, b, c, d);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
100 printf("real: hash parameter:\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
101 hexdump(param, 64);
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
102 printf("real: hash field:\n");
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
103 hexdump(field, 64+24);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
104 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
105
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
106 a = ((b & c) | (~b & d)) + le2me_32(*((uint32_t*)(param+0x00))) + a - 0x28955B88;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
107 a = ((a << 0x07) | (a >> 0x19)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
108 d = ((a & b) | (~a & c)) + le2me_32(*((uint32_t*)(param+0x04))) + d - 0x173848AA;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
109 d = ((d << 0x0c) | (d >> 0x14)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
110 c = ((d & a) | (~d & b)) + le2me_32(*((uint32_t*)(param+0x08))) + c + 0x242070DB;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
111 c = ((c << 0x11) | (c >> 0x0f)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
112 b = ((c & d) | (~c & a)) + le2me_32(*((uint32_t*)(param+0x0c))) + b - 0x3E423112;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
113 b = ((b << 0x16) | (b >> 0x0a)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
114 a = ((b & c) | (~b & d)) + le2me_32(*((uint32_t*)(param+0x10))) + a - 0x0A83F051;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
115 a = ((a << 0x07) | (a >> 0x19)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
116 d = ((a & b) | (~a & c)) + le2me_32(*((uint32_t*)(param+0x14))) + d + 0x4787C62A;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
117 d = ((d << 0x0c) | (d >> 0x14)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
118 c = ((d & a) | (~d & b)) + le2me_32(*((uint32_t*)(param+0x18))) + c - 0x57CFB9ED;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
119 c = ((c << 0x11) | (c >> 0x0f)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
120 b = ((c & d) | (~c & a)) + le2me_32(*((uint32_t*)(param+0x1c))) + b - 0x02B96AFF;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
121 b = ((b << 0x16) | (b >> 0x0a)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
122 a = ((b & c) | (~b & d)) + le2me_32(*((uint32_t*)(param+0x20))) + a + 0x698098D8;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
123 a = ((a << 0x07) | (a >> 0x19)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
124 d = ((a & b) | (~a & c)) + le2me_32(*((uint32_t*)(param+0x24))) + d - 0x74BB0851;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
125 d = ((d << 0x0c) | (d >> 0x14)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
126 c = ((d & a) | (~d & b)) + le2me_32(*((uint32_t*)(param+0x28))) + c - 0x0000A44F;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
127 c = ((c << 0x11) | (c >> 0x0f)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
128 b = ((c & d) | (~c & a)) + le2me_32(*((uint32_t*)(param+0x2C))) + b - 0x76A32842;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
129 b = ((b << 0x16) | (b >> 0x0a)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
130 a = ((b & c) | (~b & d)) + le2me_32(*((uint32_t*)(param+0x30))) + a + 0x6B901122;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
131 a = ((a << 0x07) | (a >> 0x19)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
132 d = ((a & b) | (~a & c)) + le2me_32(*((uint32_t*)(param+0x34))) + d - 0x02678E6D;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
133 d = ((d << 0x0c) | (d >> 0x14)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
134 c = ((d & a) | (~d & b)) + le2me_32(*((uint32_t*)(param+0x38))) + c - 0x5986BC72;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
135 c = ((c << 0x11) | (c >> 0x0f)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
136 b = ((c & d) | (~c & a)) + le2me_32(*((uint32_t*)(param+0x3c))) + b + 0x49B40821;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
137 b = ((b << 0x16) | (b >> 0x0a)) + c;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
138
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
139 a = ((b & d) | (~d & c)) + le2me_32(*((uint32_t*)(param+0x04))) + a - 0x09E1DA9E;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
140 a = ((a << 0x05) | (a >> 0x1b)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
141 d = ((a & c) | (~c & b)) + le2me_32(*((uint32_t*)(param+0x18))) + d - 0x3FBF4CC0;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
142 d = ((d << 0x09) | (d >> 0x17)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
143 c = ((d & b) | (~b & a)) + le2me_32(*((uint32_t*)(param+0x2c))) + c + 0x265E5A51;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
144 c = ((c << 0x0e) | (c >> 0x12)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
145 b = ((c & a) | (~a & d)) + le2me_32(*((uint32_t*)(param+0x00))) + b - 0x16493856;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
146 b = ((b << 0x14) | (b >> 0x0c)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
147 a = ((b & d) | (~d & c)) + le2me_32(*((uint32_t*)(param+0x14))) + a - 0x29D0EFA3;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
148 a = ((a << 0x05) | (a >> 0x1b)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
149 d = ((a & c) | (~c & b)) + le2me_32(*((uint32_t*)(param+0x28))) + d + 0x02441453;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
150 d = ((d << 0x09) | (d >> 0x17)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
151 c = ((d & b) | (~b & a)) + le2me_32(*((uint32_t*)(param+0x3c))) + c - 0x275E197F;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
152 c = ((c << 0x0e) | (c >> 0x12)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
153 b = ((c & a) | (~a & d)) + le2me_32(*((uint32_t*)(param+0x10))) + b - 0x182C0438;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
154 b = ((b << 0x14) | (b >> 0x0c)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
155 a = ((b & d) | (~d & c)) + le2me_32(*((uint32_t*)(param+0x24))) + a + 0x21E1CDE6;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
156 a = ((a << 0x05) | (a >> 0x1b)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
157 d = ((a & c) | (~c & b)) + le2me_32(*((uint32_t*)(param+0x38))) + d - 0x3CC8F82A;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
158 d = ((d << 0x09) | (d >> 0x17)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
159 c = ((d & b) | (~b & a)) + le2me_32(*((uint32_t*)(param+0x0c))) + c - 0x0B2AF279;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
160 c = ((c << 0x0e) | (c >> 0x12)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
161 b = ((c & a) | (~a & d)) + le2me_32(*((uint32_t*)(param+0x20))) + b + 0x455A14ED;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
162 b = ((b << 0x14) | (b >> 0x0c)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
163 a = ((b & d) | (~d & c)) + le2me_32(*((uint32_t*)(param+0x34))) + a - 0x561C16FB;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
164 a = ((a << 0x05) | (a >> 0x1b)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
165 d = ((a & c) | (~c & b)) + le2me_32(*((uint32_t*)(param+0x08))) + d - 0x03105C08;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
166 d = ((d << 0x09) | (d >> 0x17)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
167 c = ((d & b) | (~b & a)) + le2me_32(*((uint32_t*)(param+0x1c))) + c + 0x676F02D9;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
168 c = ((c << 0x0e) | (c >> 0x12)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
169 b = ((c & a) | (~a & d)) + le2me_32(*((uint32_t*)(param+0x30))) + b - 0x72D5B376;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
170 b = ((b << 0x14) | (b >> 0x0c)) + c;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
171
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
172 a = (b ^ c ^ d) + le2me_32(*((uint32_t*)(param+0x14))) + a - 0x0005C6BE;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
173 a = ((a << 0x04) | (a >> 0x1c)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
174 d = (a ^ b ^ c) + le2me_32(*((uint32_t*)(param+0x20))) + d - 0x788E097F;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
175 d = ((d << 0x0b) | (d >> 0x15)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
176 c = (d ^ a ^ b) + le2me_32(*((uint32_t*)(param+0x2c))) + c + 0x6D9D6122;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
177 c = ((c << 0x10) | (c >> 0x10)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
178 b = (c ^ d ^ a) + le2me_32(*((uint32_t*)(param+0x38))) + b - 0x021AC7F4;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
179 b = ((b << 0x17) | (b >> 0x09)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
180 a = (b ^ c ^ d) + le2me_32(*((uint32_t*)(param+0x04))) + a - 0x5B4115BC;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
181 a = ((a << 0x04) | (a >> 0x1c)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
182 d = (a ^ b ^ c) + le2me_32(*((uint32_t*)(param+0x10))) + d + 0x4BDECFA9;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
183 d = ((d << 0x0b) | (d >> 0x15)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
184 c = (d ^ a ^ b) + le2me_32(*((uint32_t*)(param+0x1c))) + c - 0x0944B4A0;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
185 c = ((c << 0x10) | (c >> 0x10)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
186 b = (c ^ d ^ a) + le2me_32(*((uint32_t*)(param+0x28))) + b - 0x41404390;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
187 b = ((b << 0x17) | (b >> 0x09)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
188 a = (b ^ c ^ d) + le2me_32(*((uint32_t*)(param+0x34))) + a + 0x289B7EC6;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
189 a = ((a << 0x04) | (a >> 0x1c)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
190 d = (a ^ b ^ c) + le2me_32(*((uint32_t*)(param+0x00))) + d - 0x155ED806;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
191 d = ((d << 0x0b) | (d >> 0x15)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
192 c = (d ^ a ^ b) + le2me_32(*((uint32_t*)(param+0x0c))) + c - 0x2B10CF7B;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
193 c = ((c << 0x10) | (c >> 0x10)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
194 b = (c ^ d ^ a) + le2me_32(*((uint32_t*)(param+0x18))) + b + 0x04881D05;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
195 b = ((b << 0x17) | (b >> 0x09)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
196 a = (b ^ c ^ d) + le2me_32(*((uint32_t*)(param+0x24))) + a - 0x262B2FC7;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
197 a = ((a << 0x04) | (a >> 0x1c)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
198 d = (a ^ b ^ c) + le2me_32(*((uint32_t*)(param+0x30))) + d - 0x1924661B;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
199 d = ((d << 0x0b) | (d >> 0x15)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
200 c = (d ^ a ^ b) + le2me_32(*((uint32_t*)(param+0x3c))) + c + 0x1fa27cf8;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
201 c = ((c << 0x10) | (c >> 0x10)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
202 b = (c ^ d ^ a) + le2me_32(*((uint32_t*)(param+0x08))) + b - 0x3B53A99B;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
203 b = ((b << 0x17) | (b >> 0x09)) + c;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
204
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
205 a = ((~d | b) ^ c) + le2me_32(*((uint32_t*)(param+0x00))) + a - 0x0BD6DDBC;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
206 a = ((a << 0x06) | (a >> 0x1a)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
207 d = ((~c | a) ^ b) + le2me_32(*((uint32_t*)(param+0x1c))) + d + 0x432AFF97;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
208 d = ((d << 0x0a) | (d >> 0x16)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
209 c = ((~b | d) ^ a) + le2me_32(*((uint32_t*)(param+0x38))) + c - 0x546BDC59;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
210 c = ((c << 0x0f) | (c >> 0x11)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
211 b = ((~a | c) ^ d) + le2me_32(*((uint32_t*)(param+0x14))) + b - 0x036C5FC7;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
212 b = ((b << 0x15) | (b >> 0x0b)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
213 a = ((~d | b) ^ c) + le2me_32(*((uint32_t*)(param+0x30))) + a + 0x655B59C3;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
214 a = ((a << 0x06) | (a >> 0x1a)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
215 d = ((~c | a) ^ b) + le2me_32(*((uint32_t*)(param+0x0C))) + d - 0x70F3336E;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
216 d = ((d << 0x0a) | (d >> 0x16)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
217 c = ((~b | d) ^ a) + le2me_32(*((uint32_t*)(param+0x28))) + c - 0x00100B83;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
218 c = ((c << 0x0f) | (c >> 0x11)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
219 b = ((~a | c) ^ d) + le2me_32(*((uint32_t*)(param+0x04))) + b - 0x7A7BA22F;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
220 b = ((b << 0x15) | (b >> 0x0b)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
221 a = ((~d | b) ^ c) + le2me_32(*((uint32_t*)(param+0x20))) + a + 0x6FA87E4F;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
222 a = ((a << 0x06) | (a >> 0x1a)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
223 d = ((~c | a) ^ b) + le2me_32(*((uint32_t*)(param+0x3c))) + d - 0x01D31920;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
224 d = ((d << 0x0a) | (d >> 0x16)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
225 c = ((~b | d) ^ a) + le2me_32(*((uint32_t*)(param+0x18))) + c - 0x5CFEBCEC;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
226 c = ((c << 0x0f) | (c >> 0x11)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
227 b = ((~a | c) ^ d) + le2me_32(*((uint32_t*)(param+0x34))) + b + 0x4E0811A1;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
228 b = ((b << 0x15) | (b >> 0x0b)) + c;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
229 a = ((~d | b) ^ c) + le2me_32(*((uint32_t*)(param+0x10))) + a - 0x08AC817E;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
230 a = ((a << 0x06) | (a >> 0x1a)) + b;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
231 d = ((~c | a) ^ b) + le2me_32(*((uint32_t*)(param+0x2c))) + d - 0x42C50DCB;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
232 d = ((d << 0x0a) | (d >> 0x16)) + a;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
233 c = ((~b | d) ^ a) + le2me_32(*((uint32_t*)(param+0x08))) + c + 0x2AD7D2BB;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
234 c = ((c << 0x0f) | (c >> 0x11)) + d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
235 b = ((~a | c) ^ d) + le2me_32(*((uint32_t*)(param+0x24))) + b - 0x14792C6F;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
236 b = ((b << 0x15) | (b >> 0x0b)) + c;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
237
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
238 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
239 printf("real: hash output: %x %x %x %x\n", a, b, c, d);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
240 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
241
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
242 a += le2me_32(*((uint32_t *)(field+0)));
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
243 *((uint32_t *)(field+0)) = le2me_32(a);
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
244 b += le2me_32(*((uint32_t *)(field+4)));
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
245 *((uint32_t *)(field+4)) = le2me_32(b);
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
246 c += le2me_32(*((uint32_t *)(field+8)));
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
247 *((uint32_t *)(field+8)) = le2me_32(c);
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
248 d += le2me_32(*((uint32_t *)(field+12)));
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
249 *((uint32_t *)(field+12)) = le2me_32(d);
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
250
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
251 #ifdef LOG
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
252 printf("real: hash field:\n");
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
253 hexdump(field, 64+24);
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
254 #endif
9922
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
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
257 static void call_hash (char *key, char *challenge, int len) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
258
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
259 uint32_t *ptr1, *ptr2;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
260 uint32_t a, b, c, d;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
261 uint32_t tmp;
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
262
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
263 ptr1=(uint32_t*)(key+16);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
264 ptr2=(uint32_t*)(key+20);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
265
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
266 a = le2me_32(*ptr1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
267 b = (a >> 3) & 0x3f;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
268 a += len * 8;
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
269 *ptr1 = le2me_32(a);
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 if (a < (len << 3))
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 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
274 printf("not verified: (len << 3) > a true\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
275 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
276 ptr2 += 4;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
277 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
278
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
279 tmp = le2me_32(*ptr2);
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
280 tmp += (len >> 0x1d);
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
281 *ptr2 = le2me_32(tmp);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
282 a = 64 - b;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
283 c = 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
284 if (a <= len)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
285 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
286
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
287 memcpy(key+b+24, challenge, a);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
288 hash(key, key+24);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
289 c = a;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
290 d = c + 0x3f;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
291
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
292 while ( d < len ) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
293
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
294 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
295 printf("not verified: while ( d < len )\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
296 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
297 hash(key, challenge+d-0x3f);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
298 d += 64;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
299 c += 64;
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 b = 0;
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
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
304 memcpy(key+b+24, challenge+c, len-c);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
305 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
306
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
307 static void calc_response (char *result, char *field) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
308
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
309 char buf1[128];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
310 char buf2[128];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
311 int i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
312
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
313 memset (buf1, 0, 64);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
314 *buf1 = 128;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
315
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
316 memcpy (buf2, field+16, 8);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
317
10115
0ddf649cff61 Bigendian fix, with help from Viktor Rosenfeld
rtognimp
parents: 9922
diff changeset
318 i = ( le2me_32(*((uint32_t*)(buf2))) >> 3 ) & 0x3f;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
319
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
320 if (i < 56) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
321 i = 56 - i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
322 } else {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
323 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
324 printf("not verified: ! (i < 56)\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
325 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
326 i = 120 - i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
327 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
328
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
329 call_hash (field, buf1, i);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
330 call_hash (field, buf2, 8);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
331
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
332 memcpy (result, field, 16);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
333
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
334 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
335
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 static void calc_response_string (char *result, char *challenge) {
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 char field[128];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
340 char zres[20];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
341 int i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
342
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
343 /* initialize our field */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
344 BE_32C (field, 0x01234567);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
345 BE_32C ((field+4), 0x89ABCDEF);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
346 BE_32C ((field+8), 0xFEDCBA98);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
347 BE_32C ((field+12), 0x76543210);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
348 BE_32C ((field+16), 0x00000000);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
349 BE_32C ((field+20), 0x00000000);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
350
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
351 /* calculate response */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
352 call_hash(field, challenge, 64);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
353 calc_response(zres,field);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
354
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
355 /* convert zres to ascii string */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
356 for (i=0; i<16; i++ ) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
357 char a, b;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
358
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
359 a = (zres[i] >> 4) & 15;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
360 b = zres[i] & 15;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
361
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
362 result[i*2] = ((a<10) ? (a+48) : (a+87)) & 255;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
363 result[i*2+1] = ((b<10) ? (b+48) : (b+87)) & 255;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
364 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
365 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
366
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
367 void real_calc_response_and_checksum (char *response, char *chksum, char *challenge) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
368
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
369 int ch_len, table_len, resp_len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
370 int i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
371 char *ptr;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
372 char buf[128];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
373
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
374 /* initialize return values */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
375 memset(response, 0, 64);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
376 memset(chksum, 0, 34);
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 /* initialize buffer */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
379 memset(buf, 0, 128);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
380 ptr=buf;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
381 BE_32C(ptr, 0xa1e9149d);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
382 ptr+=4;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
383 BE_32C(ptr, 0x0e6b3b59);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
384 ptr+=4;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
385
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
386 /* some (length) checks */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
387 if (challenge != NULL)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
388 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
389 ch_len = strlen (challenge);
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 if (ch_len == 40) /* what a hack... */
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 challenge[32]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
394 ch_len=32;
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 if ( ch_len > 56 ) ch_len=56;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
397
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
398 /* copy challenge to buf */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
399 memcpy(ptr, challenge, ch_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
400 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
401
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
402 if (xor_table != NULL)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
403 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
404 table_len = strlen(xor_table);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
405
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
406 if (table_len > 56) table_len=56;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
407
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
408 /* xor challenge bytewise with xor_table */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
409 for (i=0; i<table_len; i++)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
410 ptr[i] = ptr[i] ^ xor_table[i];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
411 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
412
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
413 calc_response_string (response, buf);
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 /* add tail */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
416 resp_len = strlen (response);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
417 strcpy (&response[resp_len], "01d0a8e3");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
418
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
419 /* calculate checksum */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
420 for (i=0; i<resp_len/4; i++)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
421 chksum[i] = response[i*4];
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
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
424
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 * takes a MLTI-Chunk and a rule number got from match_asm_rule,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
427 * returns a pointer to selected data and number of bytes in that.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
428 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
429
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
430 static int select_mlti_data(const char *mlti_chunk, int mlti_size, int selection, char **out) {
9922
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 int numrules, codec, size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
433 int i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
434
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
435 /* MLTI chunk should begin with MLTI */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
436
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
437 if ((mlti_chunk[0] != 'M')
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
438 ||(mlti_chunk[1] != 'L')
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
439 ||(mlti_chunk[2] != 'T')
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
440 ||(mlti_chunk[3] != 'I'))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
441 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
442 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
443 printf("libreal: MLTI tag not detected, copying data\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
444 #endif
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
445 *out = xbuffer_copyin(*out, 0, mlti_chunk, mlti_size);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
446 return mlti_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
447 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
448
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
449 mlti_chunk+=4;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
450
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
451 /* next 16 bits are the number of rules */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
452 numrules=BE_16(mlti_chunk);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
453 if (selection >= numrules) return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
454
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
455 /* now <numrules> indices of codecs follows */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
456 /* we skip to selection */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
457 mlti_chunk+=(selection+1)*2;
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 /* get our index */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
460 codec=BE_16(mlti_chunk);
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 /* skip to number of codecs */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
463 mlti_chunk+=(numrules-selection)*2;
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 /* get number of codecs */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
466 numrules=BE_16(mlti_chunk);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
467
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
468 if (codec >= numrules) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
469 printf("codec index >= number of codecs. %i %i\n", codec, numrules);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
470 return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
471 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
472
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
473 mlti_chunk+=2;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
474
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
475 /* now seek to selected codec */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
476 for (i=0; i<codec; i++) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
477 size=BE_32(mlti_chunk);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
478 mlti_chunk+=size+4;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
479 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
480
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
481 size=BE_32(mlti_chunk);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
482
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
483 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
484 hexdump(mlti_chunk+4, size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
485 #endif
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
486 *out = xbuffer_copyin(*out, 0, mlti_chunk+4, size);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
487 return size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
488 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
489
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
490 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
491 * looking at stream description.
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
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
494 rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidth) {
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
495
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
496 sdpplin_t *desc;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
497 rmff_header_t *header;
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
498 char *buf;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
499 int len, i;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
500 int max_bit_rate=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
501 int avg_bit_rate=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
502 int max_packet_size=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
503 int avg_packet_size=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
504 int duration=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
505
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
506
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
507 if (!data) return NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
508
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
509 desc=sdpplin_parse(data);
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 if (!desc) return NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
512
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
513 buf = xbuffer_init(2048);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
514 header=calloc(1,sizeof(rmff_header_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 header->fileheader=rmff_new_fileheader(4+desc->stream_count);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
517 header->cont=rmff_new_cont(
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
518 desc->title,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
519 desc->author,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
520 desc->copyright,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
521 desc->abstract);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
522 header->data=rmff_new_dataheader(0,0);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
523 header->streams=calloc(1,sizeof(rmff_mdpr_t*)*(desc->stream_count+1));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
524 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
525 printf("number of streams: %u\n", desc->stream_count);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
526 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
527
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
528 for (i=0; i<desc->stream_count; i++) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
529
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
530 int j=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
531 int n;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
532 char b[64];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
533 int rulematches[16];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
534
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
535 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
536 printf("calling asmrp_match with:\n%s\n%u\n", desc->stream[i]->asm_rule_book, bandwidth);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
537 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
538 n=asmrp_match(desc->stream[i]->asm_rule_book, bandwidth, rulematches);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
539 for (j=0; j<n; j++) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
540 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
541 printf("asmrp rule match: %u for stream %u\n", rulematches[j], desc->stream[i]->stream_id);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
542 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
543 sprintf(b,"stream=%u;rule=%u,", desc->stream[i]->stream_id, rulematches[j]);
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
544 *stream_rules = xbuffer_strcat(*stream_rules, b);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
545 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
546
14144
1fcb18e39ef9 Fix streaming if not mlti_data (for some non-multirate streams)
rtognimp
parents: 13676
diff changeset
547 if (!desc->stream[i]->mlti_data) {
1fcb18e39ef9 Fix streaming if not mlti_data (for some non-multirate streams)
rtognimp
parents: 13676
diff changeset
548 len = 0;
1fcb18e39ef9 Fix streaming if not mlti_data (for some non-multirate streams)
rtognimp
parents: 13676
diff changeset
549 buf = NULL;
1fcb18e39ef9 Fix streaming if not mlti_data (for some non-multirate streams)
rtognimp
parents: 13676
diff changeset
550 } else
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
551 len=select_mlti_data(desc->stream[i]->mlti_data, desc->stream[i]->mlti_data_size, rulematches[0], &buf);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
552
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
553 header->streams[i]=rmff_new_mdpr(
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
554 desc->stream[i]->stream_id,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
555 desc->stream[i]->max_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
556 desc->stream[i]->avg_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
557 desc->stream[i]->max_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
558 desc->stream[i]->avg_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
559 desc->stream[i]->start_time,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
560 desc->stream[i]->preroll,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
561 desc->stream[i]->duration,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
562 desc->stream[i]->stream_name,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
563 desc->stream[i]->mime_type,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
564 len,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
565 buf);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
566
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
567 duration=MAX(duration,desc->stream[i]->duration);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
568 max_bit_rate+=desc->stream[i]->max_bit_rate;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
569 avg_bit_rate+=desc->stream[i]->avg_bit_rate;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
570 max_packet_size=MAX(max_packet_size, desc->stream[i]->max_packet_size);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
571 if (avg_packet_size)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
572 avg_packet_size=(avg_packet_size + desc->stream[i]->avg_packet_size) / 2;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
573 else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
574 avg_packet_size=desc->stream[i]->avg_packet_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
575 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
576
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
577 if (*stream_rules && strlen(*stream_rules) && (*stream_rules)[strlen(*stream_rules)-1] == ',')
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
578 (*stream_rules)[strlen(*stream_rules)-1]=0; /* delete last ',' in stream_rules */
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
579
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
580 header->prop=rmff_new_prop(
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
581 max_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
582 avg_bit_rate,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
583 max_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
584 avg_packet_size,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
585 0,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
586 duration,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
587 0,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
588 0,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
589 0,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
590 desc->stream_count,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
591 desc->flags);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
592
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
593 rmff_fix_header(header);
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
594 buf = xbuffer_free(buf);
9922
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 return header;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
597 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
598
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
599 int real_get_rdt_chunk(rtsp_t *rtsp_session, char **buffer) {
9922
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 int n=1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
602 uint8_t header[8];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
603 rmff_pheader_t ph;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
604 int size;
11595
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
605 int flags1, flags2;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
606 int unknown1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
607 uint32_t ts;
11595
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
608 static uint32_t prev_ts = -1;
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
609 static int prev_stream_number = -1;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
610
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
611 n=rtsp_read_data(rtsp_session, header, 8);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
612 if (n<8) return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
613 if (header[0] != 0x24)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
614 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
615 printf("rdt chunk not recognized: got 0x%02x\n", header[0]);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
616 return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
617 }
13289
2cb80075204c chunk size fix from Ross Finlayson, ported from xine
diego
parents: 12845
diff changeset
618 size=(header[1]<<16)+(header[2]<<8)+(header[3]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
619 flags1=header[4];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
620 if ((flags1!=0x40)&&(flags1!=0x42))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
621 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
622 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
623 printf("got flags1: 0x%02x\n",flags1);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
624 #endif
13676
929af3b49c8e EOF detection (fix hanging at end of stream)
rtognimp
parents: 13289
diff changeset
625 if(header[6] == 0x06) {
929af3b49c8e EOF detection (fix hanging at end of stream)
rtognimp
parents: 13289
diff changeset
626 printf("Stream EOF detected\n");
929af3b49c8e EOF detection (fix hanging at end of stream)
rtognimp
parents: 13289
diff changeset
627 return -1;
929af3b49c8e EOF detection (fix hanging at end of stream)
rtognimp
parents: 13289
diff changeset
628 }
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
629 header[0]=header[5];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
630 header[1]=header[6];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
631 header[2]=header[7];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
632 n=rtsp_read_data(rtsp_session, header+3, 5);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
633 if (n<5) return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
634 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
635 printf("ignoring bytes:\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
636 hexdump(header, 8);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
637 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
638 n=rtsp_read_data(rtsp_session, header+4, 4);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
639 if (n<4) return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
640 flags1=header[4];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
641 size-=9;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
642 }
11595
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
643 flags2=header[7];
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
644 // header[5..6] == frame number in stream
13289
2cb80075204c chunk size fix from Ross Finlayson, ported from xine
diego
parents: 12845
diff changeset
645 unknown1=(header[5]<<16)+(header[6]<<8)+(header[7]);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
646 n=rtsp_read_data(rtsp_session, header, 6);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
647 if (n<6) return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
648 ts=BE_32(header);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
649
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
650 #ifdef LOG
11595
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
651 printf("ts: %u, size: %u, flags: 0x%02x, unknown values: 0x%06x 0x%02x 0x%02x\n",
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
652 ts, size, flags1, unknown1, header[4], header[5]);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
653 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
654 size+=2;
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 ph.object_version=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
657 ph.length=size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
658 ph.stream_number=(flags1>>1)&1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
659 ph.timestamp=ts;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
660 ph.reserved=0;
11595
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
661 if ((flags2&1) == 0 && (prev_ts != ts || prev_stream_number != ph.stream_number))
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
662 {
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
663 prev_ts = ts;
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
664 prev_stream_number = ph.stream_number;
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
665 ph.flags=2;
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
666 }
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
667 else
95413c6d76a0 keyframe detection support by rgselk <rgselknospam@yahoo.com>
alex
parents: 11506
diff changeset
668 ph.flags=0;
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
669 *buffer = xbuffer_ensure_size(*buffer, 12+size);
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
670 rmff_dump_pheader(&ph, *buffer);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
671 size-=12;
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
672 n=rtsp_read_data(rtsp_session, (*buffer)+12, size);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
673
12271
4adb4a3b52a2 More bounds checking fixes (thnaks to Miguel Freitas)
rtognimp
parents: 12266
diff changeset
674 return (n <= 0) ? 0 : n+12;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
675 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
676
11506
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
677 int convert_timestamp(char *str, int *sec, int *msec) {
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
678 int hh, mm, ss, ms = 0;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
679 if (sscanf(str, "%d:%d:%d.%d", &hh, &mm, &ss, &ms) < 3) {
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
680 hh = 0;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
681 if (sscanf(str, "%d:%d.%d", &mm, &ss, &ms) < 2) {
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
682 mm = 0;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
683 if (sscanf(str, "%d.%d", &ss, &ms) < 1) {
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
684 ss = 0;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
685 ms = 0;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
686 }
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
687 }
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
688 }
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
689 if (sec)
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
690 *sec = hh * 3600 + mm * 60 + ss;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
691 if (msec)
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
692 *msec = ms;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
693 return 1;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
694 }
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
695
14159
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
696 //! maximum size of the rtsp description, must be < INT_MAX
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
697 #define MAX_DESC_BUF (20 * 1024 * 1024)
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
698 rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwidth) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
699
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
700 char *description=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
701 char *session_id=NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
702 rmff_header_t *h;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
703 char *challenge1;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
704 char challenge2[64];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
705 char checksum[34];
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
706 char *subscribe;
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
707 char *buf = xbuffer_init(256);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
708 char *mrl=rtsp_get_mrl(rtsp_session);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
709 unsigned int size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
710 int status;
17332
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
711 uint32_t maxbandwidth = bandwidth;
9922
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 /* get challenge */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
714 challenge1=strdup(rtsp_search_answers(rtsp_session,"RealChallenge1"));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
715 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
716 printf("real: Challenge1: %s\n", challenge1);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
717 #endif
17332
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
718
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
719 /* set a reasonable default to get the best stream, unless bandwidth given */
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
720 if (!bandwidth)
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
721 bandwidth = 10485800;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
722
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
723 /* request stream description */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
724 rtsp_schedule_field(rtsp_session, "Accept: application/sdp");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
725 sprintf(buf, "Bandwidth: %u", bandwidth);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
726 rtsp_schedule_field(rtsp_session, buf);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
727 rtsp_schedule_field(rtsp_session, "GUID: 00000000-0000-0000-0000-000000000000");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
728 rtsp_schedule_field(rtsp_session, "RegionData: 0");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
729 rtsp_schedule_field(rtsp_session, "ClientID: Linux_2.4_6.0.9.1235_play32_RN01_EN_586");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
730 rtsp_schedule_field(rtsp_session, "SupportsMaximumASMBandwidth: 1");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
731 rtsp_schedule_field(rtsp_session, "Language: en-US");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
732 rtsp_schedule_field(rtsp_session, "Require: com.real.retain-entity-for-setup");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
733 status=rtsp_request_describe(rtsp_session,NULL);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
734
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
735 if ( status<200 || status>299 )
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
736 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
737 char *alert=rtsp_search_answers(rtsp_session,"Alert");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
738 if (alert) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
739 printf("real: got message from server:\n%s\n", alert);
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 rtsp_send_ok(rtsp_session);
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
742 buf = xbuffer_free(buf);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
743 return NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
744 }
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 /* receive description */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
747 size=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
748 if (!rtsp_search_answers(rtsp_session,"Content-length"))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
749 printf("real: got no Content-length!\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
750 else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
751 size=atoi(rtsp_search_answers(rtsp_session,"Content-length"));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
752
14159
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
753 // as size is unsigned this also catches the case (size < 0)
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
754 if (size > MAX_DESC_BUF) {
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
755 printf("real: Content-length for description too big (> %uMB)!\n",
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
756 MAX_DESC_BUF/(1024*1024) );
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
757 xbuffer_free(buf);
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
758 return NULL;
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
759 }
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
760
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
761 if (!rtsp_search_answers(rtsp_session,"ETag"))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
762 printf("real: got no ETag!\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
763 else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
764 session_id=strdup(rtsp_search_answers(rtsp_session,"ETag"));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
765
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
766 #ifdef LOG
14159
88a58f2dda55 fix security vulnerability reported by iDEFENSE
reimar
parents: 14144
diff changeset
767 printf("real: Stream description size: %u\n", size);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
768 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
769
19074
d385666efa27 removes unused parentheses lefted behind in the r19075 sizeof(char) cleanups, noticed by dalias
reynaldo
parents: 19070
diff changeset
770 description=malloc(size+1);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
771
12271
4adb4a3b52a2 More bounds checking fixes (thnaks to Miguel Freitas)
rtognimp
parents: 12266
diff changeset
772 if( rtsp_read_data(rtsp_session, description, size) <= 0) {
4adb4a3b52a2 More bounds checking fixes (thnaks to Miguel Freitas)
rtognimp
parents: 12266
diff changeset
773 buf = xbuffer_free(buf);
4adb4a3b52a2 More bounds checking fixes (thnaks to Miguel Freitas)
rtognimp
parents: 12266
diff changeset
774 return NULL;
4adb4a3b52a2 More bounds checking fixes (thnaks to Miguel Freitas)
rtognimp
parents: 12266
diff changeset
775 }
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
776 description[size]=0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
777
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
778 /* parse sdp (sdpplin) and create a header and a subscribe string */
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
779 subscribe = xbuffer_init(256);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
780 strcpy(subscribe, "Subscribe: ");
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
781 h=real_parse_sdp(description, &subscribe, bandwidth);
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
782 if (!h) {
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
783 subscribe = xbuffer_free(subscribe);
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
784 buf = xbuffer_free(buf);
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
785 return NULL;
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
786 }
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
787 rmff_fix_header(h);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
788
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("Title: %s\nCopyright: %s\nAuthor: %s\nStreams: %i\n",
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
791 h->cont->title, h->cont->copyright, h->cont->author, h->prop->num_streams);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
792 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
793
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
794 /* setup our streams */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
795 real_calc_response_and_checksum (challenge2, checksum, challenge1);
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
796 buf = xbuffer_ensure_size(buf, strlen(challenge2) + strlen(checksum) + 32);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
797 sprintf(buf, "RealChallenge2: %s, sd=%s", challenge2, checksum);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
798 rtsp_schedule_field(rtsp_session, buf);
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
799 buf = xbuffer_ensure_size(buf, strlen(session_id) + 32);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
800 sprintf(buf, "If-Match: %s", session_id);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
801 rtsp_schedule_field(rtsp_session, buf);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
802 rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
803 buf = xbuffer_ensure_size(buf, strlen(mrl) + 32);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
804 sprintf(buf, "%s/streamid=0", mrl);
18772
eb60c209a117 better RTSP RFC compliance (fixes in CSeq and TEARDOWN handling)
ben
parents: 17332
diff changeset
805 rtsp_request_setup(rtsp_session,buf,NULL);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
806
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
807 if (h->prop->num_streams > 1) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
808 rtsp_schedule_field(rtsp_session, "Transport: x-pn-tng/tcp;mode=play,rtp/avp/tcp;unicast;mode=play");
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
809 buf = xbuffer_ensure_size(buf, strlen(session_id) + 32);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
810 sprintf(buf, "If-Match: %s", session_id);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
811 rtsp_schedule_field(rtsp_session, buf);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
812
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
813 buf = xbuffer_ensure_size(buf, strlen(mrl) + 32);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
814 sprintf(buf, "%s/streamid=1", mrl);
18772
eb60c209a117 better RTSP RFC compliance (fixes in CSeq and TEARDOWN handling)
ben
parents: 17332
diff changeset
815 rtsp_request_setup(rtsp_session,buf,NULL);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
816 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
817 /* set stream parameter (bandwidth) with our subscribe string */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
818 rtsp_schedule_field(rtsp_session, subscribe);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
819 rtsp_request_setparameter(rtsp_session,NULL);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
820
17332
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
821 /* set delivery bandwidth */
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
822 if (maxbandwidth) {
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
823 sprintf(buf, "SetDeliveryBandwidth: Bandwidth=%u;BackOff=0", maxbandwidth);
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
824 rtsp_schedule_field(rtsp_session, buf);
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
825 rtsp_request_setparameter(rtsp_session,NULL);
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
826 }
88adbc28f60b This patch makes real rtsp tell the server to deliver data at specified
rtognimp
parents: 14159
diff changeset
827
11506
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
828 {
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
829 int s_ss = 0, s_ms = 0, e_ss = 0, e_ms = 0;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
830 char *str;
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
831 if ((str = rtsp_get_param(rtsp_session, "start"))) {
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
832 convert_timestamp(str, &s_ss, &s_ms);
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
833 free(str);
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
834 }
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
835 if ((str = rtsp_get_param(rtsp_session, "end"))) {
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
836 convert_timestamp(str, &e_ss, &e_ms);
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
837 free(str);
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
838 }
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
839 str = buf + sprintf(buf, s_ms ? "%s%d.%d-" : "%s%d-", "Range: npt=", s_ss, s_ms);
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
840 if (e_ss || e_ms)
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
841 sprintf(str, e_ms ? "%d.%d" : "%d", e_ss, e_ms);
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
842 }
fff1b6f1a9cc Real rtsp Range parameter (Start and End) support.
rtognimp
parents: 10115
diff changeset
843 rtsp_schedule_field(rtsp_session, buf);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
844 /* and finally send a play request */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
845 rtsp_request_play(rtsp_session,NULL);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
846
12266
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
847 subscribe = xbuffer_free(subscribe);
096072d234c6 Some sanity and bound checking
rtognimp
parents: 11595
diff changeset
848 buf = xbuffer_free(buf);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
849 return h;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
850 }
18792
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
851
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
852 struct real_rtsp_session_t *
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
853 init_real_rtsp_session (void)
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
854 {
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
855 struct real_rtsp_session_t *real_rtsp_session = NULL;
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
856
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
857 real_rtsp_session = malloc (sizeof (struct real_rtsp_session_t));
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
858 real_rtsp_session->recv = xbuffer_init (BUF_SIZE);
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
859
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
860 return real_rtsp_session;
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
861 }
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
862
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
863 void
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
864 free_real_rtsp_session (struct real_rtsp_session_t* real_session)
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
865 {
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
866 if (!real_session)
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
867 return;
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
868
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
869 xbuffer_free (real_session->recv);
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
870 free (real_session);
6a015ba5bf45 move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents: 18772
diff changeset
871 }