1.1 --- a/gmyth-stream/libgnomevfs2/modules/gmythstream-method.c Thu Apr 12 22:38:44 2007 +0100
1.2 +++ b/gmyth-stream/libgnomevfs2/modules/gmythstream-method.c Fri Apr 13 20:07:32 2007 +0100
1.3 @@ -155,60 +155,52 @@
1.4 return;
1.5 }
1.6
1.7 +char* _parse_opt(char* opt)
1.8 +{
1.9 + char** list = g_strsplit(opt, "opt=", 2);
1.10 + char** opts = g_strsplit(list[1], "+", 32);
1.11 + char* value = "";
1.12 + char* aux;
1.13 + gint i = 0;
1.14 +
1.15 + for (aux = opts[0]; aux != NULL; aux = opts[++i])
1.16 + value = g_strdup_printf("%s %s", value, aux);
1.17 +
1.18 + g_free(aux);
1.19 + g_strfreev(list);
1.20 + g_strfreev(opts);
1.21 + return value;
1.22 +}
1.23 +
1.24 static UriArgs *
1.25 _uri_parse_args (const GnomeVFSURI *uri)
1.26 {
1.27 + gchar *file = gnome_vfs_unescape_string (uri->text, NULL);
1.28
1.29 - gchar *file;
1.30 + gchar **list = g_strsplit(file, "\'", 3);
1.31 + gchar **prefix = g_strsplit_set(list[0], "/=", 3);
1.32 + gchar **lst = g_strsplit (list[2], "?", 0);
1.33 +
1.34 UriArgs *info = g_new0 (UriArgs, 1);
1.35 - GSList *args = NULL;
1.36 - gchar *c;
1.37 - GString *entry;
1.38 - gboolean open = FALSE;
1.39 - gchar **prop;
1.40 - GSList* walk;
1.41 - gchar *uri_str = gnome_vfs_uri_to_string (uri,
1.42 - GNOME_VFS_URI_HIDE_USER_NAME |
1.43 - GNOME_VFS_URI_HIDE_PASSWORD |
1.44 - GNOME_VFS_URI_HIDE_HOST_NAME |
1.45 - GNOME_VFS_URI_HIDE_HOST_PORT |
1.46 - GNOME_VFS_URI_HIDE_TOPLEVEL_METHOD);
1.47 + gint i = 1;
1.48
1.49 - file = gnome_vfs_unescape_string (uri_str, "");
1.50 - c = file;
1.51 - entry = g_string_new ("");
1.52 - c = c + 1;
1.53 - do {
1.54 - if ((*c == '\"') || (*c == '\'')) {
1.55 - open = !open;
1.56 - }
1.57 + gchar** prop = NULL;
1.58 + prop = g_strsplit_set(lst[0], "/=", 3);
1.59
1.60 - if (((*c == '?') || (c[1] == '\0')) && !open) {
1.61 - if (*c != '?')
1.62 - g_string_append_c (entry, *c);
1.63 - args = g_slist_append (args, g_strdup (entry->str));
1.64 - entry = g_string_assign (entry, "");
1.65 - } else {
1.66 - if (*c == '+')
1.67 - g_string_append_c (entry, "//");
1.68 - else
1.69 - g_string_append_c (entry, *c);
1.70 - }
1.71 - c = c + 1;
1.72 - } while (*c != '\0');
1.73 + info->file_name = g_strdup_printf ("%s://%s",\
1.74 + prefix[1],list[1]);
1.75
1.76 - g_string_free (entry, TRUE);
1.77 + //g_debug("FILENAME: [%s]", info->file_name);
1.78
1.79 - for (walk = args; walk != NULL; walk = walk->next)
1.80 + g_strfreev(prop);
1.81 +
1.82 + gchar* walk;
1.83 + for (walk = lst[1]; walk != NULL; walk = lst[++i])
1.84 {
1.85 - gchar *arg = (gchar *) walk->data;
1.86 - prop = g_strsplit(arg, "=", 2);
1.87 - g_debug ("arg = %s", arg);
1.88 + prop = g_strsplit(walk, "=", 2);
1.89
1.90 if (g_strv_length (prop) == 2) {
1.91 - if (strcmp (prop[0], "file") == 0) {
1.92 - info->file_name = g_strdup (prop[1]);
1.93 - } else if (strcmp (prop[0], "mux") == 0) {
1.94 + if (strcmp (prop[0], "mux") == 0) {
1.95 info->mux = g_strdup (prop[1]);
1.96 } else if (strcmp (prop[0], "vcodec") == 0) {
1.97 info->vcodec = g_strdup (prop[1]);
1.98 @@ -225,16 +217,16 @@
1.99 } else if (strcmp (prop[0], "height") == 0) {
1.100 info->height = atoi (prop[1]);
1.101 } else if (strcmp (prop[0], "opt") == 0) {
1.102 - g_debug("DENTRO DE OPT: %s", arg);
1.103 - //char* v = _parse_opt(walk);
1.104 - info->opt = g_strdup (arg);
1.105 + info->opt = g_strdup (_parse_opt(walk));
1.106 }
1.107 }
1.108 g_strfreev (prop);
1.109 - g_free (arg);
1.110 }
1.111 +
1.112 g_free (file);
1.113 - g_slist_free (args);
1.114 + g_strfreev (list);
1.115 + g_strfreev (prefix);
1.116 + g_strfreev (lst);
1.117 return info;
1.118 }
1.119
1.120 @@ -248,8 +240,6 @@
1.121 gmsHandle *handle = gmsHandle_new(uri);
1.122 UriArgs *args;
1.123
1.124 - args = _uri_parse_args (uri);
1.125 -
1.126 if (!gmyth_stream_client_connect (handle->stream,
1.127 gnome_vfs_uri_get_host_name (uri),
1.128 gnome_vfs_uri_get_host_port (uri))) {
1.129 @@ -301,9 +291,14 @@
1.130 gint64 total_read = 0;
1.131 gmsHandle *handle = (gmsHandle *) method_handle;
1.132
1.133 + //g_debug("waiting something");
1.134 +
1.135 total_read = recv(handle->fd, buffer, BUFFER_SIZE, 0);
1.136 + //g_debug("COULD READ: %d bytes", total_read);
1.137 *bytes_read = (GnomeVFSFileSize) total_read;
1.138
1.139 + //if (total_read < 0) g_debug("ERROR!!!!!!!!!!!!!!!!");
1.140 +
1.141 if (total_read < 0) return GNOME_VFS_ERROR_INTERNAL;
1.142 else return GNOME_VFS_OK;
1.143
1.144 @@ -316,6 +311,8 @@
1.145 {
1.146 gmsHandle *handle = (gmsHandle *) method_handle;
1.147
1.148 + g_debug("close close close");
1.149 +
1.150 gmyth_stream_client_close_stream (handle->stream);
1.151 gmyth_stream_client_disconnect (handle->stream);
1.152