[Swfdec] 7 commits - libswfdec/jpeg libswfdec/swfdec_button_movie.c libswfdec/swfdec_js_net_stream.c libswfdec/swfdec_movie.c libswfdec/swfdec_net_stream.c libswfdec/swfdec_video.c player/swfdec_debug_movies.c

Benjamin Otte company at kemper.freedesktop.org
Mon Mar 19 08:32:50 PDT 2007


 libswfdec/jpeg/Makefile.am       |    4 ++--
 libswfdec/jpeg/jpeg.c            |    2 +-
 libswfdec/jpeg/jpeg.h            |    2 +-
 libswfdec/jpeg/test.c            |    7 ++++---
 libswfdec/swfdec_button_movie.c  |   32 ++++++++++++++++++++++++++++++++
 libswfdec/swfdec_js_net_stream.c |   23 +++++++++++++++++++++++
 libswfdec/swfdec_movie.c         |    4 ++++
 libswfdec/swfdec_net_stream.c    |    2 +-
 libswfdec/swfdec_video.c         |    2 +-
 player/swfdec_debug_movies.c     |    2 --
 10 files changed, 69 insertions(+), 11 deletions(-)

New commits:
diff-tree 203fadf70250f74a895940b2682ebaf39a68839d (from aa8feb3ed06ab79e3c622a79faa1e44d2b400bb5)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Mar 19 16:31:42 2007 +0100

    remove leftover g_print's

diff --git a/player/swfdec_debug_movies.c b/player/swfdec_debug_movies.c
index 649f19a..14e4281 100644
--- a/player/swfdec_debug_movies.c
+++ b/player/swfdec_debug_movies.c
@@ -299,7 +299,6 @@ swfdec_debug_movies_added (SwfdecPlayer 
   GtkTreeIter iter;
 
   iter.user_data = movie;
-  g_print ("movie %s added\n", movie->name);
   gtk_tree_model_row_inserted (GTK_TREE_MODEL (movies), path, &iter);
   gtk_tree_path_free (path);
 }
@@ -324,7 +323,6 @@ swfdec_debug_movies_removed (SwfdecPlaye
     i++;
   }
   gtk_tree_path_append_index (path, i);
-  g_print ("movie %s removed\n", movie->name);
   gtk_tree_model_row_deleted (GTK_TREE_MODEL (movies), path);
   gtk_tree_path_free (path);
 }
diff-tree aa8feb3ed06ab79e3c622a79faa1e44d2b400bb5 (from ae9a32b99f5c17460709832562a94f83c527efd3)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Mar 19 16:30:01 2007 +0100

    emit onFoo events on the button's JS object

diff --git a/libswfdec/swfdec_button_movie.c b/libswfdec/swfdec_button_movie.c
index 3c0e9b7..3c7b0b4 100644
--- a/libswfdec/swfdec_button_movie.c
+++ b/libswfdec/swfdec_button_movie.c
@@ -63,10 +63,40 @@ static const int sound_table[2][4][4] = 
     { -1,  0,  3, -1 } }
 };
 
