[Swfdec-commits] 2 commits - swfdec/swfdec_as_strings.c swfdec/swfdec_video_movie.c test/trace

Pekka Lampila medar at kemper.freedesktop.org
Sat Feb 16 11:23:46 PST 2008


 swfdec/swfdec_as_strings.c                |    4 +
 swfdec/swfdec_video_movie.c               |   75 ++++++++++++++++++++++++++++++
 test/trace/Makefile.am                    |    3 +
 test/trace/netstream-dimensions.c         |   51 ++++++++++++++++++++
 test/trace/netstream-dimensions.swf       |binary
 test/trace/netstream-dimensions.swf.trace |   14 +++++
 6 files changed, 147 insertions(+)

New commits:
commit 8b55c768628838f91aa7325d0412233256a03687
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Feb 16 21:19:59 2008 +0200

    Add a test for Video's width and height properties

diff --git a/test/trace/Makefile.am b/test/trace/Makefile.am
index 84e1729..6b332b6 100644
--- a/test/trace/Makefile.am
+++ b/test/trace/Makefile.am
@@ -1724,6 +1724,9 @@ EXTRA_DIST = \
 	native-run-8.swf.trace \
 	netconnection.swf \
 	netconnection.swf.trace \
+	netstream-dimensions.c \
+	netstream-dimensions.swf \
+	netstream-dimensions.swf.trace \
 	netstream-fscommand.as \
 	netstream-fscommand-6.swf \
 	netstream-fscommand-6.swf.trace \
diff --git a/test/trace/netstream-dimensions.c b/test/trace/netstream-dimensions.c
new file mode 100644
index 0000000..7496f7f
--- /dev/null
+++ b/test/trace/netstream-dimensions.c
@@ -0,0 +1,51 @@
+/* gcc `pkg-config --libs --cflags libming` netstream-dimensions.c -o netstream-dimensions && ./netstream-dimensions
+ */
+
+#include <ming.h>
+
+int
+main (int argc, char **argv)
+{
+  SWFMovie movie;
+  SWFVideoStream video;
+  SWFDisplayItem item;
+  SWFAction action;
+
+  if (Ming_init ())
+    return 1;
+  Ming_useSWFVersion (7);
+
+  movie = newSWFMovie();
+  SWFMovie_setRate (movie, 1);
+  SWFMovie_setDimension (movie, 200, 150);
+  video = newSWFVideoStream ();
+  SWFVideoStream_setDimension (video, 200, 150);
+  item = SWFMovie_add (movie, (SWFBlock) video);
+  SWFDisplayItem_setName (item, "video");
+  action = compileSWFActionCode (""
+      "trace (\"Test Video object's width and height properties\");"
+      "nc = new NetConnection ();"
+      "nc.connect (null);"
+      "ns = new NetStream (nc);"
+      "ns.onStatus = function (info)"
+      "{"
+      "  trace ('onStatus ' + info.code);"
+      "  trace ('width = ' + video.width);"
+      "  trace ('height = ' + video.height);"
+      "  video.width++;"
+      "  video.height++;"
+      "  if (info.code == 'NetStream.Play.Stop')"
+      "    loadMovie ('FSCommand:quit', '');"
+      "};"
+      "video.attachVideo (ns);"
+      "ns.setBufferTime (5);"
+      "trace (\"Calling play\");"
+      "ns.play (\"video.flv\");"
+      "trace (\"done calling play\");"
+      "trace ('width = ' + video.width);"
+      "trace ('height = ' + video.height);"
+      "");
+  SWFMovie_add (movie, (SWFBlock) action);
+  SWFMovie_save (movie, "netstream-dimensions.swf");
+  return 0;
+}
diff --git a/test/trace/netstream-dimensions.swf b/test/trace/netstream-dimensions.swf
new file mode 100644
index 0000000..fab7f18
Binary files /dev/null and b/test/trace/netstream-dimensions.swf differ
diff --git a/test/trace/netstream-dimensions.swf.trace b/test/trace/netstream-dimensions.swf.trace
new file mode 100644
index 0000000..087de32
--- /dev/null
+++ b/test/trace/netstream-dimensions.swf.trace
@@ -0,0 +1,14 @@
+Test Video object's width and height properties
+Calling play
+done calling play
+width = 0
+height = 0
+onStatus NetStream.Play.Start
+width = 0
+height = 0
+onStatus NetStream.Buffer.Flush
+width = 0
+height = 0
+onStatus NetStream.Play.Stop
+width = 466
+height = 311
commit 1414736db7ad5a9a45dd2608073fc903c8d831e9
Author: Pekka Lampila <pekka.lampila at iki.fi>
Date:   Sat Feb 16 21:16:25 2008 +0200

    Implement Video's width and height, add stubs for smoothing and deblocking

diff --git a/swfdec/swfdec_as_strings.c b/swfdec/swfdec_as_strings.c
index 7f880aa..50db45a 100644
--- a/swfdec/swfdec_as_strings.c
+++ b/swfdec/swfdec_as_strings.c
@@ -487,5 +487,9 @@ const char swfdec_as_strings[] =
   SWFDEC_AS_CONSTANT_STRING ("id")
   SWFDEC_AS_CONSTANT_STRING ("onClose")
   SWFDEC_AS_CONSTANT_STRING ("onConnect")
