summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorattila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-11-01 14:43:28 +0000
committerattila <attila@b3059339-0415-0410-9bf9-f77b7e298cf2>2003-11-01 14:43:28 +0000
commit28f5233b36ea14ce9470cdc20a3bcc5908941e4b (patch)
treed92c9ed923b9ce27898579aef7cdda5f78fa9715 /libmpdemux
parenta2be6012e5349ce81ed0b779abf650600e346185 (diff)
downloadmpv-28f5233b36ea14ce9470cdc20a3bcc5908941e4b.tar.bz2
mpv-28f5233b36ea14ce9470cdc20a3bcc5908941e4b.tar.xz
Current mplayer (mine is mplayer-1.0-pre1cvs20031001) cannot play mms
stream with multibyte characters in the url. There is a bug in string_utf16() of libmpdemux/asf_mmst_streaming.c: the url encoding code is written for single-byte character only. It just fill a zero byte between every two adjacent bytes of the url string. This is wrong when the url string contains multi-byte characters. My patch is in the attachment, and has been tested working. It uses iconv() to convert the url's encoding to utf-16 correctly. So can this patch be accepted and commit into CVS? patch by Wang WenRui <wangwr@mail.ustc.edu.cn> git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@11351 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/asf_mmst_streaming.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/libmpdemux/asf_mmst_streaming.c b/libmpdemux/asf_mmst_streaming.c
index 24a7d8abd6..d0c8dd1c76 100644
--- a/libmpdemux/asf_mmst_streaming.c
+++ b/libmpdemux/asf_mmst_streaming.c
@@ -22,6 +22,12 @@
#include <winsock2.h>
#endif
+#ifdef USE_ICONV
+#include <locale.h>
+#include <langinfo.h>
+#include <iconv.h>
+#endif
+
#include "url.h"
#include "asf.h"
@@ -103,6 +109,38 @@ static void send_command (int s, int command, uint32_t switches,
}
}
+#ifdef USE_ICONV
+static iconv_t url_conv;
+
+static void string_utf16_open() {
+ setlocale(LC_CTYPE, "");
+ url_conv = iconv_open("UTF-16LE",nl_langinfo(CODESET));
+}
+
+static void string_utf16_close() {
+
+ iconv_close(url_conv);
+}
+
+static void string_utf16(char *dest, char *src, int len) {
+ size_t len1, len2;
+ char *ip, *op;
+
+ memset(dest, 0, 1000);
+ len1 = len; len2 = 1000;
+ ip = src; op = dest;
+
+ iconv(url_conv, &ip, &len1, &op, &len2);
+}
+
+#else
+
+static void string_utf16_open() {
+}
+
+static void string_utf16_close() {
+}
+
static void string_utf16(char *dest, char *src, int len)
{
int i;
@@ -116,6 +154,7 @@ static void string_utf16(char *dest, char *src, int len)
dest[i*2] = 0;
dest[i*2+1] = 0;
}
+#endif
static void get_answer (int s)
{
@@ -462,6 +501,9 @@ int asf_mmst_streaming_start(stream_t *stream)
* cmd 1 0x01
* */
+ /* prepare for the url encoding conversion */
+ string_utf16_open();
+
snprintf (str, 1023, "\034\003NSPlayer/7.0.0.1956; {33715801-BAB3-9D85-24E9-03B90328270A}; Host: %s", url1->hostname);
string_utf16 (data, str, strlen(str));
// send_command(s, commandno ....)
@@ -557,5 +599,7 @@ int asf_mmst_streaming_start(stream_t *stream)
packet_length1 = packet_length;
printf("mmst packet_length = %d\n",packet_length);
+ string_utf16_close();
+
return 0;
}