annotate stream/asf_mmst_streaming.c @ 35092:cc8276116e95

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