+  SWFDEC_AS_CONSTANT_STRING ("width")
+  SWFDEC_AS_CONSTANT_STRING ("height")
+  SWFDEC_AS_CONSTANT_STRING ("deblocking")
+  SWFDEC_AS_CONSTANT_STRING ("smoothing")
   /* add more here */
 ;
diff --git a/swfdec/swfdec_video_movie.c b/swfdec/swfdec_video_movie.c
index 087797d..1f32922 100644
--- a/swfdec/swfdec_video_movie.c
+++ b/swfdec/swfdec_video_movie.c
@@ -24,6 +24,9 @@
 #include "swfdec_video_movie.h"
 #include "swfdec_player_internal.h"
 #include "swfdec_resource.h"
+#include "swfdec_as_strings.h"
+#include "swfdec_utils.h"
+#include "swfdec_debug.h"
 
 G_DEFINE_TYPE (SwfdecVideoMovie, swfdec_video_movie, SWFDEC_TYPE_MOVIE)
 
@@ -115,6 +118,73 @@ swfdec_video_movie_set_ratio (SwfdecMovie *movie)
   }
 }
 
+static gboolean
+swfdec_video_movie_get_variable (SwfdecAsObject *object, SwfdecAsObject *orig,
+    const char *variable, SwfdecAsValue *val, guint *flags)
+{
+  guint version = object->context->version;
+  SwfdecVideoMovie *video;
+
+  video = SWFDEC_VIDEO_MOVIE (object);
+
+  if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_width) == 0) {
+    swfdec_video_movie_update_image (video);
+    SWFDEC_AS_VALUE_SET_NUMBER (val, (video->image != NULL ?
+	  cairo_image_surface_get_width (video->image) : 0));
+    return TRUE;
+  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_height) == 0) {
+    swfdec_video_movie_update_image (video);
+    SWFDEC_AS_VALUE_SET_NUMBER (val, (video->image != NULL ?
+	  cairo_image_surface_get_height (video->image) : 0));
+    return TRUE;
+  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_deblocking) == 0) {
+    SWFDEC_STUB ("Video.deblocking (get)");
+    SWFDEC_AS_VALUE_SET_NUMBER (val, 0);
+    return TRUE;
+  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_smoothing) == 0) {
+    SWFDEC_STUB ("Video.smoothing (get)");
+    SWFDEC_AS_VALUE_SET_BOOLEAN (val, FALSE);
+    return TRUE;
+  } else {
+    return SWFDEC_AS_OBJECT_CLASS (swfdec_video_movie_parent_class)->get (
+	object, orig, variable, val, flags);
+  }
+}
+
+static void
+swfdec_video_movie_set_variable (SwfdecAsObject *object, const char *variable,
+    const SwfdecAsValue *val, guint flags)
+{
+  guint version = object->context->version;
+
+  if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_deblocking) == 0) {
+    SWFDEC_STUB ("Video.deblocking (set)");
+  } else if (swfdec_strcmp (version, variable, SWFDEC_AS_STR_smoothing) == 0) {
+    SWFDEC_STUB ("Video.smoothing (set)");
+  } else {
+    SWFDEC_AS_OBJECT_CLASS (swfdec_video_movie_parent_class)->set (object,
+	variable, val, flags);
+  }
+}
+
+static gboolean
+swfdec_video_movie_foreach_variable (SwfdecAsObject *object, SwfdecAsVariableForeach func, gpointer data)
+{
+  const char *native_variables[] = { SWFDEC_AS_STR_width, SWFDEC_AS_STR_height,
+    SWFDEC_AS_STR_smoothing, SWFDEC_AS_STR_deblocking, NULL };
+  int i;
+
+  for (i = 0; native_variables[i] != NULL; i++) {
+    SwfdecAsValue val;
+    swfdec_as_object_get_variable (object, native_variables[i], &val);
+    if (!func (object, native_variables[i], &val, 0, data))
+      return FALSE;
+  }
+
+  return SWFDEC_AS_OBJECT_CLASS (swfdec_video_movie_parent_class)->foreach (
+      object, func, data);
+}
+
 static void
 swfdec_video_movie_invalidate (SwfdecMovie *movie, const cairo_matrix_t *matrix, gboolean last)
 {
@@ -137,10 +207,15 @@ static void
 swfdec_video_movie_class_init (SwfdecVideoMovieClass * g_class)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (g_class);
+  SwfdecAsObjectClass *asobject_class = SWFDEC_AS_OBJECT_CLASS (g_class);
   SwfdecMovieClass *movie_class = SWFDEC_MOVIE_CLASS (g_class);
 
   object_class->dispose = swfdec_video_movie_dispose;
 
+  asobject_class->get = swfdec_video_movie_get_variable;
+  asobject_class->set = swfdec_video_movie_set_variable;
+  asobject_class->foreach = swfdec_video_movie_foreach_variable;
+
   movie_class->update_extents = swfdec_video_movie_update_extents;
   movie_class->render = swfdec_video_movie_render;
   movie_class->invalidate = swfdec_video_movie_invalidate;


More information about the Swfdec-commits mailing list