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