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