Mercurial > mplayer.hg
annotate libmpdemux/asf_mmst_streaming.c @ 16798:9d293690ecad
synced with 1.1140
author | gpoirier |
---|---|
date | Tue, 18 Oct 2005 20:26:08 +0000 |
parents | 9b41de428e7e |
children | dfbe8cd0e081 |
rev | line source |
---|---|
6092 | 1 // mmst implementation taken from the xine-mms plugin made by majormms (http://geocities.com/majormms/) |
2 // | |
3 // ported to mplayer by Abhijeet Phatak <abhijeetphatak@yahoo.com> | |
4 // date : 16 April 2002 | |
5 // | |
6 // information about the mms protocol can be find at http://get.to/sdp | |
7 // | |
8 | |
9 | |
10 #include <stdio.h> | |
11 #include <stdlib.h> | |
12 #include <string.h> | |
13 #include <unistd.h> | |
14 #include <errno.h> | |
7880 | 15 #include <inttypes.h> |
6092 | 16 |
17 #include "config.h" | |
18 | |
10281 | 19 #ifndef HAVE_WINSOCK2 |
20 #define closesocket close | |
21 #else | |
22 #include <winsock2.h> | |
23 #endif | |
24 | |
13600
a0bb374553a1
typo noticed by Shixin Zeng <shixinzeng at sjtu dot edu dot cn>
diego
parents:
12968
diff
changeset
|
25 #ifndef USE_SETLOCALE |
12675
7c5dee73a7dc
disable iconv in case setlocale is disabled - compile fix
alex
parents:
12674
diff
changeset
|
26 #undef USE_ICONV |
7c5dee73a7dc
disable iconv in case setlocale is disabled - compile fix
alex
parents:
12674
diff
changeset
|
27 #endif |
7c5dee73a7dc
disable iconv in case setlocale is disabled - compile fix
alex
parents:
12674
diff
changeset
|
28 |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
29 #ifdef USE_ICONV |
12674
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
30 #include <iconv.h> |
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
31 #ifdef USE_LANGINFO |
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
32 #include <langinfo.h> |
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
33 #endif |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
34 #endif |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
35 |
6092 | 36 #include "url.h" |
37 #include "asf.h" | |
38 | |
39 #include "stream.h" | |
40 | |
41 #include "network.h" | |
42 | |
43 #define BUF_SIZE 102400 | |
14163
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
44 #define HDR_BUF_SIZE 8192 |
15181
ed74657f25b1
Use define instead of hardcodec value for max streams number
rtognimp
parents:
15173
diff
changeset
|
45 #define MAX_STREAMS 20 |
6092 | 46 |
47 typedef struct | |
48 { | |
49 uint8_t buf[BUF_SIZE]; | |
50 int num_bytes; | |
51 | |
52 } command_t; | |
53 | |
7880 | 54 static int seq_num; |
55 static int num_stream_ids; | |
15181
ed74657f25b1
Use define instead of hardcodec value for max streams number
rtognimp
parents:
15173
diff
changeset
|
56 static int stream_ids[MAX_STREAMS]; |
6092 | 57 |
58 static int get_data (int s, char *buf, size_t count); | |
59 | |
60 static void put_32 (command_t *cmd, uint32_t value) | |
61 { | |
62 cmd->buf[cmd->num_bytes ] = value % 256; | |
63 value = value >> 8; | |
64 cmd->buf[cmd->num_bytes+1] = value % 256 ; | |
65 value = value >> 8; | |
66 cmd->buf[cmd->num_bytes+2] = value % 256 ; | |
67 value = value >> 8; | |
68 cmd->buf[cmd->num_bytes+3] = value % 256 ; | |
69 | |
70 cmd->num_bytes += 4; | |
71 } | |
72 | |
73 static uint32_t get_32 (unsigned char *cmd, int offset) | |
74 { | |
75 uint32_t ret; | |
76 | |
77 ret = cmd[offset] ; | |
78 ret |= cmd[offset+1]<<8 ; | |
79 ret |= cmd[offset+2]<<16 ; | |
80 ret |= cmd[offset+3]<<24 ; | |
81 | |
82 return ret; | |
83 } | |
84 | |
85 static void send_command (int s, int command, uint32_t switches, | |
86 uint32_t extra, int length, | |
87 char *data) | |
88 { | |
89 command_t cmd; | |
90 int len8; | |
91 | |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
92 len8 = (length + 7) / 8; |
6092 | 93 |
94 cmd.num_bytes = 0; | |
95 | |
96 put_32 (&cmd, 0x00000001); /* start sequence */ | |
97 put_32 (&cmd, 0xB00BFACE); /* #-)) */ | |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
98 put_32 (&cmd, len8*8 + 32); |
6092 | 99 put_32 (&cmd, 0x20534d4d); /* protocol type "MMS " */ |
100 put_32 (&cmd, len8 + 4); | |
101 put_32 (&cmd, seq_num); | |
102 seq_num++; | |
103 put_32 (&cmd, 0x0); /* unknown */ | |
104 put_32 (&cmd, 0x0); | |
105 put_32 (&cmd, len8+2); | |
106 put_32 (&cmd, 0x00030000 | command); /* dir | command */ | |
107 put_32 (&cmd, switches); | |
108 put_32 (&cmd, extra); | |
109 | |
110 memcpy (&cmd.buf[48], data, length); | |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
111 if (length & 7) |
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
112 memset(&cmd.buf[48 + length], 0, 8 - (length & 7)); |
6092 | 113 |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
114 if (send (s, cmd.buf, len8*8+48, 0) != (len8*8+48)) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
115 mp_msg(MSGT_NETWORK,MSGL_ERR,"write error\n"); |
6092 | 116 } |
117 } | |
118 | |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
119 #ifdef USE_ICONV |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
120 static iconv_t url_conv; |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
121 #endif |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
122 |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
123 static void string_utf16(char *dest, char *src, int len) { |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
124 int i; |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
125 #ifdef USE_ICONV |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
126 size_t len1, len2; |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
127 char *ip, *op; |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
128 |
11412 | 129 if (url_conv != (iconv_t)(-1)) |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
130 { |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
131 memset(dest, 0, 1000); |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
132 len1 = len; len2 = 1000; |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
133 ip = src; op = dest; |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
134 |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
135 iconv(url_conv, &ip, &len1, &op, &len2); |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
136 } |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
137 else |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
138 { |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
139 #endif |
15150
38ec64821910
Make string_utf16 code behave almost the same with or without iconv
rtognimp
parents:
14542
diff
changeset
|
140 if (len > 499) len = 499; |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
141 for (i=0; i<len; i++) { |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
142 dest[i*2] = src[i]; |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
143 dest[i*2+1] = 0; |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
144 } |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
145 /* trailing zeroes */ |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
146 dest[i*2] = 0; |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
147 dest[i*2+1] = 0; |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
148 #ifdef USE_ICONV |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
149 } |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
150 #endif |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
151 } |
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
152 |
6092 | 153 static void get_answer (int s) |
154 { | |
155 char data[BUF_SIZE]; | |
156 int command = 0x1b; | |
157 | |
158 while (command == 0x1b) { | |
159 int len; | |
160 | |
10206
35e306346e59
Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
alex
parents:
10183
diff
changeset
|
161 len = recv (s, data, BUF_SIZE, 0) ; |
6092 | 162 if (!len) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
163 mp_msg(MSGT_NETWORK,MSGL_ERR,"\nalert! eof\n"); |
6092 | 164 return; |
165 } | |
166 | |
167 command = get_32 (data, 36) & 0xFFFF; | |
168 | |
169 if (command == 0x1b) | |
170 send_command (s, 0x1b, 0, 0, 0, data); | |
171 } | |
172 } | |
173 | |
174 static int get_data (int s, char *buf, size_t count) | |
175 { | |
7953 | 176 ssize_t len; |
177 size_t total = 0; | |
6092 | 178 |
179 while (total < count) { | |
180 | |
10206
35e306346e59
Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
alex
parents:
10183
diff
changeset
|
181 len = recv (s, &buf[total], count-total, 0); |
6092 | 182 |
12545 | 183 if (len<=0) { |
6092 | 184 perror ("read error:"); |
185 return 0; | |
186 } | |
187 | |
188 total += len; | |
189 | |
190 if (len != 0) { | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
191 // mp_msg(MSGT_NETWORK,MSGL_INFO,"[%d/%d]", total, count); |
6092 | 192 fflush (stdout); |
193 } | |
194 | |
195 } | |
196 | |
197 return 1; | |
198 | |
199 } | |
200 | |
201 static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl) | |
202 { | |
203 unsigned char pre_header[8]; | |
7953 | 204 int header_len; |
6092 | 205 |
206 header_len = 0; | |
207 | |
208 while (1) { | |
209 if (!get_data (s, pre_header, 8)) { | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
210 mp_msg(MSGT_NETWORK,MSGL_ERR,"pre-header read failed\n"); |
6092 | 211 return 0; |
212 } | |
213 if (pre_header[4] == 0x02) { | |
214 | |
215 int packet_len; | |
216 | |
217 packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; | |
218 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
219 // mp_msg(MSGT_NETWORK,MSGL_INFO,"asf header packet detected, len=%d\n", packet_len); |
6092 | 220 |
14163
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
221 if (packet_len < 0 || packet_len > HDR_BUF_SIZE - header_len) { |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
222 mp_msg(MSGT_NETWORK, MSGL_FATAL, "Invalid header size, giving up\n"); |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
223 return 0; |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
224 } |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
225 |
6092 | 226 if (!get_data (s, &header[header_len], packet_len)) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
227 mp_msg(MSGT_NETWORK,MSGL_ERR,"header data read failed\n"); |
6092 | 228 return 0; |
229 } | |
230 | |
231 header_len += packet_len; | |
232 | |
233 if ( (header[header_len-1] == 1) && (header[header_len-2]==1)) { | |
234 | |
235 | |
236 if( streaming_bufferize( streaming_ctrl, header, header_len )<0 ) { | |
237 return -1; | |
238 } | |
239 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
240 // mp_msg(MSGT_NETWORK,MSGL_INFO,"get header packet finished\n"); |
6092 | 241 |
242 return (header_len); | |
243 | |
244 } | |
245 | |
246 } else { | |
247 | |
7953 | 248 int32_t packet_len; |
6092 | 249 int command; |
250 char data[BUF_SIZE]; | |
251 | |
7953 | 252 if (!get_data (s, (char*)&packet_len, 4)) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
253 mp_msg(MSGT_NETWORK,MSGL_ERR,"packet_len read failed\n"); |
6092 | 254 return 0; |
255 } | |
256 | |
7953 | 257 packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; |
6092 | 258 |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
259 // mp_msg(MSGT_NETWORK,MSGL_INFO,"command packet detected, len=%d\n", packet_len); |
14163
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
260 |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
261 if (packet_len < 0 || packet_len > BUF_SIZE) { |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
262 mp_msg(MSGT_NETWORK, MSGL_FATAL, |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
263 "Invalid rtsp packet size, giving up\n"); |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
264 return 0; |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
265 } |
6092 | 266 |
267 if (!get_data (s, data, packet_len)) { | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
268 mp_msg(MSGT_NETWORK,MSGL_ERR,"command data read failed\n"); |
6092 | 269 return 0; |
270 } | |
271 | |
272 command = get_32 (data, 24) & 0xFFFF; | |
273 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
274 // mp_msg(MSGT_NETWORK,MSGL_INFO,"command: %02x\n", command); |
6092 | 275 |
276 if (command == 0x1b) | |
277 send_command (s, 0x1b, 0, 0, 0, data); | |
278 | |
279 } | |
280 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
281 // mp_msg(MSGT_NETWORK,MSGL_INFO,"get header packet succ\n"); |
6092 | 282 } |
283 } | |
284 | |
7880 | 285 static int interp_header (uint8_t *header, int header_len) |
6092 | 286 { |
287 int i; | |
7472
c4434bdf6e51
tons of warning fixes, also some 10l bugfixes, including Dominik's PVA bug
arpi
parents:
7309
diff
changeset
|
288 int packet_length=-1; |
6092 | 289 |
290 /* | |
291 * parse header | |
292 */ | |
293 | |
294 i = 30; | |
295 while (i<header_len) { | |
296 | |
297 uint64_t guid_1, guid_2, length; | |
298 | |
299 guid_2 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) | |
300 | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) | |
301 | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) | |
302 | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); | |
303 i += 8; | |
304 | |
305 guid_1 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) | |
306 | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) | |
307 | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) | |
308 | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); | |
309 i += 8; | |
310 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
311 // mp_msg(MSGT_NETWORK,MSGL_INFO,"guid found: %016llx%016llx\n", guid_1, guid_2); |
6092 | 312 |
313 length = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8) | |
314 | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24) | |
315 | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40) | |
316 | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56); | |
317 | |
318 i += 8; | |
319 | |
12121 | 320 if ( (guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22630ULL) ) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
321 mp_msg(MSGT_NETWORK,MSGL_INFO,"header object\n"); |
12121 | 322 } else if ((guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22636ULL)) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
323 mp_msg(MSGT_NETWORK,MSGL_INFO,"data object\n"); |
12121 | 324 } else if ((guid_1 == 0x6553200cc000e48eULL) && (guid_2 == 0x11cfa9478cabdca1ULL)) { |
6092 | 325 |
326 packet_length = get_32(header, i+92-24); | |
327 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
328 mp_msg(MSGT_NETWORK,MSGL_INFO,"file object, packet length = %d (%d)\n", |
6092 | 329 packet_length, get_32(header, i+96-24)); |
330 | |
331 | |
12121 | 332 } else if ((guid_1 == 0x6553200cc000e68eULL) && (guid_2 == 0x11cfa9b7b7dc0791ULL)) { |
6092 | 333 |
334 int stream_id = header[i+48] | header[i+49] << 8; | |
335 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
336 mp_msg(MSGT_NETWORK,MSGL_INFO,"stream object, stream id: %d\n", stream_id); |
6092 | 337 |
15181
ed74657f25b1
Use define instead of hardcodec value for max streams number
rtognimp
parents:
15173
diff
changeset
|
338 if (num_stream_ids < MAX_STREAMS) { |
6092 | 339 stream_ids[num_stream_ids] = stream_id; |
340 num_stream_ids++; | |
15173
424386614ad5
Fix potential buffer overflow for urls with more than 20 streams
rtognimp
parents:
15150
diff
changeset
|
341 } else { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
342 mp_msg(MSGT_NETWORK,MSGL_ERR,"too many id, stream skipped"); |
15173
424386614ad5
Fix potential buffer overflow for urls with more than 20 streams
rtognimp
parents:
15150
diff
changeset
|
343 } |
6092 | 344 |
345 } else { | |
15628 | 346 #if 0 |
347 int b = i; | |
348 printf ("unknown object (guid: %016llx, %016llx, len: %lld)\n", guid_1, guid_2, length); | |
349 for (; b < length; b++) | |
350 { | |
351 if (isascii(header[b]) || isalpha(header[b])) | |
352 printf("%c ", header[b]); | |
353 else | |
354 printf("%x ", header[b]); | |
355 } | |
356 printf("\n"); | |
357 #else | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
358 mp_msg(MSGT_NETWORK,MSGL_WARN,"unknown object\n"); |
15628 | 359 #endif |
6092 | 360 } |
361 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
362 // mp_msg(MSGT_NETWORK,MSGL_INFO,"length : %lld\n", length); |
6092 | 363 |
364 i += length-24; | |
365 | |
366 } | |
367 | |
368 return packet_length; | |
369 | |
370 } | |
371 | |
372 | |
7880 | 373 static int get_media_packet (int s, int padding, streaming_ctrl_t *stream_ctrl) { |
6092 | 374 unsigned char pre_header[8]; |
375 char data[BUF_SIZE]; | |
7880 | 376 |
377 if (!get_data (s, pre_header, 8)) { | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
378 mp_msg(MSGT_NETWORK,MSGL_ERR,"pre-header read failed\n"); |
7880 | 379 return 0; |
380 } | |
381 | |
382 // for (i=0; i<8; i++) | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
383 // mp_msg(MSGT_NETWORK,MSGL_INFO,"pre_header[%d] = %02x (%d)\n", |
7880 | 384 // i, pre_header[i], pre_header[i]); |
385 | |
386 if (pre_header[4] == 0x04) { | |
387 | |
388 int packet_len; | |
389 | |
390 packet_len = (pre_header[7] << 8 | pre_header[6]) - 8; | |
391 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
392 // mp_msg(MSGT_NETWORK,MSGL_INFO,"asf media packet detected, len=%d\n", packet_len); |
7880 | 393 |
14163
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
394 if (packet_len < 0 || packet_len > BUF_SIZE) { |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
395 mp_msg(MSGT_NETWORK, MSGL_FATAL, |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
396 "Invalid rtsp packet size, giving up\n"); |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
397 return 0; |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
398 } |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
399 |
7880 | 400 if (!get_data (s, data, packet_len)) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
401 mp_msg(MSGT_NETWORK,MSGL_ERR,"media data read failed\n"); |
7880 | 402 return 0; |
403 } | |
404 | |
405 streaming_bufferize(stream_ctrl, data, padding); | |
406 | |
407 } else { | |
408 | |
7953 | 409 int32_t packet_len; |
410 int command; | |
7880 | 411 |
7953 | 412 if (!get_data (s, (char*)&packet_len, 4)) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
413 mp_msg(MSGT_NETWORK,MSGL_ERR,"packet_len read failed\n"); |
7880 | 414 return 0; |
415 } | |
416 | |
7953 | 417 packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4; |
7880 | 418 |
14163
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
419 if (packet_len < 0 || packet_len > BUF_SIZE) { |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
420 mp_msg(MSGT_NETWORK, MSGL_FATAL, |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
421 "Invalid rtsp packet size, giving up\n"); |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
422 return 0; |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
423 } |
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
424 |
7880 | 425 if (!get_data (s, data, packet_len)) { |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
426 mp_msg(MSGT_NETWORK,MSGL_ERR,"command data read failed\n"); |
7880 | 427 return 0; |
428 } | |
429 | |
430 if ( (pre_header[7] != 0xb0) || (pre_header[6] != 0x0b) | |
431 || (pre_header[5] != 0xfa) || (pre_header[4] != 0xce) ) { | |
432 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
433 mp_msg(MSGT_NETWORK,MSGL_ERR,"missing signature\n"); |
7880 | 434 return -1; |
435 } | |
436 | |
437 command = get_32 (data, 24) & 0xFFFF; | |
438 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
439 // mp_msg(MSGT_NETWORK,MSGL_INFO,"\ncommand packet detected, len=%d cmd=0x%X\n", packet_len, command); |
7880 | 440 |
441 if (command == 0x1b) | |
442 send_command (s, 0x1b, 0, 0, 0, data); | |
443 else if (command == 0x1e) { | |
16330 | 444 mp_msg(MSGT_NETWORK,MSGL_INFO,"everything done. Thank you for downloading a media file containing proprietary and patented technology.\n"); |
7880 | 445 return 0; |
446 } | |
447 else if (command == 0x21 ) { | |
448 // Looks like it's new in WMS9 | |
449 // Unknown command, but ignoring it seems to work. | |
450 return 0; | |
451 } | |
452 else if (command != 0x05) { | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
453 mp_msg(MSGT_NETWORK,MSGL_ERR,"unknown command %02x\n", command); |
7880 | 454 return -1; |
455 } | |
456 } | |
457 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
458 // mp_msg(MSGT_NETWORK,MSGL_INFO,"get media packet succ\n"); |
7880 | 459 |
460 return 1; | |
461 } | |
6092 | 462 |
463 | |
7880 | 464 static int packet_length1; |
6092 | 465 |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
466 static int asf_mmst_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *stream_ctrl ) |
6092 | 467 { |
7880 | 468 int len; |
469 | |
470 while( stream_ctrl->buffer_size==0 ) { | |
471 // buffer is empty - fill it! | |
472 int ret = get_media_packet( fd, packet_length1, stream_ctrl); | |
473 if( ret<0 ) { | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
474 mp_msg(MSGT_NETWORK,MSGL_ERR,"get_media_packet error : %s\n",strerror(errno)); |
7880 | 475 return -1; |
12077 | 476 } else if (ret==0) //EOF? |
477 return ret; | |
7880 | 478 } |
479 | |
480 len = stream_ctrl->buffer_size-stream_ctrl->buffer_pos; | |
481 if(len>size) len=size; | |
6092 | 482 memcpy( buffer, (stream_ctrl->buffer)+(stream_ctrl->buffer_pos), len ); |
483 stream_ctrl->buffer_pos += len; | |
484 if( stream_ctrl->buffer_pos>=stream_ctrl->buffer_size ) { | |
485 free( stream_ctrl->buffer ); | |
486 stream_ctrl->buffer = NULL; | |
487 stream_ctrl->buffer_size = 0; | |
488 stream_ctrl->buffer_pos = 0; | |
489 } | |
7880 | 490 return len; |
6092 | 491 |
492 } | |
493 | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
494 static int asf_mmst_streaming_seek( int fd, off_t pos, streaming_ctrl_t *streaming_ctrl ) |
6092 | 495 { |
496 return -1; | |
7953 | 497 // Shut up gcc warning |
498 fd++; | |
499 pos++; | |
500 streaming_ctrl=NULL; | |
6092 | 501 } |
502 | |
503 int asf_mmst_streaming_start(stream_t *stream) | |
504 { | |
505 char str[1024]; | |
10183 | 506 char data[BUF_SIZE]; |
14163
dd835e8f3698
fix a problem pointed out by iDEFENSE and several similar ones.
reimar
parents:
13600
diff
changeset
|
507 uint8_t asf_header[HDR_BUF_SIZE]; |
6092 | 508 int asf_header_len; |
509 int len, i, packet_length; | |
12751 | 510 char *path, *unescpath; |
6092 | 511 URL_t *url1 = stream->streaming_ctrl->url; |
7953 | 512 int s = stream->fd; |
6092 | 513 |
7250
27a1315d6af4
Checked if the connection succeeded before writing in the socket.
bertrand
parents:
6092
diff
changeset
|
514 if( s>0 ) { |
10281 | 515 closesocket( stream->fd ); |
7250
27a1315d6af4
Checked if the connection succeeded before writing in the socket.
bertrand
parents:
6092
diff
changeset
|
516 stream->fd = -1; |
27a1315d6af4
Checked if the connection succeeded before writing in the socket.
bertrand
parents:
6092
diff
changeset
|
517 } |
27a1315d6af4
Checked if the connection succeeded before writing in the socket.
bertrand
parents:
6092
diff
changeset
|
518 |
6092 | 519 /* parse url */ |
520 path = strchr(url1->file,'/') + 1; | |
521 | |
12751 | 522 /* mmst filename are not url_escaped by MS MediaPlayer and are expected as |
523 * "plain text" by the server, so need to decode it here | |
524 */ | |
525 unescpath=malloc(strlen(path)+1); | |
526 if (!unescpath) { | |
527 mp_msg(MSGT_NETWORK,MSGL_FATAL,"Memory allocation failed!\n"); | |
528 return -1; | |
529 } | |
530 url_unescape_string(unescpath,path); | |
531 path=unescpath; | |
532 | |
533 | |
12968 | 534 if( url1->port==0 ) { |
535 url1->port=1755; | |
536 } | |
10625
620cc649f519
ftp support. The change on connect2Server is needed bcs we need 2
albeu
parents:
10281
diff
changeset
|
537 s = connect2Server( url1->hostname, url1->port, 1); |
7250
27a1315d6af4
Checked if the connection succeeded before writing in the socket.
bertrand
parents:
6092
diff
changeset
|
538 if( s<0 ) { |
12751 | 539 free(path); |
7250
27a1315d6af4
Checked if the connection succeeded before writing in the socket.
bertrand
parents:
6092
diff
changeset
|
540 return s; |
27a1315d6af4
Checked if the connection succeeded before writing in the socket.
bertrand
parents:
6092
diff
changeset
|
541 } |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
542 mp_msg(MSGT_NETWORK,MSGL_INFO,"connected\n"); |
7880 | 543 |
544 seq_num=0; | |
6092 | 545 |
546 /* | |
547 * Send the initial connect info including player version no. Client GUID (random) and the host address being connected to. | |
548 * This command is sent at the very start of protocol initiation. It sends local information to the serve | |
549 * cmd 1 0x01 | |
550 * */ | |
551 | |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
552 /* prepare for the url encoding conversion */ |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
553 #ifdef USE_ICONV |
12674
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
554 #ifdef USE_LANGINFO |
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
555 url_conv = iconv_open("UTF-16LE",nl_langinfo(CODESET)); |
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
556 #else |
14542
4a6b79a1ad52
remove all setlocale calls, they break the behaviour of sscanf and
reimar
parents:
14163
diff
changeset
|
557 url_conv = iconv_open("UTF-16LE", NULL); |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
558 #endif |
12674
0392f36045f4
user nl_langinfo if langinfo support present for proper chinese support, feature requested by Shixin Zheng <shixinzheng@sjtu.edu.cn>
alex
parents:
12545
diff
changeset
|
559 #endif |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
560 |
10183 | 561 snprintf (str, 1023, "\034\003NSPlayer/7.0.0.1956; {33715801-BAB3-9D85-24E9-03B90328270A}; Host: %s", url1->hostname); |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
562 string_utf16 (data, str, strlen(str)); |
6092 | 563 // send_command(s, commandno ....) |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
564 send_command (s, 1, 0, 0x0004000b, strlen(str)*2+2, data); |
6092 | 565 |
10206
35e306346e59
Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
alex
parents:
10183
diff
changeset
|
566 len = recv (s, data, BUF_SIZE, 0) ; |
6092 | 567 |
568 /*This sends details of the local machine IP address to a Funnel system at the server. | |
569 * Also, the TCP or UDP transport selection is sent. | |
570 * | |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
571 * here 192.168.0.1 is local ip address TCP/UDP states the tronsport we r using |
6092 | 572 * and 1037 is the local TCP or UDP socket number |
573 * cmd 2 0x02 | |
574 * */ | |
575 | |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
576 string_utf16 (&data[8], "\002\000\\\\192.168.0.1\\TCP\\1037", 24); |
6092 | 577 memset (data, 0, 8); |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
578 send_command (s, 2, 0, 0, 24*2+10, data); |
6092 | 579 |
10206
35e306346e59
Using recv/send instead read/write for proper MinGW support (it's a 4.2BSD standard). Patch by FloDt <flodt8@yahoo.de>
alex
parents:
10183
diff
changeset
|
580 len = recv (s, data, BUF_SIZE, 0) ; |
6092 | 581 |
582 /* This command sends file path (at server) and file name request to the server. | |
583 * 0x5 */ | |
584 | |
585 string_utf16 (&data[8], path, strlen(path)); | |
586 memset (data, 0, 8); | |
11225
48bb1fd37d2a
Fixing tons of 10ls. Patch by rgselk <rgselknospam@yahoo.com>
alex
parents:
10625
diff
changeset
|
587 send_command (s, 5, 0, 0, strlen(path)*2+10, data); |
12751 | 588 free(path); |
6092 | 589 |
590 get_answer (s); | |
591 | |
592 /* The ASF header chunk request. Includes ?session' variable for pre header value. | |
593 * After this command is sent, | |
594 * the server replies with 0x11 command and then the header chunk with header data follows. | |
595 * 0x15 */ | |
596 | |
597 memset (data, 0, 40); | |
598 data[32] = 2; | |
599 | |
600 send_command (s, 0x15, 1, 0, 40, data); | |
601 | |
602 num_stream_ids = 0; | |
603 /* get_headers(s, asf_header); */ | |
604 | |
605 asf_header_len = get_header (s, asf_header, stream->streaming_ctrl); | |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
606 // mp_msg(MSGT_NETWORK,MSGL_INFO,"---------------------------------- asf_header %d\n",asf_header); |
12545 | 607 if (asf_header_len==0) return -1; //error reading header |
6092 | 608 packet_length = interp_header (asf_header, asf_header_len); |
609 | |
610 | |
611 /* | |
612 * This command is the media stream MBR selector. Switches are always 6 bytes in length. | |
613 * After all switch elements, data ends with bytes [00 00] 00 20 ac 40 [02]. | |
614 * Where: | |
615 * [00 00] shows 0x61 0x00 (on the first 33 sent) or 0xff 0xff for ASF files, and with no ending data for WMV files. | |
616 * It is not yet understood what all this means. | |
617 * And the last [02] byte is probably the header ?session' value. | |
618 * | |
619 * 0x33 */ | |
620 | |
621 memset (data, 0, 40); | |
622 | |
623 for (i=1; i<num_stream_ids; i++) { | |
624 data [ (i-1) * 6 + 2 ] = 0xFF; | |
625 data [ (i-1) * 6 + 3 ] = 0xFF; | |
626 data [ (i-1) * 6 + 4 ] = stream_ids[i]; | |
627 data [ (i-1) * 6 + 5 ] = 0x00; | |
628 } | |
629 | |
630 send_command (s, 0x33, num_stream_ids, 0xFFFF | stream_ids[0] << 16, (num_stream_ids-1)*6+2 , data); | |
631 | |
632 get_answer (s); | |
633 | |
634 /* Start sending file from packet xx. | |
635 * This command is also used for resume downloads or requesting a lost packet. | |
636 * Also used for seeking by sending a play point value which seeks to the media time point. | |
637 * Includes ?session' value in pre header and the maximum media stream time. | |
638 * 0x07 */ | |
639 | |
640 memset (data, 0, 40); | |
641 | |
642 for (i=8; i<16; i++) | |
643 data[i] = 0xFF; | |
644 | |
645 data[20] = 0x04; | |
646 | |
647 send_command (s, 0x07, 1, 0xFFFF | stream_ids[0] << 16, 24, data); | |
648 | |
7880 | 649 stream->fd = s; |
650 stream->streaming_ctrl->streaming_read = asf_mmst_streaming_read; | |
651 stream->streaming_ctrl->streaming_seek = asf_mmst_streaming_seek; | |
652 stream->streaming_ctrl->buffering = 1; | |
653 stream->streaming_ctrl->status = streaming_playing_e; | |
6092 | 654 |
7880 | 655 packet_length1 = packet_length; |
15626
941b1a71351f
printf converted to mp_msg; made static many unnecessarily global symbols
nicodvb
parents:
15181
diff
changeset
|
656 mp_msg(MSGT_NETWORK,MSGL_INFO,"mmst packet_length = %d\n",packet_length); |
6092 | 657 |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
658 #ifdef USE_ICONV |
11412 | 659 if (url_conv != (iconv_t)(-1)) |
11403
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
660 iconv_close(url_conv); |
86ab7e0b2a65
fallback to non-iconv dummy utf16 conversion if iconv failed
alex
parents:
11402
diff
changeset
|
661 #endif |
11350
007ec48cf146
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
attila
parents:
11226
diff
changeset
|
662 |
6092 | 663 return 0; |
664 } |