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