[Swfdec] Branch 'as' - 3 commits - libswfdec/Makefile.am libswfdec/swfdec_as_interpret.c libswfdec/swfdec_js_video.c libswfdec/swfdec_player.c libswfdec/swfdec_player_internal.h libswfdec/swfdec_video_movie_as.c libswfdec/swfdec_video_movie.c

Benjamin Otte company at kemper.freedesktop.org
Wed Jun 27 04:34:25 PDT 2007


 libswfdec/Makefile.am              |    2 +-
 libswfdec/swfdec_as_interpret.c    |   13 +++++--------
 libswfdec/swfdec_player.c          |    9 +++------
 libswfdec/swfdec_player_internal.h |    1 +
 libswfdec/swfdec_video_movie.c     |   13 ++++++++++++-
 libswfdec/swfdec_video_movie_as.c  |    7 ++++---
 6 files changed, 26 insertions(+), 19 deletions(-)

New commits:
diff-tree ffe888d4c04af436959d7279bc4e5a8fae6d0acf (from 9bae6b7c4a6fad458140df74ac4d43d4a5491813)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jun 27 13:30:54 2007 +0200

    fix NewMethod action

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index b4bcc4f..376f41f 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1365,16 +1365,13 @@ swfdec_action_new_method (SwfdecAsContex
   constructor = swfdec_as_stack_pop (cx->frame->stack);
   n_args = swfdec_as_value_to_integer (cx, swfdec_as_stack_peek (cx->frame->stack, 1));
   n_args = MIN (swfdec_as_stack_get_size (cx->frame->stack) - 1, n_args);
-  if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) ||
-      !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) {
-    SWFDEC_WARNING ("%s is not a constructor", name);
-    goto fail;
-  }
   if (name != SWFDEC_AS_STR_EMPTY) {
-    if (SWFDEC_AS_VALUE_IS_OBJECT (constructor)) {
-      swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (constructor),
-	  name, constructor);
+    if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor)) {
+      SWFDEC_WARNING ("NewMethod called without an object to get variable %s from", name);
+      goto fail;
     }
