summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--DOCS/man/en/options.rst28
-rw-r--r--Makefile12
-rwxr-xr-xconfigure190
-rw-r--r--core/m_option.c34
-rw-r--r--core/options.c11
-rw-r--r--core/options.h3
-rw-r--r--stream/asf_mmst_streaming.c686
-rw-r--r--stream/asf_mmst_streaming.h26
-rw-r--r--stream/asf_streaming.c855
-rw-r--r--stream/cookies.c86
-rw-r--r--stream/cookies.h4
-rw-r--r--stream/http.c966
-rw-r--r--stream/http.h70
-rw-r--r--stream/network.c455
-rw-r--r--stream/network.h84
-rw-r--r--stream/stream.c76
-rw-r--r--stream/stream.h29
-rw-r--r--stream/stream_cdda.c32
-rw-r--r--stream/stream_cddb.c902
-rw-r--r--stream/stream_ftp.c520
-rw-r--r--stream/stream_lavf.c3
-rw-r--r--stream/stream_udp.c105
-rw-r--r--stream/tcp.c279
-rw-r--r--stream/tcp.h35
-rw-r--r--stream/udp.c201
-rw-r--r--stream/udp.h30
-rw-r--r--stream/url.c506
-rw-r--r--stream/url.h55
28 files changed, 43 insertions, 6240 deletions
diff --git a/DOCS/man/en/options.rst b/DOCS/man/en/options.rst
index 8a5a9baa44..0d83764d80 100644
--- a/DOCS/man/en/options.rst
+++ b/DOCS/man/en/options.rst
@@ -1051,12 +1051,6 @@
work (key bindings that normally quit will be shown on OSD only, just
like any other binding).
---ipv4-only-proxy
- Skip any HTTP proxy for IPv6 addresses. It will still be used for IPv4
- connections.
-
- *WARNING*: works with the deprecated ``mp_http://`` protocol only.
-
--joystick, --no-joystick
Enable/disable joystick support. Enabled by default.
@@ -1416,12 +1410,6 @@
allows a zoom factor of up to 4. This feature is experimental. Do not
report bugs unless you are using ``--vo=opengl``.
---passwd=<password>
- Used with some network protocols. Specify password for HTTP authentication.
- See also ``--user``.
-
- *WARNING*: works with the deprecated ``mp_http://`` protocol only.
-
--playing-msg=<string>
Print out a string after starting playback. The string is expanded for
properties, e.g. ``--playing-msg=file: ${filename}`` will print the string
@@ -1466,16 +1454,6 @@
--pphelp
See also ``--vf=pp``.
---prefer-ipv4
- Use IPv4 on network connections. Falls back on IPv6 automatically.
-
- *WARNING*: works with the deprecated ``mp_http://`` protocol only.
-
---prefer-ipv6
- Use IPv6 on network connections. Falls back on IPv4 automatically.
-
- *WARNING*: works with the deprecated ``mp_http://`` protocol only.
-
--priority=<prio>
(Windows only.)
Set process priority for mpv according to the predefined priorities
@@ -2284,12 +2262,6 @@
*WARNING*: May be dangerous if playing from untrusted media.
---user=<username>
- Used with some network protocols.
- Specify username for HTTP authentication. See also ``--passwd``.
-
- *WARNING*: works with the deprecated ``mp_http://`` protocol only.
-
--user-agent=<string>
Use <string> as user agent for HTTP streaming.
diff --git a/Makefile b/Makefile
index 6b6f05dc86..373a6f3ddc 100644
--- a/Makefile
+++ b/Makefile
@@ -28,13 +28,11 @@ SOURCES_AUDIO_INPUT-$(OSS) += stream/ai_oss.c
SOURCES-$(AUDIO_INPUT) += $(SOURCES_AUDIO_INPUT-yes)
SOURCES-$(CDDA) += stream/stream_cdda.c \
stream/cdinfo.c
-SOURCES-$(CDDB) += stream/stream_cddb.c
SOURCES-$(DVBIN) += stream/dvb_tune.c \
stream/stream_dvb.c
SOURCES-$(DVDREAD) += stream/stream_dvd.c \
stream/stream_dvd_common.c
-SOURCES-$(FTP) += stream/stream_ftp.c
SOURCES-$(HAVE_SYS_MMAN_H) += audio/filter/af_export.c osdep/mmap_anon.c
SOURCES-$(LADSPA) += audio/filter/af_ladspa.c
SOURCES-$(LIBASS) += sub/ass_mp.c sub/sd_ass.c \
@@ -56,14 +54,6 @@ SOURCES-$(MPG123) += audio/decode/ad_mpg123.c
SOURCES-$(NEED_GETTIMEOFDAY) += osdep/gettimeofday.c
SOURCES-$(NEED_GLOB) += osdep/glob-win.c
-SOURCES-$(NETWORKING) += stream/asf_mmst_streaming.c \
- stream/asf_streaming.c \
- stream/cookies.c \
- stream/http.c \
- stream/network.c \
- stream/udp.c \
- stream/tcp.c \
- stream/stream_udp.c \
SOURCES-$(PRIORITY) += osdep/priority.c
SOURCES-$(PVR) += stream/stream_pvr.c
@@ -223,6 +213,7 @@ SOURCES = talloc.c \
osdep/io.c \
osdep/numcores.c \
osdep/timer.c \
+ stream/cookies.c \
stream/stream.c \
stream/stream_avdevice.c \
stream/stream_file.c \
@@ -230,7 +221,6 @@ SOURCES = talloc.c \
stream/stream_memory.c \
stream/stream_mf.c \
stream/stream_null.c \
- stream/url.c \
sub/dec_sub.c \
sub/draw_bmp.c \
sub/find_subfiles.c \
diff --git a/configure b/configure
index 78385e1276..58e615de26 100755
--- a/configure
+++ b/configure
@@ -307,8 +307,6 @@ Optional features:
--disable-tv disable TV interface (TV/DVB grabbers) [enable]
--disable-tv-v4l2 disable Video4Linux2 TV interface [autodetect]
--disable-pvr disable Video4Linux2 MPEG PVR [autodetect]
- --disable-networking disable networking [enable]
- --enable-winsock2_h enable winsock2_h [autodetect]
--enable-smb enable Samba (SMB) input [autodetect]
--disable-libquvi4 disable libquvi 0.4.x [autodetect]
--disable-libquvi9 disable libquvi 0.9.x [autodetect]
@@ -316,12 +314,10 @@ Optional features:
--disable-vcd disable VCD support [autodetect]
--disable-bluray disable Blu-ray support [autodetect]
--disable-dvdread disable libdvdread [autodetect]
- --disable-cddb disable cddb [autodetect]
--disable-enca disable ENCA charset oracle library [autodetect]
--enable-macosx-bundle enable Mac OS X bundle file locations [autodetect]
--disable-inet6 disable IPv6 support [autodetect]
--disable-gethostbyname2 gethostbyname2 part of the C library [autodetect]
- --disable-ftp disable FTP support [enabled]
--disable-vstream disable TiVo vstream client support [autodetect]
--disable-pthreads disable Posix threads support [autodetect]
--disable-libass disable subtitle rendering with libass [autodetect]
@@ -463,8 +459,6 @@ _radio_v4l2=auto
_tv=yes
_tv_v4l2=auto
_pvr=auto
-networking=yes
-_winsock2_h=auto
_smb=auto
_libquvi4=auto
_libquvi9=auto
@@ -477,7 +471,6 @@ _termios=auto
_shm=auto
_gettext=no
_cdda=auto
-_cddb=auto
_coreaudio=auto
_corevideo=auto
_cocoa=auto
@@ -485,7 +478,6 @@ _macosx_bundle=auto
_enca=auto
_inet6=auto
_gethostbyname2=auto
-_ftp=auto
_vstream=auto
_pthreads=auto
_ass=auto
@@ -662,10 +654,6 @@ for ac_option do
--disable-radio-v4l2) _radio_v4l2=no ;;
--enable-pvr) _pvr=yes ;;
--disable-pvr) _pvr=no ;;
- --enable-networking) networking=yes ;;
- --disable-networking) networking=no ;;
- --enable-winsock2_h) _winsock2_h=yes ;;
- --disable-winsock2_h) _winsock2_h=no ;;
--enable-smb) _smb=yes ;;
--disable-smb) _smb=no ;;
--enable-libquvi4) _libquvi4=yes ;;
@@ -692,10 +680,6 @@ for ac_option do
--disable-shm) _shm=no ;;
--enable-select) _select=yes ;;
--disable-select) _select=no ;;
- --enable-cddb) _cddb=yes ;;
- --disable-cddb) _cddb=no ;;
- --enable-ftp) _ftp=yes ;;
- --disable-ftp) _ftp=no ;;
--enable-vstream) _vstream=yes ;;
--disable-vstream) _vstream=no ;;
--enable-pthreads) _pthreads=yes ;;
@@ -1247,146 +1231,6 @@ fi
echores "$_nanosleep"
-echocheck "socklib"
-# for Solaris (socket stuff is in -lsocket, gethostbyname and friends in -lnsl):
-cat > $TMPC << EOF
-#include <netdb.h>
-#include <sys/socket.h>
-int main(void) { gethostbyname(0); socket(AF_INET, SOCK_STREAM, 0); return 0; }
-EOF
-_socklib=no
-for _ld_tmp in "" "-lsocket -lbind" "-lsocket -ldnet" "-lsocket -lnsl" "-lnsl" "-lsocket" ; do
- cc_check $_ld_tmp && _ld_sock="$_ld_tmp" && _socklib=yes && break
-done
-test $_socklib = yes && test $_winsock2_h = auto && _winsock2_h=no
-if test $_winsock2_h = auto ; then
- _winsock2_h=no
- statement_check winsock2.h 'gethostbyname(0)' -lws2_32 && _ld_sock="-lws2_32" && _winsock2_h=yes
-fi
-test "$_ld_sock" && res_comment="using $_ld_sock"
-echores "$_socklib"
-
-
-if test $_winsock2_h = yes ; then
- _ld_sock="-lws2_32"
- def_winsock2_h='#define HAVE_WINSOCK2_H 1'
-else
- def_winsock2_h='#define HAVE_WINSOCK2_H 0'
-fi
-
-
-echocheck "inet_pton()"
-def_inet_pton='#define HAVE_INET_PTON 0'
-inet_pton=no
-for _ld_tmp in "$_ld_sock" "$_ld_sock -lresolv" ; do
- statement_check arpa/inet.h 'inet_pton(0, 0, 0)' $_ld_tmp && inet_pton=yes && break
-done
-if test $inet_pton = yes ; then
- test "$_ld_tmp" && res_comment="using $_ld_tmp"
- def_inet_pton='#define HAVE_INET_PTON 1'
-fi
-echores "$inet_pton"
-
-
-echocheck "inet_aton()"
-def_inet_aton='#define HAVE_INET_ATON 0'
-inet_aton=no
-for _ld_tmp in "$_ld_sock" "$_ld_sock -lresolv" ; do
- statement_check arpa/inet.h 'inet_aton(0, 0)' $_ld_tmp && inet_aton=yes && break
-done
-if test $inet_aton = yes ; then
- test "$_ld_tmp" && res_comment="using $_ld_tmp"
- def_inet_aton='#define HAVE_INET_ATON 1'
-fi
-echores "$inet_aton"
-
-
-echocheck "socklen_t"
-_socklen_t=no
-for header in "sys/socket.h" "ws2tcpip.h" "sys/types.h" ; do
- statement_check $header 'socklen_t v = 0' && _socklen_t=yes && break
-done
-if test "$_socklen_t" = yes ; then
- def_socklen_t='#define HAVE_SOCKLEN_T 1'
-else
- def_socklen_t='#define HAVE_SOCKLEN_T 0'
-fi
-echores "$_socklen_t"
-
-
-echocheck "closesocket()"
-_closesocket=no
-statement_check winsock2.h 'closesocket(~0)' $_ld_sock && _closesocket=yes
-if test "$_closesocket" = yes ; then
- def_closesocket='#define HAVE_CLOSESOCKET 1'
-else
- def_closesocket='#define HAVE_CLOSESOCKET 0'
-fi
-echores "$_closesocket"
-
-
-echocheck "networking"
-test $_winsock2_h = no && test $inet_pton = no &&
- test $inet_aton = no && networking=no
-if test "$networking" = yes ; then
- def_network='#define CONFIG_NETWORK 1'
- def_networking='#define CONFIG_NETWORKING 1'
- libs_mplayer="$libs_mplayer $_ld_sock"
- inputmodules="networking $inputmodules"
-else
- noinputmodules="networking $noinputmodules"
- def_network='#define CONFIG_NETWORK 0'
- def_networking='#undef CONFIG_NETWORKING'
-fi
-echores "$networking"
-
-
-echocheck "inet6"
-if test "$_inet6" = auto ; then
- cat > $TMPC << EOF
-#include <sys/types.h>
-#if !defined(_WIN32)
-#include <sys/socket.h>
-#include <netinet/in.h>
-#else
-#include <ws2tcpip.h>
-#endif
-int main(void) { struct sockaddr_in6 six; socket(AF_INET6, SOCK_STREAM, AF_INET6); return 0; }
-EOF
- _inet6=no
- if cc_check $_ld_sock ; then
- _inet6=yes
- fi
-fi
-if test "$_inet6" = yes ; then
- def_inet6='#define HAVE_AF_INET6 1'
-else
- def_inet6='#undef HAVE_AF_INET6'
-fi
-echores "$_inet6"
-
-
-echocheck "gethostbyname2"
-if test "$_gethostbyname2" = auto ; then
-cat > $TMPC << EOF
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-int main(void) { gethostbyname2("", AF_INET); return 0; }
-EOF
- _gethostbyname2=no
- if cc_check ; then
- _gethostbyname2=yes
- fi
-fi
-if test "$_gethostbyname2" = yes ; then
- def_gethostbyname2='#define HAVE_GETHOSTBYNAME2 1'
-else
- def_gethostbyname2='#undef HAVE_GETHOSTBYNAME2'
-fi
-echores "$_gethostbyname2"
-
-
echocheck "mman.h"
_mman=no
statement_check sys/mman.h 'mmap(0, 0, 0, 0, 0, 0)' && _mman=yes
@@ -2585,7 +2429,6 @@ fi
if test "$_libcdio" = yes ; then
_cdda='yes'
def_cdda='#define CONFIG_CDDA 1'
- test $_cddb = auto && test $networking = yes && _cddb=yes
inputmodules="cdda $inputmodules"
else
_libcdio=no
@@ -2595,15 +2438,6 @@ else
fi
echores "$_libcdio"
-if test "$_cddb" = yes ; then
- def_cddb='#define CONFIG_CDDB 1'
- inputmodules="cddb $inputmodules"
-else
- _cddb=no
- def_cddb='#undef CONFIG_CDDB'
- noinputmodules="cddb $noinputmodules"
-fi
-
echocheck "SSA/ASS support"
if test "$_ass" = auto ; then
@@ -2999,19 +2833,6 @@ fi
echores "$_pvr"
-echocheck "ftp"
-if test "$_ftp" = "auto" ; then
-test "$networking" = "yes" && _ftp=yes
-fi
-if test "$_ftp" = yes ; then
- def_ftp='#define CONFIG_FTP 1'
- inputmodules="ftp $inputmodules"
-else
- noinputmodules="ftp $noinputmodules"
- def_ftp='#undef CONFIG_FTP'
-fi
-echores "$_ftp"
-
echocheck "vstream client"
if test "$_vstream" = auto ; then
_vstream=no
@@ -3175,7 +2996,6 @@ ALSA = $_alsa
AUDIO_INPUT = $_audio_input
CACA = $_caca
CDDA = $_cdda
-CDDB = $_cddb
COCOA = $_cocoa
COREAUDIO = $_coreaudio
COREVIDEO = $_corevideo
@@ -3187,7 +3007,6 @@ WASAPI0 = $_wasapi0
DVBIN = $_dvbin
DVDREAD = $_dvdread
DXR3 = $_dxr3
-FTP = $_ftp
GL = $_gl
GL_COCOA = $_gl_cocoa
GL_WIN32 = $_gl_win32
@@ -3220,7 +3039,6 @@ LIRC = $_lirc
MACOSX_BUNDLE = $_macosx_bundle
MNG = $_mng
MPG123 = $_mpg123
-NETWORKING = $networking
OPENAL = $_openal
OSS = $_ossaudio
PE_EXECUTABLE = $_pe_executable
@@ -3344,7 +3162,6 @@ $(ff_config_enable "$subarch_all" "$subarch" "ARCH")
$def_bluray
$def_bsdi_dvd
$def_cdda
-$def_cddb
$def_cdio
$def_cdrom
$def_dvd
@@ -3405,17 +3222,10 @@ $def_ass
$def_enca
/* networking */
-$def_closesocket
-$def_ftp
-$def_inet6
-$def_inet_aton
-$def_inet_pton
-$def_networking
$def_smb
$def_libquvi4
$def_libquvi9
$def_libguess
-$def_socklen_t
$def_vstream
$def_lcms2
diff --git a/core/m_option.c b/core/m_option.c
index 9ef968194f..9b8256abe4 100644
--- a/core/m_option.c
+++ b/core/m_option.c
@@ -29,6 +29,7 @@
#include <limits.h>
#include <inttypes.h>
#include <unistd.h>
+#include <ctype.h>
#include <assert.h>
#include <libavutil/common.h>
@@ -38,7 +39,6 @@
#include "core/mp_common.h"
#include "core/m_option.h"
#include "core/mp_msg.h"
-#include "stream/url.h"
char *m_option_strerror(int code)
{
@@ -2367,6 +2367,38 @@ const m_option_type_t m_option_type_obj_settings_list = {
};
+/* Replace escape sequences in an URL (or a part of an URL) */
+/* works like strcpy(), but without return argument,
+ except that outbuf == inbuf is allowed */
+static void url_unescape_string(char *outbuf, const char *inbuf)
+{
+ unsigned char c,c1,c2;
+ int i,len=strlen(inbuf);
+ for (i=0;i<len;i++) {
+ c = inbuf[i];
+ if (c == '%' && i<len-2) { //must have 2 more chars
+ c1 = toupper(inbuf[i+1]); // we need uppercase characters
+ c2 = toupper(inbuf[i+2]);
+ if (((c1>='0' && c1<='9') || (c1>='A' && c1<='F')) &&
+ ((c2>='0' && c2<='9') || (c2>='A' && c2<='F')) )
+ {
+ if (c1>='0' && c1<='9')
+ c1-='0';
+ else
+ c1-='A'-10;
+ if (c2>='0' && c2<='9')
+ c2-='0';
+ else
+ c2-='A'-10;
+ c = (c1<<4) + c2;
+ i=i+2; //only skip next 2 chars if valid esc
+ }
+ }
+ *outbuf++ = c;
+ }
+ *outbuf++='\0'; //add nullterm to string
+}
+
static int parse_custom_url(const m_option_t *opt, struct bstr name,
struct bstr url, void *dst)
{
diff --git a/core/options.c b/core/options.c
index 3a60e3c810..b00f79c003 100644
--- a/core/options.c
+++ b/core/options.c
@@ -40,8 +40,6 @@
#include "mp_core.h"
#include "osdep/priority.h"
-char *network_username=NULL;
-char *network_password=NULL;
int network_bandwidth=0;
int network_cookies_enabled = 0;
char *network_useragent="MPlayer 1.1-4.7";
@@ -351,20 +349,11 @@ const m_option_t mp_opts[] = {
{"bluray-angle", &bluray_angle, CONF_TYPE_INT, CONF_RANGE, 0, 999, NULL},
#endif /* CONFIG_LIBBLURAY */
- {"user", &network_username, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"passwd", &network_password, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"bandwidth", &network_bandwidth, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
{"http-header-fields", &network_http_header_fields, CONF_TYPE_STRING_LIST, 0, 0, 0, NULL},
{"user-agent", &network_useragent, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"referrer", &network_referrer, CONF_TYPE_STRING, 0, 0, 0, NULL},
{"cookies", &network_cookies_enabled, CONF_TYPE_FLAG, 0, 0, 1, NULL},
{"cookies-file", &cookies_file, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"prefer-ipv4", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"ipv4-only-proxy", &network_ipv4_only_proxy, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"reuse-socket", &reuse_socket, CONF_TYPE_FLAG, 0, 0, 1, NULL},
-#ifdef HAVE_AF_INET6
- {"prefer-ipv6", &network_prefer_ipv4, CONF_TYPE_FLAG, 0, 1, 0, NULL},
-#endif /* HAVE_AF_INET6 */
// ------------------------- demuxer options --------------------
diff --git a/core/options.h b/core/options.h
index 54048d9966..1eb111e33e 100644
--- a/core/options.h
+++ b/core/options.h
@@ -268,9 +268,6 @@ typedef struct MPOpts {
// Should be moved into MPOpts
extern char **network_http_header_fields;
-extern char *network_username;
-extern char *network_password;
-extern int network_bandwidth;
extern char *network_useragent;
extern char *network_referrer;
extern int network_cookies_enabled;
diff --git a/stream/asf_mmst_streaming.c b/stream/asf_mmst_streaming.c
deleted file mode 100644
index 98c386d11d..0000000000
--- a/stream/asf_mmst_streaming.c
+++ /dev/null
@@ -1,686 +0,0 @@
-/*
- * MMST implementation taken from the xine-mms plugin made by
- * Major MMS (http://geocities.com/majormms/).
- * Ported to MPlayer by Abhijeet Phatak <abhijeetphatak@yahoo.com>.
- *
- * Information about the MMS protocol can be found at http://get.to/sdp
- *
- * copyright (C) 2002 Abhijeet Phatak <abhijeetphatak@yahoo.com>
- * copyright (C) 2002 the xine project
- * copyright (C) 2000-2001 major mms
- *
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-#include <errno.h>
-#include <inttypes.h>
-
-#include "config.h"
-#include "core/options.h"
-#include "core/mp_msg.h"
-
-#if HAVE_WINSOCK2_H
-#include <winsock2.h>
-#endif
-
-#ifdef CONFIG_ICONV
-#include <iconv.h>
-#endif
-
-#include "url.h"
-#include "demux/asf.h"
-
-#include "stream.h"
-#include "asf_mmst_streaming.h"
-#include "network.h"
-#include "tcp.h"
-
-extern int audio_id;
-extern int video_id;
-
-#define BUF_SIZE 102400
-#define HDR_BUF_SIZE 8192
-#define MAX_STREAMS 20
-
-typedef struct
-{
- uint8_t buf[BUF_SIZE];
- int num_bytes;
-
-} command_t;
-
-static int seq_num;
-static int num_stream_ids;
-static int stream_ids[MAX_STREAMS];
-
-static int get_data (int s, char *buf, size_t count);
-
-static void put_32 (command_t *cmd, uint32_t value)
-{
- cmd->buf[cmd->num_bytes ] = value % 256;
- value = value >> 8;
- cmd->buf[cmd->num_bytes+1] = value % 256 ;
- value = value >> 8;
- cmd->buf[cmd->num_bytes+2] = value % 256 ;
- value = value >> 8;
- cmd->buf[cmd->num_bytes+3] = value % 256 ;
-
- cmd->num_bytes += 4;
-}
-
-static uint32_t get_32 (unsigned char *cmd, int offset)
-{
- uint32_t ret;
-
- ret = cmd[offset] ;
- ret |= cmd[offset+1]<<8 ;
- ret |= cmd[offset+2]<<16 ;
- ret |= cmd[offset+3]<<24 ;
-
- return ret;
-}
-
-static void send_command (int s, int command, uint32_t switches,
- uint32_t extra, int length,
- char *data)
-{
- command_t cmd;
- int len8;
-
- len8 = (length + 7) / 8;
-
- cmd.num_bytes = 0;
-
- put_32 (&cmd, 0x00000001); /* start sequence */
- put_32 (&cmd, 0xB00BFACE); /* #-)) */
- put_32 (&cmd, len8*8 + 32);
- put_32 (&cmd, 0x20534d4d); /* protocol type "MMS " */
- put_32 (&cmd, len8 + 4);
- put_32 (&cmd, seq_num);
- seq_num++;
- put_32 (&cmd, 0x0); /* unknown */
- put_32 (&cmd, 0x0);
- put_32 (&cmd, len8+2);
- put_32 (&cmd, 0x00030000 | command); /* dir | command */
- put_32 (&cmd, switches);
- put_32 (&cmd, extra);
-
- memcpy (&cmd.buf[48], data, length);
- if (length & 7)
- memset(&cmd.buf[48 + length], 0, 8 - (length & 7));
-
- if (send (s, cmd.buf, len8*8+48, 0) != (len8*8+48)) {
- mp_tmsg(MSGT_NETWORK,MSGL_ERR,"write error\n");
- }
-}
-
-#ifdef CONFIG_ICONV
-static iconv_t url_conv;
-#endif
-
-static void string_utf16(char *dest, char *src, int len) {
- int i;
-#ifdef CONFIG_ICONV
- size_t len1, len2;
- char *ip, *op;
-
- if (url_conv != (iconv_t)(-1))
- {
- memset(dest, 0, 1000);
- len1 = len; len2 = 1000;
- ip = src; op = dest;
-
- iconv(url_conv, &ip, &len1, &op, &len2);
- }
- else
- {
-#endif
- if (len > 499) len = 499;
- for (i=0; i<len; i++) {
- dest[i*2] = src[i];
- dest[i*2+1] = 0;
- }
- /* trailing zeroes */
- dest[i*2] = 0;
- dest[i*2+1] = 0;
-#ifdef CONFIG_ICONV
- }
-#endif
-}
-
-static void get_answer (int s)
-{
- char data[BUF_SIZE];
- int command = 0x1b;
-
- while (command == 0x1b) {
- int len;
-
- len = recv (s, data, BUF_SIZE, 0) ;
- if (!len) {
- mp_tmsg(MSGT_NETWORK,MSGL_ERR,"\nAlert! EOF\n");
- return;
- }
-
- command = get_32 (data, 36) & 0xFFFF;
-
- if (command == 0x1b)
- send_command (s, 0x1b, 0, 0, 0, data);
- }
-}
-
-static int get_data (int s, char *buf, size_t count)
-{
- ssize_t len;
- size_t total = 0;
-
- while (total < count) {
-
- len = recv (s, &buf[total], count-total, 0);
-
- if (len<=0) {
- perror ("read error:");
- return 0;
- }
-
- total += len;
-
- if (len != 0) {
-// mp_msg(MSGT_NETWORK,MSGL_INFO,"[%d/%d]", total, count);
- fflush (stdout);
- }
-
- }
-
- return 1;
-
-}
-
-static int get_header (int s, uint8_t *header, streaming_ctrl_t *streaming_ctrl)
-{
- unsigned char pre_header[8];
- int header_len;
-
- header_len = 0;
-
- while (1) {
- if (!get_data (s, pre_header, 8)) {
- mp_tmsg(MSGT_NETWORK,MSGL_ERR,"pre-header read failed\n");
- return 0;
- }
- if (pre_header[4] == 0x02) {
-
- int packet_len;
-
- packet_len = (pre_header[7] << 8 | pre_header[6]) - 8;
-
-// mp_msg(MSGT_NETWORK,MSGL_INFO,"asf header packet detected, len=%d\n", packet_len);
-
- if (packet_len < 0 || packet_len > HDR_BUF_SIZE - header_len) {
- mp_tmsg(MSGT_NETWORK, MSGL_FATAL, "Invalid header size, giving up.\n");
- return 0;
- }
-
- if (!get_data (s, &header[header_len], packet_len)) {
- mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Header data read failed.\n");
- return 0;
- }
-
- header_len += packet_len;
-
- if ( (header[header_len-1] == 1) && (header[header_len-2]==1)) {
-
-
- if( streaming_bufferize( streaming_ctrl, header, header_len )<0 ) {
- return -1;
- }
-
- // mp_msg(MSGT_NETWORK,MSGL_INFO,"get header packet finished\n");
-
- return header_len;
-
- }
-
- } else {
-
- int32_t packet_len;
- int command;
- char data[BUF_SIZE];
-
- if (!get_data (s, (char*)&packet_len, 4)) {
- mp_tmsg(MSGT_NETWORK,MSGL_ERR,"packet_len read failed.\n");
- return 0;
- }
-
- packet_len = get_32 ((unsigned char*)&packet_len, 0) + 4;
-
-// mp_msg(MSGT_NETWORK,MSGL_INFO,"command packet detected, len=%d\n", packet_len);
-
- if (packet_len < 0 || packet_len > BUF_SIZE) {
- mp_tmsg(MSGT_NETWORK, MSGL_FATAL,
- "Invalid RTSP packet size, giving up.\n");
- return 0;
- }
-
- if (!get_data (s, data, packet_len)) {
- mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Command data read failed.\n");
- return 0;
- }
-
- command = get_32 (data, 24) & 0xFFFF;
-
-// mp_msg(MSGT_NETWORK,MSGL_INFO,"command: %02x\n", command);
-
- if (command == 0x1b)
- send_command (s, 0x1b, 0, 0, 0, data);
-
- }
-
-// mp_msg(MSGT_NETWORK,MSGL_INFO,"get header packet succ\n");
- }
-}
-
-static int interp_header (uint8_t *header, int header_len)
-{
- int i;
- int packet_length=-1;
-
- /*
- * parse header
- */
-
- i = 30;
- while (i<header_len) {
-
- uint64_t guid_1, guid_2, length;
-
- guid_2 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8)
- | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24)
- | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40)
- | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56);
- i += 8;
-
- guid_1 = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8)
- | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24)
- | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40)
- | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56);
- i += 8;
-
-// mp_msg(MSGT_NETWORK,MSGL_INFO,"guid found: %016llx%016llx\n", guid_1, guid_2);
-
- length = (uint64_t)header[i] | ((uint64_t)header[i+1]<<8)
- | ((uint64_t)header[i+2]<<16) | ((uint64_t)header[i+3]<<24)
- | ((uint64_t)header[i+4]<<32) | ((uint64_t)header[i+5]<<40)
- | ((uint64_t)header[i+6]<<48) | ((uint64_t)header[i+7]<<56);
-
- i += 8;
-
- if ( (guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22630ULL) ) {
- mp_tmsg(MSGT_NETWORK,MSGL_INFO,"header object\n");
- } else if ((guid_1 == 0x6cce6200aa00d9a6ULL) && (guid_2 == 0x11cf668e75b22636ULL)) {
- mp_tmsg(MSGT_NETWORK,MSGL_INFO,"data object\n");
- } else if ((guid_1 == 0x6553200cc000e48eULL) && (guid_2 == 0x11cfa9478cabdca1ULL)) {
-
- packet_length = get_32(header, i+92-24);
-
- mp_tmsg(MSGT_NETWORK,MSGL_INFO,"file object, packet length = %d (%d)\n",
- packet_length, get_32(header, i+96-24));
-
-
- } else if ((guid_1 == 0x6553200cc000e68eULL) && (guid_2 == 0x11cfa9b7b7dc0791ULL)) {
-
- int stream_id = header[i+48] | header[i+49] << 8;
-
- mp_tmsg(MSGT_NETWORK,MSGL_INFO,"stream object, stream ID: %d\n", stream_id);
-
- if (num_stream_ids < MAX_STREAMS) {
- stream_ids[num_stream_ids] = stream_id;
- num_stream_ids++;
- } else {
- mp_tmsg(MSGT_NETWORK,MSGL_ERR,"Too many IDs, stream skipped.");
- }
-
- } else {
-#if 0
- int b = i;
- printf ("unknown object (guid: %016llx, %016llx, len: %lld)\n", guid_1, guid_2, length);
- for (; b < length; b++)
- {
- if (isascii(header[b]) || isalpha(header[b]))
- printf("%c ", header[b]);
- else
- printf("%x ", header[b]);
- }
- printf("\n");
-#else
- mp_tmsg(MSGT_NETWORK,MSGL_WARN,"unknown object\n");
-#endif
- }
-
-// mp_msg(MSGT_NETWORK,MSGL_INFO,"length : %lld\n", length);
-
- i += length-24;
-
- }
-
- return packet_length;
-
-}
-
-
-static int get_media_packet (int s, int p