+const char *
+swfdec_button_condition_get_name (SwfdecButtonCondition condition)
+{
+  /* FIXME: check if these events are based on conditions or if they're independant of button type */
+  switch (condition) {
+    case SWFDEC_BUTTON_IDLE_TO_OVER_UP:
+      return "onRollOver";
+    case SWFDEC_BUTTON_OVER_UP_TO_IDLE:
+      return "onRollOut";
+    case SWFDEC_BUTTON_OVER_UP_TO_OVER_DOWN:
+      return "onPress";
+    case SWFDEC_BUTTON_OVER_DOWN_TO_OVER_UP:
+      return "onRelease";
+    case SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN:
+      return "onDragOut";
+    case SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN:
+      return "onDragOver";
+    case SWFDEC_BUTTON_OUT_DOWN_TO_IDLE:
+      return "onReleaseOutside";
+    case SWFDEC_BUTTON_IDLE_TO_OVER_DOWN:
+      return "onDragOver";
+    case SWFDEC_BUTTON_OVER_DOWN_TO_IDLE:
+      return "onDragOut";
+    default:
+      g_assert_not_reached ();
+      return NULL;
+  }
+}
 static void
 swfdec_button_movie_execute (SwfdecButtonMovie *movie,
     SwfdecButtonCondition condition)
 {
+  const char *name;
+
   if (movie->button->menubutton) {
     g_assert ((condition & (SWFDEC_BUTTON_OVER_DOWN_TO_OUT_DOWN \
                          | SWFDEC_BUTTON_OUT_DOWN_TO_OVER_DOWN \
@@ -78,6 +108,8 @@ swfdec_button_movie_execute (SwfdecButto
   if (movie->button->events)
     swfdec_event_list_execute (movie->button->events, 
 	SWFDEC_SCRIPTABLE (SWFDEC_MOVIE (movie)->parent), condition, 0);
+  name = swfdec_button_condition_get_name (condition);
+  swfdec_scriptable_execute (SWFDEC_SCRIPTABLE (movie), name, 0, NULL);
 }
 
 #define CONTENT_IN_FRAME(content, frame) \
diff-tree ae9a32b99f5c17460709832562a94f83c527efd3 (from 66c73cff80ee0553549a566b7159687f65e6efc2)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Mar 19 16:29:43 2007 +0100

    invisible movies don't receive click events

diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index c4a2733..4c4ec47 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -530,6 +530,10 @@ swfdec_movie_get_movie_at (SwfdecMovie *
       SWFDEC_DEBUG ("ignoring depth=%d, it's clipped (clip_depth %d)", child->depth, clip_depth);
       continue;
     }
+    if (!child->visible) {
+      SWFDEC_LOG ("child %s %s (depth %d) is invisible, ignoring", G_OBJECT_TYPE_NAME (movie), movie->name, movie->depth);
+      continue;
+    }
 
     ret = swfdec_movie_get_movie_at (child, x, y);
     if (ret)
diff-tree 66c73cff80ee0553549a566b7159687f65e6efc2 (from cd812227f73b57d4dc92bb173e3b8c6c8be1acba)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Mar 19 16:29:27 2007 +0100

    return a const component_ptr

diff --git a/libswfdec/jpeg/jpeg.c b/libswfdec/jpeg/jpeg.c
index 06c60c5..7c9086d 100644
--- a/libswfdec/jpeg/jpeg.c
+++ b/libswfdec/jpeg/jpeg.c
@@ -805,7 +805,7 @@ jpeg_decoder_get_image_size (JpegDecoder
 
 int
 jpeg_decoder_get_component_ptr (JpegDecoder * dec, int id,
-    unsigned char **image, int *rowstride)
+    const unsigned char **image, int *rowstride)
 {
   int i;
 
diff --git a/libswfdec/jpeg/jpeg.h b/libswfdec/jpeg/jpeg.h
index fac03bc..f9fd194 100644
--- a/libswfdec/jpeg/jpeg.h
+++ b/libswfdec/jpeg/jpeg.h
@@ -15,7 +15,7 @@ int jpeg_decoder_get_component_size(Jpeg
 int jpeg_decoder_get_component_subsampling(JpegDecoder *dec, int id,
 	int *h_subsample, int *v_subsample);
 int jpeg_decoder_get_component_ptr(JpegDecoder *dec, int id,
-	unsigned char **image, int *rowstride);
+	const unsigned char **image, int *rowstride);
 
 unsigned char *jpeg_decoder_get_argb_image (JpegDecoder *dec);
 
diff --git a/libswfdec/jpeg/test.c b/libswfdec/jpeg/test.c
index 0ebdae0..c5614ec 100644
--- a/libswfdec/jpeg/test.c
+++ b/libswfdec/jpeg/test.c
@@ -10,7 +10,7 @@
 /* getfile */
 
 void *getfile (char *path, int *n_bytes);
-static void dump_pgm (unsigned char *ptr, int rowstride, int width, int height);
+static void dump_pgm (const unsigned char *ptr, int rowstride, int width, int height);
 
 
 int
@@ -20,7 +20,7 @@ main (int argc, char *argv[])
   int len;
   JpegDecoder *dec;
   char *fn = "biglebowski.jpg";
-  unsigned char *ptr;
+  const unsigned char *ptr;
   int rowstride;
   int width;
   int height;
@@ -38,6 +38,7 @@ main (int argc, char *argv[])
   jpeg_decoder_get_component_size (dec, 1, &width, &height);
 
   dump_pgm (ptr, rowstride, width, height);
+  jpeg_decoder_free (dec);
 
   return 0;
 }
@@ -87,7 +88,7 @@ getfile (char *path, int *n_bytes)
 }
 
 static void
-dump_pgm (unsigned char *ptr, int rowstride, int width, int height)
+dump_pgm (const unsigned char *ptr, int rowstride, int width, int height)
 {
   int x, y;
 
diff-tree cd812227f73b57d4dc92bb173e3b8c6c8be1acba (from aaf177846e73cfaf396b5e3fe2b8dfdf4165d849)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Mar 19 16:28:51 2007 +0100

    add GLOBAL_CFLAGS to tests, too - they should get -Wall, too

diff --git a/libswfdec/jpeg/Makefile.am b/libswfdec/jpeg/Makefile.am
index 88356fa..14f2cf8 100644
--- a/libswfdec/jpeg/Makefile.am
+++ b/libswfdec/jpeg/Makefile.am
@@ -12,10 +12,10 @@ noinst_HEADERS = bits.h huffman.h jpeg.h
 
 
 jpeg_test_SOURCES = test.c
-jpeg_test_CFLAGS = $(LIBOIL_CFLAGS)
+jpeg_test_CFLAGS = $(GLOBAL_CFLAGS) $(LIBOIL_CFLAGS)
 jpeg_test_LDADD = libjpeg.la $(LIBOIL_LIBS)
 
 jpeg_rgb_test_SOURCES = test_rgb.c
-jpeg_rgb_test_CFLAGS = $(LIBOIL_CFLAGS)
+jpeg_rgb_test_CFLAGS = $(GLOBAL_CFLAGS) $(LIBOIL_CFLAGS)
 jpeg_rgb_test_LDADD = libjpeg.la $(LIBOIL_LIBS)
 
diff-tree aaf177846e73cfaf396b5e3fe2b8dfdf4165d849 (from fcbe5c01466babaa3d8c81333b885de03e9a7935)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Mar 19 16:27:49 2007 +0100

    implement NetStream::pause

diff --git a/libswfdec/swfdec_js_net_stream.c b/libswfdec/swfdec_js_net_stream.c
index 46cb1dc..8348279 100644
--- a/libswfdec/swfdec_js_net_stream.c
+++ b/libswfdec/swfdec_js_net_stream.c
@@ -44,6 +44,28 @@ swfdec_js_net_stream_play (JSContext *cx
 }
 
 static JSBool
+swfdec_js_net_stream_pause (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
+{
+  SwfdecNetStream *stream;
+  gboolean playing;
+
+  stream = swfdec_scriptable_from_object (cx, obj, SWFDEC_TYPE_NET_STREAM);
+  if (stream == NULL)
+    return JS_TRUE;
+  if (argc == 0) {
+    playing = !swfdec_net_stream_get_playing (stream);
+  } else {
+    JSBool b;
+    if (!JS_ValueToBoolean (cx, argv[0], &b))
+      return JS_FALSE;
+    playing = !b;
+  }
+  g_print ("%s\n", playing ? "PLAY" : "PAUSE");
+  swfdec_net_stream_set_playing (stream, playing);
+  return JS_TRUE;
+}
+
+static JSBool
 swfdec_js_net_stream_set_buffer_time (JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
 {
   SwfdecNetStream *stream;
@@ -59,6 +81,7 @@ swfdec_js_net_stream_set_buffer_time (JS
 }
 
 static JSFunctionSpec net_stream_methods[] = {
+  { "pause",		swfdec_js_net_stream_pause,		0, 0, 0 },
   { "play",		swfdec_js_net_stream_play,		1, 0, 0 },
   { "setBufferTime",  	swfdec_js_net_stream_set_buffer_time,	1, 0, 0 },
   {0,0,0,0,0}
diff-tree fcbe5c01466babaa3d8c81333b885de03e9a7935 (from 98cefbbedf8f1b5f7c1b9169f546cc92e149c341)
Author: Benjamin Otte <otte at gnome.org>
Date:   Mon Mar 19 16:16:16 2007 +0100

    performance: don't create ARGB surfaces for video

diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 1e69ac3..b722095 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -96,7 +96,7 @@ swfdec_net_stream_video_goto (SwfdecNetS
 	    g_assert_not_reached ();
 	}
 	stream->surface = cairo_image_surface_create_for_data (decoded->data, 
-	    CAIRO_FORMAT_ARGB32, w, h, w * 4);
+	    CAIRO_FORMAT_RGB24, w, h, w * 4);
 	cairo_surface_set_user_data (stream->surface, &key, 
 	    decoded, (cairo_destroy_func_t) swfdec_buffer_unref);
 	if (old != stream->surface) {
diff --git a/libswfdec/swfdec_video.c b/libswfdec/swfdec_video.c
index bf6b460..f163ffd 100644
--- a/libswfdec/swfdec_video.c
+++ b/libswfdec/swfdec_video.c
@@ -88,7 +88,7 @@ swfdec_video_input_iterate (SwfdecVideoM
       g_assert_not_reached ();
   }
   surface = cairo_image_surface_create_for_data (buffer->data, 
-      CAIRO_FORMAT_ARGB32, w, h, w * 4);
+      CAIRO_FORMAT_RGB24, w, h, w * 4);
   cairo_surface_set_user_data (surface, &key, 
       buffer, (cairo_destroy_func_t) swfdec_buffer_unref);
   swfdec_video_movie_new_image (input->movie, surface, w, h);


More information about the Swfdec mailing list