[Swfdec] 11 commits - libswfdec/swfdec_as_interpret.c libswfdec/swfdec_loader.c libswfdec/swfdec_loader.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_player_internal.h libswfdec/swfdec_resource.c libswfdec/swfdec_resource_request.c libswfdec/swfdec_resource_request.h test/trace
Benjamin Otte
company at kemper.freedesktop.org
Thu Nov 8 06:09:49 PST 2007
libswfdec/swfdec_as_interpret.c | 5
libswfdec/swfdec_loader.c | 110 +++++-------
libswfdec/swfdec_loader.h | 2
libswfdec/swfdec_net_stream.c | 23 --
libswfdec/swfdec_player.c | 54 -----
libswfdec/swfdec_player_internal.h | 3
libswfdec/swfdec_resource.c | 4
libswfdec/swfdec_resource_request.c | 101 +++++++++--
libswfdec/swfdec_resource_request.h | 10 -
test/trace/Makefile.am | 14 +
test/trace/moviecliploader-error-illegalrequest-6.swf |binary
test/trace/moviecliploader-error-illegalrequest-6.swf.trace | 7
test/trace/moviecliploader-error-illegalrequest-7.swf |binary
test/trace/moviecliploader-error-illegalrequest-7.swf.trace | 4
test/trace/moviecliploader-error-illegalrequest-8.swf |binary
test/trace/moviecliploader-error-illegalrequest-8.swf.trace | 4
test/trace/moviecliploader-error-illegalrequest.as | 16 +
test/trace/moviecliploader-error-urlnotfound-6.swf |binary
test/trace/moviecliploader-error-urlnotfound-6.swf.trace | 7
test/trace/moviecliploader-error-urlnotfound-7.swf |binary
test/trace/moviecliploader-error-urlnotfound-7.swf.trace | 4
test/trace/moviecliploader-error-urlnotfound-8.swf |binary
test/trace/moviecliploader-error-urlnotfound-8.swf.trace | 4
test/trace/moviecliploader-error-urlnotfound.as | 16 +
test/trace/netstream-load-loop-6.swf.trace | 9
test/trace/netstream-load-loop-7.swf.trace | 9
test/trace/netstream-load-loop-8.swf.trace | 9
27 files changed, 236 insertions(+), 179 deletions(-)
New commits:
commit e4a1e22910d10c3613a130f0b15fb8b591ebc13e
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 15:08:10 2007 +0100
add 2 tests that check MovieClipLoader error messages
Note that they are compiled to run in the local sandbox.
The Flash 5 versions have been skipped, as they don't work for other reasons.
diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index b7474f0..0cc753f 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -982,6 +982,20 @@ EXTRA_DIST = \
movieclip-target-6.swf.trace \
movieclip-target-7.swf \
movieclip-target-7.swf.trace \
+ moviecliploader-error-illegalrequest.as \
+ moviecliploader-error-illegalrequest-6.swf \
+ moviecliploader-error-illegalrequest-6.swf.trace \
+ moviecliploader-error-illegalrequest-7.swf \
+ moviecliploader-error-illegalrequest-7.swf.trace \
+ moviecliploader-error-illegalrequest-8.swf \
+ moviecliploader-error-illegalrequest-8.swf.trace \
+ moviecliploader-error-urlnotfound.as \
+ moviecliploader-error-urlnotfound-6.swf \
+ moviecliploader-error-urlnotfound-6.swf.trace \
+ moviecliploader-error-urlnotfound-7.swf \
+ moviecliploader-error-urlnotfound-7.swf.trace \
+ moviecliploader-error-urlnotfound-8.swf \
+ moviecliploader-error-urlnotfound-8.swf.trace \
moviecliploader-getprogress.as \
moviecliploader-getprogress-5.swf \
moviecliploader-getprogress-5.swf.trace \
diff --git a/test/trace/moviecliploader-error-illegalrequest-6.swf b/test/trace/moviecliploader-error-illegalrequest-6.swf
new file mode 100644
index 0000000..146b082
Binary files /dev/null and b/test/trace/moviecliploader-error-illegalrequest-6.swf differ
diff --git a/test/trace/moviecliploader-error-illegalrequest-6.swf.trace b/test/trace/moviecliploader-error-illegalrequest-6.swf.trace
new file mode 100644
index 0000000..0a1f52f
--- /dev/null
+++ b/test/trace/moviecliploader-error-illegalrequest-6.swf.trace
@@ -0,0 +1,7 @@
+setup done
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
diff --git a/test/trace/moviecliploader-error-illegalrequest-7.swf b/test/trace/moviecliploader-error-illegalrequest-7.swf
new file mode 100644
index 0000000..7a3f963
Binary files /dev/null and b/test/trace/moviecliploader-error-illegalrequest-7.swf differ
diff --git a/test/trace/moviecliploader-error-illegalrequest-7.swf.trace b/test/trace/moviecliploader-error-illegalrequest-7.swf.trace
new file mode 100644
index 0000000..e94bc20
--- /dev/null
+++ b/test/trace/moviecliploader-error-illegalrequest-7.swf.trace
@@ -0,0 +1,4 @@
+setup done
+enterFrame: old movie
+onLoadError: IllegalRequest (0)
+enterFrame: old movie
diff --git a/test/trace/moviecliploader-error-illegalrequest-8.swf b/test/trace/moviecliploader-error-illegalrequest-8.swf
new file mode 100644
index 0000000..2e9b5b4
Binary files /dev/null and b/test/trace/moviecliploader-error-illegalrequest-8.swf differ
diff --git a/test/trace/moviecliploader-error-illegalrequest-8.swf.trace b/test/trace/moviecliploader-error-illegalrequest-8.swf.trace
new file mode 100644
index 0000000..e94bc20
--- /dev/null
+++ b/test/trace/moviecliploader-error-illegalrequest-8.swf.trace
@@ -0,0 +1,4 @@
+setup done
+enterFrame: old movie
+onLoadError: IllegalRequest (0)
+enterFrame: old movie
diff --git a/test/trace/moviecliploader-error-illegalrequest.as b/test/trace/moviecliploader-error-illegalrequest.as
new file mode 100644
index 0000000..17c7bfb
--- /dev/null
+++ b/test/trace/moviecliploader-error-illegalrequest.as
@@ -0,0 +1,16 @@
+// makeswf -v 7 -s 200x150 -r 1 -o moviecliploader-error-illegalrequest.swf moviecliploader-error-illegalrequest.as
+
+x = createEmptyMovieClip ("a", 0);
+l = new MovieClipLoader ();
+l.onLoadError = function (m, error, status) {
+ trace ("onLoadError: " + error + " (" + status + ")");
+ loadMovie ("fscommand:quit", "");
+};
+l.loadClip ("http://example.com/404", "a");
+
+onEnterFrame = function () {
+ trace ("enterFrame: " + (x == a ? "old movie" : "new movie"));
+};
+
+setTimeout (function () { loadMovie ("fscommand:quit", ""); }, 5000);
+trace ("setup done");
diff --git a/test/trace/moviecliploader-error-urlnotfound-6.swf b/test/trace/moviecliploader-error-urlnotfound-6.swf
new file mode 100644
index 0000000..ce13476
Binary files /dev/null and b/test/trace/moviecliploader-error-urlnotfound-6.swf differ
diff --git a/test/trace/moviecliploader-error-urlnotfound-6.swf.trace b/test/trace/moviecliploader-error-urlnotfound-6.swf.trace
new file mode 100644
index 0000000..0a1f52f
--- /dev/null
+++ b/test/trace/moviecliploader-error-urlnotfound-6.swf.trace
@@ -0,0 +1,7 @@
+setup done
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
+enterFrame: old movie
diff --git a/test/trace/moviecliploader-error-urlnotfound-7.swf b/test/trace/moviecliploader-error-urlnotfound-7.swf
new file mode 100644
index 0000000..1cc0466
Binary files /dev/null and b/test/trace/moviecliploader-error-urlnotfound-7.swf differ
diff --git a/test/trace/moviecliploader-error-urlnotfound-7.swf.trace b/test/trace/moviecliploader-error-urlnotfound-7.swf.trace
new file mode 100644
index 0000000..b85f38d
--- /dev/null
+++ b/test/trace/moviecliploader-error-urlnotfound-7.swf.trace
@@ -0,0 +1,4 @@
+setup done
+enterFrame: old movie
+onLoadError: URLNotFound (0)
+enterFrame: old movie
diff --git a/test/trace/moviecliploader-error-urlnotfound-8.swf b/test/trace/moviecliploader-error-urlnotfound-8.swf
new file mode 100644
index 0000000..5d036f9
Binary files /dev/null and b/test/trace/moviecliploader-error-urlnotfound-8.swf differ
diff --git a/test/trace/moviecliploader-error-urlnotfound-8.swf.trace b/test/trace/moviecliploader-error-urlnotfound-8.swf.trace
new file mode 100644
index 0000000..b85f38d
--- /dev/null
+++ b/test/trace/moviecliploader-error-urlnotfound-8.swf.trace
@@ -0,0 +1,4 @@
+setup done
+enterFrame: old movie
+onLoadError: URLNotFound (0)
+enterFrame: old movie
diff --git a/test/trace/moviecliploader-error-urlnotfound.as b/test/trace/moviecliploader-error-urlnotfound.as
new file mode 100644
index 0000000..10f9219
--- /dev/null
+++ b/test/trace/moviecliploader-error-urlnotfound.as
@@ -0,0 +1,16 @@
+// makeswf -v 7 -s 200x150 -r 1 -o moviecliploader-error-urlnotfound.swf moviecliploader-error-urlnotfound.as
+
+x = createEmptyMovieClip ("a", 0);
+l = new MovieClipLoader ();
+l.onLoadError = function (m, error, status) {
+ trace ("onLoadError: " + error + " (" + status + ")");
+ loadMovie ("fscommand:quit", "");
+};
+l.loadClip ("404", "a");
+
+onEnterFrame = function () {
+ trace ("enterFrame: " + (x == a ? "old movie" : "new movie"));
+};
+
+setTimeout (function () { loadMovie ("fscommand:quit", ""); }, 5000);
+trace ("setup done");
commit c9aaf933d25b5cac686001b508f00fc59ba1276a
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 14:18:10 2007 +0100
only set the target of the loader when it actually exists
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 9a4f1c9..4e50123 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -345,8 +345,8 @@ swfdec_resource_dispose (GObject *object)
{
SwfdecResource *resource = SWFDEC_RESOURCE (object);
- swfdec_loader_set_target (resource->loader, NULL);
if (resource->loader) {
+ swfdec_loader_set_target (resource->loader, NULL);
g_object_unref (resource->loader);
resource->loader = NULL;
}
commit 9f1406855d58c01a500496731c8030807b7ed9e0
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 14:05:51 2007 +0100
FScommands are handled in the resource loading phase.
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 2cac041..a1c456c 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -43,6 +43,7 @@
#include "swfdec_sprite.h"
#include "swfdec_sprite_movie.h"
#include "swfdec_resource.h"
+#include "swfdec_resource_request.h"
#include "swfdec_text_field_movie.h" // for typeof
/* Define this to get SWFDEC_WARN'd about missing properties of objects.
@@ -1139,7 +1140,7 @@ swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, gu
}
if (!SWFDEC_IS_PLAYER (cx)) {
SWFDEC_ERROR ("GetURL without a SwfdecPlayer");
- } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) {
+ } else if (swfdec_player_request_fscommand (SWFDEC_PLAYER (cx), url, target)) {
/* nothing to do here */
} else if (swfdec_player_get_level (SWFDEC_PLAYER (cx), target) >= 0) {
swfdec_resource_load (SWFDEC_PLAYER (cx), target, url,
@@ -1176,7 +1177,7 @@ swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, g
if (!SWFDEC_IS_PLAYER (cx)) {
SWFDEC_ERROR ("GetURL2 action requires a SwfdecPlayer");
- } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) {
+ } else if (swfdec_player_request_fscommand (SWFDEC_PLAYER (cx), url, target)) {
/* nothing to do here */
} else if (variables) {
SwfdecMovie *movie;
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index fdf6872..fb5e2d6 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1801,52 +1801,6 @@ swfdec_player_get_movie_at_level (SwfdecPlayer *player, int level)
return NULL;
}
-static gboolean
-is_ascii (const char *s)
-{
- while (*s) {
- if (*s & 0x80)
- return FALSE;
- s++;
- }
- return TRUE;
-}
-
-/**
- * swfdec_player_fscommand:
- * @player: a #SwfdecPlayer
- * @command: the command to parse
- * @value: the value passed to the command
- *
- * Checks if @command is an FSCommand and if so, emits the
- * SwfdecPlayer::fscommand signal.
- *
- * Returns: %TRUE if an fscommand was found and the signal emitted, %FALSE
- * otherwise.
- **/
-gboolean
-swfdec_player_fscommand (SwfdecPlayer *player, const char *command, const char *value)
-{
- char *real_command;
-
- g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
- g_return_val_if_fail (command != NULL, FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
-
- if (g_ascii_strncasecmp (command, "FSCommand:", 10) != 0)
- return FALSE;
-
- command += 10;
- if (!is_ascii (command)) {
- SWFDEC_ERROR ("command \"%s\" are not ascii, skipping fscommand", command);
- return TRUE;
- }
- real_command = g_ascii_strdown (command, -1);
- g_signal_emit (player, signals[FSCOMMAND], 0, real_command, value);
- g_free (real_command);
- return TRUE;
-}
-
void
swfdec_player_launch (SwfdecPlayer *player, SwfdecLoaderRequest request, const char *url,
const char *target, SwfdecBuffer *data)
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index a30433a..a9d870a 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -216,9 +216,6 @@ SwfdecSpriteMovie *
(SwfdecPlayer * player,
SwfdecResource * resource,
int level);
-gboolean swfdec_player_fscommand (SwfdecPlayer * player,
- const char * command,
- const char * value);
void swfdec_player_launch (SwfdecPlayer * player,
SwfdecLoaderRequest request,
const char * url,
diff --git a/libswfdec/swfdec_resource_request.c b/libswfdec/swfdec_resource_request.c
index 07b768a..0b67a66 100644
--- a/libswfdec/swfdec_resource_request.c
+++ b/libswfdec/swfdec_resource_request.c
@@ -32,7 +32,8 @@ swfdec_resource_request_free (SwfdecResourceRequest *request)
{
g_return_if_fail (request != NULL);
- g_object_unref (request->security);
+ if (request->security)
+ g_object_unref (request->security);
if (request->destroy)
request->destroy (request->data);
g_free (request->url);
@@ -77,6 +78,11 @@ swfdec_request_resource_perform_one (gpointer requestp, gpointer playerp)
SwfdecResourceRequest *request = requestp;
SwfdecLoader *loader;
+ if (request->security == NULL) {
+ g_signal_emit_by_name (player, "fscommand", request->url, request->data);
+ swfdec_resource_request_free (request);
+ return;
+ }
g_assert (player->resource);
loader = swfdec_player_request_resource_now (player, request->security,
request->url, request->request, request->buffer);
@@ -122,6 +128,56 @@ swfdec_player_request_resource (SwfdecPlayer *player, SwfdecSecurity *security,
player->resource_requests = g_slist_append (player->resource_requests, request);
}
+static gboolean
+is_ascii (const char *s)
+{
+ while (*s) {
+ if (*s & 0x80)
+ return FALSE;
+ s++;
+ }
+ return TRUE;
+}
+
+/**
+ * swfdec_player_request_fscommand:
+ * @player: a #SwfdecPlayer
+ * @command: the command to parse
+ * @value: the value passed to the command
+ *
+ * Checks if @command is an FSCommand and if so, queues emission of the
+ * SwfdecPlayer::fscommand signal.
+ *
+ * Returns: %TRUE if an fscommand was found and the signal emitted, %FALSE
+ * otherwise.
+ **/
+gboolean
+swfdec_player_request_fscommand (SwfdecPlayer *player, const char *command,
+ const char *value)
+{
+ SwfdecResourceRequest *request;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), FALSE);
+ g_return_val_if_fail (command != NULL, FALSE);
+ g_return_val_if_fail (value != NULL, FALSE);
+
+ if (g_ascii_strncasecmp (command, "FSCommand:", 10) != 0)
+ return FALSE;
+
+ command += 10;
+ if (!is_ascii (command)) {
+ SWFDEC_ERROR ("command \"%s\" are not ascii, skipping fscommand", command);
+ return TRUE;
+ }
+ request = g_slice_new0 (SwfdecResourceRequest);
+ request->url = g_ascii_strdown (command, -1);
+ request->destroy = g_free;
+ request->data = g_strdup (value);
+
+ player->resource_requests = g_slist_append (player->resource_requests, request);
+ return TRUE;
+}
+
void
swfdec_player_resource_request_init (SwfdecPlayer *player)
{
diff --git a/libswfdec/swfdec_resource_request.h b/libswfdec/swfdec_resource_request.h
index a251c5d..bb6669f 100644
--- a/libswfdec/swfdec_resource_request.h
+++ b/libswfdec/swfdec_resource_request.h
@@ -30,7 +30,7 @@ typedef void (* SwfdecResourceFunc) (SwfdecPlayer *player, SwfdecLoader *loader,
struct _SwfdecResourceRequest
{
- SwfdecSecurity * security; /* security context when loading */
+ SwfdecSecurity * security; /* security context when loading or NULL for fscommand */
char * url; /* URL we're gonna load */
SwfdecLoaderRequest request; /* how are we goona load this URL? */
@@ -51,6 +51,9 @@ void swfdec_player_request_resource (SwfdecPlayer * player,
SwfdecResourceFunc func,
gpointer data,
GDestroyNotify destroy);
+gboolean swfdec_player_request_fscommand (SwfdecPlayer * player,
+ const char * command,
+ const char * value);
SwfdecLoader * swfdec_player_request_resource_now (SwfdecPlayer * player,
SwfdecSecurity * security,
const char * url,
commit e543f153529cdc5310645db37167a8f029b84418
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 13:40:10 2007 +0100
typo
diff --git a/libswfdec/swfdec_resource_request.h b/libswfdec/swfdec_resource_request.h
index 9f9f69f..a251c5d 100644
--- a/libswfdec/swfdec_resource_request.h
+++ b/libswfdec/swfdec_resource_request.h
@@ -30,7 +30,7 @@ typedef void (* SwfdecResourceFunc) (SwfdecPlayer *player, SwfdecLoader *loader,
struct _SwfdecResourceRequest
{
- SwfdecSecurity * security; /* security context hen loading */
+ SwfdecSecurity * security; /* security context when loading */
char * url; /* URL we're gonna load */
SwfdecLoaderRequest request; /* how are we goona load this URL? */
commit 80b8bff7478489573aa4a4be9b90ca9cdf81f7fa
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 12:42:14 2007 +0100
external actions, don't trigger execution of resource requests.
Only iterating does.
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index dd5484f..fdf6872 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -515,8 +515,6 @@ swfdec_player_trigger_external_actions (SwfdecTimeout *advance)
player->external_timeout.callback = NULL;
swfdec_player_perform_external_actions (player);
- swfdec_player_resource_request_perform (player);
- swfdec_player_perform_actions (player);
}
void
commit 54ffa034d9f20ead99bed361f147cb8b75f28410
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 12:40:23 2007 +0100
make NetStream use swfdec_player_request_resource_now()
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 255bb34..d4ac232 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -469,22 +469,11 @@ swfdec_net_stream_new (SwfdecNetConnection *conn)
return stream;
}
-static void
-swfdec_net_stream_got_loader (SwfdecPlayer *player, SwfdecLoader *loader, gpointer streamp)
-{
- SwfdecNetStream *stream = SWFDEC_NET_STREAM (streamp);
-
- if (loader == NULL || SWFDEC_AS_OBJECT (stream)->context == NULL)
- return;
-
- swfdec_net_stream_set_loader (stream, loader);
- g_object_unref (loader);
-}
-
void
swfdec_net_stream_set_url (SwfdecNetStream *stream, const char *url)
{
SwfdecAsContext *cx;
+ SwfdecLoader *loader;
g_return_if_fail (SWFDEC_IS_NET_STREAM (stream));
g_return_if_fail (url != NULL);
@@ -492,10 +481,12 @@ swfdec_net_stream_set_url (SwfdecNetStream *stream, const char *url)
/* FIXME: use the connection once connections are implemented */
cx = SWFDEC_AS_OBJECT (stream)->context;
g_assert (cx->frame);
- g_object_ref (stream);
- swfdec_player_request_resource (SWFDEC_PLAYER (cx), cx->frame->security, url,
- SWFDEC_LOADER_REQUEST_DEFAULT, NULL, swfdec_net_stream_got_loader, stream,
- g_object_unref);
+ loader = swfdec_player_request_resource_now (SWFDEC_PLAYER (cx), cx->frame->security,
+ url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
+ if (loader) {
+ swfdec_net_stream_set_loader (stream, loader);
+ g_object_unref (loader);
+ }
}
void
commit fa580e5ec64231a946e8ffbc21b107619b056873
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 12:40:06 2007 +0100
add swfdec_player_request_resource_now()
It seems NetStream resource requests are immediately executed
diff --git a/libswfdec/swfdec_resource_request.c b/libswfdec/swfdec_resource_request.c
index 48ffcd3..07b768a 100644
--- a/libswfdec/swfdec_resource_request.c
+++ b/libswfdec/swfdec_resource_request.c
@@ -41,30 +41,45 @@ swfdec_resource_request_free (SwfdecResourceRequest *request)
g_slice_free (SwfdecResourceRequest, request);
}
-static void
-swfdec_request_resource_perform_one (gpointer requestp, gpointer playerp)
+SwfdecLoader *
+swfdec_player_request_resource_now (SwfdecPlayer *player, SwfdecSecurity *security,
+ const char *url, SwfdecLoaderRequest req, SwfdecBuffer *buffer)
{
- SwfdecPlayer *player = SWFDEC_PLAYER (playerp);
- SwfdecResourceRequest *request = requestp;
SwfdecLoader *loader;
- SwfdecURL *url;
+ SwfdecURL *absolute;
+
+ g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
+ g_return_val_if_fail (SWFDEC_IS_SECURITY (security), NULL);
+ g_return_val_if_fail (url != NULL, NULL);
- g_assert (player->resource);
/* create absolute url first */
- url = swfdec_url_new_relative (swfdec_loader_get_url (player->resource->loader), request->url);
- if (!swfdec_security_allow_url (request->security, url)) {
+ absolute = swfdec_url_new_relative (swfdec_loader_get_url (player->resource->loader), url);
+ if (!swfdec_security_allow_url (security, absolute)) {
/* FIXME: Need to load policy file from given URL */
- SWFDEC_ERROR ("not allowing access to %s", swfdec_url_get_url (url));
+ SWFDEC_ERROR ("not allowing access to %s", swfdec_url_get_url (absolute));
loader = NULL;
} else {
- if (request->buffer) {
- loader = swfdec_loader_load (player->resource->loader, url, request->request,
- (const char *) request->buffer->data, request->buffer->length);
+ if (buffer) {
+ loader = swfdec_loader_load (player->resource->loader, absolute, req,
+ (const char *) buffer->data, buffer->length);
} else {
- loader = swfdec_loader_load (player->resource->loader, url, request->request, NULL, 0);
+ loader = swfdec_loader_load (player->resource->loader, absolute, req, NULL, 0);
}
}
- swfdec_url_free (url);
+ swfdec_url_free (absolute);
+ return loader;
+}
+
+static void
+swfdec_request_resource_perform_one (gpointer requestp, gpointer playerp)
+{
+ SwfdecPlayer *player = SWFDEC_PLAYER (playerp);
+ SwfdecResourceRequest *request = requestp;
+ SwfdecLoader *loader;
+
+ g_assert (player->resource);
+ loader = swfdec_player_request_resource_now (player, request->security,
+ request->url, request->request, request->buffer);
request->func (player, loader, request->data);
swfdec_resource_request_free (request);
}
diff --git a/libswfdec/swfdec_resource_request.h b/libswfdec/swfdec_resource_request.h
index 0c6977b..9f9f69f 100644
--- a/libswfdec/swfdec_resource_request.h
+++ b/libswfdec/swfdec_resource_request.h
@@ -51,6 +51,11 @@ void swfdec_player_request_resource (SwfdecPlayer * player,
SwfdecResourceFunc func,
gpointer data,
GDestroyNotify destroy);
+SwfdecLoader * swfdec_player_request_resource_now (SwfdecPlayer * player,
+ SwfdecSecurity * security,
+ const char * url,
+ SwfdecLoaderRequest req,
+ SwfdecBuffer * buffer);
/* private api for swfdec_player.c */
void swfdec_player_resource_request_init (SwfdecPlayer * player);
commit 3171db4592ff6730b8e60e7fddfb12bbd948b495
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 11:55:34 2007 +0100
fix test results
They actually match the official player better than previously.
(FIXME: Where are the .org files)
diff --git a/test/trace/netstream-load-loop-6.swf.trace b/test/trace/netstream-load-loop-6.swf.trace
index 294ee20..d0d0146 100644
--- a/test/trace/netstream-load-loop-6.swf.trace
+++ b/test/trace/netstream-load-loop-6.swf.trace
@@ -1,13 +1,4 @@
hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
ho
hey
hey
diff --git a/test/trace/netstream-load-loop-7.swf.trace b/test/trace/netstream-load-loop-7.swf.trace
index 294ee20..d0d0146 100644
--- a/test/trace/netstream-load-loop-7.swf.trace
+++ b/test/trace/netstream-load-loop-7.swf.trace
@@ -1,13 +1,4 @@
hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
ho
hey
hey
diff --git a/test/trace/netstream-load-loop-8.swf.trace b/test/trace/netstream-load-loop-8.swf.trace
index 294ee20..d0d0146 100644
--- a/test/trace/netstream-load-loop-8.swf.trace
+++ b/test/trace/netstream-load-loop-8.swf.trace
@@ -1,13 +1,4 @@
hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
-hey
ho
hey
hey
commit f612b742d4019655b47bc64a977b79db337ba89b
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 11:54:56 2007 +0100
rework iteration timeouts
The first movie is inited immediately, and does not require an advance of 0
anymore. The first iteration happens after 0.1/fps seconds as opposed to 1/fps
seconds previously.
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 0450441..dd5484f 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1906,6 +1906,7 @@ swfdec_player_initialize (SwfdecPlayer *player, guint version,
player->initialized = TRUE;
g_object_notify (G_OBJECT (player), "initialized");
} else {
+ /* FIXME: need to kick all other movies out here */
swfdec_player_remove_timeout (player, &player->iterate_timeout);
}
@@ -1926,7 +1927,7 @@ swfdec_player_initialize (SwfdecPlayer *player, guint version,
player->internal_height = player->stage_height >= 0 ? (guint) player->stage_height : player->height;
swfdec_player_update_scale (player);
- player->iterate_timeout.timestamp = player->time;
+ player->iterate_timeout.timestamp = player->time + SWFDEC_TICKS_PER_SECOND * 256 / player->rate / 10;
swfdec_player_add_timeout (player, &player->iterate_timeout);
SWFDEC_LOG ("initialized iterate timeout %p to %"G_GUINT64_FORMAT" (now %"G_GUINT64_FORMAT")",
&player->iterate_timeout, player->iterate_timeout.timestamp, player->time);
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index ddb170e..9a4f1c9 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -94,6 +94,8 @@ swfdec_resource_loader_target_image (SwfdecResource *instance)
movie->n_frames = movie->sprite->n_frames;
swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
swfdec_resource_check_rights (instance);
+ if (swfdec_resource_is_root (instance))
+ swfdec_movie_initialize (SWFDEC_MOVIE (movie));
} else {
g_assert_not_reached ();
}
commit 48d6f79e405020452293e4646ca02d6f7b175eab
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 11:06:36 2007 +0100
make a loader only add one external action when something changed.
This is necessary to avoid action execution between MovieClipLoader callbacks.
diff --git a/libswfdec/swfdec_loader.c b/libswfdec/swfdec_loader.c
index 255b943..04c21a0 100644
--- a/libswfdec/swfdec_loader.c
+++ b/libswfdec/swfdec_loader.c
@@ -208,35 +208,48 @@ swfdec_loader_init (SwfdecLoader *loader)
/*** INTERNAL API ***/
static void
-swfdec_loader_perform_open (gpointer loaderp, gpointer unused)
+swfdec_loader_process (gpointer loaderp, gpointer unused)
{
+ SwfdecLoaderTarget *target;
SwfdecLoader *loader = loaderp;
- swfdec_loader_target_open (loader->target, loader);
-}
-
-static void
-swfdec_loader_perform_eof (gpointer loaderp, gpointer unused)
-{
- SwfdecLoader *loader = loaderp;
-
- swfdec_loader_target_eof (loader->target, loader);
-}
-
-static void
-swfdec_loader_perform_error (gpointer loaderp, gpointer unused)
-{
- SwfdecLoader *loader = loaderp;
-
- swfdec_loader_target_error (loader->target, loader);
+ loader->queued = FALSE;
+ if (loader->state == loader->processed_state)
+ return;
+ g_assert (loader->state != SWFDEC_LOADER_STATE_CLOSED);
+ if (loader->state == SWFDEC_LOADER_STATE_ERROR) {
+ swfdec_loader_target_error (loader->target, loader);
+ return;
+ }
+ target = loader->target;
+ while (loader->state != loader->processed_state) {
+ /* stupid reentrancy */
+ if (loader->target != target)
+ break;
+ if (loader->processed_state == SWFDEC_LOADER_STATE_NEW) {
+ swfdec_loader_target_open (target, loader);
+ loader->processed_state = SWFDEC_LOADER_STATE_OPEN;
+ } else if (loader->processed_state == SWFDEC_LOADER_STATE_OPEN) {
+ swfdec_loader_target_parse (target, loader);
+ loader->processed_state = SWFDEC_LOADER_STATE_READING;
+ } else if (loader->processed_state == SWFDEC_LOADER_STATE_READING) {
+ swfdec_loader_target_eof (target, loader);
+ loader->processed_state = SWFDEC_LOADER_STATE_EOF;
+ }
+ }
}
static void
-swfdec_loader_perform_push (gpointer loaderp, gpointer unused)
+swfdec_loader_queue_processing (SwfdecLoader *loader)
{
- SwfdecLoader *loader = loaderp;
-
- swfdec_loader_target_parse (loader->target, loader);
+ if (loader->queued)
+ return;
+ loader->queued = TRUE;
+ if (loader->target) {
+ g_assert (loader->player);
+ swfdec_player_add_external_action (loader->player, loader,
+ swfdec_loader_process, NULL);
+ }
}
SwfdecLoader *
@@ -267,8 +280,10 @@ swfdec_loader_close (SwfdecLoader *loader)
if (klass->close)
klass->close (loader);
- if (loader->state != SWFDEC_LOADER_STATE_ERROR)
+ if (loader->state != SWFDEC_LOADER_STATE_ERROR) {
loader->state = SWFDEC_LOADER_STATE_CLOSED;
+ loader->processed_state = SWFDEC_LOADER_STATE_CLOSED;
+ }
}
void
@@ -280,38 +295,12 @@ swfdec_loader_set_target (SwfdecLoader *loader, SwfdecLoaderTarget *target)
if (loader->target) {
swfdec_player_remove_all_external_actions (loader->player, loader);
}
+ loader->queued = FALSE;
loader->target = target;
+ loader->processed_state = SWFDEC_LOADER_STATE_NEW;
if (target) {
loader->player = swfdec_loader_target_get_player (target);
- switch (loader->state) {
- case SWFDEC_LOADER_STATE_NEW:
- break;
- case SWFDEC_LOADER_STATE_OPEN:
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_open, NULL);
- break;
- case SWFDEC_LOADER_STATE_READING:
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_open, NULL);
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_push, NULL);
- break;
- case SWFDEC_LOADER_STATE_EOF:
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_open, NULL);
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_push, NULL);
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_eof, NULL);
- break;
- case SWFDEC_LOADER_STATE_ERROR:
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_error, NULL);
- break;
- default:
- g_assert_not_reached ();
- break;
- }
+ swfdec_loader_queue_processing (loader);
} else {
loader->player = NULL;
}
@@ -342,9 +331,7 @@ swfdec_loader_error (SwfdecLoader *loader, const char *error)
SWFDEC_ERROR ("error in loader %p: %s", loader, error);
loader->state = SWFDEC_LOADER_STATE_ERROR;
loader->error = g_strdup (error);
- if (loader->target)
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_error, NULL);
+ swfdec_loader_queue_processing (loader);
}
/**
@@ -369,8 +356,7 @@ swfdec_loader_open (SwfdecLoader *loader, const char *url)
loader->url = swfdec_url_new (url);
g_object_notify (G_OBJECT (loader), "url");
}
- if (loader->player)
- swfdec_player_add_external_action (loader->player, loader, swfdec_loader_perform_open, NULL);
+ swfdec_loader_queue_processing (loader);
}
/**
@@ -392,9 +378,9 @@ swfdec_loader_push (SwfdecLoader *loader, SwfdecBuffer *buffer)
swfdec_buffer_queue_push (loader->queue, buffer);
g_object_notify (G_OBJECT (loader), "loaded");
loader->state = SWFDEC_LOADER_STATE_READING;
- if (loader->player)
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_push, NULL);
+ if (loader->processed_state == SWFDEC_LOADER_STATE_READING)
+ loader->processed_state = SWFDEC_LOADER_STATE_OPEN;
+ swfdec_loader_queue_processing (loader);
}
/**
@@ -416,9 +402,7 @@ swfdec_loader_eof (SwfdecLoader *loader)
}
g_object_notify (G_OBJECT (loader), "eof");
loader->state = SWFDEC_LOADER_STATE_EOF;
- if (loader->player)
- swfdec_player_add_external_action (loader->player, loader,
- swfdec_loader_perform_eof, NULL);
+ swfdec_loader_queue_processing (loader);
}
/**
diff --git a/libswfdec/swfdec_loader.h b/libswfdec/swfdec_loader.h
index 614907a..9eb5b2a 100644
--- a/libswfdec/swfdec_loader.h
+++ b/libswfdec/swfdec_loader.h
@@ -57,6 +57,8 @@ struct _SwfdecLoader
/*< private >*/
guint state; /* SwfdecLoaderState the loader is currently in */
+ guint processed_state;/* SwfdecLoaderState the target knows about */
+ gboolean queued; /* TRUE if we have queued an action already */
SwfdecURL * url; /* the URL for this loader in UTF-8 - must be set on creation */
glong size; /* number of bytes in stream or -1 if unknown */
char * error; /* error message if in error state or NULL */
commit 9ad5401e88b24bb85ead03c50ca7cac0c2c846fd
Author: Benjamin Otte <otte at gnome.org>
Date: Thu Nov 8 11:05:41 2007 +0100
perform actions after every external event
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 4d7e723..0450441 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -504,9 +504,8 @@ swfdec_player_perform_external_actions (SwfdecPlayer *player)
if (action->object == NULL)
continue;
action->func (action->object, action->data);
+ swfdec_player_perform_actions (player);
}
-
- swfdec_player_perform_actions (player);
}
static void
More information about the Swfdec
mailing list