Fix issues with Gstreamer not considering our custom protocol handler a streaming...
authorIlpo Ruotsalainen <ilpo.ruotsalainen@movial.fi>
Wed, 26 Nov 2008 13:36:31 +0000 (15:36 +0200)
committerIlpo Ruotsalainen <ilpo.ruotsalainen@movial.fi>
Wed, 26 Nov 2008 13:36:31 +0000 (15:36 +0200)
isatis-player/isatissrc.c
isatis-player/isatissrc.h
isatis-player/player.c
isatis-plugin/plugin.c

index 81f857b..51cbfb6 100644 (file)
@@ -25,6 +25,8 @@
 #include <string.h>
 #include <fcntl.h>
 
+static gint isatis_fd = -1;
+
 GST_DEBUG_CATEGORY_STATIC(isatissrc_debug);
 #define GST_CAT_DEFAULT isatissrc_debug
 
@@ -40,6 +42,13 @@ static GstStaticPadTemplate srctemplate =
                        GST_PAD_ALWAYS,
                        GST_STATIC_CAPS_ANY);
 
+void gst_isatis_src_set_fd(gint fd)
+{
+       GST_DEBUG("setting fd to %d", fd);
+
+       isatis_fd = fd;
+}
+
 static GstURIType gst_isatis_src_uri_get_type(void)
 {
        return GST_URI_SRC;
@@ -47,7 +56,7 @@ static GstURIType gst_isatis_src_uri_get_type(void)
 
 static gchar **gst_isatis_src_uri_get_protocols(void)
 {
-       static gchar *protocols[] = { "isatis", NULL };
+       static gchar *protocols[] = { "http", NULL };
 
        return protocols;
 }
@@ -62,16 +71,15 @@ static const gchar *gst_isatis_src_uri_get_uri(GstURIHandler *handler)
 static gboolean gst_isatis_src_uri_set_uri(GstURIHandler *handler, const gchar *uri)
 {
        GstIsatisSrc *src = GST_ISATIS_SRC(handler);
-       gint fd;
 
-       GST_DEBUG_OBJECT(src, "setting URI to %s", uri);
-
-       if (sscanf(uri, "isatis://%d", &fd) != 1 || fd < 0)
+       if (isatis_fd < 0)
                return FALSE;
 
+       GST_DEBUG_OBJECT(src, "setting URI to %s", uri);
+
        g_free(src->uri);
 
-       src->socket = isatis_socket_create(fd);
+       src->socket = isatis_socket_create(isatis_fd);
        src->uri = g_strdup(uri);
 
        return TRUE;
@@ -250,7 +258,7 @@ static void gst_isatis_src_init(GstIsatisSrc *src, GstIsatisSrcClass *klass)
        GST_DEBUG_OBJECT(src, "initializing");
 
        src->socket = NULL;
-       src->uri = g_strdup("isatis://0");
+       src->uri = g_strdup("");
        src->eos = FALSE;
        src->buffer_queue = g_queue_new();
 }
@@ -291,7 +299,8 @@ static void gst_isatis_src_class_init(GstIsatisSrcClass *klass)
 
 static gboolean gst_isatis_plugin_init(GstPlugin *plugin)
 {
-       return gst_element_register(plugin, "isatissrc", GST_RANK_PRIMARY, gst_isatis_src_get_type());
+       /* Kludge: ensure we're definitely ranked higher than anyone else */
+       return gst_element_register(plugin, "isatissrc", GST_RANK_PRIMARY + 128, gst_isatis_src_get_type());
 }
 
 /* Sigh. */
index 94c20ae..e9780a9 100644 (file)
@@ -60,6 +60,8 @@ struct _GstIsatisSrcClass
 
 GType gst_isatis_src_get_type(void);
 
+void gst_isatis_src_set_fd(gint fd);
+
 G_END_DECLS
 
 #endif
index e7db439..5946da6 100644 (file)
@@ -24,6 +24,8 @@
 #include <gdk/gdkx.h>
 #include <glib.h>
 
+#include "isatissrc.h"
+
 typedef struct _PlayerInternal
 {
        gint xid;
@@ -274,9 +276,11 @@ static void stopbutton_clicked_callback(GtkButton *button, PlayerInternal *priv)
 
 static gboolean parse_args(int *argc, char ***argv, PlayerInternal *priv)
 {
+       gint fd = -1;
        GOptionEntry options[] =
        {
                { "xid", 'x', 0, G_OPTION_ARG_INT, &priv->xid, "XID of embed window", NULL },
+               { "isatis-fd", 'i', 0, G_OPTION_ARG_INT, &fd, "Plugin communication FD", NULL },
                { NULL }
        };
        GOptionContext *ctx;
@@ -293,6 +297,9 @@ static gboolean parse_args(int *argc, char ***argv, PlayerInternal *priv)
 
        g_option_context_free(ctx);
 
+       if (fd >= 0)
+               gst_isatis_src_set_fd(fd);
+
        return TRUE;
 }
 
index 9a48d2a..968787c 100644 (file)
@@ -137,29 +137,21 @@ static NPError NPP_SpawnPlayer(NPP instance)
                        /* Child process */
                        {
                                char xid_buf[32];
-                               char uri_buf[32];
-                               char *uri;
+                               char fd_buf[32];
 
                                /* Close the input side of the pipe in the child process */
                                close(socket_fds[1]);
 
                                snprintf(xid_buf, sizeof(xid_buf), "0x%lx", priv->xid);
-
-                               /* Shortcut file:// URIs for direct file access */
-                               if (!strncmp("file://", priv->uri, 7))
-                                       uri = priv->uri;
-                               else
-                               {
-                                       snprintf(uri_buf, sizeof(uri_buf), "isatis://%d", socket_fds[0]);
-
-                                       uri = uri_buf;
-                               }
+                               snprintf(fd_buf, sizeof(fd_buf), "%d", socket_fds[0]);
 
                                execl(BINDIR "/isatis-player",
                                                "isatis-player",
                                                "--xid",
                                                xid_buf,
-                                               uri,
+                                               "--isatis-fd",
+                                               fd_buf,
+                                               priv->uri,
                                                NULL);
 
                                DBG(("exec() failed\n"));