Mercurial > audlegacy
annotate Plugins/Input/wma/libffwma/mmsh.c @ 1411:bf7fe0421354 trunk
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
author | chainsaw |
---|---|
date | Sat, 15 Jul 2006 17:03:07 -0700 |
parents | |
children | f12d7e208b43 |
rev | line source |
---|---|
1411
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
2 * Copyright (C) 2002-2003 the xine project |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
3 * |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
4 * This file is part of xine, a free video player. |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
5 * |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
6 * xine is free software; you can redistribute it and/or modify |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
9 * (at your option) any later version. |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
10 * |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
11 * xine is distributed in the hope that it will be useful, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
15 * |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
19 * |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
20 * $Id: mmsh.c,v 1.5 2006/07/13 12:32:20 shawarma Exp $ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
21 * |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
22 * MMS over HTTP protocol |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
23 * written by Thibaut Mattern |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
24 * based on mms.c and specs from avifile |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
25 * (http://avifile.sourceforge.net/asf-1.0.htm) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
26 * |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
27 * TODO: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
28 * error messages |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
29 * http support cleanup, find a way to share code with input_http.c (http.h|c) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
30 * http proxy support |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
31 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
32 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
33 #ifdef HAVE_CONFIG_H |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
34 #include "config.h" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
35 #endif |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
36 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
37 #include <unistd.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
38 #include <stdio.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
39 #include <stdlib.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
40 #include <sys/socket.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
41 #include <netinet/in.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
42 #include <netdb.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
43 #include <string.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
44 #include <sys/types.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
45 #include <sys/stat.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
46 #include <fcntl.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
47 #include <errno.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
48 #include <stdlib.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
49 #include <time.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
50 #include <assert.h> |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
51 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
52 #define LOG_MODULE "mmsh" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
53 #define LOG_VERBOSE |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
54 #ifdef DEBUG |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
55 # define lprintf printf |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
56 #else |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
57 # define lprintf(x...) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
58 #endif |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
59 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
60 #include "bswap.h" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
61 #include "mmsh.h" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
62 #include "asfheader.h" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
63 #include "uri.h" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
64 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
65 /* #define USERAGENT "User-Agent: NSPlayer/7.1.0.3055\r\n" */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
66 #define USERAGENT "User-Agent: NSPlayer/4.1.0.3856\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
67 #define CLIENTGUID "Pragma: xClientGUID={c77e7400-738a-11d2-9add-0020af0a3278}\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
68 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
69 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
70 #define MMSH_PORT 80 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
71 #define MMSH_UNKNOWN 0 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
72 #define MMSH_SEEKABLE 1 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
73 #define MMSH_LIVE 2 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
74 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
75 #define CHUNK_HEADER_LENGTH 4 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
76 #define EXT_HEADER_LENGTH 8 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
77 #define CHUNK_TYPE_RESET 0x4324 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
78 #define CHUNK_TYPE_DATA 0x4424 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
79 #define CHUNK_TYPE_END 0x4524 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
80 #define CHUNK_TYPE_ASF_HEADER 0x4824 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
81 #define CHUNK_SIZE 65536 /* max chunk size */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
82 #define ASF_HEADER_SIZE 8192 /* max header size */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
83 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
84 #define SCRATCH_SIZE 1024 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
85 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
86 static const char* mmsh_FirstRequest = |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
87 "GET %s HTTP/1.0\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
88 "Accept: */*\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
89 USERAGENT |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
90 "Host: %s:%d\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
91 "Pragma: no-cache,rate=1.000000,stream-time=0,stream-offset=0:0,request-context=%u,max-duration=0\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
92 CLIENTGUID |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
93 "Connection: Close\r\n\r\n"; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
94 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
95 static const char* mmsh_SeekableRequest = |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
96 "GET %s HTTP/1.0\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
97 "Accept: */*\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
98 USERAGENT |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
99 "Host: %s:%d\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
100 "Pragma: no-cache,rate=1.000000,stream-time=%u,stream-offset=%u:%u,request-context=%u,max-duration=%u\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
101 CLIENTGUID |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
102 "Pragma: xPlayStrm=1\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
103 "Pragma: stream-switch-count=%d\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
104 "Pragma: stream-switch-entry=%s\r\n" /* ffff:1:0 ffff:2:0 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
105 "Connection: Close\r\n\r\n"; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
106 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
107 static const char* mmsh_LiveRequest = |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
108 "GET %s HTTP/1.0\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
109 "Accept: */*\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
110 USERAGENT |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
111 "Host: %s:%d\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
112 "Pragma: no-cache,rate=1.000000,request-context=%u\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
113 "Pragma: xPlayStrm=1\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
114 CLIENTGUID |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
115 "Pragma: stream-switch-count=%d\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
116 "Pragma: stream-switch-entry=%s\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
117 "Connection: Close\r\n\r\n"; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
118 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
119 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
120 #if 0 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
121 /* Unused requests */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
122 static const char* mmsh_PostRequest = |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
123 "POST %s HTTP/1.0\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
124 "Accept: */*\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
125 USERAGENT |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
126 "Host: %s\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
127 "Pragma: client-id=%u\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
128 /* "Pragma: log-line=no-cache,rate=1.000000,stream-time=%u,stream-offset=%u:%u,request-context=2,max-duration=%u\r\n" */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
129 "Pragma: Content-Length: 0\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
130 CLIENTGUID |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
131 "\r\n"; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
132 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
133 static const char* mmsh_RangeRequest = |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
134 "GET %s HTTP/1.0\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
135 "Accept: */*\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
136 USERAGENT |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
137 "Host: %s:%d\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
138 "Range: bytes=%Lu-\r\n" |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
139 CLIENTGUID |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
140 "Connection: Close\r\n\r\n"; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
141 #endif |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
142 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
143 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
144 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
145 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
146 * mmsh specific types |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
147 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
148 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
149 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
150 struct mmsh_s { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
151 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
152 /* FIXME: de-xine-ification */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
153 void *custom_data; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
154 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
155 int s; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
156 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
157 /* url parsing */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
158 char *url; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
159 char *proxy_url; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
160 char *proto; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
161 char *connect_host; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
162 int connect_port; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
163 char *http_host; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
164 int http_port; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
165 char *proxy_user; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
166 char *proxy_password; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
167 char *host_user; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
168 char *host_password; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
169 char *uri; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
170 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
171 char str[SCRATCH_SIZE]; /* scratch buffer to built strings */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
172 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
173 int stream_type; /* seekable or broadcast */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
174 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
175 /* receive buffer */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
176 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
177 /* chunk */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
178 uint16_t chunk_type; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
179 uint16_t chunk_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
180 uint16_t chunk_seq_number; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
181 uint8_t buf[CHUNK_SIZE]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
182 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
183 int buf_size; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
184 int buf_read; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
185 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
186 uint8_t asf_header[ASF_HEADER_SIZE]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
187 uint32_t asf_header_len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
188 uint32_t asf_header_read; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
189 int seq_num; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
190 int num_stream_ids; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
191 int stream_ids[ASF_MAX_NUM_STREAMS]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
192 int stream_types[ASF_MAX_NUM_STREAMS]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
193 uint32_t packet_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
194 int64_t file_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
195 char guid[37]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
196 uint32_t bitrates[ASF_MAX_NUM_STREAMS]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
197 uint32_t bitrates_pos[ASF_MAX_NUM_STREAMS]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
198 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
199 int has_audio; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
200 int has_video; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
201 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
202 off_t current_pos; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
203 int user_bandwidth; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
204 }; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
205 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
206 static int fallback_io_select(void *data, int socket, int state, int timeout_msec) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
207 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
208 fd_set set; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
209 struct timeval tv = { timeout_msec / 1000, (timeout_msec % 1000) * 1000}; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
210 FD_ZERO(&set); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
211 FD_SET(socket, &set); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
212 return select(1, (state == MMS_IO_READ_READY) ? &set : NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
213 (state == MMS_IO_WRITE_READY) ? &set : NULL, NULL, &tv); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
214 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
215 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
216 static off_t fallback_io_read(void *data, int socket, char *buf, off_t num) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
217 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
218 off_t len = 0, ret; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
219 /* lprintf("%d\n", fallback_io_select(data, socket, MMS_IO_READ_READY, 1000)); */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
220 errno = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
221 while (len < num) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
222 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
223 ret = (off_t)read(socket, buf + len, num - len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
224 if(ret == 0) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
225 break; /* EOF */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
226 if(ret < 0) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
227 switch(errno) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
228 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
229 case EAGAIN: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
230 lprintf("len == %lld\n", (long long int) len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
231 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
232 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
233 lprintf("len == %lld\n", (long long int) len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
234 perror(NULL); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
235 /* if already read something, return it, we will fail next time */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
236 return len ? len : ret; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
237 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
238 len += ret; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
239 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
240 lprintf("ret len == %lld\nnum == %lld\n", (long long int) len, (long long int) num); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
241 lprintf("read\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
242 return len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
243 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
244 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
245 static off_t fallback_io_write(void *data, int socket, char *buf, off_t num) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
246 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
247 return (off_t)write(socket, buf, num); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
248 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
249 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
250 static int fallback_io_tcp_connect(void *data, const char *host, int port) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
251 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
252 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
253 struct hostent *h; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
254 int i, s; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
255 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
256 h = gethostbyname(host); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
257 if (h == NULL) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
258 /* fprintf(stderr, "unable to resolve host: %s\n", host); */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
259 return -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
260 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
261 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
262 s = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
263 if (s == -1) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
264 /* fprintf(stderr, "failed to create socket: %s", strerror(errno)); */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
265 return -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
266 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
267 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
268 if (fcntl (s, F_SETFL, fcntl (s, F_GETFL) & ~O_NONBLOCK) == -1) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
269 /* _x_message(stream, XINE_MSG_CONNECTION_REFUSED, "can't put socket in non-blocking mode", strerror(errno), NULL); */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
270 return -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
271 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
272 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
273 for (i = 0; h->h_addr_list[i]; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
274 struct in_addr ia; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
275 struct sockaddr_in sin; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
276 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
277 memcpy (&ia, h->h_addr_list[i], 4); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
278 sin.sin_family = AF_INET; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
279 sin.sin_addr = ia; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
280 sin.sin_port = htons(port); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
281 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
282 if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) ==-1 && errno != EINPROGRESS) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
283 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
284 /* FIXME: de-xine-ification */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
285 /* _x_message(stream, XINE_MSG_CONNECTION_REFUSED, strerror(errno), NULL); */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
286 close(s); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
287 continue; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
288 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
289 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
290 return s; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
291 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
292 return -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
293 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
294 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
295 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
296 static mms_io_t fallback_io = |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
297 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
298 &fallback_io_select, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
299 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
300 &fallback_io_read, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
301 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
302 &fallback_io_write, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
303 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
304 &fallback_io_tcp_connect, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
305 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
306 }; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
307 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
308 static mms_io_t default_io = { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
309 &fallback_io_select, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
310 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
311 &fallback_io_read, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
312 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
313 &fallback_io_write, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
314 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
315 &fallback_io_tcp_connect, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
316 NULL, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
317 }; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
318 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
319 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
320 #define io_read(io, args...) ((io) ? (io)->read(io->read_data , ## args) : default_io.read(NULL , ## args)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
321 #define io_write(io, args...) ((io) ? (io)->write(io->write_data , ## args) : default_io.write(NULL , ## args)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
322 #define io_select(io, args...) ((io) ? (io)->select(io->select_data , ## args) : default_io.select(NULL , ## args)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
323 #define io_connect(io, args...) ((io) ? (io)->connect(io->connect_data , ## args) : default_io.connect(NULL , ## args)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
324 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
325 static int get_guid (unsigned char *buffer, int offset) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
326 int i; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
327 GUID g; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
328 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
329 g.Data1 = LE_32(buffer + offset); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
330 g.Data2 = LE_16(buffer + offset + 4); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
331 g.Data3 = LE_16(buffer + offset + 6); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
332 for(i = 0; i < 8; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
333 g.Data4[i] = buffer[offset + 8 + i]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
334 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
335 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
336 for (i = 1; i < GUID_END; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
337 if (!memcmp(&g, &guids[i].guid, sizeof(GUID))) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
338 lprintf ("GUID: %s\n", guids[i].name); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
339 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
340 return i; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
341 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
342 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
343 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
344 lprintf ("libmmsh: unknown GUID: 0x%x, 0x%x, 0x%x, " |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
345 "{ 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx }\n", |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
346 g.Data1, g.Data2, g.Data3, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
347 g.Data4[0], g.Data4[1], g.Data4[2], g.Data4[3], |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
348 g.Data4[4], g.Data4[5], g.Data4[6], g.Data4[7]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
349 return GUID_ERROR; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
350 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
351 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
352 static int send_command (mms_io_t *io, mmsh_t *this, char *cmd) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
353 int length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
354 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
355 lprintf ("send_command:\n%s\n", cmd); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
356 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
357 length = strlen(cmd); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
358 if (io_write(io, this->s, cmd, length) != length) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
359 lprintf ("mmsh: send error.\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
360 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
361 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
362 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
363 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
364 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
365 static int get_answer (mms_io_t *io, mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
366 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
367 int done, len, linenum; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
368 char *features; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
369 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
370 lprintf ("get_answer\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
371 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
372 done = 0; len = 0; linenum = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
373 this->stream_type = MMSH_UNKNOWN; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
374 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
375 while (!done) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
376 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
377 if (io_read(io, this->s, &(this->buf[len]), 1) != 1) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
378 lprintf ("mmsh: alart: end of stream\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
379 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
380 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
381 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
382 if (this->buf[len] == '\012') { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
383 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
384 this->buf[len] = '\0'; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
385 len--; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
386 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
387 if ((len >= 0) && (this->buf[len] == '\015')) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
388 this->buf[len] = '\0'; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
389 len--; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
390 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
391 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
392 linenum++; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
393 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
394 lprintf ("answer: >%s<\n", this->buf); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
395 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
396 if (linenum == 1) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
397 int httpver, httpsub, httpcode; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
398 char httpstatus[51]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
399 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
400 if (sscanf(this->buf, "HTTP/%d.%d %d %50[^\015\012]", &httpver, &httpsub, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
401 &httpcode, httpstatus) != 4) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
402 lprintf ("mmsh: bad response format\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
403 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
404 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
405 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
406 if (httpcode >= 300 && httpcode < 400) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
407 lprintf ("mmsh: 3xx redirection not implemented: >%d %s<\n", httpcode, httpstatus); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
408 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
409 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
410 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
411 if (httpcode < 200 || httpcode >= 300) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
412 lprintf ("mmsh: http status not 2xx: >%d %s<\n", httpcode, httpstatus); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
413 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
414 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
415 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
416 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
417 if (!strncasecmp(this->buf, "Location: ", 10)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
418 lprintf ("mmsh: Location redirection not implemented.\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
419 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
420 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
421 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
422 if (!strncasecmp(this->buf, "Pragma:", 7)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
423 features = strstr(this->buf + 7, "features="); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
424 if (features) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
425 if (strstr(features, "seekable")) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
426 lprintf("seekable stream\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
427 this->stream_type = MMSH_SEEKABLE; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
428 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
429 if (strstr(features, "broadcast")) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
430 lprintf("live stream\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
431 this->stream_type = MMSH_LIVE; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
432 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
433 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
434 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
435 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
436 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
437 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
438 if (len == -1) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
439 done = 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
440 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
441 len = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
442 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
443 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
444 len ++; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
445 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
446 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
447 if (this->stream_type == MMSH_UNKNOWN) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
448 lprintf ("mmsh: unknown stream type\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
449 this->stream_type = MMSH_SEEKABLE; /* FIXME ? */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
450 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
451 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
452 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
453 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
454 static int get_chunk_header (mms_io_t *io, mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
455 uint8_t chunk_header[CHUNK_HEADER_LENGTH]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
456 uint8_t ext_header[EXT_HEADER_LENGTH]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
457 int read_len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
458 int ext_header_len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
459 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
460 lprintf ("get_chunk_header\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
461 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
462 /* read chunk header */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
463 read_len = io_read(io, this->s, chunk_header, CHUNK_HEADER_LENGTH); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
464 if (read_len != CHUNK_HEADER_LENGTH) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
465 lprintf ("chunk header read failed, %d != %d\n", len, CHUNK_HEADER_LENGTH); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
466 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
467 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
468 this->chunk_type = LE_16 (&chunk_header[0]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
469 this->chunk_length = LE_16 (&chunk_header[2]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
470 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
471 switch (this->chunk_type) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
472 case CHUNK_TYPE_DATA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
473 ext_header_len = 8; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
474 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
475 case CHUNK_TYPE_END: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
476 ext_header_len = 4; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
477 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
478 case CHUNK_TYPE_ASF_HEADER: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
479 ext_header_len = 8; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
480 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
481 case CHUNK_TYPE_RESET: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
482 ext_header_len = 4; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
483 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
484 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
485 ext_header_len = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
486 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
487 /* read extended header */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
488 if (ext_header_len > 0) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
489 read_len = io_read (io, this->s, ext_header, ext_header_len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
490 if (read_len != ext_header_len) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
491 lprintf ("extended header read failed. %d != %d\n", read_len, ext_header_len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
492 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
493 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
494 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
495 /* display debug infos */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
496 #ifdef DEBUG |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
497 switch (this->chunk_type) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
498 case CHUNK_TYPE_DATA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
499 this->chunk_seq_number = LE_32 (&ext_header[0]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
500 lprintf ("chunk type: CHUNK_TYPE_DATA\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
501 lprintf ("chunk length: %d\n", this->chunk_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
502 lprintf ("chunk seq: %d\n", this->chunk_seq_number); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
503 lprintf ("unknown: %d\n", ext_header[4]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
504 lprintf ("mmsh seq: %d\n", ext_header[5]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
505 lprintf ("len2: %d\n", LE_16(&ext_header[6])); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
506 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
507 case CHUNK_TYPE_END: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
508 this->chunk_seq_number = LE_32 (&ext_header[0]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
509 lprintf ("chunk type: CHUNK_TYPE_END\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
510 lprintf ("continue: %d\n", this->chunk_seq_number); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
511 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
512 case CHUNK_TYPE_ASF_HEADER: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
513 lprintf ("chunk type: CHUNK_TYPE_ASF_HEADER\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
514 lprintf ("chunk length: %d\n", this->chunk_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
515 lprintf ("unknown: %2X %2X %2X %2X %2X %2X\n", |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
516 ext_header[0], ext_header[1], ext_header[2], ext_header[3], |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
517 ext_header[4], ext_header[5]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
518 lprintf ("len2: %d\n", LE_16(&ext_header[6])); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
519 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
520 case CHUNK_TYPE_RESET: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
521 lprintf ("chunk type: CHUNK_TYPE_RESET\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
522 lprintf ("chunk seq: %d\n", this->chunk_seq_number); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
523 lprintf ("unknown: %2X %2X %2X %2X\n", |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
524 ext_header[0], ext_header[1], ext_header[2], ext_header[3]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
525 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
526 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
527 lprintf ("unknown chunk: %4X\n", this->chunk_type); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
528 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
529 #endif |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
530 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
531 this->chunk_length -= ext_header_len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
532 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
533 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
534 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
535 static int get_header (mms_io_t *io, mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
536 int len = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
537 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
538 lprintf("get_header\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
539 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
540 this->asf_header_len = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
541 this->asf_header_read = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
542 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
543 /* read chunk */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
544 while (1) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
545 if (get_chunk_header(io, this)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
546 if (this->chunk_type == CHUNK_TYPE_ASF_HEADER) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
547 if ((this->asf_header_len + this->chunk_length) > ASF_HEADER_SIZE) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
548 lprintf ("mmsh: the asf header exceed %d bytes\n", ASF_HEADER_SIZE); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
549 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
550 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
551 len = io_read(io, this->s, this->asf_header + this->asf_header_len, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
552 this->chunk_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
553 this->asf_header_len += len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
554 if (len != this->chunk_length) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
555 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
556 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
557 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
558 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
559 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
560 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
561 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
562 lprintf("get_chunk_header failed\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
563 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
564 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
565 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
566 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
567 if (this->chunk_type == CHUNK_TYPE_DATA) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
568 /* read the first data chunk */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
569 len = io_read (io, this->s, this->buf, this->chunk_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
570 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
571 if (len != this->chunk_length) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
572 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
573 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
574 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
575 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
576 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
577 /* unexpected packet type */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
578 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
579 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
580 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
581 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
582 static void interp_header (mms_io_t *io, mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
583 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
584 int i; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
585 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
586 lprintf ("interp_header, header_len=%d\n", this->asf_header_len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
587 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
588 this->packet_length = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
589 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
590 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
591 * parse asf header |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
592 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
593 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
594 i = 30; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
595 while ((i + 24) < this->asf_header_len) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
596 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
597 int guid; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
598 uint64_t length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
599 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
600 guid = get_guid(this->asf_header, i); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
601 i += 16; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
602 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
603 length = LE_64(this->asf_header + i); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
604 i += 8; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
605 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
606 if ((i + length) >= this->asf_header_len) return; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
607 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
608 switch (guid) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
609 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
610 case GUID_ASF_FILE_PROPERTIES: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
611 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
612 this->packet_length = LE_32(this->asf_header + i + 92 - 24); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
613 if (this->packet_length > CHUNK_SIZE) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
614 this->packet_length = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
615 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
616 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
617 this->file_length = LE_64(this->asf_header + i + 40 - 24); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
618 lprintf ("file object, packet length = %d (%d)\n", |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
619 this->packet_length, LE_32(this->asf_header + i + 96 - 24)); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
620 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
621 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
622 case GUID_ASF_STREAM_PROPERTIES: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
623 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
624 uint16_t flags; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
625 uint16_t stream_id; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
626 int type; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
627 int encrypted; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
628 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
629 guid = get_guid(this->asf_header, i); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
630 switch (guid) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
631 case GUID_ASF_AUDIO_MEDIA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
632 type = ASF_STREAM_TYPE_AUDIO; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
633 this->has_audio = 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
634 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
635 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
636 case GUID_ASF_VIDEO_MEDIA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
637 case GUID_ASF_JFIF_MEDIA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
638 case GUID_ASF_DEGRADABLE_JPEG_MEDIA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
639 type = ASF_STREAM_TYPE_VIDEO; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
640 this->has_video = 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
641 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
642 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
643 case GUID_ASF_COMMAND_MEDIA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
644 type = ASF_STREAM_TYPE_CONTROL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
645 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
646 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
647 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
648 type = ASF_STREAM_TYPE_UNKNOWN; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
649 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
650 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
651 flags = LE_16(this->asf_header + i + 48); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
652 stream_id = flags & 0x7F; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
653 encrypted = flags >> 15; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
654 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
655 lprintf ("stream object, stream id: %d, type: %d, encrypted: %d\n", |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
656 stream_id, type, encrypted); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
657 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
658 this->stream_types[stream_id] = type; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
659 this->stream_ids[this->num_stream_ids] = stream_id; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
660 this->num_stream_ids++; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
661 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
662 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
663 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
664 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
665 case GUID_ASF_STREAM_BITRATE_PROPERTIES: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
666 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
667 uint16_t streams = LE_16(this->asf_header + i); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
668 uint16_t stream_id; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
669 int j; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
670 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
671 lprintf ("stream bitrate properties\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
672 lprintf ("streams %d\n", streams); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
673 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
674 for(j = 0; j < streams; j++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
675 stream_id = LE_16(this->asf_header + i + 2 + j * 6); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
676 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
677 lprintf ("stream id %d\n", stream_id); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
678 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
679 this->bitrates[stream_id] = LE_32(this->asf_header + i + 4 + j * 6); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
680 this->bitrates_pos[stream_id] = i + 4 + j * 6; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
681 lprintf ("mmsh: stream id %d, bitrate %d\n", stream_id, this->bitrates[stream_id]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
682 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
683 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
684 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
685 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
686 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
687 lprintf ("unknown object\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
688 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
689 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
690 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
691 lprintf ("length : %lld\n", length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
692 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
693 if (length > 24) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
694 i += length - 24; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
695 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
696 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
697 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
698 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
699 const static char *const mmsh_proto_s[] = { "mms", "mmsh", NULL }; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
700 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
701 static int mmsh_valid_proto (char *proto) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
702 int i = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
703 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
704 lprintf("mmsh_valid_proto\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
705 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
706 if (!proto) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
707 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
708 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
709 while(mmsh_proto_s[i]) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
710 if (!strcasecmp(proto, mmsh_proto_s[i])) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
711 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
712 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
713 i++; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
714 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
715 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
716 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
717 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
718 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
719 * returns 1 on error |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
720 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
721 static int mmsh_tcp_connect(mms_io_t *io, mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
722 int progress, res; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
723 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
724 if (!this->connect_port) this->connect_port = MMSH_PORT; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
725 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
726 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
727 * try to connect |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
728 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
729 lprintf("try to connect to %s on port %d \n", this->connect_host, this->connect_port); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
730 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
731 this->s = io_connect (io, this->connect_host, this->connect_port); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
732 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
733 if (this->s == -1) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
734 lprintf ("mmsh: failed to connect '%s'\n", this->connect_host); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
735 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
736 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
737 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
738 /* connection timeout 15s */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
739 progress = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
740 do { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
741 // report_progress(this->stream, progress); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
742 res = io_select (io, this->s, MMS_IO_WRITE_READY, 500); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
743 progress += 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
744 } while ((res == MMS_IO_STATUS_TIMEOUT) && (progress < 30)); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
745 if (res != MMS_IO_STATUS_READY) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
746 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
747 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
748 lprintf ("connected\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
749 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
750 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
751 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
752 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
753 static int mmsh_connect_int (mms_io_t *io, mmsh_t *this, int bandwidth) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
754 int i; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
755 int video_stream = -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
756 int audio_stream = -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
757 int max_arate = -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
758 int min_vrate = -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
759 int min_bw_left = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
760 int stream_id; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
761 int bandwitdh_left; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
762 char stream_selection[10 * ASF_MAX_NUM_STREAMS]; /* 10 chars per stream */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
763 int offset; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
764 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
765 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
766 * let the negotiations begin... |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
767 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
768 this->num_stream_ids = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
769 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
770 /* first request */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
771 lprintf("first http request\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
772 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
773 snprintf (this->str, SCRATCH_SIZE, mmsh_FirstRequest, this->uri, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
774 this->http_host, this->http_port, 1); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
775 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
776 if (!send_command (io, this, this->str)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
777 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
778 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
779 if (!get_answer (io, this)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
780 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
781 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
782 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
783 get_header(io, this); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
784 interp_header(io, this); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
785 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
786 close(this->s); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
787 // report_progress (stream, 20); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
788 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
789 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
790 /* choose the best quality for the audio stream */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
791 /* i've never seen more than one audio stream */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
792 for (i = 0; i < this->num_stream_ids; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
793 stream_id = this->stream_ids[i]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
794 switch (this->stream_types[stream_id]) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
795 case ASF_STREAM_TYPE_AUDIO: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
796 if ((audio_stream == -1) || (this->bitrates[stream_id] > max_arate)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
797 audio_stream = stream_id; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
798 max_arate = this->bitrates[stream_id]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
799 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
800 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
801 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
802 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
803 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
804 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
805 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
806 /* choose a video stream adapted to the user bandwidth */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
807 bandwitdh_left = bandwidth - max_arate; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
808 if (bandwitdh_left < 0) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
809 bandwitdh_left = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
810 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
811 lprintf("bandwitdh %d, left %d\n", bandwidth, bandwitdh_left); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
812 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
813 min_bw_left = bandwitdh_left; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
814 for (i = 0; i < this->num_stream_ids; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
815 stream_id = this->stream_ids[i]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
816 switch (this->stream_types[stream_id]) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
817 case ASF_STREAM_TYPE_VIDEO: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
818 if (((bandwitdh_left - this->bitrates[stream_id]) < min_bw_left) && |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
819 (bandwitdh_left >= this->bitrates[stream_id])) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
820 video_stream = stream_id; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
821 min_bw_left = bandwitdh_left - this->bitrates[stream_id]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
822 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
823 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
824 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
825 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
826 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
827 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
828 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
829 /* choose the stream with the lower bitrate */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
830 if ((video_stream == -1) && this->has_video) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
831 for (i = 0; i < this->num_stream_ids; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
832 stream_id = this->stream_ids[i]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
833 switch (this->stream_types[stream_id]) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
834 case ASF_STREAM_TYPE_VIDEO: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
835 if ((video_stream == -1) || |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
836 (this->bitrates[stream_id] < min_vrate) || |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
837 (!min_vrate)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
838 video_stream = stream_id; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
839 min_vrate = this->bitrates[stream_id]; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
840 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
841 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
842 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
843 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
844 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
845 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
846 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
847 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
848 lprintf("audio stream %d, video stream %d\n", audio_stream, video_stream); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
849 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
850 /* second request */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
851 lprintf("second http request\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
852 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
853 if (mmsh_tcp_connect(io, this)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
854 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
855 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
856 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
857 /* stream selection string */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
858 /* The same selection is done with mmst */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
859 /* 0 means selected */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
860 /* 2 means disabled */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
861 offset = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
862 for (i = 0; i < this->num_stream_ids; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
863 int size; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
864 if ((this->stream_ids[i] == audio_stream) || |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
865 (this->stream_ids[i] == video_stream)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
866 size = snprintf(stream_selection + offset, sizeof(stream_selection) - offset, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
867 "ffff:%d:0 ", this->stream_ids[i]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
868 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
869 lprintf ("disabling stream %d\n", this->stream_ids[i]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
870 size = snprintf(stream_selection + offset, sizeof(stream_selection) - offset, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
871 "ffff:%d:2 ", this->stream_ids[i]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
872 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
873 if (size < 0) goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
874 offset += size; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
875 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
876 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
877 switch (this->stream_type) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
878 case MMSH_SEEKABLE: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
879 snprintf (this->str, SCRATCH_SIZE, mmsh_SeekableRequest, this->uri, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
880 this->http_host, this->http_port, 0, 0, 0, 2, 0, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
881 this->num_stream_ids, stream_selection); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
882 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
883 case MMSH_LIVE: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
884 snprintf (this->str, SCRATCH_SIZE, mmsh_LiveRequest, this->uri, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
885 this->http_host, this->http_port, 2, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
886 this->num_stream_ids, stream_selection); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
887 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
888 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
889 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
890 if (!send_command (io, this, this->str)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
891 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
892 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
893 lprintf("before read \n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
894 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
895 if (!get_answer (io, this)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
896 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
897 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
898 if (!get_header(io, this)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
899 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
900 interp_header(io, this); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
901 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
902 for (i = 0; i < this->num_stream_ids; i++) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
903 if ((this->stream_ids[i] != audio_stream) && |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
904 (this->stream_ids[i] != video_stream)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
905 lprintf("disabling stream %d\n", this->stream_ids[i]); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
906 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
907 /* forces the asf demuxer to not choose this stream */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
908 if (this->bitrates_pos[this->stream_ids[i]]) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
909 this->asf_header[this->bitrates_pos[this->stream_ids[i]]] = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
910 this->asf_header[this->bitrates_pos[this->stream_ids[i]] + 1] = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
911 this->asf_header[this->bitrates_pos[this->stream_ids[i]] + 2] = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
912 this->asf_header[this->bitrates_pos[this->stream_ids[i]] + 3] = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
913 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
914 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
915 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
916 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
917 fail: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
918 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
919 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
920 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
921 mmsh_t *mmsh_connect (mms_io_t *io, void *data, const char *url, int bandwidth) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
922 mmsh_t *this; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
923 GURI *uri = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
924 GURI *proxy_uri = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
925 char *proxy_env; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
926 if (!url) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
927 return NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
928 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
929 // report_progress (stream, 0); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
930 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
931 * initializatoin is essential here. the fail: label depends |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
932 * on the various char * in our this structure to be |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
933 * NULL if they haven't been assigned yet. |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
934 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
935 this = (mmsh_t*) malloc (sizeof (mmsh_t)); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
936 this->url=NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
937 this->proxy_url = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
938 this->proto = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
939 this->connect_host = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
940 this->http_host = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
941 this->proxy_user = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
942 this->proxy_password = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
943 this->host_user = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
944 this->host_password = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
945 this->uri = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
946 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
947 this->custom_data = data; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
948 this->url = strdup(url); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
949 if ((proxy_env = getenv("http_proxy")) != NULL) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
950 this->proxy_url = strdup(proxy_env); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
951 else |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
952 this->proxy_url = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
953 this->s = -1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
954 this->asf_header_len = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
955 this->asf_header_read = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
956 this->num_stream_ids = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
957 this->packet_length = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
958 this->buf_size = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
959 this->buf_read = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
960 this->has_audio = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
961 this->has_video = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
962 this->current_pos = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
963 this->user_bandwidth = bandwidth; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
964 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
965 // report_progress (stream, 0); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
966 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
967 if (this->proxy_url) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
968 proxy_uri = gnet_uri_new(this->proxy_url); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
969 if (!proxy_uri) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
970 lprintf("invalid proxy url\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
971 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
972 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
973 if (! proxy_uri->port ) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
974 proxy_uri->port = 3128; //default squid port |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
975 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
976 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
977 uri = gnet_uri_new(this->url); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
978 if (!uri) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
979 lprintf ("invalid url\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
980 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
981 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
982 if (! uri->port ) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
983 //checked in tcp_connect, but it's better to initialize it here |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
984 uri->port = MMSH_PORT; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
985 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
986 if (this->proxy_url) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
987 this->proto = (uri->scheme) ? strdup(uri->scheme) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
988 this->connect_host = (proxy_uri->hostname) ? strdup(proxy_uri->hostname) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
989 this->connect_port = proxy_uri->port; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
990 this->http_host = (uri->scheme) ? strdup(uri->hostname) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
991 this->http_port = uri->port; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
992 this->proxy_user = (proxy_uri->user) ? strdup(proxy_uri->user) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
993 this->proxy_password = (proxy_uri->passwd) ? strdup(proxy_uri->passwd) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
994 this->host_user = (uri->user) ? strdup(uri->user) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
995 this->host_password = (uri->passwd) ? strdup(uri->passwd) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
996 gnet_uri_set_scheme(uri,"http"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
997 char * uri_string = gnet_uri_get_string(uri); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
998 this->uri = strdup(uri_string); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
999 g_free(uri_string); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1000 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1001 this->proto = (uri->scheme) ? strdup(uri->scheme) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1002 this->connect_host = (uri->hostname) ? strdup(uri->hostname) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1003 this->connect_port = uri->port; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1004 this->http_host = (uri->hostname) ? strdup(uri->hostname) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1005 this->http_port = uri->port; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1006 this->proxy_user = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1007 this->proxy_password = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1008 this->host_user =(uri->user) ? strdup(uri->user) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1009 this->host_password = (uri->passwd) ? strdup(uri->passwd) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1010 this->uri = (uri->path) ? strdup(uri->path) : NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1011 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1012 if (proxy_uri) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1013 gnet_uri_delete(proxy_uri); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1014 proxy_uri = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1015 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1016 if (uri) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1017 gnet_uri_delete(uri); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1018 uri = NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1019 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1020 if (!mmsh_valid_proto(this->proto)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1021 lprintf ("unsupported protocol\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1022 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1023 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1024 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1025 if (mmsh_tcp_connect(io, this)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1026 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1027 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1028 // report_progress (stream, 30); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1029 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1030 if (!mmsh_connect_int(io, this, this->user_bandwidth)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1031 goto fail; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1032 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1033 // report_progress (stream, 100); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1034 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1035 lprintf("mmsh_connect: passed\n" ); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1036 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1037 return this; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1038 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1039 fail: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1040 lprintf("mmsh_connect: failed\n" ); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1041 if (proxy_uri) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1042 gnet_uri_delete(proxy_uri); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1043 if (uri) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1044 gnet_uri_delete(uri); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1045 if (this->s != -1) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1046 close(this->s); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1047 if (this->url) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1048 free(this->url); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1049 if (this->proxy_url) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1050 free(this->proxy_url); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1051 if (this->proto) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1052 free(this->proto); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1053 if (this->connect_host) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1054 free(this->connect_host); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1055 if (this->http_host) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1056 free(this->http_host); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1057 if (this->proxy_user) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1058 free(this->proxy_user); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1059 if (this->proxy_password) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1060 free(this->proxy_password); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1061 if (this->host_user) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1062 free(this->host_user); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1063 if (this->host_password) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1064 free(this->host_password); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1065 if (this->uri) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1066 free(this->uri); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1067 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1068 free(this); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1069 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1070 lprintf("mmsh_connect: failed return\n" ); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1071 return NULL; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1072 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1073 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1074 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1075 /* |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1076 * returned value: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1077 * 0: error |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1078 * 1: data packet read |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1079 * 2: new header read |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1080 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1081 static int get_media_packet (mms_io_t *io, mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1082 int len = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1083 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1084 lprintf("get_media_packet: this->packet_length: %d\n", this->packet_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1085 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1086 if (get_chunk_header(io, this)) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1087 switch (this->chunk_type) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1088 case CHUNK_TYPE_END: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1089 /* this->chunk_seq_number: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1090 * 0: stop |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1091 * 1: a new stream follows |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1092 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1093 if (this->chunk_seq_number == 0) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1094 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1095 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1096 close (this->s); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1097 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1098 if (mmsh_tcp_connect (io, this)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1099 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1100 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1101 if (!mmsh_connect_int (io, this, this->user_bandwidth)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1102 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1103 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1104 /* mmsh_connect_int reads the first data packet */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1105 /* this->buf_size is set by mmsh_connect_int */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1106 return 2; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1107 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1108 case CHUNK_TYPE_DATA: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1109 /* nothing to do */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1110 break; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1111 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1112 case CHUNK_TYPE_RESET: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1113 /* next chunk is an ASF header */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1114 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1115 if (this->chunk_length != 0) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1116 /* that's strange, don't know what to do */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1117 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1118 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1119 if (!get_header (io, this)) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1120 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1121 interp_header(io, this); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1122 this->buf_size = this->packet_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1123 return 2; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1124 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1125 default: |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1126 lprintf ("mmsh: unexpected chunk type\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1127 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1128 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1129 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1130 len = io_read (io, this->s, this->buf, this->chunk_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1131 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1132 if (len == this->chunk_length) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1133 /* explicit padding with 0 */ |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1134 if (this->chunk_length > this->packet_length) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1135 lprintf ("mmsh: chunk_length(%d) > packet_length(%d)\n", |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1136 this->chunk_length, this->packet_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1137 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1138 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1139 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1140 { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1141 char *base = (char *)(this->buf); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1142 char *start = base + this->chunk_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1143 char *end = start + this->packet_length - this->chunk_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1144 if ((start > base) && (start < (base+CHUNK_SIZE-1)) && |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1145 (start < end) && (end < (base+CHUNK_SIZE-1))) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1146 memset(start, 0, |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1147 this->packet_length - this->chunk_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1148 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1149 if (this->packet_length > CHUNK_SIZE) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1150 this->buf_size = CHUNK_SIZE; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1151 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1152 this->buf_size = this->packet_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1153 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1154 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1155 return 1; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1156 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1157 lprintf ("mmsh: read error, %d != %d\n", len, this->chunk_length); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1158 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1159 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1160 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1161 return 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1162 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1163 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1164 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1165 int mmsh_peek_header (mmsh_t *this, char *data, int maxsize) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1166 int len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1167 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1168 lprintf("mmsh_peek_header\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1169 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1170 len = (this->asf_header_len < maxsize) ? this->asf_header_len : maxsize; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1171 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1172 memcpy(data, this->asf_header, len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1173 return len; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1174 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1175 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1176 int mmsh_read (mms_io_t *io, mmsh_t *this, char *data, int len) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1177 int total; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1178 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1179 total = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1180 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1181 lprintf ("mmsh_read: len: %d\n", len); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1182 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1183 while (total < len) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1184 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1185 if (this->asf_header_read < this->asf_header_len) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1186 int n, bytes_left ; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1187 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1188 bytes_left = this->asf_header_len - this->asf_header_read ; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1189 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1190 if ((len-total) < bytes_left) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1191 n = len-total; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1192 else |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1193 n = bytes_left; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1194 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1195 memcpy (&data[total], &this->asf_header[this->asf_header_read], n); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1196 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1197 this->asf_header_read += n; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1198 total += n; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1199 this->current_pos += n; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1200 } else { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1201 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1202 int n, bytes_left ; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1203 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1204 bytes_left = this->buf_size - this->buf_read; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1205 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1206 if (bytes_left == 0) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1207 int packet_type; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1208 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1209 this->buf_size=this ->buf_read = 0; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1210 packet_type = get_media_packet (io, this); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1211 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1212 if (packet_type == 0) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1213 lprintf ("mmsh: get_media_packet failed\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1214 return total; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1215 } else if (packet_type == 2) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1216 continue; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1217 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1218 bytes_left = this->buf_size; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1219 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1220 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1221 if ((len-total) < bytes_left) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1222 n = len-total; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1223 else |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1224 n = bytes_left; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1225 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1226 memcpy (&data[total], &this->buf[this->buf_read], n); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1227 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1228 this->buf_read += n; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1229 total += n; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1230 this->current_pos += n; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1231 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1232 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1233 return total; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1234 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1235 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1236 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1237 void mmsh_close (mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1238 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1239 lprintf("mmsh_close\n"); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1240 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1241 if (this->s != -1) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1242 close(this->s); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1243 if (this->url) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1244 free(this->url); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1245 if (this->proxy_url) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1246 free(this->proxy_url); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1247 if (this->proto) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1248 free(this->proto); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1249 if (this->connect_host) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1250 free(this->connect_host); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1251 if (this->http_host) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1252 free(this->http_host); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1253 if (this->proxy_user) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1254 free(this->proxy_user); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1255 if (this->proxy_password) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1256 free(this->proxy_password); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1257 if (this->host_user) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1258 free(this->host_user); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1259 if (this->host_password) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1260 free(this->host_password); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1261 if (this->uri) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1262 free(this->uri); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1263 if (this) |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1264 free (this); |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1265 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1266 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1267 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1268 uint32_t mmsh_get_length (mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1269 return this->file_length; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1270 } |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1271 |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1272 off_t mmsh_get_current_pos (mmsh_t *this) { |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1273 return this->current_pos; |
bf7fe0421354
[svn] Bolt on libmms versions of byteswap macros and bring yet more files in (mmsh.c & mms.h).
chainsaw
parents:
diff
changeset
|
1274 } |