[Swfdec] 6 commits - libswfdec-gtk/swfdec_gtk_loader.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h libswfdec/swfdec_loader_internal.h libswfdec/swfdec_net_stream_as.c libswfdec/swfdec_net_stream.c
Benjamin Otte
company at kemper.freedesktop.org
Wed Aug 8 02:27:21 PDT 2007
libswfdec-gtk/swfdec_gtk_loader.c | 15 +++++++++++++++
libswfdec/swfdec_as_strings.c | 1 +
libswfdec/swfdec_loader.c | 15 +++++++++++++++
libswfdec/swfdec_loader.h | 2 ++
libswfdec/swfdec_loader_internal.h | 2 ++
libswfdec/swfdec_net_stream.c | 1 +
libswfdec/swfdec_net_stream_as.c | 11 +++++++++++
7 files changed, 47 insertions(+)
New commits:
diff-tree f322d58cdb5b8e566b1ea25d3d3d6dc73b209560 (from b7887f64973eb2ba7ff5c560bc32db37023fb455)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 8 11:05:35 2007 +0200
implement NetStream.close()
diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index ab08338..75589b7 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -249,6 +249,7 @@ const char swfdec_as_strings[] =
SWFDEC_AS_CONSTANT_STRING ("xMax")
SWFDEC_AS_CONSTANT_STRING ("yMin")
SWFDEC_AS_CONSTANT_STRING ("yMax")
+ SWFDEC_AS_CONSTANT_STRING ("close")
/* add more here */
;
diff --git a/libswfdec/swfdec_net_stream_as.c b/libswfdec/swfdec_net_stream_as.c
index ae85908..fd16876 100644
--- a/libswfdec/swfdec_net_stream_as.c
+++ b/libswfdec/swfdec_net_stream_as.c
@@ -30,6 +30,15 @@
#include "swfdec_player_internal.h"
static void
+swfdec_net_stream_close (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+ SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
+
+ swfdec_net_stream_set_loader (stream, NULL);
+ swfdec_net_stream_set_playing (stream, TRUE);
+}
+
+static void
swfdec_net_stream_play (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
{
SwfdecNetStream *stream = SWFDEC_NET_STREAM (obj);
@@ -119,6 +128,8 @@ swfdec_net_stream_init_context (SwfdecPl
swfdec_net_stream_pause, 0);
swfdec_as_object_add_function (proto, SWFDEC_AS_STR_play, SWFDEC_TYPE_NET_STREAM,
swfdec_net_stream_play, 1);
+ swfdec_as_object_add_function (proto, SWFDEC_AS_STR_close, SWFDEC_TYPE_NET_STREAM,
+ swfdec_net_stream_close, 0);
swfdec_as_object_add_function (proto, SWFDEC_AS_STR_seek, SWFDEC_TYPE_NET_STREAM,
swfdec_net_stream_do_seek, 1);
swfdec_as_object_add_function (proto, SWFDEC_AS_STR_setBufferTime, SWFDEC_TYPE_NET_STREAM,
diff-tree b7887f64973eb2ba7ff5c560bc32db37023fb455 (from c10ef4a4721e1aa5f07aebb6320226dbb93bc974)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 8 11:05:16 2007 +0200
close the loader when removing it
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 6f266b7..b95f7a4 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -468,6 +468,7 @@ swfdec_net_stream_set_loader (SwfdecNetS
if (stream->loader) {
swfdec_loader_set_target (stream->loader, NULL);
+ swfdec_loader_close (stream->loader);
g_object_unref (stream->loader);
}
if (stream->flvdecoder) {
diff-tree c10ef4a4721e1aa5f07aebb6320226dbb93bc974 (from 58b73bfa1e54bd95744e89e7f9fc6902ab1a48d3)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 8 11:04:19 2007 +0200
implement close()
diff --git a/libswfdec-gtk/swfdec_gtk_loader.c b/libswfdec-gtk/swfdec_gtk_loader.c
index bc3894a..aff6da1 100644
--- a/libswfdec-gtk/swfdec_gtk_loader.c
+++ b/libswfdec-gtk/swfdec_gtk_loader.c
@@ -141,6 +141,20 @@ swfdec_gtk_loader_load (SwfdecLoader *lo
}
static void
+swfdec_gtk_loader_close (SwfdecLoader *loader)
+{
+ SwfdecGtkLoader *gtk = SWFDEC_GTK_LOADER (loader);
+
+ if (gtk->message) {
+ SwfdecGtkLoaderClass *klass = SWFDEC_GTK_LOADER_GET_CLASS (gtk);
+
+ soup_session_cancel_message (klass->session, gtk->message);
+ g_object_unref (gtk->message);
+ gtk->message = NULL;
+ }
+}
+
+static void
swfdec_gtk_loader_class_init (SwfdecGtkLoaderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -149,6 +163,7 @@ swfdec_gtk_loader_class_init (SwfdecGtkL
object_class->dispose = swfdec_gtk_loader_dispose;
loader_class->load = swfdec_gtk_loader_load;
+ loader_class->close = swfdec_gtk_loader_close;
g_thread_init (NULL);
klass->session = soup_session_async_new ();
diff-tree 58b73bfa1e54bd95744e89e7f9fc6902ab1a48d3 (from 36cb0e40b75982fd64589be06bdeebbf4957817e)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 8 10:59:00 2007 +0200
make the closing code more strict
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index 85ff5fd..b6885e7 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -268,6 +268,8 @@ swfdec_loader_close (SwfdecLoader *loade
if (klass->close)
klass->close (loader);
+ if (loader->state != SWFDEC_LOADER_STATE_ERROR)
+ loader->state = SWFDEC_LOADER_STATE_CLOSED;
}
void
diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h
index 5fc561f..61e0b31 100644
--- a/libswfdec/swfdec_loader.h
+++ b/libswfdec/swfdec_loader.h
@@ -76,7 +76,7 @@ struct _SwfdecLoaderClass
SwfdecLoaderRequest request,
const char * data,
gsize data_len);
- /* if open, close the loader */
+ /* if open, close the loader. NB: you may not call push() or eof() after the loader has been closed */
void (* close) (SwfdecLoader * loader);
};
diff --git a/libswfdec/swfdec_loader_internal.h b/libswfdec/swfdec_loader_internal.h
index 6de9233..386f910 100644
--- a/libswfdec/swfdec_loader_internal.h
+++ b/libswfdec/swfdec_loader_internal.h
@@ -30,6 +30,7 @@ typedef enum {
SWFDEC_LOADER_STATE_OPEN, /* loader is opened and has got the HTTP headers */
SWFDEC_LOADER_STATE_READING, /* loader has read some bytes of data and is still reading */
SWFDEC_LOADER_STATE_EOF, /* swfdec_loader_eof() has been called */
+ SWFDEC_LOADER_STATE_CLOSED, /* loader has been closed by Swfdec */
SWFDEC_LOADER_STATE_ERROR /* loader is in error state */
} SwfdecLoaderState;
diff-tree 36cb0e40b75982fd64589be06bdeebbf4957817e (from 019799d4d5320fd23cfb18e11d9c85c5c553fe8e)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 8 10:51:37 2007 +0200
print error message on loader error
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index bb210fd..85ff5fd 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -338,6 +338,7 @@ swfdec_loader_error (SwfdecLoader *loade
return;
}
+ SWFDEC_ERROR ("error in loader %p: %s", loader, error);
loader->state = SWFDEC_LOADER_STATE_ERROR;
loader->error = g_strdup (error);
if (loader->target)
diff-tree 019799d4d5320fd23cfb18e11d9c85c5c553fe8e (from efc9ce9124f28dfad6858a83fc2fdc749ab4ee2c)
Author: Benjamin Otte <otte at gnome.org>
Date: Wed Aug 8 10:50:10 2007 +0200
add swfdec_loader_close() to allow scripts to close a stream.
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index c5b4de5..bb210fd 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -259,6 +259,18 @@ swfdec_loader_load (SwfdecLoader *loader
}
void
+swfdec_loader_close (SwfdecLoader *loader)
+{
+ SwfdecLoaderClass *klass;
+
+ g_return_if_fail (SWFDEC_IS_LOADER (loader));
+ klass = SWFDEC_LOADER_GET_CLASS (loader);
+
+ if (klass->close)
+ klass->close (loader);
+}
+
+void
swfdec_loader_set_target (SwfdecLoader *loader, SwfdecLoaderTarget *target)
{
g_return_if_fail (SWFDEC_IS_LOADER (loader));
diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h
index f0bd717..5fc561f 100644
--- a/libswfdec/swfdec_loader.h
+++ b/libswfdec/swfdec_loader.h
@@ -76,6 +76,8 @@ struct _SwfdecLoaderClass
SwfdecLoaderRequest request,
const char * data,
gsize data_len);
+ /* if open, close the loader */
+ void (* close) (SwfdecLoader * loader);
};
GType swfdec_loader_get_type (void);
diff --git a/libswfdec/swfdec_loader_internal.h b/libswfdec/swfdec_loader_internal.h
index fb851bd..6de9233 100644
--- a/libswfdec/swfdec_loader_internal.h
+++ b/libswfdec/swfdec_loader_internal.h
@@ -38,6 +38,7 @@ SwfdecLoader * swfdec_loader_load (Swf
SwfdecLoaderRequest request,
const char * data,
gsize data_len);
+void swfdec_loader_close (SwfdecLoader * loader);
void swfdec_loader_set_target (SwfdecLoader * loader,
SwfdecLoaderTarget * target);
void swfdec_loader_set_data_type (SwfdecLoader * loader,
More information about the Swfdec
mailing list