summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuo Jinghua <sunmoon1997@gmail.com>2009-09-10 11:21:17 +0800
committerLuo Jinghua <sunmoon1997@gmail.com>2009-09-10 11:21:17 +0800
commite9e5089932de65e46827c17b4bd76b38ae6b7bc3 (patch)
tree5c9c3a4ed8ea89b966e18418bc8b31c49c40942c
parent3741b7b600815ba740f9d953229160f4f39cce38 (diff)
ppssrc: recoded the uri if possible.
With this commit, the totem can play pps:// from pps.tv directly
-rw-r--r--src/gstppssrc.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/src/gstppssrc.c b/src/gstppssrc.c
index dcd5ed5..adb68b6 100644
--- a/src/gstppssrc.c
+++ b/src/gstppssrc.c
@@ -1029,9 +1029,32 @@ static char* gst_pps_src_encrypt_uri (const char *url, int id)
}
static gchar*
+gst_pps_src_recode_uri (const gchar *pps)
+{
+ gchar *uri, *recoded_uri;
+ gchar *result = NULL;
+
+ uri = g_uri_unescape_string (pps, NULL);
+ if (g_utf8_validate (uri, -1, NULL))
+ recoded_uri = g_convert (uri, strlen (uri), "gbk", "utf-8", NULL, NULL, NULL);
+ else
+ recoded_uri = g_strdup (uri);
+ if (!recoded_uri)
+ goto free_uri;
+
+ result = g_uri_escape_string
+ (recoded_uri, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
+
+ g_free (recoded_uri);
+free_uri:
+ g_free (uri);
+ return result;
+}
+
+static gchar*
gst_pps_src_transform_uri (const gchar *pps, int id)
{
- gchar *uri, *gb_uri, *reencoded_uri;
+ gchar *uri, *gb_uri, *recoded_uri;
gchar *result = NULL;
if (!g_str_has_prefix (pps, "pps://"))
@@ -1045,14 +1068,14 @@ gst_pps_src_transform_uri (const gchar *pps, int id)
if (!gb_uri)
goto free_uri;
- reencoded_uri = g_uri_escape_string
+ recoded_uri = g_uri_escape_string
(gb_uri, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE);
- if (!reencoded_uri)
+ if (!recoded_uri)
goto free_gb_uri;
- result = gst_pps_src_encrypt_uri (reencoded_uri, id);
+ result = gst_pps_src_encrypt_uri (recoded_uri, id);
- g_free (reencoded_uri);
+ g_free (recoded_uri);
free_gb_uri:
g_free (gb_uri);
free_uri:
@@ -1066,7 +1089,7 @@ gst_pps_src_set_location (GstPpsSrc * src, const gchar * uri)
g_free (src->location);
g_free (src->tvod_location);
- src->location = g_strdup (uri);
+ src->location = gst_pps_src_recode_uri (uri);
src->tvod_location = gst_pps_src_transform_uri (uri, 0);
src->location_changed = TRUE;