[Swfdec] Branch 'as' - 4 commits - libswfdec/swfdec_movie.c libswfdec/swfdec_player.c libswfdec/swfdec_sprite.c test/trace

Benjamin Otte company at kemper.freedesktop.org
Fri Jun 15 06:51:18 PDT 2007


 libswfdec/swfdec_movie.c  |    5 +----
 libswfdec/swfdec_player.c |   36 ++++++++++++++++++++++++++++++++++++
 libswfdec/swfdec_sprite.c |    4 +++-
 test/trace/trace.c        |   27 ++++++++++++++++++++++++---
 4 files changed, 64 insertions(+), 8 deletions(-)

New commits:
diff-tree 0b6e91a7cfe6614977c78321d3e19bf8e8035f9d (from d8b550fa5c0a47912941ab3e3bb0358fa3c481e9)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 14 16:06:38 2007 +0200

    remove all actions on destruction

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index c3faa96..a1c9be6 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -322,6 +322,7 @@ swfdec_movie_destroy (SwfdecMovie *movie
    * This is just a stop-gap measure to avoid dead movies in those queues */
   g_queue_remove (player->init_queue, movie);
   g_queue_remove (player->construct_queue, movie);
+  swfdec_player_remove_all_actions (player, movie);
   if (klass->finish_movie)
     klass->finish_movie (movie);
   player->movies = g_list_remove (player->movies, movie);
diff-tree d8b550fa5c0a47912941ab3e3bb0358fa3c481e9 (from 7126839b418cf8980ab2c67401e99010d11c496c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 14 16:06:25 2007 +0200

    implement FSCommand:quit so tests can decide to quit whenever they like

diff --git a/test/trace/trace.c b/test/trace/trace.c
index 55f8e98..50bb5c6 100644
--- a/test/trace/trace.c
+++ b/test/trace/trace.c
@@ -11,16 +11,27 @@ trace_cb (SwfdecPlayer *player, const ch
   g_string_append_printf (string, "%s\n", message);
 }
 
+static void
+fscommand_cb (SwfdecPlayer *player, const char *command, const char *parameter, gpointer data)
+{
+  gboolean *quit = data;
+
+  if (g_str_equal (command, "quit")) {
+    *quit = TRUE;
+  }
+}
+
 static gboolean
 run_test (const char *filename)
 {
   SwfdecLoader *loader;
   SwfdecPlayer *player;
   SwfdecBuffer *buffer;
-  guint advance;
+  guint time_left;
   char *str;
   GString *string;
   GError *error = NULL;
+  gboolean quit = FALSE;
 
   g_print ("Testing %s:\n", filename);
   loader = swfdec_loader_new_from_file (filename);
@@ -31,6 +42,7 @@ run_test (const char *filename)
   string = g_string_new ("");
   player = swfdec_player_new ();
   g_signal_connect (player, "trace", G_CALLBACK (trace_cb), string);
+  g_signal_connect (player, "fscommand", G_CALLBACK (fscommand_cb), &quit);
   swfdec_player_set_loader (player, loader);
   if (!swfdec_player_is_initialized (player)) {
     g_print ("  ERROR: player is not initialized\n");
@@ -38,8 +50,17 @@ run_test (const char *filename)
     return FALSE;
   }
 
-  advance = ceil (10000 / swfdec_player_get_rate (player));
-  swfdec_player_advance (player, advance);
+  time_left = ceil (10000 / swfdec_player_get_rate (player));
+  /* FIXME: Make the number of iterations configurable? */
+  while (quit == FALSE) {
+    /* FIXME: will not do 10 iterations if there's other stuff loaded */
+    guint advance = swfdec_player_get_next_event (player);
+
+    if (advance > time_left)
+      break;
+    swfdec_player_advance (player, advance);
+    time_left -= advance;
+  }
   g_signal_handlers_disconnect_by_func (player, trace_cb, string);
   g_object_unref (player);
 
diff-tree 7126839b418cf8980ab2c67401e99010d11c496c (from c877d7d30f470a1035ee89e8aa616c958f49df70)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 14 15:55:20 2007 +0200

    implement fscommnds. They're now handled by the SwfdecPlayer which emits an
    "fscommand" signal.

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index be3e877..c3faa96 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -1039,10 +1039,6 @@ swfdec_movie_load (SwfdecMovie *movie, c
     }
     /* FIXME: what do we do here? Is returning correct?*/
     return;
-  } else if (g_str_has_prefix (target, "FSCommand:")) {
-    const char *command = url + strlen ("FSCommand:");
-    SWFDEC_WARNING ("unhandled fscommand: %s %s", command, target);
-    return;
   }
   swfdec_player_launch (player, url, target);
 }
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index bcc3952..a5d302c 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -293,6 +293,7 @@ enum {
   AUDIO_ADDED,
   AUDIO_REMOVED,
   LAUNCH,
+  FSCOMMAND,
   LAST_SIGNAL
 };
 
@@ -887,6 +888,36 @@ swfdec_player_class_init (SwfdecPlayerCl
       G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT,
       G_TYPE_NONE, 1, SWFDEC_TYPE_AUDIO);
   /**
+   * SwfdecPlayer::fscommand:
+   * @player: the #SwfdecPlayer affected
+   * @command: the command to execute
+   * @paramter: parameter to pass to the command. The parameter depends on the 
+   *            function.
+   *
+   * This signal is emited whenever a Flash script command (also known as 
+   * fscommand) is encountered. This method is ued by the Flash file to
+   * communicate with the hosting environment. In web browsers it is used to 
+   * call Javascript functions. Standalone Flash players understand a limited 
+   * set of functions. They vary from player to player, but the most common are 
+   * listed here: <itemizedlist>
+   * <listitem><para>"quit": quits the player.</para>
+   * <listitem><para>"fullscreen": A boolean setting (parameter is "true" or 
+   * "false") that sets the player into fullscreen mode.</para>
+   * <listitem><para>"allowscale": A boolean setting that tells the player to
+   * not scale the Flash application.</para>
+   * <listitem><para>"showmenu": A boolean setting that tells the Flash player
+   * to not show its own entries in the right-click menu.</para>
+   * <listitem><para>"exec": Run an external executable. The parameter 
+   * specifies the path.</para>
+   * <listitem><para>"trapallkeys": A boolean setting that tells the Flash 
+   * player to pass all key events to the Flash application instead of using it
+   * for keyboard shortcuts or similar.
+   * </itemizedlist>
+   */
+  signals[FSCOMMAND] = g_signal_new ("fscommand", G_TYPE_FROM_CLASS (klass),
+      G_SIGNAL_RUN_LAST, 0, NULL, NULL, swfdec_marshal_VOID__STRING_STRING,
+      G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING);
+  /**
    * SwfdecPlayer::launch:
    * @player: the #SwfdecPlayer affected
    * @url: URL to open
@@ -1012,6 +1043,11 @@ swfdec_player_launch (SwfdecPlayer *play
   g_return_if_fail (url != NULL);
   g_return_if_fail (target != NULL);
 
+  if (g_str_has_prefix (url, "FSCommand:")) {
+    const char *command = url + strlen ("FSCommand:");
+    g_signal_emit (player, signals[FSCOMMAND], 0, command, target);
+    return;
+  }
   g_signal_emit (player, signals[LAUNCH], 0, url, target);
 }
 
diff-tree c877d7d30f470a1035ee89e8aa616c958f49df70 (from 228be8a9445d25e41ecd7a09102c85609ec81ad7)
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Jun 14 15:02:32 2007 +0200

    WE're not guaranteed to have a graphic

diff --git a/libswfdec/swfdec_sprite.c b/libswfdec/swfdec_sprite.c
index cd678a9..73eeea5 100644
--- a/libswfdec/swfdec_sprite.c
+++ b/libswfdec/swfdec_sprite.c
@@ -357,8 +357,10 @@ swfdec_spriteseg_do_place_object (Swfdec
 
     if (content->name)
       script_name = g_strdup (content->name);
-    else
+    else if (content->graphic)
       script_name = g_strdup_printf ("Sprite%u", SWFDEC_CHARACTER (content->graphic)->id);
+    else
+      script_name = g_strdup ("unknown");
     while ((event_flags = swfdec_get_clipeventflags (s, bits)) != 0) {
       guint length = swfdec_bits_get_u32 (bits);
       SwfdecBits action_bits;


More information about the Swfdec mailing list