+    swfdec_as_object_get_variable (SWFDEC_AS_VALUE_GET_OBJECT (constructor),
+	name, constructor);
   }
   if (!SWFDEC_AS_VALUE_IS_OBJECT (constructor) ||
       !SWFDEC_IS_AS_FUNCTION (fun = (SwfdecAsFunction *) SWFDEC_AS_VALUE_GET_OBJECT (constructor))) {
diff-tree 9bae6b7c4a6fad458140df74ac4d43d4a5491813 (from 3973025c435f045ee78444a20926cd5448b34a2c)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jun 27 13:30:36 2007 +0200

    various fixes for attachMovie
    
    - video movies get officially registered as Video objects now
    - swfdec_video_movie_set_input takes NULL as an argument just fine

diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index aa7de2f..554d22b 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -791,6 +791,7 @@ swfdec_player_mark (SwfdecAsContext *con
   swfdec_listener_mark (player->mouse_listener);
   swfdec_listener_mark (player->key_listener);
   swfdec_as_object_mark (player->MovieClip);
+  swfdec_as_object_mark (player->Video);
   for (walk = player->roots; walk; walk = walk->next) {
     swfdec_as_object_mark (walk->data);
   }
@@ -1070,6 +1071,7 @@ extern void swfdec_movie_color_init_cont
 extern void swfdec_net_connection_init_context (SwfdecPlayer *player, guint version);
 extern void swfdec_net_stream_init_context (SwfdecPlayer *player, guint version);
 extern void swfdec_sprite_movie_init_context (SwfdecPlayer *player, guint version);
+extern void swfdec_video_movie_init_context (SwfdecPlayer *player, guint version);
 extern void swfdec_xml_init_context (SwfdecPlayer *player, guint version);
 /**
  * swfdec_player_initialize:
@@ -1102,6 +1104,7 @@ swfdec_player_initialize (SwfdecPlayer *
     swfdec_player_init_global (player, version);
     swfdec_mouse_init_context (player, version);
     swfdec_sprite_movie_init_context (player, version);
+    swfdec_video_movie_init_context (player, version);
     swfdec_movie_color_init_context (player, version);
     swfdec_net_connection_init_context (player, version);
     swfdec_net_stream_init_context (player, version);
@@ -1394,12 +1397,6 @@ swfdec_player_advance (SwfdecPlayer *pla
   g_return_if_fail (SWFDEC_IS_PLAYER (player));
   g_return_if_fail (msecs > 0);
 
-#if 0
-  while (TRUE)
-    swfdec_js_run (player, "i = new Object(); i.foo = 7", NULL);
-  //swfdec_js_run (player, "s=\"/A/B:foo\"; t=s.indexOf (\":\"); if (t) t=s.substring(0,s.indexOf (\":\")); else t=s;", NULL);
-#endif
-
   frames = SWFDEC_TICKS_TO_SAMPLES (player->time + SWFDEC_MSECS_TO_TICKS (msecs))
     - SWFDEC_TICKS_TO_SAMPLES (player->time);
   g_signal_emit (player, signals[ADVANCE], 0, msecs, frames);
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index 6ef00b3..473871a 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -59,6 +59,7 @@ struct _SwfdecPlayer
   SwfdecListener *	mouse_listener;		/* emitting mouse events */
   SwfdecListener *	key_listener;		/* emitting keyboard events */
   SwfdecAsObject *	MovieClip;		/* MovieClip object */
+  SwfdecAsObject *	Video;			/* Video object */
 
   /* rendering */
   SwfdecRect		invalid;      		/* area that needs a rredraw */
diff --git a/libswfdec/swfdec_video_movie.c b/libswfdec/swfdec_video_movie.c
index 0f90dbc..60676e0 100644
--- a/libswfdec/swfdec_video_movie.c
+++ b/libswfdec/swfdec_video_movie.c
@@ -22,6 +22,7 @@
 #endif
 
 #include "swfdec_video_movie.h"
+#include "swfdec_player_internal.h"
 
 G_DEFINE_TYPE (SwfdecVideoMovie, swfdec_video_movie, SWFDEC_TYPE_MOVIE)
 
@@ -95,6 +96,14 @@ swfdec_video_movie_iterate_end (SwfdecMo
 }
 
 static void
+swfdec_video_movie_init_movie (SwfdecMovie *movie)
+{
+  SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+
+  swfdec_as_object_set_constructor (SWFDEC_AS_OBJECT (movie), player->Video, FALSE);
+}
+
+static void
 swfdec_video_movie_class_init (SwfdecVideoMovieClass * g_class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (g_class);
@@ -104,6 +113,7 @@ swfdec_video_movie_class_init (SwfdecVid
 
   movie_class->update_extents = swfdec_video_movie_update_extents;
   movie_class->render = swfdec_video_movie_render;
+  movie_class->init_movie = swfdec_video_movie_init_movie;
   movie_class->iterate_end = swfdec_video_movie_iterate_end;
 }
 
@@ -116,10 +126,11 @@ void
 swfdec_video_movie_set_input (SwfdecVideoMovie *movie, SwfdecVideoMovieInput *input)
 {
   g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
-  g_return_if_fail (input != NULL);
 
   swfdec_video_movie_unset_input (movie);
   movie->input = input;
+  if (input == NULL)
+    return;
   if (input->connect)
     input->connect (input, movie);
 }
diff --git a/libswfdec/swfdec_video_movie_as.c b/libswfdec/swfdec_video_movie_as.c
index 76d978b..ad45317 100644
--- a/libswfdec/swfdec_video_movie_as.c
+++ b/libswfdec/swfdec_video_movie_as.c
@@ -63,14 +63,15 @@ swfdec_video_movie_init_context (SwfdecP
       SWFDEC_AS_STR_Video, 0, NULL, 0));
   if (video == NULL)
     return;
+  player->Video = video;
   proto = swfdec_as_object_new (context);
-  /* set the right properties on the NetStream object */
+  /* set the right properties on the Video object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
   swfdec_as_object_set_variable (video, SWFDEC_AS_STR_prototype, &val);
-  /* set the right properties on the NetStream.prototype object */
+  /* set the right properties on the Video.prototype object */
   SWFDEC_AS_VALUE_SET_OBJECT (&val, video);
   swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_attachMovie, SWFDEC_TYPE_VIDEO_MOVIE,
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_attachVideo, SWFDEC_TYPE_VIDEO_MOVIE,
       swfdec_video_attach_video, 1);
   swfdec_as_object_add_function (proto, SWFDEC_AS_STR_clear, SWFDEC_TYPE_VIDEO_MOVIE,
       swfdec_video_clear, 0);
diff-tree 3973025c435f045ee78444a20926cd5448b34a2c (from 6926ffebd79fd8fb3ab853c39f071925fc8066bd)
Author: Benjamin Otte <otte at gnome.org>
Date:   Wed Jun 27 10:39:01 2007 +0200

    rename swfdec_js_video.c -> swfdec_video_movie_as.c

diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index 14e50fb..62363b3 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -70,7 +70,6 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
 	swfdec_html_parser.c \
 	swfdec_image.c \
 	swfdec_interval.c \
-	swfdec_js_video.c \
 	swfdec_listener.c \
 	swfdec_loader.c \
 	swfdec_loadertarget.c \
@@ -102,6 +101,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES
 	swfdec_utils.c \
 	swfdec_video.c \
 	swfdec_video_movie.c \
+	swfdec_video_movie_as.c \
 	swfdec_xml.c \
 	swfdec_xml_as.c
 
diff --git a/libswfdec/swfdec_js_video.c b/libswfdec/swfdec_js_video.c
deleted file mode 100644
index 76d978b..0000000
--- a/libswfdec/swfdec_js_video.c
+++ /dev/null
@@ -1,78 +0,0 @@
-/* Swfdec
- * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- * 
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- * 
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
- * Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "swfdec_video.h"
-#include "swfdec_debug.h"
-#include "swfdec_net_stream.h"
-#include "swfdec_player_internal.h"
-
-static void
-swfdec_video_attach_video (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
-  SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (obj);
-  SwfdecNetStream *stream;
-
-  if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) ||
-      !SWFDEC_IS_NET_STREAM (stream = (SwfdecNetStream *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]))) {
-    SWFDEC_WARNING ("calling attachVideo without a NetStraem object");
-    swfdec_video_movie_set_input (video, NULL);
-    return;
-  }
-  swfdec_video_movie_set_input (video, &stream->input);
-}
-
-static void
-swfdec_video_clear (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
-{
-  SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (obj);
-
-  swfdec_video_movie_clear (video);
-}
-
-void
-swfdec_video_movie_init_context (SwfdecPlayer *player, guint version)
-{
-  SwfdecAsContext *context;
-  SwfdecAsObject *video, *proto;
-  SwfdecAsValue val;
-
-  g_return_if_fail (SWFDEC_IS_PLAYER (player));
-
-  context = SWFDEC_AS_CONTEXT (player);
-  video = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global, 
-      SWFDEC_AS_STR_Video, 0, NULL, 0));
-  if (video == NULL)
-    return;
-  proto = swfdec_as_object_new (context);
-  /* set the right properties on the NetStream object */
-  SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
-  swfdec_as_object_set_variable (video, SWFDEC_AS_STR_prototype, &val);
-  /* set the right properties on the NetStream.prototype object */
-  SWFDEC_AS_VALUE_SET_OBJECT (&val, video);
-  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_attachMovie, SWFDEC_TYPE_VIDEO_MOVIE,
-      swfdec_video_attach_video, 1);
-  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_clear, SWFDEC_TYPE_VIDEO_MOVIE,
-      swfdec_video_clear, 0);
-}
-
diff --git a/libswfdec/swfdec_video_movie_as.c b/libswfdec/swfdec_video_movie_as.c
new file mode 100644
index 0000000..76d978b
--- /dev/null
+++ b/libswfdec/swfdec_video_movie_as.c
@@ -0,0 +1,78 @@
+/* Swfdec
+ * Copyright (C) 2007 Benjamin Otte <otte at gnome.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "swfdec_video.h"
+#include "swfdec_debug.h"
+#include "swfdec_net_stream.h"
+#include "swfdec_player_internal.h"
+
+static void
+swfdec_video_attach_video (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (obj);
+  SwfdecNetStream *stream;
+
+  if (!SWFDEC_AS_VALUE_IS_OBJECT (&argv[0]) ||
+      !SWFDEC_IS_NET_STREAM (stream = (SwfdecNetStream *) SWFDEC_AS_VALUE_GET_OBJECT (&argv[0]))) {
+    SWFDEC_WARNING ("calling attachVideo without a NetStraem object");
+    swfdec_video_movie_set_input (video, NULL);
+    return;
+  }
+  swfdec_video_movie_set_input (video, &stream->input);
+}
+
+static void
+swfdec_video_clear (SwfdecAsContext *cx, SwfdecAsObject *obj, guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
+{
+  SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (obj);
+
+  swfdec_video_movie_clear (video);
+}
+
+void
+swfdec_video_movie_init_context (SwfdecPlayer *player, guint version)
+{
+  SwfdecAsContext *context;
+  SwfdecAsObject *video, *proto;
+  SwfdecAsValue val;
+
+  g_return_if_fail (SWFDEC_IS_PLAYER (player));
+
+  context = SWFDEC_AS_CONTEXT (player);
+  video = SWFDEC_AS_OBJECT (swfdec_as_object_add_function (context->global, 
+      SWFDEC_AS_STR_Video, 0, NULL, 0));
+  if (video == NULL)
+    return;
+  proto = swfdec_as_object_new (context);
+  /* set the right properties on the NetStream object */
+  SWFDEC_AS_VALUE_SET_OBJECT (&val, proto);
+  swfdec_as_object_set_variable (video, SWFDEC_AS_STR_prototype, &val);
+  /* set the right properties on the NetStream.prototype object */
+  SWFDEC_AS_VALUE_SET_OBJECT (&val, video);
+  swfdec_as_object_set_variable (proto, SWFDEC_AS_STR_constructor, &val);
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_attachMovie, SWFDEC_TYPE_VIDEO_MOVIE,
+      swfdec_video_attach_video, 1);
+  swfdec_as_object_add_function (proto, SWFDEC_AS_STR_clear, SWFDEC_TYPE_VIDEO_MOVIE,
+      swfdec_video_clear, 0);
+}
+


More information about the Swfdec mailing list