[Swfdec] 18 commits - doc/swfdec-sections.txt libswfdec/Makefile.am libswfdec/swfdec_as_interpret.c libswfdec/swfdec_as_strings.c libswfdec/swfdec_button_movie.c libswfdec/swfdec_event.c libswfdec/swfdec_event.h libswfdec/swfdec_flash_security.c libswfdec/swfdec_flash_security.h libswfdec/swfdec_graphic_movie.c libswfdec/swfdec_load_object.c libswfdec/swfdec_morph_movie.c libswfdec/swfdec_morph_movie.h libswfdec/swfdec_movie_asprops.c libswfdec/swfdec_movie.c libswfdec/swfdec_movie.h libswfdec/swfdec_net_stream.c libswfdec/swfdec_player.c libswfdec/swfdec_player_internal.h libswfdec/swfdec_resource.c libswfdec/swfdec_resource.h libswfdec/swfdec_sound_object.c libswfdec/swfdec_sprite_movie_as.c libswfdec/swfdec_sprite_movie.c libswfdec/swfdec_swf_decoder.c libswfdec/swfdec_swf_instance.c libswfdec/swfdec_swf_instance.h libswfdec/swfdec_tag.c libswfdec/swfdec_tag.h libswfdec/swfdec_text_field_movie_as.c libswfdec/swfdec_types.h libswfdec/swfdec_url.c libswfdec/swfdec_url.h libswfdec/swfdec_video.c libswfdec/swfdec_video_movie.c libswfdec/swfdec_video_movie.h test/dump.c test/swfdec-extract.c

Benjamin Otte company at kemper.freedesktop.org
Thu Oct 18 13:19:59 PDT 2007


 doc/swfdec-sections.txt                |    1 
 libswfdec/Makefile.am                  |    4 
 libswfdec/swfdec_as_interpret.c        |   24 +-
 libswfdec/swfdec_as_strings.c          |    1 
 libswfdec/swfdec_button_movie.c        |    3 
 libswfdec/swfdec_event.c               |    5 
 libswfdec/swfdec_event.h               |    2 
 libswfdec/swfdec_flash_security.c      |   95 ++++++----
 libswfdec/swfdec_flash_security.h      |   16 +
 libswfdec/swfdec_graphic_movie.c       |    2 
 libswfdec/swfdec_load_object.c         |   15 +
 libswfdec/swfdec_morph_movie.c         |   37 ++-
 libswfdec/swfdec_morph_movie.h         |    3 
 libswfdec/swfdec_movie.c               |   58 +++++-
 libswfdec/swfdec_movie.h               |    5 
 libswfdec/swfdec_movie_asprops.c       |    4 
 libswfdec/swfdec_net_stream.c          |   17 +
 libswfdec/swfdec_player.c              |   90 +++------
 libswfdec/swfdec_player_internal.h     |   10 -
 libswfdec/swfdec_resource.c            |  310 +++++++++++++++++++++++++++++++++
 libswfdec/swfdec_resource.h            |   73 +++++++
 libswfdec/swfdec_sound_object.c        |    4 
 libswfdec/swfdec_sprite_movie.c        |   41 ++--
 libswfdec/swfdec_sprite_movie_as.c     |   20 +-
 libswfdec/swfdec_swf_decoder.c         |   14 +
 libswfdec/swfdec_swf_instance.c        |  308 --------------------------------
 libswfdec/swfdec_swf_instance.h        |   72 -------
 libswfdec/swfdec_tag.c                 |   34 +--
 libswfdec/swfdec_tag.h                 |    6 
 libswfdec/swfdec_text_field_movie_as.c |    2 
 libswfdec/swfdec_types.h               |    2 
 libswfdec/swfdec_url.c                 |   16 +
 libswfdec/swfdec_url.h                 |    2 
 libswfdec/swfdec_video.c               |   64 +++++-
 libswfdec/swfdec_video_movie.c         |   72 ++++---
 libswfdec/swfdec_video_movie.h         |   15 -
 test/dump.c                            |   10 -
 test/swfdec-extract.c                  |    6 
 38 files changed, 823 insertions(+), 640 deletions(-)

New commits:
commit 18c69ec89d20eb74a205d76f202123c4e9bec71f
Merge: 3a60b20... 60c0c37...
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 22:19:33 2007 +0200

    Merge branch 'master' of ssh://company@git.freedesktop.org/git/swfdec/swfdec
    
    Conflicts:
    
    	libswfdec/swfdec_as_strings.c

diff --cc libswfdec/swfdec_as_strings.c
index f5eed8a,2c6c0e9..313383a
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@@ -411,6 -411,14 +411,15 @@@ const char swfdec_as_strings[] 
    SWFDEC_AS_CONSTANT_STRING ("variable")
    SWFDEC_AS_CONSTANT_STRING ("restrict")
    SWFDEC_AS_CONSTANT_STRING ("mouseWheelEnabled")
 +  SWFDEC_AS_CONSTANT_STRING ("_level0")
+   SWFDEC_AS_CONSTANT_STRING ("hscroll")
+   SWFDEC_AS_CONSTANT_STRING ("maxhscroll")
+   SWFDEC_AS_CONSTANT_STRING ("maxscroll")
+   SWFDEC_AS_CONSTANT_STRING ("bottomScroll")
+   SWFDEC_AS_CONSTANT_STRING ("Sans")
+   SWFDEC_AS_CONSTANT_STRING ("Serif")
+   SWFDEC_AS_CONSTANT_STRING ("Monospace")
+   SWFDEC_AS_CONSTANT_STRING ("textHeight")
+   SWFDEC_AS_CONSTANT_STRING ("textWidth")
    /* add more here */
  ;
commit 3a60b202da5fd9e5bce61f04b73c229f77c6707f
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 21:47:12 2007 +0200

    fix SwfdecVideoMovie to work with ratio
    
    fixes:
    - ratio describes the current frame
    - only decode video when displaying it
    - fix size computation for VdeoFrame'd videos
    
    problems:
    - must decode whole movie when going one frame backwards

diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 135bae8..c401125 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -115,7 +115,7 @@ swfdec_net_stream_video_goto (SwfdecNetStream *stream, guint timestamp)
     if (stream->surface) {
       GList *walk;
       for (walk = stream->movies; walk; walk = walk->next) {
-	swfdec_video_movie_new_image (walk->data, stream->surface);
+	swfdec_video_movie_new_image (walk->data);
       }
     }
   }
@@ -350,6 +350,14 @@ swfdec_net_stream_input_disconnect (SwfdecVideoMovieInput *input, SwfdecVideoMov
   g_object_unref (stream);
 }
 
+static cairo_surface_t *
+swfdec_net_stream_input_get_image (SwfdecVideoMovieInput *input)
+{
+  SwfdecNetStream *stream = SWFDEC_NET_STREAM ((guchar *) input - G_STRUCT_OFFSET (SwfdecNetStream, input));
+
+  return stream->surface;
+}
+
 /*** SWFDEC_NET_STREAM ***/
 
 G_DEFINE_TYPE_WITH_CODE (SwfdecNetStream, swfdec_net_stream, SWFDEC_TYPE_AS_OBJECT,
@@ -451,6 +459,7 @@ swfdec_net_stream_init (SwfdecNetStream *stream)
 {
   stream->input.connect = swfdec_net_stream_input_connect;
   stream->input.disconnect = swfdec_net_stream_input_disconnect;
+  stream->input.get_image = swfdec_net_stream_input_get_image;
 
   stream->buffer_time = 100; /* msecs */
 }
diff --git a/libswfdec/swfdec_video.c b/libswfdec/swfdec_video.c
index 768babd..520960c 100644
--- a/libswfdec/swfdec_video.c
+++ b/libswfdec/swfdec_video.c
@@ -63,27 +63,52 @@ typedef struct {
   SwfdecVideo *		video;
   gpointer		decoder;
   guint			current_frame;
+  cairo_surface_t *	surface;
 } SwfdecVideoInput;
 
 static void
-swfdec_video_input_iterate (SwfdecVideoMovieInput *input_)
+swfdec_video_input_set_ratio (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *movie)
 {
   SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
+  guint ratio = SWFDEC_MOVIE (movie)->original_ratio;
   SwfdecBuffer *buffer;
-  cairo_surface_t *surface;
 
-  input->current_frame = (input->current_frame + 1) % input->video->n_frames;
   if (input->decoder == NULL)
     return;
-  buffer = swfdec_video_find_frame (input->video, input->current_frame);
-  if (buffer == NULL)
-    return;
+  ratio++;
+  if (ratio > input->video->n_frames) {
+    SWFDEC_ERROR ("ratio %u too big: only %u frames", ratio, input->video->n_frames);
+    ratio = input->video->n_frames - 1;
+  }
+  if (ratio < input->current_frame) {
+    /* FIXME: need to reset decoder here? */
+    input->current_frame = 0;
+  }
 
-  surface = swfdec_video_decoder_decode (input->decoder, buffer);
-  if (surface == NULL)
-    return;
-  swfdec_video_movie_new_image (input->movie, surface);
-  cairo_surface_destroy (surface);
+  while (input->current_frame < ratio) {
+    buffer = swfdec_video_find_frame (input->video, input->current_frame);
+    if (buffer == NULL) {
+      SWFDEC_INFO ("no buffer for frame %u", input->current_frame);
+    } else {
+      if (input->surface)
+	cairo_surface_destroy (input->surface);
+      input->surface = swfdec_video_decoder_decode (input->decoder, buffer);
+      if (input->surface == NULL)
+	return;
+      if (input->video->width < (guint) cairo_image_surface_get_width (input->surface) ||
+	  input->video->height < (guint) cairo_image_surface_get_height (input->surface)) {
+	static cairo_user_data_key_t key;
+	cairo_surface_t *old = input->surface;
+	input->surface = cairo_image_surface_create_for_data (
+	    cairo_image_surface_get_data (old), cairo_image_surface_get_format (old),
+	    input->video->width, input->video->height,
+	    cairo_image_surface_get_stride (old));
+	cairo_surface_set_user_data (input->surface, &key, old, 
+	    (cairo_destroy_func_t) cairo_surface_destroy);
+      }
+    }
+    input->current_frame++;
+  }
 }
 
 static void
@@ -104,7 +129,15 @@ swfdec_video_input_disconnect (SwfdecVideoMovieInput *input_, SwfdecVideoMovie *
   if (input->decoder)
     swfdec_video_decoder_free (input->decoder);
   g_object_unref (input->video);
-  g_free (input);
+  g_slice_free (SwfdecVideoInput, input);
+}
+
+static cairo_surface_t *
+swfdec_video_input_get_image (SwfdecVideoMovieInput *input_)
+{
+  SwfdecVideoInput *input = (SwfdecVideoInput *) input_;
+
+  return input->surface;
 }
 
 static SwfdecVideoMovieInput *
@@ -114,15 +147,16 @@ swfdec_video_input_new (SwfdecVideo *video)
   
   if (video->n_frames == 0)
     return NULL;
-  input = g_new0 (SwfdecVideoInput, 1);
+  input = g_slice_new0 (SwfdecVideoInput);
   input->decoder = swfdec_video_decoder_new (video->format);
   if (input->decoder == NULL) {
-    g_free (input);
+    g_slice_free (SwfdecVideoInput, input);
     return NULL;
   }
   input->input.connect = swfdec_video_input_connect;
-  input->input.iterate = swfdec_video_input_iterate;
   input->input.disconnect = swfdec_video_input_disconnect;
+  input->input.set_ratio = swfdec_video_input_set_ratio;
+  input->input.get_image = swfdec_video_input_get_image;
   g_object_ref (video);
   input->video = video;
   input->current_frame = (guint) -1;
diff --git a/libswfdec/swfdec_video_movie.c b/libswfdec/swfdec_video_movie.c
index d17c0cb..f95c2db 100644
--- a/libswfdec/swfdec_video_movie.c
+++ b/libswfdec/swfdec_video_movie.c
@@ -39,17 +39,39 @@ swfdec_video_movie_update_extents (SwfdecMovie *movie,
 }
 
 static void
+swfdec_video_movie_update_image (SwfdecVideoMovie *movie)
+{
+  if (!movie->needs_update)
+    return;
+
+  if (movie->input != NULL) {
+    if (movie->input->set_ratio)
+      movie->input->set_ratio (movie->input, movie);
+    
+    if (movie->image)
+      cairo_surface_destroy (movie->image);
+    movie->image = movie->input->get_image (movie->input);
+    if (movie->image)
+      cairo_surface_reference (movie->image);
+  }
+  movie->needs_update = FALSE;
+}
+
+static void
 swfdec_video_movie_render (SwfdecMovie *mov, cairo_t *cr, 
     const SwfdecColorTransform *trans, const SwfdecRect *inval)
 {
   SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (mov);
 
+  swfdec_video_movie_update_image (movie);
   if (movie->image == NULL)
     return;
 
   cairo_scale (cr, 
-      (mov->original_extents.x1 - mov->original_extents.x0) / movie->image_width,
-      (mov->original_extents.y1 - mov->original_extents.y0) / movie->image_height);
+      (mov->original_extents.x1 - mov->original_extents.x0)
+      / cairo_image_surface_get_width (movie->image),
+      (mov->original_extents.y1 - mov->original_extents.y0)
+      / cairo_image_surface_get_height (movie->image));
   cairo_set_source_surface (cr, movie->image, 0.0, 0.0);
   cairo_paint (cr);
 }
@@ -60,6 +82,7 @@ swfdec_video_movie_unset_input (SwfdecVideoMovie *movie)
   if (movie->input == NULL)
     return;
 
+  swfdec_video_movie_update_image (movie);
   if (movie->input->disconnect)
     movie->input->disconnect (movie->input, movie);
   movie->input = NULL;
@@ -71,28 +94,24 @@ swfdec_video_movie_dispose (GObject *object)
   SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (object);
 
   swfdec_video_movie_unset_input (movie);
+  g_object_unref (movie->video);
   if (movie->image) {
     cairo_surface_destroy (movie->image);
     movie->image = NULL;
   }
-  g_object_unref (movie->video);
 
   G_OBJECT_CLASS (swfdec_video_movie_parent_class)->dispose (object);
 }
 
-static gboolean
-swfdec_video_movie_iterate_end (SwfdecMovie *mov)
+static void
+swfdec_video_movie_set_ratio (SwfdecMovie *movie)
 {
-  SwfdecVideoMovie *movie = SWFDEC_VIDEO_MOVIE (mov);
-
-  if (!SWFDEC_MOVIE_CLASS (swfdec_video_movie_parent_class)->iterate_end (mov))
-    return FALSE;
+  SwfdecVideoMovie *video = SWFDEC_VIDEO_MOVIE (movie);
 
-  if (movie->input && movie->input->iterate) {
-    movie->input->iterate (movie->input);
+  if (video->input->set_ratio) {
+    video->needs_update = TRUE;
+    swfdec_movie_invalidate (movie);
   }
-
-  return TRUE;
 }
 
 static void
@@ -114,7 +133,7 @@ swfdec_video_movie_class_init (SwfdecVideoMovieClass * g_class)
   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;
+  movie_class->set_ratio = swfdec_video_movie_set_ratio;
 }
 
 static void
@@ -131,6 +150,10 @@ swfdec_video_movie_set_input (SwfdecVideoMovie *movie, SwfdecVideoMovieInput *in
   movie->input = input;
   if (input == NULL)
     return;
+  if (movie->input->set_ratio) {
+    swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
+  }
+  movie->needs_update = TRUE;
   if (input->connect)
     input->connect (input, movie);
 }
@@ -140,26 +163,23 @@ swfdec_video_movie_clear (SwfdecVideoMovie *movie)
 {
   g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
 
-  if (movie->image == NULL)
-    return;
-
-  cairo_surface_destroy (movie->image);
-  movie->image = NULL;
+  if (movie->image) {
+    cairo_surface_destroy (movie->image);
+    movie->image = NULL;
+  }
   swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
 }
 
 void
-swfdec_video_movie_new_image (SwfdecVideoMovie *movie, cairo_surface_t *image)
+swfdec_video_movie_new_image (SwfdecVideoMovie *movie)
 {
   g_return_if_fail (SWFDEC_IS_VIDEO_MOVIE (movie));
-  g_return_if_fail (image != NULL);
 
-  if (movie->image)
+  if (movie->image) {
     cairo_surface_destroy (movie->image);
-  cairo_surface_reference (image);
-  movie->image = image;
-  movie->image_width = cairo_image_surface_get_width (image);
-  movie->image_height = cairo_image_surface_get_height (image);
+    movie->image = NULL;
+  }
+  movie->needs_update = TRUE;
   swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
 }
 
diff --git a/libswfdec/swfdec_video_movie.h b/libswfdec/swfdec_video_movie.h
index 9ba9f1a..958bc49 100644
--- a/libswfdec/swfdec_video_movie.h
+++ b/libswfdec/swfdec_video_movie.h
@@ -45,8 +45,11 @@ struct _SwfdecVideoMovieInput {
   /* called when input is unset */
   void			(* disconnect)	(SwfdecVideoMovieInput *input,
 					 SwfdecVideoMovie *	movie);
-  /* called when movie is iterating */
-  void			(* iterate)	(SwfdecVideoMovieInput *input);
+  /* called when movie ratio changed */
+  void			(* set_ratio)	(SwfdecVideoMovieInput *input,
+					 SwfdecVideoMovie *	movie);
+  /* called to request the current image */
+  cairo_surface_t *	(* get_image)	(SwfdecVideoMovieInput *input);
 };
 
 struct _SwfdecVideoMovie {
@@ -54,9 +57,8 @@ struct _SwfdecVideoMovie {
 
   SwfdecVideo *		video;		/* video we play back */
   SwfdecVideoMovieInput *input;		/* where we take the input from */
-  cairo_surface_t *	image;		/* current image or NULL */
-  guint			image_width;	/* width of current image */
-  guint			image_height; 	/* height of current image */
+  gboolean		needs_update;	/* TRUE if we should call set_ratio and get_image */
+  cairo_surface_t *	image;	 	/* currently displayed image */
 };
 
 struct _SwfdecVideoMovieClass {
@@ -69,8 +71,7 @@ void		swfdec_video_movie_set_input		(SwfdecVideoMovie *	movie,
 							 SwfdecVideoMovieInput *input);
 void		swfdec_video_movie_clear	      	(SwfdecVideoMovie *	movie);
 /* API for SwfdecVideoMovieInput */
-void		swfdec_video_movie_new_image		(SwfdecVideoMovie *	movie,
-							 cairo_surface_t *	surface);
+void		swfdec_video_movie_new_image		(SwfdecVideoMovie *	movie);
 
 G_END_DECLS
 #endif
commit 4081ac4bb4c6ceebb52e55f766bee298d23fb492
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 19:52:38 2007 +0200

    set ratio via a set_ratio vfunc

diff --git a/libswfdec/swfdec_morph_movie.c b/libswfdec/swfdec_morph_movie.c
index ae52d8a..7997827 100644
--- a/libswfdec/swfdec_morph_movie.c
+++ b/libswfdec/swfdec_morph_movie.c
@@ -40,22 +40,30 @@ swfdec_morph_movie_update_extents (SwfdecMovie *movie,
   extents->x1 = ((65535 - ratio) * graphic->extents.x1 + ratio * morph->end_extents.x1) / 65535;
   extents->y0 = ((65535 - ratio) * graphic->extents.y0 + ratio * morph->end_extents.y0) / 65535;
   extents->y1 = ((65535 - ratio) * graphic->extents.y1 + ratio * morph->end_extents.y1) / 65535;
+}
+
+static void
+swfdec_morph_movie_set_ratio (SwfdecMovie *movie)
+{
+  SwfdecMorphMovie *mmovie = SWFDEC_MORPH_MOVIE (movie);
 
-  /* update the vectors */
-  if (ratio != mmovie->ratio) {
-    SwfdecShape *shape = SWFDEC_SHAPE (mmovie->morph);
-    GSList *walk;
+  g_slist_foreach (mmovie->draws, (GFunc) g_object_unref, NULL);
+  g_slist_free (mmovie->draws);
+  mmovie->draws = NULL;
+  swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_CONTENTS);
+}
 
-    g_slist_foreach (mmovie->draws, (GFunc) g_object_unref, NULL);
-    g_slist_free (mmovie->draws);
-    mmovie->draws = NULL;
+static void
+swfdec_morph_movie_create_morphs (SwfdecMorphMovie *mmovie)
+{
+  SwfdecShape *shape = SWFDEC_SHAPE (mmovie->morph);
+  guint ratio = SWFDEC_MOVIE (mmovie)->original_ratio;
+  GSList *walk;
 
-    for (walk = shape->draws; walk; walk = walk->next) {
-      mmovie->draws = g_slist_prepend (mmovie->draws, swfdec_draw_morph (walk->data, ratio));
-    }
-    mmovie->draws = g_slist_reverse (mmovie->draws);
-    mmovie->ratio = ratio;
+  for (walk = shape->draws; walk; walk = walk->next) {
+    mmovie->draws = g_slist_prepend (mmovie->draws, swfdec_draw_morph (walk->data, ratio));
   }
+  mmovie->draws = g_slist_reverse (mmovie->draws);
 }
 
 static void
@@ -65,6 +73,9 @@ swfdec_morph_movie_render (SwfdecMovie *movie, cairo_t *cr,
   SwfdecMorphMovie *morph = SWFDEC_MORPH_MOVIE (movie);
   GSList *walk;
 
+  if (morph->draws == NULL)
+    swfdec_morph_movie_create_morphs (morph);
+
   for (walk = morph->draws; walk; walk = walk->next) {
     SwfdecDraw *draw = walk->data;
 
@@ -98,6 +109,7 @@ swfdec_morph_movie_class_init (SwfdecMorphMovieClass * g_class)
 
   movie_class->update_extents = swfdec_morph_movie_update_extents;
   movie_class->render = swfdec_morph_movie_render;
+  movie_class->set_ratio = swfdec_morph_movie_set_ratio;
   /* FIXME */
   //movie_class->handle_mouse = swfdec_morph_movie_handle_mouse;
 }
@@ -105,6 +117,5 @@ swfdec_morph_movie_class_init (SwfdecMorphMovieClass * g_class)
 static void
 swfdec_morph_movie_init (SwfdecMorphMovie *morph)
 {
-  morph->ratio = (guint) -1;
 }
 
diff --git a/libswfdec/swfdec_morph_movie.h b/libswfdec/swfdec_morph_movie.h
index 9c18d50..c8dd6cc 100644
--- a/libswfdec/swfdec_morph_movie.h
+++ b/libswfdec/swfdec_morph_movie.h
@@ -40,8 +40,7 @@ struct _SwfdecMorphMovie {
   SwfdecMovie		movie;
 
   SwfdecMorphShape *	morph;
-  guint			ratio;		/* current ratio for paths */
-  GSList *		draws;		/* drawing operations to use */
+  GSList *		draws;		/* drawing operations to use or NULL if not yet created */
 };
 
 struct _SwfdecMorphMovieClass {
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 4617169..3f91015 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -1330,8 +1330,11 @@ swfdec_movie_set_static_properties (SwfdecMovie *movie, const cairo_matrix_t *tr
     swfdec_movie_invalidate (movie);
   }
   if (ratio >= 0 && (guint) ratio != movie->original_ratio) {
+    SwfdecMovieClass *klass;
     movie->original_ratio = ratio;
-    swfdec_movie_queue_update (movie, SWFDEC_MOVIE_INVALID_CONTENTS);
+    klass = SWFDEC_MOVIE_GET_CLASS (movie);
+    if (klass->set_ratio)
+      klass->set_ratio (movie);
   }
   if (clip_depth && clip_depth != movie->clip_depth) {
     movie->clip_depth = clip_depth;
diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h
index 5cac2a5..d074ba9 100644
--- a/libswfdec/swfdec_movie.h
+++ b/libswfdec/swfdec_movie.h
@@ -155,6 +155,7 @@ struct _SwfdecMovieClass {
   void			(* finish_movie)	(SwfdecMovie *		movie);
   void			(* replace)		(SwfdecMovie *		movie,
 						 SwfdecGraphic *	graphic);
+  void			(* set_ratio)		(SwfdecMovie *		movie);
   void			(* update_extents)	(SwfdecMovie *		movie,
 						 SwfdecRect *   	extents);
   void			(* render)		(SwfdecMovie *		movie, 
commit 07f3af8f1025ef2757dd92fa54127ba128bc4c63
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 19:05:17 2007 +0200

    fix for SwfInstance => Resource rename

diff --git a/test/dump.c b/test/dump.c
index 47fb1ea..b66f8fc 100644
--- a/test/dump.c
+++ b/test/dump.c
@@ -41,7 +41,7 @@
 #include <libswfdec/swfdec_shape.h>
 #include <libswfdec/swfdec_sound.h>
 #include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_swf_instance.h>
+#include <libswfdec/swfdec_resource.h>
 #include <libswfdec/swfdec_tag.h>
 #include <libswfdec/swfdec_text.h>
 
@@ -414,20 +414,20 @@ main (int argc, char *argv[])
   }
 
   player = swfdec_player_new_from_file (argv[1]);
-  if (player->loader->error) {
-    g_printerr ("Couldn't open file \"%s\": %s\n", argv[1], player->loader->error);
+  if (player->resource->loader->error) {
+    g_printerr ("Couldn't open file \"%s\": %s\n", argv[1], player->resource->loader->error);
     g_object_unref (player);
     return 1;
   }
   /* FIXME: HACK! */
   swfdec_player_advance (player, 0);
-  if (swfdec_player_is_initialized (player)) {
+  if (!swfdec_player_is_initialized (player)) {
     g_printerr ("File \"%s\" is not a SWF file\n", argv[1]);
     g_object_unref (player);
     player = NULL;
     return 1;
   }
-  s = (SwfdecSwfDecoder *) SWFDEC_MOVIE (player->roots->data)->swf->decoder;
+  s = (SwfdecSwfDecoder *) SWFDEC_MOVIE (player->roots->data)->resource->decoder;
   /* FIXME: can happen after a _root.loadMovie() call */
   if (!SWFDEC_IS_SWF_DECODER (s)) {
     g_printerr ("Movie already unloaded from \"%s\"\n", argv[1]);
diff --git a/test/swfdec-extract.c b/test/swfdec-extract.c
index 07dce11..cdc74a7 100644
--- a/test/swfdec-extract.c
+++ b/test/swfdec-extract.c
@@ -41,7 +41,7 @@
 #include <libswfdec/swfdec_sprite.h>
 #include <libswfdec/swfdec_sprite_movie.h>
 #include <libswfdec/swfdec_swf_decoder.h>
-#include <libswfdec/swfdec_swf_instance.h>
+#include <libswfdec/swfdec_resource.h>
 
 static SwfdecBuffer *
 encode_wav (SwfdecBuffer *buffer, SwfdecAudioFormat format)
@@ -270,11 +270,11 @@ main (int argc, char *argv[])
   id = strtol (argv[2], NULL, 0);
   if (id >= 0) {
     character = swfdec_swf_decoder_get_character (
-	SWFDEC_SWF_DECODER (SWFDEC_MOVIE (player->roots->data)->swf->decoder),
+	SWFDEC_SWF_DECODER (SWFDEC_MOVIE (player->roots->data)->resource->decoder),
 	id);
   } else {
     character = SWFDEC_CHARACTER (SWFDEC_SWF_DECODER (
-	  SWFDEC_MOVIE (player->roots->data)->swf->decoder)->main_sprite);
+	  SWFDEC_MOVIE (player->roots->data)->resource->decoder)->main_sprite);
   }
   if (SWFDEC_IS_SPRITE (character)) {
     if (!export_sprite_sound (SWFDEC_SPRITE (character), argv[3]))
commit c69b7afe5cb37f764b2c41397cba38d68f952ff3
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 18:52:28 2007 +0200

    make swfdec_player_load fail when the security doesn't allow opening the URL

diff --git a/libswfdec/swfdec_load_object.c b/libswfdec/swfdec_load_object.c
index 7174aa2..09ac8c8 100644
--- a/libswfdec/swfdec_load_object.c
+++ b/libswfdec/swfdec_load_object.c
@@ -181,18 +181,21 @@ swfdec_load_object_init (SwfdecLoadObject *load_object)
 {
 }
 
-static void
+static gboolean
 swfdec_load_object_load (SwfdecLoadObject *load_object, const char *url, 
     SwfdecLoaderRequest request, SwfdecBuffer *data)
 {
   SwfdecAsValue val;
 
-  g_return_if_fail (SWFDEC_IS_LOAD_OBJECT (load_object));
-  g_return_if_fail (url != NULL);
+  g_return_val_if_fail (SWFDEC_IS_LOAD_OBJECT (load_object), FALSE);
+  g_return_val_if_fail (url != NULL, FALSE);
 
   swfdec_load_object_reset (load_object);
   load_object->loader = swfdec_player_load (
       SWFDEC_PLAYER (SWFDEC_AS_OBJECT (load_object)->context), url, request, data);
+  if (load_object->loader == NULL)
+    return FALSE;
+
   swfdec_loader_set_target (load_object->loader,
       SWFDEC_LOADER_TARGET (load_object));
   swfdec_loader_set_data_type (load_object->loader, SWFDEC_LOADER_DATA_TEXT);
@@ -207,6 +210,7 @@ swfdec_load_object_load (SwfdecLoadObject *load_object, const char *url,
   SWFDEC_AS_VALUE_SET_BOOLEAN (&val, FALSE);
   swfdec_as_object_set_variable_and_flags (load_object->target,
       SWFDEC_AS_STR_loaded, &val, SWFDEC_AS_VARIABLE_HIDDEN);
+  return TRUE;
 }
 
 SwfdecAsObject *
@@ -226,10 +230,11 @@ swfdec_load_object_new (SwfdecAsObject *target, const char *url,
 
   SWFDEC_LOAD_OBJECT (load_object)->target = target;
 
+  if (!swfdec_load_object_load (SWFDEC_LOAD_OBJECT (load_object), url, request, data))
+    return NULL;
+
   SWFDEC_PLAYER (target->context)->load_objects =
     g_list_append (SWFDEC_PLAYER (target->context)->load_objects, load_object);
 
-  swfdec_load_object_load (SWFDEC_LOAD_OBJECT (load_object), url, request, data);
-
   return load_object;
 }
diff --git a/libswfdec/swfdec_net_stream.c b/libswfdec/swfdec_net_stream.c
index 59cb836..135bae8 100644
--- a/libswfdec/swfdec_net_stream.c
+++ b/libswfdec/swfdec_net_stream.c
@@ -484,8 +484,10 @@ swfdec_net_stream_set_url (SwfdecNetStream *stream, const char *url)
   /* FIXME: use the connection once connections are implemented */
   loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (stream)->context), url,
       SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
-  swfdec_net_stream_set_loader (stream, loader);
-  g_object_unref (loader);
+  if (loader) {
+    swfdec_net_stream_set_loader (stream, loader);
+    g_object_unref (loader);
+  }
 }
 
 void
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 420820e..6355c42 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -28,6 +28,7 @@
 #include <liboil/liboil.h>
 
 #include "swfdec_player_internal.h"
+#include "swfdec_as_frame_internal.h"
 #include "swfdec_as_internal.h"
 #include "swfdec_as_strings.h"
 #include "swfdec_audio_internal.h"
@@ -1656,10 +1657,29 @@ SwfdecLoader *
 swfdec_player_load (SwfdecPlayer *player, const char *url, 
     SwfdecLoaderRequest request, SwfdecBuffer *buffer)
 {
+  SwfdecAsContext *cx;
+  SwfdecSecurity *sec;
+  SwfdecURL *full;
+
   g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
   g_return_val_if_fail (url != NULL, NULL);
 
   g_assert (player->resource);
+  /* create absolute url first */
+  full = swfdec_url_new_relative (swfdec_loader_get_url (player->resource->loader), url);
+  /* figure out the right security object (FIXME: let the person loading it provide it?) */
+  cx = SWFDEC_AS_CONTEXT (player);
+  if (cx->frame) {
+    sec = cx->frame->security;
+  } else {
+    g_warning ("swfdec_player_load() should only be called from scripts");
+    sec = SWFDEC_SECURITY (player->resource);
+  }
+  if (!swfdec_security_allow_url (sec, full)) {
+    SWFDEC_ERROR ("not allowing access to %s", url);
+    return NULL;
+  }
+
   if (buffer) {
     return swfdec_loader_load (player->resource->loader, url, request, 
 	(const char *) buffer->data, buffer->length);
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index bf80f93..91bfb2f 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -722,9 +722,11 @@ swfdec_sprite_movie_load (SwfdecSpriteMovie *movie, const char *url, SwfdecLoade
 
   swfdec_sprite_movie_unload (movie);
 
-  /* FIXME: load relative to other movie? */
   loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context),
       url, request, data);
+  if (loader == NULL)
+    return;
+
   resource = swfdec_resource_new (loader, NULL);
   g_object_unref (SWFDEC_MOVIE (movie)->resource);
   SWFDEC_MOVIE (movie)->resource = resource;
commit ef0da1f12dd355bf62799b810026e1d8ad07cd40
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 17:12:50 2007 +0200

    add flag for "only used as first flag" and use it for FileAttributes

diff --git a/libswfdec/swfdec_swf_decoder.c b/libswfdec/swfdec_swf_decoder.c
index fe964ff..a864ecb 100644
--- a/libswfdec/swfdec_swf_decoder.c
+++ b/libswfdec/swfdec_swf_decoder.c
@@ -38,11 +38,13 @@
 #include "swfdec_script.h"
 #include "swfdec_script_internal.h"
 #include "swfdec_sprite.h"
+#include "swfdec_tag.h"
 
 enum {
   SWFDEC_STATE_INIT1 = 0,
   SWFDEC_STATE_INIT2,
-  SWFDEC_STATE_PARSETAG,
+  SWFDEC_STATE_PARSE_FIRST_TAG,
+  SWFDEC_STATE_PARSE_TAG,
   SWFDEC_STATE_EOF,
 };
 
@@ -270,7 +272,7 @@ swf_parse_header2 (SwfdecSwfDecoder * s)
 
   swfdec_swf_decoder_flush_bits (s, &s->b);
 
-  s->state = SWFDEC_STATE_PARSETAG;
+  s->state = SWFDEC_STATE_PARSE_FIRST_TAG;
   return SWFDEC_STATUS_INIT;
 }
 
@@ -292,7 +294,8 @@ swfdec_swf_decoder_parse (SwfdecDecoder *dec)
 	return SWFDEC_STATUS_ERROR;
       ret = swf_parse_header2 (s);
       break;
-    case SWFDEC_STATE_PARSETAG:
+    case SWFDEC_STATE_PARSE_FIRST_TAG:
+    case SWFDEC_STATE_PARSE_TAG:
     {
       guint header_length;
       guint x;
@@ -336,6 +339,10 @@ swfdec_swf_decoder_parse (SwfdecDecoder *dec)
       func = swfdec_swf_decoder_get_tag_func (tag);
       if (tag == 0) {
 	s->state = SWFDEC_STATE_EOF;
+      } else if ((swfdec_swf_decoder_get_tag_flag (tag) & SWFDEC_TAG_FIRST_ONLY) 
+	  && s->state == SWFDEC_STATE_PARSE_TAG) {
+	SWFDEC_WARNING ("tag %d %s must be first tag in file, ignoring",
+	    tag, swfdec_swf_decoder_get_tag_name (tag));
       } else if (func == NULL) {
 	SWFDEC_WARNING ("tag function not implemented for %d %s",
 	    tag, swfdec_swf_decoder_get_tag_name (tag));
@@ -355,6 +362,7 @@ swfdec_swf_decoder_parse (SwfdecDecoder *dec)
 	ret = SWFDEC_STATE_EOF;
 	SWFDEC_ERROR ("data after last frame");
       }
+      s->state = SWFDEC_STATE_PARSE_TAG;
 
       break;
     }
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index c9ce1a6..bad0be3 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -638,8 +638,6 @@ tag_func_do_action (SwfdecSwfDecoder * s, guint tag)
   return SWFDEC_STATUS_OK;
 }
 
-/* may appear inside DefineSprite */
-#define SPRITE 1
 struct tag_func_struct
 {
   const char *name;
@@ -647,12 +645,12 @@ struct tag_func_struct
   int flag;
 };
 static struct tag_func_struct tag_funcs[] = {
-  [SWFDEC_TAG_END] = {"End", tag_func_end, SPRITE},
-  [SWFDEC_TAG_SHOWFRAME] = {"ShowFrame", tag_func_show_frame, SPRITE},
+  [SWFDEC_TAG_END] = {"End", tag_func_end, SWFDEC_TAG_DEFINE_SPRITE },
+  [SWFDEC_TAG_SHOWFRAME] = {"ShowFrame", tag_func_show_frame, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINESHAPE] = {"DefineShape", tag_define_shape, 0},
   [SWFDEC_TAG_FREECHARACTER] = {"FreeCharacter", NULL, 0},
-  [SWFDEC_TAG_PLACEOBJECT] = {"PlaceObject", NULL, SPRITE},
-  [SWFDEC_TAG_REMOVEOBJECT] = {"RemoveObject", tag_func_enqueue, SPRITE},
+  [SWFDEC_TAG_PLACEOBJECT] = {"PlaceObject", NULL, SWFDEC_TAG_DEFINE_SPRITE },
+  [SWFDEC_TAG_REMOVEOBJECT] = {"RemoveObject", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEBITSJPEG] = {"DefineBitsJPEG", tag_func_define_bits_jpeg, 0},
   [SWFDEC_TAG_DEFINEBUTTON] = {"DefineButton", tag_func_define_button, 0},
   [SWFDEC_TAG_JPEGTABLES] = {"JPEGTables", swfdec_image_jpegtables, 0},
@@ -660,22 +658,22 @@ static struct tag_func_struct tag_funcs[] = {
       {"SetBackgroundColor", tag_func_set_background_color, 0},
   [SWFDEC_TAG_DEFINEFONT] = {"DefineFont", tag_func_define_font, 0},
   [SWFDEC_TAG_DEFINETEXT] = {"DefineText", tag_func_define_text, 0},
-  [SWFDEC_TAG_DOACTION] = {"DoAction", tag_func_do_action, SPRITE},
+  [SWFDEC_TAG_DOACTION] = {"DoAction", tag_func_do_action, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEFONTINFO] = {"DefineFontInfo", tag_func_define_font_info, 0},
   [SWFDEC_TAG_DEFINESOUND] = {"DefineSound", tag_func_define_sound, 0},
-  [SWFDEC_TAG_STARTSOUND] = {"StartSound", tag_func_enqueue, SPRITE},
+  [SWFDEC_TAG_STARTSOUND] = {"StartSound", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEBUTTONSOUND] =
       {"DefineButtonSound", tag_func_define_button_sound, 0},
-  [SWFDEC_TAG_SOUNDSTREAMHEAD] = {"SoundStreamHead", tag_func_sound_stream_head, SPRITE},
-  [SWFDEC_TAG_SOUNDSTREAMBLOCK] = {"SoundStreamBlock", tag_func_sound_stream_block, SPRITE},
+  [SWFDEC_TAG_SOUNDSTREAMHEAD] = {"SoundStreamHead", tag_func_sound_stream_head, SWFDEC_TAG_DEFINE_SPRITE },
+  [SWFDEC_TAG_SOUNDSTREAMBLOCK] = {"SoundStreamBlock", tag_func_sound_stream_block, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEBITSLOSSLESS] =
       {"DefineBitsLossless", tag_func_define_bits_lossless, 0},
   [SWFDEC_TAG_DEFINEBITSJPEG2] = {"DefineBitsJPEG2", tag_func_define_bits_jpeg_2, 0},
   [SWFDEC_TAG_DEFINESHAPE2] = {"DefineShape2", tag_define_shape, 0},
   [SWFDEC_TAG_DEFINEBUTTONCXFORM] = {"DefineButtonCXForm", NULL, 0},
   [SWFDEC_TAG_PROTECT] = {"Protect", tag_func_protect, 0},
-  [SWFDEC_TAG_PLACEOBJECT2] = {"PlaceObject2", tag_func_enqueue, SPRITE},
-  [SWFDEC_TAG_REMOVEOBJECT2] = {"RemoveObject2", tag_func_enqueue, SPRITE},
+  [SWFDEC_TAG_PLACEOBJECT2] = {"PlaceObject2", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
+  [SWFDEC_TAG_REMOVEOBJECT2] = {"RemoveObject2", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINESHAPE3] = {"DefineShape3", tag_define_shape_3, 0},
   [SWFDEC_TAG_DEFINETEXT2] = {"DefineText2", tag_func_define_text, 0},
   [SWFDEC_TAG_DEFINEBUTTON2] = {"DefineButton2", tag_func_define_button_2, 0},
@@ -688,8 +686,8 @@ static struct tag_func_struct tag_funcs[] = {
   [SWFDEC_TAG_NAMECHARACTER] = {"NameCharacter", NULL, 0},
   [SWFDEC_TAG_SERIALNUMBER] = {"SerialNumber", NULL, 0},
   [SWFDEC_TAG_GENERATORTEXT] = {"GeneratorText", NULL, 0},
-  [SWFDEC_TAG_FRAMELABEL] = {"FrameLabel", tag_func_frame_label, SPRITE},
-  [SWFDEC_TAG_SOUNDSTREAMHEAD2] = {"SoundStreamHead2", tag_func_sound_stream_head, SPRITE},
+  [SWFDEC_TAG_FRAMELABEL] = {"FrameLabel", tag_func_frame_label, SWFDEC_TAG_DEFINE_SPRITE },
+  [SWFDEC_TAG_SOUNDSTREAMHEAD2] = {"SoundStreamHead2", tag_func_sound_stream_head, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEMORPHSHAPE] =
       {"DefineMorphShape", tag_define_morph_shape, 0},
   [SWFDEC_TAG_DEFINEFONT2] = {"DefineFont2", tag_func_define_font_2, 0},
@@ -699,16 +697,16 @@ static struct tag_func_struct tag_funcs[] = {
   [SWFDEC_TAG_EXPORTASSETS] = {"ExportAssets", tag_func_export_assets, 0},
   [SWFDEC_TAG_IMPORTASSETS] = {"ImportAssets", NULL, 0},
   [SWFDEC_TAG_ENABLEDEBUGGER] = {"EnableDebugger", NULL, 0},
-  [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_do_init_action, SPRITE},
+  [SWFDEC_TAG_DOINITACTION] = {"DoInitAction", tag_func_do_init_action, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEVIDEOSTREAM] = {"DefineVideoStream", tag_func_define_video, 0},
-  [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, SPRITE},
+  [SWFDEC_TAG_VIDEOFRAME] = {"VideoFrame", tag_func_video_frame, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_DEFINEFONTINFO2] = {"DefineFontInfo2", tag_func_define_font_info, 0},
   [SWFDEC_TAG_MX4] = {"MX4", NULL, 0},
   [SWFDEC_TAG_ENABLEDEBUGGER2] = {"EnableDebugger2", NULL, 0},
   [SWFDEC_TAG_SCRIPTLIMITS] = {"ScriptLimits", NULL, 0},
   [SWFDEC_TAG_SETTABINDEX] = {"SetTabIndex", NULL, 0},
-  [SWFDEC_TAG_FILEATTRIBUTES] = {"FileAttributes", tag_func_file_attributes, 0},
-  [SWFDEC_TAG_PLACEOBJECT3] = {"PlaceObject3", tag_func_enqueue, SPRITE},
+  [SWFDEC_TAG_FILEATTRIBUTES] = {"FileAttributes", tag_func_file_attributes, SWFDEC_TAG_FIRST_ONLY },
+  [SWFDEC_TAG_PLACEOBJECT3] = {"PlaceObject3", tag_func_enqueue, SWFDEC_TAG_DEFINE_SPRITE },
   [SWFDEC_TAG_IMPORTASSETS2] = {"ImportAssets2", NULL, 0},
   [SWFDEC_TAG_DEFINEFONTALIGNZONES] = {"DefineFontAlignZones", NULL, 0},
   [SWFDEC_TAG_CSMTEXTSETTINGS] = {"CSMTextSettings", NULL, 0},
diff --git a/libswfdec/swfdec_tag.h b/libswfdec/swfdec_tag.h
index cbb6de0..a3df92b 100644
--- a/libswfdec/swfdec_tag.h
+++ b/libswfdec/swfdec_tag.h
@@ -92,5 +92,11 @@ typedef enum {
   SWFDEC_TAG_DEFINEMORPHSHAPE2    = 84
 } SwfdecTag;
 
+typedef enum {
+  /* tag is allowe inside DefineSprite */
+  SWFDEC_TAG_DEFINE_SPRITE = (1 << 0),
+  /* tag must be first tag */
+  SWFDEC_TAG_FIRST_ONLY = (1 << 1)
+} SwfdecTagFlag;
 
 #endif
commit 488a233fcf44a08e6f4a10cdc056dec3fbde5526
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 17:00:39 2007 +0200

    remove g_print

diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index 7913383..c9ce1a6 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -517,7 +517,6 @@ tag_func_file_attributes (SwfdecSwfDecoder *s, guint tag)
     SWFDEC_INFO ("reserved bits (2) aren't 0");
   s->use_network = swfdec_bits_getbit (&s->b);
   SWFDEC_LOG ("  use network: %d", s->use_network);
-  g_print ("  use network: %d\n", s->use_network);
   if (swfdec_bits_getbits (&s->b, 24))
     SWFDEC_INFO ("reserved bits (3) aren't 0");
   /* initialize default security if it wasn't initialized yet */
commit 29ae44d7a7faaff225603a76b2d8c3cc0705d7e2
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 16:57:10 2007 +0200

    fix allow security handling

diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c
index c13d0e0..0acf747 100644
--- a/libswfdec/swfdec_flash_security.c
+++ b/libswfdec/swfdec_flash_security.c
@@ -35,8 +35,10 @@ swfdec_flash_security_allow (SwfdecSecurity *guard, SwfdecSecurity *key)
   if (guard == key) {
     return g_object_ref (guard);
   } else if (SWFDEC_IS_SECURITY_ALLOW (key)) {
-    return g_object_ref (key);
+    /* This only happens when calling functions (I hope) */
+    return g_object_ref (guard);
   } else if (SWFDEC_IS_FLASH_SECURITY (key)) {
+    /* FIXME: what do we do here? */
     return g_object_ref (key);
   } else {
     SWFDEC_ERROR ("unknown security %s, denying access", G_OBJECT_TYPE_NAME (key));
commit 2c9ea37ee7248455fc1fa4478cf638b3dbc7675b
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 16:47:51 2007 +0200

    make the flash security use the sandbox type explicitly

diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c
index 4b27c53..c13d0e0 100644
--- a/libswfdec/swfdec_flash_security.c
+++ b/libswfdec/swfdec_flash_security.c
@@ -35,10 +35,9 @@ swfdec_flash_security_allow (SwfdecSecurity *guard, SwfdecSecurity *key)
   if (guard == key) {
     return g_object_ref (guard);
   } else if (SWFDEC_IS_SECURITY_ALLOW (key)) {
-    return g_object_ref (guard);
+    return g_object_ref (key);
   } else if (SWFDEC_IS_FLASH_SECURITY (key)) {
-    SWFDEC_FIXME ("merging flash securities - how is this supposed to work?");
-    return key;
+    return g_object_ref (key);
   } else {
     SWFDEC_ERROR ("unknown security %s, denying access", G_OBJECT_TYPE_NAME (key));
     return NULL;
@@ -46,22 +45,55 @@ swfdec_flash_security_allow (SwfdecSecurity *guard, SwfdecSecurity *key)
 }
 
 static gboolean
+swfdec_flash_security_match_domain (const SwfdecURL *guard, const SwfdecURL *key)
+{
+  return g_ascii_strcasecmp (swfdec_url_get_host (guard), swfdec_url_get_host (key)) == 0;
+}
+
+static gboolean
 swfdec_flash_security_allow_url (SwfdecSecurity *guard, const SwfdecURL *url)
 {
   SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (guard);
 
-  if (swfdec_url_is_local (url)) {
-    return sec->allow_local;
-  } else {
-    return sec->allow_remote;
+  switch (sec->sandbox) {
+    case SWFDEC_SANDBOX_NONE:
+      return FALSE;
+    case SWFDEC_SANDBOX_REMOTE:
+      if (swfdec_url_is_local (url))
+	return FALSE;
+      return swfdec_flash_security_match_domain (sec->url, url);
+    case SWFDEC_SANDBOX_LOCAL_FILE:
+      return swfdec_url_is_local (url);
+    case SWFDEC_SANDBOX_LOCAL_NETWORK:
+      return !swfdec_url_is_local (url);
+    case SWFDEC_SANDBOX_LOCAL_TRUSTED:
+      return TRUE;
   }
+  g_assert_not_reached ();
+  return FALSE;
+}
+
+static void
+swfdec_flash_security_dispose (GObject *object)
+{
+  SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (object);
+
+  if (sec->url) {
+    swfdec_url_free (sec->url);
+    sec->url = NULL;
+  }
+  sec->sandbox = SWFDEC_SANDBOX_NONE;
+  G_OBJECT_CLASS (swfdec_flash_security_parent_class)->dispose (object);
 }
 
 static void
 swfdec_flash_security_class_init (SwfdecFlashSecurityClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
   SwfdecSecurityClass *security_class = SWFDEC_SECURITY_CLASS (klass);
 
+  object_class->dispose = swfdec_flash_security_dispose;
+
   security_class->allow = swfdec_flash_security_allow;
   security_class->allow_url = swfdec_flash_security_allow_url;
 }
@@ -71,25 +103,19 @@ swfdec_flash_security_init (SwfdecFlashSecurity *sec)
 {
 }
 
-/**
- * swfdec_flash_security_new:
- * @allow_local: %TRUE to allow playback of local files
- * @allow_remote: %TRUE to allow playback of remote files
- *
- * Creates a new Security object that allows everything. These objects are used 
- * by default when no other security object is in use. This is particularly 
- * useful for script engines that are not security sensitive or code injection
- * via debugging.
- *
- * Returns: a new #SwfdecSecurity object
- **/
-SwfdecSecurity *
-swfdec_flash_security_new (gboolean allow_local, gboolean allow_remote)
+void
+swfdec_flash_security_set_url (SwfdecFlashSecurity *sec, const SwfdecURL *url)
 {
-  SwfdecFlashSecurity *ret;
-  
-  ret = g_object_new (SWFDEC_TYPE_FLASH_SECURITY, NULL);
-  ret->allow_local = allow_local;
-  ret->allow_remote = allow_remote;
-  return SWFDEC_SECURITY (ret);
+  g_return_if_fail (SWFDEC_IS_FLASH_SECURITY (sec));
+  g_return_if_fail (sec->url == NULL);
+  g_return_if_fail (url != NULL);
+
+  g_assert (sec->sandbox == SWFDEC_SANDBOX_NONE);
+  sec->url = swfdec_url_copy (url);
+  if (swfdec_url_is_local (url)) {
+    sec->sandbox = SWFDEC_SANDBOX_LOCAL_FILE;
+  } else {
+    sec->sandbox = SWFDEC_SANDBOX_REMOTE;
+  }
 }
+
diff --git a/libswfdec/swfdec_flash_security.h b/libswfdec/swfdec_flash_security.h
index 00dd14f..ae1246b 100644
--- a/libswfdec/swfdec_flash_security.h
+++ b/libswfdec/swfdec_flash_security.h
@@ -27,6 +27,14 @@ G_BEGIN_DECLS
 typedef struct _SwfdecFlashSecurity SwfdecFlashSecurity;
 typedef struct _SwfdecFlashSecurityClass SwfdecFlashSecurityClass;
 
+typedef enum {
+  SWFDEC_SANDBOX_NONE,
+  SWFDEC_SANDBOX_REMOTE,
+  SWFDEC_SANDBOX_LOCAL_FILE,
+  SWFDEC_SANDBOX_LOCAL_NETWORK,
+  SWFDEC_SANDBOX_LOCAL_TRUSTED
+} SwfdecSandboxType;
+
 #define SWFDEC_TYPE_FLASH_SECURITY                    (swfdec_flash_security_get_type())
 #define SWFDEC_IS_FLASH_SECURITY(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_FLASH_SECURITY))
 #define SWFDEC_IS_FLASH_SECURITY_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_FLASH_SECURITY))
@@ -38,8 +46,8 @@ struct _SwfdecFlashSecurity
 {
   SwfdecSecurity	security;
 
-  gboolean		allow_local;	/* TRUE to allow access to local ressources */
-  gboolean		allow_remote;	/* TRUE to allow access to remote resources */
+  SwfdecSandboxType	sandbox;	/* sandbox we are operating in */
+  SwfdecURL *		url;		/* url this security was loaded from */
 };
 
 struct _SwfdecFlashSecurityClass
@@ -49,8 +57,8 @@ struct _SwfdecFlashSecurityClass
 
 GType			swfdec_flash_security_get_type	(void);
 
-SwfdecSecurity *	swfdec_flash_security_new	(gboolean	allow_local,
-							 gboolean	allow_remote);
+void			swfdec_flash_security_set_url	(SwfdecFlashSecurity *	sec,
+							 const SwfdecURL *	url);
 
 
 G_END_DECLS
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 7e514e1..420820e 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1730,23 +1730,6 @@ swfdec_player_launch (SwfdecPlayer *player, SwfdecLoaderRequest request, const c
   g_signal_emit (player, signals[LAUNCH], 0, request, url, target, data);
 }
 
-static void
-swfdec_player_create_security (SwfdecPlayer *player, guint version)
-{
-  const SwfdecURL *url;
-  SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (player->resource);
-
-  url = swfdec_loader_get_url (player->resource->loader);
-  if (version > 7) {
-    /* for local files we allow nothing by default, the FileAttributes tag fixes that */
-    sec->allow_local = FALSE;
-    sec->allow_remote = swfdec_url_has_protocol (url, "http");
-  } else {
-    sec->allow_local = swfdec_url_has_protocol (url, "file");
-    sec->allow_remote = TRUE;
-  }
-}
-
 /**
  * swfdec_player_initialize:
  * @player: a #SwfdecPlayer
@@ -1789,7 +1772,6 @@ swfdec_player_initialize (SwfdecPlayer *player, guint version,
     }
   }
   SWFDEC_INFO ("initializing player to size %ux%u", width, height);
-  swfdec_player_create_security (player, version);
   player->rate = rate;
   player->width = width;
   player->height = height;
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 68623ed..b8c0256 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -57,21 +57,11 @@ swfdec_resource_check_rights (SwfdecResource *resource)
 {
   SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (resource);
   SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (resource->decoder);
-  gboolean network;
 
-  if (dec->version < 8 || !swfdec_url_is_local (swfdec_loader_get_url (resource->loader)))
-    return;
-
-  network = dec->use_network;
-  g_print ("enabling %s access for %s\n", network ? "network" : "local",
-      swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
-  SWFDEC_INFO ("enabling %s access for %s", network ? "network" : "local",
+  if (dec->use_network && sec->sandbox == SWFDEC_SANDBOX_LOCAL_FILE)
+    sec->sandbox = SWFDEC_SANDBOX_LOCAL_NETWORK;
+  SWFDEC_INFO ("enabling local-with-network sandbox for %s",
       swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
-  SWFDEC_INFO ("enabling network access for %s",
-      swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
-
-  sec->allow_remote = network;
-  sec->allow_local = !network;
 }
 
 static void
@@ -234,6 +224,8 @@ swfdec_resource_new (SwfdecLoader *loader, const char *variables)
   swf->variables = g_strdup (variables);
   /* set loader (that depends on those vars) */
   swf->loader = g_object_ref (loader);
+  swfdec_flash_security_set_url (SWFDEC_FLASH_SECURITY (swf),
+      swfdec_loader_get_url (loader));
 
   return swf;
 }
commit 5671f65fa031d684261b29db7dfa5a46f5a42c99
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 16:17:49 2007 +0200

    add (and use) swfdec_url_is_local()

diff --git a/doc/swfdec-sections.txt b/doc/swfdec-sections.txt
index 0c22165..b3b4425 100644
--- a/doc/swfdec-sections.txt
+++ b/doc/swfdec-sections.txt
@@ -61,6 +61,7 @@ swfdec_url_get_protocol
 swfdec_url_has_protocol
 swfdec_url_get_query
 swfdec_url_get_url
+swfdec_url_is_local
 swfdec_url_new
 swfdec_url_new_relative
 <SUBSECTION Standard>
diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c
index a9c5219..4b27c53 100644
--- a/libswfdec/swfdec_flash_security.c
+++ b/libswfdec/swfdec_flash_security.c
@@ -50,13 +50,10 @@ swfdec_flash_security_allow_url (SwfdecSecurity *guard, const SwfdecURL *url)
 {
   SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (guard);
 
-  if (swfdec_url_has_protocol (url, "http")) {
-    return sec->allow_remote;
-  } else if (swfdec_url_has_protocol (url, "file")) {
+  if (swfdec_url_is_local (url)) {
     return sec->allow_local;
   } else {
-    SWFDEC_ERROR ("unknown protocol %s, denying access", swfdec_url_get_protocol (url));
-    return FALSE;
+    return sec->allow_remote;
   }
 }
 
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 4f2a6be..68623ed 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -59,8 +59,7 @@ swfdec_resource_check_rights (SwfdecResource *resource)
   SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (resource->decoder);
   gboolean network;
 
-  if (dec->version < 8 ||
-      !swfdec_url_has_protocol (swfdec_loader_get_url (resource->loader), "file"))
+  if (dec->version < 8 || !swfdec_url_is_local (swfdec_loader_get_url (resource->loader)))
     return;
 
   network = dec->use_network;
diff --git a/libswfdec/swfdec_url.c b/libswfdec/swfdec_url.c
index cb5db48..3d51d8e 100644
--- a/libswfdec/swfdec_url.c
+++ b/libswfdec/swfdec_url.c
@@ -312,4 +312,20 @@ swfdec_url_get_query (const SwfdecURL *url)
   return url->query;
 }
 
+/**
+ * swfdec_url_is_local:
+ * @url: the url to check
+ *
+ * Checks if the given @url references a local resource. Local resources are
+ * treated differently by Flash, since they get a higher degree of trust.
+ *
+ * Returns: %TRUE if the given url is local.
+ **/
+gboolean
+swfdec_url_is_local (const SwfdecURL *url)
+{
+  g_return_val_if_fail (url != NULL, FALSE);
 
+  /* FIXME: If we ever support gnome-vfs, this might become tricky */
+  return swfdec_url_has_protocol (url, "file");
+}
diff --git a/libswfdec/swfdec_url.h b/libswfdec/swfdec_url.h
index 6bf46fc..7a94039 100644
--- a/libswfdec/swfdec_url.h
+++ b/libswfdec/swfdec_url.h
@@ -43,6 +43,8 @@ const char *		swfdec_url_get_query		(const SwfdecURL *      url);
 
 gboolean		swfdec_url_has_protocol		(const SwfdecURL *	url,
 							 const char *		protocol);
+
+gboolean		swfdec_url_is_local		(const SwfdecURL *	url);
 							 
 
 G_END_DECLS
commit 4c90bdcccb86f87aaf11593cc460789c9c65ea8b
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 16:04:28 2007 +0200

    replace Player.loader and Player.security with Player.resource

diff --git a/libswfdec/swfdec_as_strings.c b/libswfdec/swfdec_as_strings.c
index 16ea014..f5eed8a 100644
--- a/libswfdec/swfdec_as_strings.c
+++ b/libswfdec/swfdec_as_strings.c
@@ -411,5 +411,6 @@ const char swfdec_as_strings[] =
   SWFDEC_AS_CONSTANT_STRING ("variable")
   SWFDEC_AS_CONSTANT_STRING ("restrict")
   SWFDEC_AS_CONSTANT_STRING ("mouseWheelEnabled")
+  SWFDEC_AS_CONSTANT_STRING ("_level0")
   /* add more here */
 ;
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index 73dce1b..7e514e1 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -800,13 +800,9 @@ swfdec_player_dispose (GObject *object)
   g_queue_free (player->init_queue);
   g_queue_free (player->construct_queue);
   swfdec_cache_unref (player->cache);
-  if (player->loader) {
-    g_object_unref (player->loader);
-    player->loader = NULL;
-  }
-  if (player->security) {
-    g_object_unref (player->security);
-    player->security = NULL;
+  if (player->resource) {
+    g_object_unref (player->resource);
+    player->resource = NULL;
   }
   if (player->system) {
     g_object_unref (player->system);
@@ -1632,23 +1628,6 @@ swfdec_player_get_level (SwfdecPlayer *player, const char *name, SwfdecResource
   return movie;
 }
 
-SwfdecMovie *
-swfdec_player_add_level_from_loader (SwfdecPlayer *player, guint depth,
-    SwfdecLoader *loader, const char *variables)
-{
-  SwfdecResource *resource;
-  SwfdecMovie *movie;
-  const char *name;
-
-  swfdec_player_remove_level (player, depth);
-  name = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%u", depth));
-  resource = swfdec_resource_new (loader, variables);
-  movie = swfdec_movie_new (player, depth - 16384, NULL, resource, NULL, name);
-  movie->name = SWFDEC_AS_STR_EMPTY;
-  g_object_unref (loader);
-  return movie;
-}
-
 void
 swfdec_player_remove_level (SwfdecPlayer *player, guint depth)
 {
@@ -1680,12 +1659,12 @@ swfdec_player_load (SwfdecPlayer *player, const char *url,
   g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
   g_return_val_if_fail (url != NULL, NULL);
 
-  g_assert (player->loader);
+  g_assert (player->resource);
   if (buffer) {
-    return swfdec_loader_load (player->loader, url, request, 
+    return swfdec_loader_load (player->resource->loader, url, request, 
 	(const char *) buffer->data, buffer->length);
   } else {
-    return swfdec_loader_load (player->loader, url, request, NULL, 0);
+    return swfdec_loader_load (player->resource->loader, url, request, NULL, 0);
   }
 }
 
@@ -1755,17 +1734,17 @@ static void
 swfdec_player_create_security (SwfdecPlayer *player, guint version)
 {
   const SwfdecURL *url;
-  gboolean allow_local, allow_remote;
+  SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (player->resource);
 
-  url = swfdec_loader_get_url (player->loader);
+  url = swfdec_loader_get_url (player->resource->loader);
   if (version > 7) {
-    allow_local = FALSE;
-    allow_remote = swfdec_url_has_protocol (url, "http");
+    /* for local files we allow nothing by default, the FileAttributes tag fixes that */
+    sec->allow_local = FALSE;
+    sec->allow_remote = swfdec_url_has_protocol (url, "http");
   } else {
-    allow_local = swfdec_url_has_protocol (url, "file");
-    allow_remote = TRUE;
+    sec->allow_local = swfdec_url_has_protocol (url, "file");
+    sec->allow_remote = TRUE;
   }
-  player->security = swfdec_flash_security_new (allow_local, allow_remote);
 }
 
 /**
@@ -1931,13 +1910,15 @@ void
 swfdec_player_set_loader_with_variables (SwfdecPlayer *player, SwfdecLoader *loader,
     const char *variables)
 {
+  SwfdecMovie *movie;
+
   g_return_if_fail (SWFDEC_IS_PLAYER (player));
-  g_return_if_fail (player->loader == NULL);
+  g_return_if_fail (player->resource == NULL);
   g_return_if_fail (SWFDEC_IS_LOADER (loader));
 
-  player->loader = loader;
-  g_object_ref (loader);
-  swfdec_player_add_level_from_loader (player, 0, loader, variables);
+  player->resource = swfdec_resource_new (loader, variables);
+  movie = swfdec_movie_new (player, -16384, NULL, player->resource, NULL, SWFDEC_AS_STR__level0);
+  movie->name = SWFDEC_AS_STR_EMPTY;
 }
 
 /**
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index afaebeb..483d487 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -62,8 +62,7 @@ struct _SwfdecPlayer
   SwfdecCache *		cache;			/* player cache */
   gboolean		bgcolor_set;		/* TRUE if the background color has been set */
   SwfdecColor		bgcolor;		/* background color */
-  SwfdecLoader *	loader;			/* initial loader */
-  SwfdecSecurity *	security;		/* the default security */
+  SwfdecResource *	resource;		/* initial resource loaded */
   /* stage properties */
   guint			internal_width;		/* width used by the scripting engine */
   guint			internal_height;	/* height used by the scripting engine */
@@ -201,11 +200,6 @@ SwfdecSpriteMovie *
 		swfdec_player_get_level		(SwfdecPlayer *		player,
 						 const char *		name,
 						 SwfdecResource *	resource);
-SwfdecMovie *	swfdec_player_add_level_from_loader 
-						(SwfdecPlayer *		player,
-						 guint			depth,
-						 SwfdecLoader *		loader,
-						 const char *		variables);
 void		swfdec_player_remove_level	(SwfdecPlayer *		player,
 						 guint			depth);
 gboolean	swfdec_player_fscommand		(SwfdecPlayer *		player,
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 21c8a82..4f2a6be 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -53,18 +53,26 @@ swfdec_resource_loader_target_get_player (SwfdecLoaderTarget *target)
 }
 
 static void
-swfdec_resource_allow_network (SwfdecPlayer *player)
+swfdec_resource_check_rights (SwfdecResource *resource)
 {
-  SwfdecFlashSecurity *sec;
+  SwfdecFlashSecurity *sec = SWFDEC_FLASH_SECURITY (resource);
+  SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (resource->decoder);
+  gboolean network;
 
-  g_print ("enabling network access for %s\n", 
-      swfdec_url_get_url (swfdec_loader_get_url (player->loader)));
+  if (dec->version < 8 ||
+      !swfdec_url_has_protocol (swfdec_loader_get_url (resource->loader), "file"))
+    return;
+
+  network = dec->use_network;
+  g_print ("enabling %s access for %s\n", network ? "network" : "local",
+      swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
+  SWFDEC_INFO ("enabling %s access for %s", network ? "network" : "local",
+      swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
   SWFDEC_INFO ("enabling network access for %s",
-      swfdec_url_get_url (swfdec_loader_get_url (player->loader)));
+      swfdec_url_get_url (swfdec_loader_get_url (resource->loader)));
 
-  sec = SWFDEC_FLASH_SECURITY (player->security);
-  sec->allow_remote = TRUE;
-  sec->allow_local = FALSE;
+  sec->allow_remote = network;
+  sec->allow_local = !network;
 }
 
 static void
@@ -82,9 +90,8 @@ swfdec_resource_loader_target_image (SwfdecResource *instance)
     swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
     
     /* if first instance */
-    if (player->loader == instance->loader && dec->use_network &&
-	swfdec_url_has_protocol (swfdec_loader_get_url (instance->loader), "file"))
-      swfdec_resource_allow_network (player);
+    if (player->resource == instance)
+      swfdec_resource_check_rights (instance);
   } else if (SWFDEC_IS_FLV_DECODER (instance->decoder)) {
     /* nothing to do, please move along */
   } else {
diff --git a/libswfdec/swfdec_tag.c b/libswfdec/swfdec_tag.c
index c9ce1a6..7913383 100644
--- a/libswfdec/swfdec_tag.c
+++ b/libswfdec/swfdec_tag.c
@@ -517,6 +517,7 @@ tag_func_file_attributes (SwfdecSwfDecoder *s, guint tag)
     SWFDEC_INFO ("reserved bits (2) aren't 0");
   s->use_network = swfdec_bits_getbit (&s->b);
   SWFDEC_LOG ("  use network: %d", s->use_network);
+  g_print ("  use network: %d\n", s->use_network);
   if (swfdec_bits_getbits (&s->b, 24))
     SWFDEC_INFO ("reserved bits (3) aren't 0");
   /* initialize default security if it wasn't initialized yet */
commit a0d4cc6a7d07360dbe3b98c5b677609a8f461d8c
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 13:24:18 2007 +0200

    don't allow any access by default

diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c
index 8d1171e..a9c5219 100644
--- a/libswfdec/swfdec_flash_security.c
+++ b/libswfdec/swfdec_flash_security.c
@@ -72,8 +72,6 @@ swfdec_flash_security_class_init (SwfdecFlashSecurityClass *klass)
 static void
 swfdec_flash_security_init (SwfdecFlashSecurity *sec)
 {
-  sec->allow_local = TRUE;
-  sec->allow_remote = TRUE;
 }
 
 /**
commit 2584f8940d5e780ed0a9d970a1eaa388c6988250
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 13:17:25 2007 +0200

    disable merging of Flash securities

diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c
index f739d27..8d1171e 100644
--- a/libswfdec/swfdec_flash_security.c
+++ b/libswfdec/swfdec_flash_security.c
@@ -37,15 +37,8 @@ swfdec_flash_security_allow (SwfdecSecurity *guard, SwfdecSecurity *key)
   } else if (SWFDEC_IS_SECURITY_ALLOW (key)) {
     return g_object_ref (guard);
   } else if (SWFDEC_IS_FLASH_SECURITY (key)) {
-    SwfdecFlashSecurity *fguard, *fkey, *ret;
-    fguard = SWFDEC_FLASH_SECURITY (guard);
-    fkey = SWFDEC_FLASH_SECURITY (key);
-
-    SWFDEC_FIXME ("merging flash securities - this should create the right type");
-    ret = g_object_new (SWFDEC_TYPE_FLASH_SECURITY, NULL);
-    ret->allow_local = fguard->allow_local && fkey->allow_local;
-    ret->allow_remote = fguard->allow_remote && fkey->allow_remote;
-    return SWFDEC_SECURITY (ret);
+    SWFDEC_FIXME ("merging flash securities - how is this supposed to work?");
+    return key;
   } else {
     SWFDEC_ERROR ("unknown security %s, denying access", G_OBJECT_TYPE_NAME (key));
     return NULL;
commit 7e9288880f2a1b51688308dee1e9226617aee64a
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 13:15:16 2007 +0200

    make the SwfdecResource an argument to swfdec_movie_new()

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index 42f8dd8..b608f31 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -1150,7 +1150,9 @@ swfdec_action_get_url (SwfdecAsContext *cx, guint action, const guint8 *data, gu
   } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) {
     /* nothing to do here */
   } else {
-    SwfdecSpriteMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, TRUE);
+    SwfdecSecurity *sec = cx->frame->security;
+    SwfdecSpriteMovie *movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, 
+	SWFDEC_IS_RESOURCE (sec) ? SWFDEC_RESOURCE (sec) : NULL);
     if (movie) {
       swfdec_sprite_movie_load (movie, url, SWFDEC_LOADER_REQUEST_DEFAULT, NULL);
     } else {
@@ -1192,9 +1194,12 @@ swfdec_action_get_url2 (SwfdecAsContext *cx, guint action, const guint8 *data, g
   } else if (swfdec_player_fscommand (SWFDEC_PLAYER (cx), url, target)) {
     /* nothing to do here */
   } else if (internal || variables) {
+    SwfdecSecurity *sec = cx->frame->security;
     SwfdecSpriteMovie *movie;
+    
     /* FIXME: This code looks wrong - figure out how levels are handled */
-    movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, !variables);
+    movie = swfdec_player_get_level (SWFDEC_PLAYER (cx), target, 
+	(SWFDEC_IS_RESOURCE (sec) && !variables) ? SWFDEC_RESOURCE (sec) : NULL);
     if (movie == NULL) {
       movie = (SwfdecSpriteMovie *) swfdec_player_get_movie_from_string (
 	SWFDEC_PLAYER (cx), target);
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 41a0007..4617169 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -1214,6 +1214,7 @@ swfdec_movie_set_depth (SwfdecMovie *movie, int depth)
  * @player: a #SwfdecPlayer
  * @depth: depth of movie
  * @parent: the parent movie or %NULL to make this a root movie
+ * @resource: the resource that is responsible for this movie
  * @graphic: the graphic that is displayed by this movie or %NULL to create an 
  *           empty movieclip
  * @name: a garbage-collected string to be used as the name for this movie or 
@@ -1229,13 +1230,15 @@ swfdec_movie_set_depth (SwfdecMovie *movie, int depth)
  * Returns: a new #SwfdecMovie
  **/
 SwfdecMovie *
-swfdec_movie_new (SwfdecPlayer *player, int depth, SwfdecMovie *parent, SwfdecGraphic *graphic, const char *name)
+swfdec_movie_new (SwfdecPlayer *player, int depth, SwfdecMovie *parent, SwfdecResource *resource,
+    SwfdecGraphic *graphic, const char *name)
 {
   SwfdecMovie *movie;
   gsize size;
 
   g_return_val_if_fail (SWFDEC_IS_PLAYER (player), NULL);
   g_return_val_if_fail (parent == NULL || SWFDEC_IS_MOVIE (parent), NULL);
+  g_return_val_if_fail (SWFDEC_IS_RESOURCE (resource), NULL);
   g_return_val_if_fail (graphic == NULL || SWFDEC_IS_GRAPHIC (graphic), NULL);
 
   /* create the right movie */
@@ -1257,8 +1260,8 @@ swfdec_movie_new (SwfdecPlayer *player, int depth, SwfdecMovie *parent, SwfdecGr
   g_object_ref (movie);
   /* set essential properties */
   movie->parent = parent;
+  movie->resource = g_object_ref (resource);
   if (parent) {
-    movie->resource = g_object_ref (parent->resource);
     parent->list = g_list_insert_sorted (parent->list, movie, swfdec_movie_compare_depths);
     SWFDEC_DEBUG ("inserting %s %s (depth %d) into %s %p", G_OBJECT_TYPE_NAME (movie), movie->name,
 	movie->depth,  G_OBJECT_TYPE_NAME (parent), parent);
@@ -1288,6 +1291,11 @@ swfdec_movie_new (SwfdecPlayer *player, int depth, SwfdecMovie *parent, SwfdecGr
   player->movies = g_list_prepend (player->movies, movie);
   /* only add the movie here, because it needs to be setup for the debugger */
   swfdec_as_object_add (SWFDEC_AS_OBJECT (movie), SWFDEC_AS_CONTEXT (player), size);
+  /* only setup here, the resource assumes it can access the player via the movie */
+  if (resource->movie == NULL) {
+    g_assert (SWFDEC_IS_SPRITE_MOVIE (movie));
+    swfdec_resource_set_movie (resource, SWFDEC_SPRITE_MOVIE (movie));
+  }
   return movie;
 }
 
@@ -1372,7 +1380,7 @@ swfdec_movie_duplicate (SwfdecMovie *movie, const char *name, int depth)
     swfdec_movie_remove (copy);
   }
   copy = swfdec_movie_new (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context), depth, 
-      parent, movie->graphic, name);
+      parent, movie->resource, movie->graphic, name);
   if (copy == NULL)
     return NULL;
   swfdec_movie_set_static_properties (copy, &movie->original_transform,
@@ -1393,7 +1401,7 @@ swfdec_movie_new_for_content (SwfdecMovie *parent, const SwfdecContent *content)
 
   SWFDEC_DEBUG ("new movie for parent %p", parent);
   player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (parent)->context);
-  movie = swfdec_movie_new (player, content->depth, parent, content->graphic, 
+  movie = swfdec_movie_new (player, content->depth, parent, parent->resource, content->graphic, 
       content->name ? swfdec_as_context_get_string (SWFDEC_AS_CONTEXT (player), content->name) : NULL);
 
   swfdec_movie_set_static_properties (movie, content->has_transform ? &content->transform : NULL,
diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h
index f5f6887..5cac2a5 100644
--- a/libswfdec/swfdec_movie.h
+++ b/libswfdec/swfdec_movie.h
@@ -182,6 +182,7 @@ GType		swfdec_movie_get_type		(void);
 SwfdecMovie *	swfdec_movie_new		(SwfdecPlayer *		player,
 						 int			depth,
 						 SwfdecMovie *		parent,
+						 SwfdecResource *	resource,
 						 SwfdecGraphic *	graphic,
 						 const char *		name);
 SwfdecMovie *	swfdec_movie_new_for_content  	(SwfdecMovie *		parent,
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index d14a5d8..73dce1b 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1578,7 +1578,7 @@ swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect)
  * swfdec_player_get_level:
  * @player: a #SwfdecPlayer
  * @name: name of the level to request
- * @create: %TRUE to create if it doesn't exist
+ * @create: resource to create the movie with if it doesn't exist
  *
  * This function is used to look up root movies in the given @player. The 
  * algorithm used is like this: First, check that @name actually references a
@@ -1591,7 +1591,7 @@ swfdec_player_invalidate (SwfdecPlayer *player, const SwfdecRect *rect)
  *          fully initialized (yes, this function sucks).
  **/
 SwfdecSpriteMovie *
-swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create)
+swfdec_player_get_level (SwfdecPlayer *player, const char *name, SwfdecResource *create)
 {
   SwfdecSpriteMovie *movie;
   GList *walk;
@@ -1623,11 +1623,11 @@ swfdec_player_get_level (SwfdecPlayer *player, const char *name, gboolean create
     break;
   }
   /* bail if create isn't set*/
-  if (!create)
+  if (create == NULL)
     return NULL;
   /* create new root movie */
   s = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%lu", l));
-  movie = SWFDEC_SPRITE_MOVIE (swfdec_movie_new (player, depth, NULL, NULL, s));
+  movie = SWFDEC_SPRITE_MOVIE (swfdec_movie_new (player, depth, NULL, create, NULL, s));
   SWFDEC_MOVIE (movie)->name = SWFDEC_AS_STR_EMPTY;
   return movie;
 }
@@ -1636,14 +1636,15 @@ SwfdecMovie *
 swfdec_player_add_level_from_loader (SwfdecPlayer *player, guint depth,
     SwfdecLoader *loader, const char *variables)
 {
+  SwfdecResource *resource;
   SwfdecMovie *movie;
   const char *name;
 
   swfdec_player_remove_level (player, depth);
   name = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%u", depth));
-  movie = swfdec_movie_new (player, depth - 16384, NULL, NULL, name);
+  resource = swfdec_resource_new (loader, variables);
+  movie = swfdec_movie_new (player, depth - 16384, NULL, resource, NULL, name);
   movie->name = SWFDEC_AS_STR_EMPTY;
-  swfdec_resource_new (SWFDEC_SPRITE_MOVIE (movie), loader, variables);
   g_object_unref (loader);
   return movie;
 }
diff --git a/libswfdec/swfdec_player_internal.h b/libswfdec/swfdec_player_internal.h
index fa34f68..afaebeb 100644
--- a/libswfdec/swfdec_player_internal.h
+++ b/libswfdec/swfdec_player_internal.h
@@ -200,7 +200,7 @@ void		swfdec_player_stop_all_sounds	(SwfdecPlayer *		player);
 SwfdecSpriteMovie *
 		swfdec_player_get_level		(SwfdecPlayer *		player,
 						 const char *		name,
-						 gboolean		create);
+						 SwfdecResource *	resource);
 SwfdecMovie *	swfdec_player_add_level_from_loader 
 						(SwfdecPlayer *		player,
 						 guint			depth,
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index 109018c..21c8a82 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -217,29 +217,32 @@ swfdec_resource_init (SwfdecResource *instance)
 }
 
 SwfdecResource *
-swfdec_resource_new (SwfdecSpriteMovie *movie, SwfdecLoader *loader, const char *variables)
+swfdec_resource_new (SwfdecLoader *loader, const char *variables)
 {
-  SwfdecMovie *mov;
   SwfdecResource *swf;
 
-  g_return_val_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie), NULL);
   g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
 
-  mov = SWFDEC_MOVIE (movie);
   swf = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
   /* set important variables */
   swf->variables = g_strdup (variables);
-  swf->movie = movie;
-  if (mov->resource)
-    g_object_unref (mov->resource);
-  mov->resource = swf;
   /* set loader (that depends on those vars) */
   swf->loader = g_object_ref (loader);
-  swfdec_loader_set_target (loader, SWFDEC_LOADER_TARGET (swf));
 
   return swf;
 }
 
+void
+swfdec_resource_set_movie (SwfdecResource *resource, SwfdecSpriteMovie *movie)
+{
+  g_return_if_fail (SWFDEC_IS_RESOURCE (resource));
+  g_return_if_fail (resource->movie == NULL);
+  g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
+
+  resource->movie = movie;
+  swfdec_loader_set_target (resource->loader, SWFDEC_LOADER_TARGET (resource));
+}
+
 gpointer
 swfdec_resource_get_export (SwfdecResource *instance, const char *name)
 {
diff --git a/libswfdec/swfdec_resource.h b/libswfdec/swfdec_resource.h
index 2c456a0..8143d01 100644
--- a/libswfdec/swfdec_resource.h
+++ b/libswfdec/swfdec_resource.h
@@ -57,10 +57,10 @@ struct _SwfdecResourceClass
 
 GType		swfdec_resource_get_type	  	(void);
 
-SwfdecResource *
-		swfdec_resource_new			(SwfdecSpriteMovie *  	movie,
-							 SwfdecLoader *		loader,
+SwfdecResource *swfdec_resource_new			(SwfdecLoader *		loader,
 							 const char *		variables);
+void		swfdec_resource_set_movie		(SwfdecResource *	resource,
+							 SwfdecSpriteMovie *	movie);
 
 void		swfdec_resource_advance			(SwfdecResource *	instance);
 
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 68c6fd7..bf80f93 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -263,7 +263,7 @@ swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, g
 	swfdec_event_list_free (events);
       return FALSE;
     }
-    cur = swfdec_movie_new (player, depth, mov, graphic, name);
+    cur = swfdec_movie_new (player, depth, mov, mov->resource, graphic, name);
     swfdec_movie_set_static_properties (cur, has_transform ? &transform : NULL, 
 	has_ctrans ? &ctrans : NULL, ratio, clip_depth, blend_mode, events);
     if (SWFDEC_IS_SPRITE_MOVIE (cur)) {
@@ -714,6 +714,7 @@ void
 swfdec_sprite_movie_load (SwfdecSpriteMovie *movie, const char *url, SwfdecLoaderRequest request, 
     SwfdecBuffer *data)
 {
+  SwfdecResource *resource;
   SwfdecLoader *loader;
 
   g_return_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie));
@@ -724,7 +725,10 @@ swfdec_sprite_movie_load (SwfdecSpriteMovie *movie, const char *url, SwfdecLoade
   /* FIXME: load relative to other movie? */
   loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context),
       url, request, data);
-  swfdec_resource_new (movie, loader, NULL);
+  resource = swfdec_resource_new (loader, NULL);
+  g_object_unref (SWFDEC_MOVIE (movie)->resource);
+  SWFDEC_MOVIE (movie)->resource = resource;
+  swfdec_resource_set_movie (resource, movie);
   g_object_unref (loader);
 }
 
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index 4cd0c0b..00e9be2 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -316,7 +316,7 @@ swfdec_sprite_movie_createEmptyMovieClip (SwfdecAsContext *cx, SwfdecAsObject *o
   movie = swfdec_movie_find (parent, depth);
   if (movie)
     swfdec_movie_remove (movie);
-  movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, NULL, name);
+  movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, parent->resource, NULL, name);
   swfdec_movie_initialize (movie);
   SWFDEC_AS_VALUE_SET_OBJECT (rval, SWFDEC_AS_OBJECT (movie));
 }
@@ -391,7 +391,7 @@ swfdec_sprite_movie_attachMovie (SwfdecAsContext *cx, SwfdecAsObject *object,
   ret = swfdec_movie_find (movie, depth);
   if (ret)
     swfdec_movie_remove (ret);
-  ret = swfdec_movie_new (SWFDEC_PLAYER (object->context), depth, movie, sprite, name);
+  ret = swfdec_movie_new (SWFDEC_PLAYER (object->context), depth, movie, movie->resource, sprite, name);
   SWFDEC_LOG ("attached %s (%u) as %s to depth %u", export, SWFDEC_CHARACTER (sprite)->id,
       ret->name, ret->depth);
   /* run init and construct */
diff --git a/libswfdec/swfdec_text_field_movie_as.c b/libswfdec/swfdec_text_field_movie_as.c
index 2930c66..16b04d7 100644
--- a/libswfdec/swfdec_text_field_movie_as.c
+++ b/libswfdec/swfdec_text_field_movie_as.c
@@ -882,7 +882,7 @@ swfdec_text_field_movie_createTextField (SwfdecAsContext *cx,
   if (movie)
     swfdec_movie_remove (movie);
 
-  movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent,
+  movie = swfdec_movie_new (SWFDEC_PLAYER (cx), depth, parent, parent->resource,
       SWFDEC_GRAPHIC (edittext), name);
   g_assert (SWFDEC_IS_TEXT_FIELD_MOVIE (movie));
   swfdec_movie_initialize (movie);
commit 19d4a71aaf9967a70648324b143be5a743bf5d20
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 13:14:57 2007 +0200

    special case guard == key

diff --git a/libswfdec/swfdec_flash_security.c b/libswfdec/swfdec_flash_security.c
index 1a88534..f739d27 100644
--- a/libswfdec/swfdec_flash_security.c
+++ b/libswfdec/swfdec_flash_security.c
@@ -32,13 +32,16 @@ G_DEFINE_TYPE (SwfdecFlashSecurity, swfdec_flash_security, SWFDEC_TYPE_SECURITY)
 static SwfdecSecurity *
 swfdec_flash_security_allow (SwfdecSecurity *guard, SwfdecSecurity *key)
 {
-  if (SWFDEC_IS_SECURITY_ALLOW (key)) {
+  if (guard == key) {
+    return g_object_ref (guard);
+  } else if (SWFDEC_IS_SECURITY_ALLOW (key)) {
     return g_object_ref (guard);
   } else if (SWFDEC_IS_FLASH_SECURITY (key)) {
     SwfdecFlashSecurity *fguard, *fkey, *ret;
     fguard = SWFDEC_FLASH_SECURITY (guard);
     fkey = SWFDEC_FLASH_SECURITY (key);
 
+    SWFDEC_FIXME ("merging flash securities - this should create the right type");
     ret = g_object_new (SWFDEC_TYPE_FLASH_SECURITY, NULL);
     ret->allow_local = fguard->allow_local && fkey->allow_local;
     ret->allow_remote = fguard->allow_remote && fkey->allow_remote;
commit 9a2800231e75f546285fd7728e0060f810f9b5b8
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 12:31:30 2007 +0200

    set security when calling functions

diff --git a/libswfdec/swfdec_button_movie.c b/libswfdec/swfdec_button_movie.c
index 2e1d80b..3aad8fd 100644
--- a/libswfdec/swfdec_button_movie.c
+++ b/libswfdec/swfdec_button_movie.c
@@ -108,7 +108,8 @@ swfdec_button_movie_execute (SwfdecButtonMovie *movie,
   }
   if (movie->button->events)
     swfdec_event_list_execute (movie->button->events, 
-	SWFDEC_AS_OBJECT (SWFDEC_MOVIE (movie)->parent), condition, 0);
+	SWFDEC_AS_OBJECT (SWFDEC_MOVIE (movie)->parent), 
+	SWFDEC_SECURITY (SWFDEC_MOVIE (movie)->resource), condition, 0);
   name = swfdec_button_condition_get_name (condition);
   swfdec_as_object_call (SWFDEC_AS_OBJECT (movie), name, 0, NULL, NULL);
 }
diff --git a/libswfdec/swfdec_event.c b/libswfdec/swfdec_event.c
index 06ce46e..03f05fa 100644
--- a/libswfdec/swfdec_event.c
+++ b/libswfdec/swfdec_event.c
@@ -212,12 +212,13 @@ swfdec_event_list_parse (SwfdecEventList *list, SwfdecBits *bits, int version,
 
 void
 swfdec_event_list_execute (SwfdecEventList *list, SwfdecAsObject *object, 
-    guint condition, guint8 key)
+    SwfdecSecurity *sec, guint condition, guint8 key)
 {
   guint i;
 
   g_return_if_fail (list != NULL);
   g_return_if_fail (SWFDEC_IS_AS_OBJECT (object));
+  g_return_if_fail (SWFDEC_IS_SECURITY (sec));
 
   /* FIXME: Do we execute all events if the event list is gone already? */
   /* need to ref here because followup code could free all references to the list */
@@ -227,7 +228,7 @@ swfdec_event_list_execute (SwfdecEventList *list, SwfdecAsObject *object,
     if ((event->conditions & condition) &&
 	event->key == key) {
       SWFDEC_LOG ("executing script for event %u on scriptable %p", condition, object);
-      swfdec_as_object_run (object, event->script);
+      swfdec_as_object_run_with_security (object, event->script, sec);
     }
   }
   swfdec_event_list_free (list);
diff --git a/libswfdec/swfdec_event.h b/libswfdec/swfdec_event.h
index 6c5be7f..3ee42cc 100644
--- a/libswfdec/swfdec_event.h
+++ b/libswfdec/swfdec_event.h
@@ -20,6 +20,7 @@
 #include <libswfdec/swfdec_bits.h>
 #include <libswfdec/swfdec_as_types.h>
 #include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_security.h>
 #include <libswfdec/swfdec_types.h>
 
 #ifndef _SWFDEC_EVENT_H_
@@ -63,6 +64,7 @@ void			swfdec_event_list_parse		(SwfdecEventList *    list,
 							 const char *	      description);
 void			swfdec_event_list_execute	(SwfdecEventList *    list,
 							 SwfdecAsObject *     object,
+							 SwfdecSecurity *     sec,
 							 guint		      condition,
 							 guint8		      key);
 gboolean		swfdec_event_list_has_conditions(SwfdecEventList *    list,
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 8a3607d..41a0007 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -387,8 +387,8 @@ swfdec_movie_execute_script (SwfdecMovie *movie, SwfdecEventType condition)
   g_return_if_fail (condition != 0);
 
   if (movie->events) {
-    swfdec_event_list_execute (movie->events, 
-	SWFDEC_AS_OBJECT (movie), condition, 0);
+    swfdec_event_list_execute (movie->events, SWFDEC_AS_OBJECT (movie), 
+	SWFDEC_SECURITY (movie->resource), condition, 0);
   }
   name = swfdec_event_type_get_name (condition);
   if (name != NULL)
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
index e3dd583..109018c 100644
--- a/libswfdec/swfdec_resource.c
+++ b/libswfdec/swfdec_resource.c
@@ -292,7 +292,8 @@ swfdec_resource_advance (SwfdecResource *instance)
     SwfdecRootAction *action = &g_array_index (array, SwfdecRootAction, i);
     switch (action->type) {
       case SWFDEC_ROOT_ACTION_INIT_SCRIPT:
-	swfdec_as_object_run (SWFDEC_AS_OBJECT (instance->movie), action->data);
+	swfdec_as_object_run_with_security (SWFDEC_AS_OBJECT (instance->movie), 
+	    action->data, SWFDEC_SECURITY (instance));
 	break;
       case SWFDEC_ROOT_ACTION_EXPORT:
 	{
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 78b1978..68c6fd7 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -55,7 +55,8 @@ swfdec_sprite_movie_remove_child (SwfdecMovie *movie, int depth)
 static void
 swfdec_sprite_movie_run_script (gpointer movie, gpointer data)
 {
-  swfdec_as_object_run (movie, data);
+  swfdec_as_object_run_with_security (movie, data, 
+      SWFDEC_SECURITY (SWFDEC_MOVIE (movie)->resource));
 }
 
 static int
commit c14e87b2e8c4976ba0934a653fb18c09904335a7
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 12:12:12 2007 +0200

    rename swfdec_swf_instance.[ch] => swfdec_resource.[ch]

diff --git a/libswfdec/Makefile.am b/libswfdec/Makefile.am
index 3bab53b..c67f132 100644
--- a/libswfdec/Makefile.am
+++ b/libswfdec/Makefile.am
@@ -95,6 +95,7 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES = \
 	swfdec_player_as.c \
 	swfdec_rect.c \
 	swfdec_rectangle.c \
+	swfdec_resource.c \
 	swfdec_ringbuffer.c \
 	swfdec_script.c \
 	swfdec_security.c \
@@ -110,7 +111,6 @@ libswfdec_ at SWFDEC_MAJORMINOR@_la_SOURCES = \
 	swfdec_stage_as.c \
 	swfdec_style_sheet.c \
 	swfdec_swf_decoder.c \
-	swfdec_swf_instance.c \
 	swfdec_system.c \
 	swfdec_system_as.c \
 	swfdec_tag.c \
@@ -218,6 +218,7 @@ noinst_HEADERS = \
 	swfdec_pattern.h \
 	swfdec_player_internal.h \
 	swfdec_rect.h \
+	swfdec_resource.h \
 	swfdec_ringbuffer.h \
 	swfdec_script_internal.h \
 	swfdec_security.h \
@@ -230,7 +231,6 @@ noinst_HEADERS = \
 	swfdec_sprite_movie.h \
 	swfdec_style_sheet.h \
 	swfdec_swf_decoder.h \
-	swfdec_swf_instance.h \
 	swfdec_stroke.h \
 	swfdec_tag.h \
 	swfdec_text.h \
diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index bd8ae18..42f8dd8 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -41,7 +41,7 @@
 #include "swfdec_player_internal.h"
 #include "swfdec_sprite.h"
 #include "swfdec_sprite_movie.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 #include "swfdec_text_field_movie.h" // for typeof
 
 /* Define this to get SWFDEC_WARN'd about missing properties of objects.
diff --git a/libswfdec/swfdec_graphic_movie.c b/libswfdec/swfdec_graphic_movie.c
index 4ffd2ce..a1e86af 100644
--- a/libswfdec/swfdec_graphic_movie.c
+++ b/libswfdec/swfdec_graphic_movie.c
@@ -29,7 +29,7 @@
 #include "swfdec_shape.h"
 #include "swfdec_sprite.h"
 #include "swfdec_swf_decoder.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 #include "swfdec_text.h"
 
 G_DEFINE_TYPE (SwfdecGraphicMovie, swfdec_graphic_movie, SWFDEC_TYPE_MOVIE)
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index f7cef8b..8a3607d 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -39,7 +39,7 @@
 #include "swfdec_player_internal.h"
 #include "swfdec_sprite.h"
 #include "swfdec_sprite_movie.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 #include "swfdec_system.h"
 #include "swfdec_utils.h"
 #include "swfdec_load_object.h"
diff --git a/libswfdec/swfdec_movie_asprops.c b/libswfdec/swfdec_movie_asprops.c
index 3a77906..deb8d7a 100644
--- a/libswfdec/swfdec_movie_asprops.c
+++ b/libswfdec/swfdec_movie_asprops.c
@@ -32,7 +32,7 @@
 #include "swfdec_player_internal.h"
 #include "swfdec_sprite.h"
 #include "swfdec_sprite_movie.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 
 static void
 mc_x_get (SwfdecMovie *movie, SwfdecAsValue *rval)
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index f70f438..d14a5d8 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -44,7 +44,7 @@
 #include "swfdec_movie.h"
 #include "swfdec_script_internal.h"
 #include "swfdec_sprite_movie.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 #include "swfdec_utils.h"
 
 /*** gtk-doc ***/
diff --git a/libswfdec/swfdec_resource.c b/libswfdec/swfdec_resource.c
new file mode 100644
index 0000000..e3dd583
--- /dev/null
+++ b/libswfdec/swfdec_resource.c
@@ -0,0 +1,308 @@
+/* Swfdec
+ * Copyright (C) 2006-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 <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include "swfdec_resource.h"
+#include "swfdec_as_internal.h"
+#include "swfdec_character.h"
+#include "swfdec_debug.h"
+#include "swfdec_decoder.h"
+#include "swfdec_flash_security.h"
+#include "swfdec_flv_decoder.h"
+#include "swfdec_loader_internal.h"
+#include "swfdec_loadertarget.h"
+#include "swfdec_player_internal.h"
+#include "swfdec_script.h"
+#include "swfdec_sprite.h"
+#include "swfdec_swf_decoder.h"
+#include "swfdec_utils.h"
+
+
+static void swfdec_resource_loader_target_init (SwfdecLoaderTargetInterface *iface);
+G_DEFINE_TYPE_WITH_CODE (SwfdecResource, swfdec_resource, SWFDEC_TYPE_FLASH_SECURITY,
+    G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_LOADER_TARGET, swfdec_resource_loader_target_init))
+
+/*** SWFDEC_LOADER_TARGET interface ***/
+
+static SwfdecPlayer *
+swfdec_resource_loader_target_get_player (SwfdecLoaderTarget *target)
+{
+  return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (SWFDEC_RESOURCE (target)->movie)->context);
+}
+
+static void
+swfdec_resource_allow_network (SwfdecPlayer *player)
+{
+  SwfdecFlashSecurity *sec;
+
+  g_print ("enabling network access for %s\n", 
+      swfdec_url_get_url (swfdec_loader_get_url (player->loader)));
+  SWFDEC_INFO ("enabling network access for %s",
+      swfdec_url_get_url (swfdec_loader_get_url (player->loader)));
+
+  sec = SWFDEC_FLASH_SECURITY (player->security);
+  sec->allow_remote = TRUE;
+  sec->allow_local = FALSE;
+}
+
+static void
+swfdec_resource_loader_target_image (SwfdecResource *instance)
+{
+  SwfdecSpriteMovie *movie = instance->movie;
+
+  if (movie->sprite != NULL)
+    return;
+
+  if (SWFDEC_IS_SWF_DECODER (instance->decoder)) {
+    SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
+    SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (instance->decoder);
+    movie->sprite = dec->main_sprite;
+    swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
+    
+    /* if first instance */
+    if (player->loader == instance->loader && dec->use_network &&
+	swfdec_url_has_protocol (swfdec_loader_get_url (instance->loader), "file"))
+      swfdec_resource_allow_network (player);
+  } else if (SWFDEC_IS_FLV_DECODER (instance->decoder)) {
+    /* nothing to do, please move along */
+  } else {
+    g_assert_not_reached ();
+  }
+}
+
+static void
+swfdec_resource_loader_target_open (SwfdecLoaderTarget *target, SwfdecLoader *loader)
+{
+  SwfdecResource *instance = SWFDEC_RESOURCE (target);
+  const char *query;
+
+  query = swfdec_url_get_query (swfdec_loader_get_url (loader));
+  if (query) {
+    SWFDEC_INFO ("set url query movie variables: %s", query);
+    swfdec_movie_set_variables (SWFDEC_MOVIE (instance->movie), query);
+  }
+  if (instance->variables) {
+    SWFDEC_INFO ("set manual movie variables: %s", instance->variables);
+    swfdec_movie_set_variables (SWFDEC_MOVIE (instance->movie), instance->variables);
+  }
+}
+
+static void
+swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *loader)
+{
+  SwfdecResource *instance = SWFDEC_RESOURCE (target);
+  SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (instance->movie)->context);
+  SwfdecDecoder *dec = instance->decoder;
+  SwfdecDecoderClass *klass;
+
+  if (dec == NULL) {
+    if (!swfdec_decoder_can_detect (loader->queue))
+      return;
+    dec = swfdec_decoder_new (player, loader->queue);
+    if (dec == NULL) {
+      SWFDEC_ERROR ("no decoder found");
+      swfdec_loader_set_target (loader, NULL);
+      return;
+    }
+
+    if (SWFDEC_IS_FLV_DECODER (dec)) {
+      swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_FLV);
+      swfdec_flv_decoder_add_movie (SWFDEC_FLV_DECODER (dec), SWFDEC_MOVIE (instance->movie));
+    } else if (SWFDEC_IS_SWF_DECODER (dec)) {
+      swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_SWF);
+      instance->decoder = dec;
+    } else {
+      SWFDEC_FIXME ("implement handling of %s", G_OBJECT_TYPE_NAME (dec));
+      g_object_unref (dec);
+      swfdec_loader_set_target (loader, NULL);
+      return;
+    }
+    /* HACK for flv playback */
+    if (target != loader->target) {
+      swfdec_loader_target_parse (loader->target, loader);
+      return;
+    }
+  }
+  klass = SWFDEC_DECODER_GET_CLASS (dec);
+  g_return_if_fail (klass->parse);
+  while (TRUE) {
+    SwfdecStatus status = klass->parse (dec);
+    switch (status) {
+      case SWFDEC_STATUS_ERROR:
+	SWFDEC_ERROR ("parsing error");
+	swfdec_loader_set_target (loader, NULL);
+	return;
+      case SWFDEC_STATUS_OK:
+	break;
+      case SWFDEC_STATUS_NEEDBITS:
+	return;
+      case SWFDEC_STATUS_IMAGE:
+	swfdec_resource_loader_target_image (instance);
+	break;
+      case SWFDEC_STATUS_INIT:
+	swfdec_player_initialize (player, 
+	    SWFDEC_IS_SWF_DECODER (dec) ? SWFDEC_SWF_DECODER (dec)->version : 7, /* <-- HACK */
+	    dec->rate, dec->width, dec->height);
+	break;
+      case SWFDEC_STATUS_EOF:
+	return;
+      default:
+	g_assert_not_reached ();
+	return;
+    }
+  }
+}
+
+static void
+swfdec_resource_loader_target_init (SwfdecLoaderTargetInterface *iface)
+{
+  iface->get_player = swfdec_resource_loader_target_get_player;
+  iface->open = swfdec_resource_loader_target_open;
+  iface->parse = swfdec_resource_loader_target_parse;
+}
+
+static void
+swfdec_resource_dispose (GObject *object)
+{
+  SwfdecResource *instance = SWFDEC_RESOURCE (object);
+
+  swfdec_loader_set_target (instance->loader, NULL);
+  g_object_unref (instance->loader);
+  if (instance->decoder) {
+    g_object_unref (instance->decoder);
+    instance->decoder = NULL;
+  }
+  g_free (instance->variables);
+  g_hash_table_destroy (instance->exports);
+  g_hash_table_destroy (instance->export_names);
+
+  G_OBJECT_CLASS (swfdec_resource_parent_class)->dispose (object);
+}
+
+static void
+swfdec_resource_class_init (SwfdecResourceClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->dispose = swfdec_resource_dispose;
+}
+
+static void
+swfdec_resource_init (SwfdecResource *instance)
+{
+  instance->exports = g_hash_table_new (swfdec_str_case_hash, swfdec_str_case_equal);
+  instance->export_names = g_hash_table_new (g_direct_hash, g_direct_equal);
+}
+
+SwfdecResource *
+swfdec_resource_new (SwfdecSpriteMovie *movie, SwfdecLoader *loader, const char *variables)
+{
+  SwfdecMovie *mov;
+  SwfdecResource *swf;
+
+  g_return_val_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie), NULL);
+  g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
+
+  mov = SWFDEC_MOVIE (movie);
+  swf = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
+  /* set important variables */
+  swf->variables = g_strdup (variables);
+  swf->movie = movie;
+  if (mov->resource)
+    g_object_unref (mov->resource);
+  mov->resource = swf;
+  /* set loader (that depends on those vars) */
+  swf->loader = g_object_ref (loader);
+  swfdec_loader_set_target (loader, SWFDEC_LOADER_TARGET (swf));
+
+  return swf;
+}
+
+gpointer
+swfdec_resource_get_export (SwfdecResource *instance, const char *name)
+{
+  g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
+  g_return_val_if_fail (name != NULL, NULL);
+
+  return g_hash_table_lookup (instance->exports, name);
+}
+
+const char *
+swfdec_resource_get_export_name (SwfdecResource *instance, SwfdecCharacter *character)
+{
+  g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
+  g_return_val_if_fail (SWFDEC_IS_CHARACTER (character), NULL);
+
+  return g_hash_table_lookup (instance->export_names, character);
+}
+
+static void
+swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character, const char *name)
+{
+  g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
+  g_return_if_fail (SWFDEC_IS_CHARACTER (character));
+  g_return_if_fail (name != NULL);
+
+  g_hash_table_insert (instance->exports, (char *) name, character);
+  g_hash_table_insert (instance->export_names, character, (char *) name);
+}
+
+void
+swfdec_resource_advance (SwfdecResource *instance)
+{
+  SwfdecSwfDecoder *s;
+  GArray *array;
+  guint i;
+
+  g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
+
+  s = SWFDEC_SWF_DECODER (instance->decoder);
+  SWFDEC_LOG ("performing actions for frame %u", instance->parse_frame);
+  if (s->root_actions) {
+    array = s->root_actions[instance->parse_frame];
+  } else {
+    array = NULL;
+  }
+  instance->parse_frame++;
+  if (array == NULL)
+    return;
+  for (i = 0; i < array->len; i++) {
+    SwfdecRootAction *action = &g_array_index (array, SwfdecRootAction, i);
+    switch (action->type) {
+      case SWFDEC_ROOT_ACTION_INIT_SCRIPT:
+	swfdec_as_object_run (SWFDEC_AS_OBJECT (instance->movie), action->data);
+	break;
+      case SWFDEC_ROOT_ACTION_EXPORT:
+	{
+	  SwfdecRootExportData *data = action->data;
+	  swfdec_resource_add_export (instance, data->character, data->name);
+	}
+	break;
+      default:
+	g_assert_not_reached ();
+    }
+  }
+}
+
diff --git a/libswfdec/swfdec_resource.h b/libswfdec/swfdec_resource.h
new file mode 100644
index 0000000..2c456a0
--- /dev/null
+++ b/libswfdec/swfdec_resource.h
@@ -0,0 +1,73 @@
+/* Swfdec
+ * Copyright (C) 2006-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
+ */
+
+#ifndef _SWFDEC_RESOURCE_H_
+#define _SWFDEC_RESOURCE_H_
+
+#include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_flash_security.h>
+#include <libswfdec/swfdec_sprite_movie.h>
+
+G_BEGIN_DECLS
+
+//typedef struct _SwfdecResource SwfdecResource;
+typedef struct _SwfdecResourceClass SwfdecResourceClass;
+
+#define SWFDEC_TYPE_RESOURCE                    (swfdec_resource_get_type())
+#define SWFDEC_IS_RESOURCE(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_RESOURCE))
+#define SWFDEC_IS_RESOURCE_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_RESOURCE))
+#define SWFDEC_RESOURCE(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_RESOURCE, SwfdecResource))
+#define SWFDEC_RESOURCE_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_RESOURCE, SwfdecResourceClass))
+
+struct _SwfdecResource
+{
+  SwfdecFlashSecurity	flash_security;
+
+  SwfdecSpriteMovie * 	movie;		/* the movie responsible for creating this instance */
+  guint			parse_frame;	/* next frame to parse */
+
+  SwfdecLoader *	loader;		/* the loader providing data for the decoder */
+  SwfdecDecoder *	decoder;	/* decoder that decoded all the stuff used by us */
+  char *		variables;	/* extra variables to be set */
+
+  GHashTable *		exports;	/* string->SwfdecCharacter mapping of exported characters */
+  GHashTable *		export_names;	/* SwfdecCharacter->string mapping of exported characters */
+};
+
+struct _SwfdecResourceClass
+{
+  SwfdecFlashSecurityClass	flash_security_class;
+};
+
+GType		swfdec_resource_get_type	  	(void);
+
+SwfdecResource *
+		swfdec_resource_new			(SwfdecSpriteMovie *  	movie,
+							 SwfdecLoader *		loader,
+							 const char *		variables);
+
+void		swfdec_resource_advance			(SwfdecResource *	instance);
+
+gpointer	swfdec_resource_get_export		(SwfdecResource *	root,
+							 const char *		name);
+const char *	swfdec_resource_get_export_name    	(SwfdecResource *	root,
+							 SwfdecCharacter *	character);
+
+G_END_DECLS
+#endif
diff --git a/libswfdec/swfdec_sound_object.c b/libswfdec/swfdec_sound_object.c
index 2089eb6..85e870e 100644
--- a/libswfdec/swfdec_sound_object.c
+++ b/libswfdec/swfdec_sound_object.c
@@ -32,7 +32,7 @@
 #include "swfdec_debug.h"
 #include "swfdec_internal.h"
 #include "swfdec_player_internal.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 
 /*** SwfdecSoundObject ***/
 
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index a8df92b..78b1978 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -35,7 +35,7 @@
 #include "swfdec_ringbuffer.h"
 #include "swfdec_script.h"
 #include "swfdec_sprite.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 #include "swfdec_tag.h"
 
 /*** SWFDEC_SPRITE_MOVIE ***/
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index 8e566c3..4cd0c0b 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -34,7 +34,7 @@
 #include "swfdec_sprite.h"
 #include "swfdec_sprite_movie.h"
 #include "swfdec_swf_decoder.h"
-#include "swfdec_swf_instance.h"
+#include "swfdec_resource.h"
 #include "swfdec_as_internal.h"
 
 SWFDEC_AS_NATIVE (900, 12, swfdec_sprite_movie_play)
diff --git a/libswfdec/swfdec_swf_instance.c b/libswfdec/swfdec_swf_instance.c
deleted file mode 100644
index c77df13..0000000
--- a/libswfdec/swfdec_swf_instance.c
+++ /dev/null
@@ -1,308 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-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 <errno.h>
-#include <stdlib.h>
-#include <string.h>
-#include "swfdec_swf_instance.h"
-#include "swfdec_as_internal.h"
-#include "swfdec_character.h"
-#include "swfdec_debug.h"
-#include "swfdec_decoder.h"
-#include "swfdec_flash_security.h"
-#include "swfdec_flv_decoder.h"
-#include "swfdec_loader_internal.h"
-#include "swfdec_loadertarget.h"
-#include "swfdec_player_internal.h"
-#include "swfdec_script.h"
-#include "swfdec_sprite.h"
-#include "swfdec_swf_decoder.h"
-#include "swfdec_utils.h"
-
-
-static void swfdec_resource_loader_target_init (SwfdecLoaderTargetInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (SwfdecResource, swfdec_resource, SWFDEC_TYPE_FLASH_SECURITY,
-    G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_LOADER_TARGET, swfdec_resource_loader_target_init))
-
-/*** SWFDEC_LOADER_TARGET interface ***/
-
-static SwfdecPlayer *
-swfdec_resource_loader_target_get_player (SwfdecLoaderTarget *target)
-{
-  return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (SWFDEC_RESOURCE (target)->movie)->context);
-}
-
-static void
-swfdec_resource_allow_network (SwfdecPlayer *player)
-{
-  SwfdecFlashSecurity *sec;
-
-  g_print ("enabling network access for %s\n", 
-      swfdec_url_get_url (swfdec_loader_get_url (player->loader)));
-  SWFDEC_INFO ("enabling network access for %s",
-      swfdec_url_get_url (swfdec_loader_get_url (player->loader)));
-
-  sec = SWFDEC_FLASH_SECURITY (player->security);
-  sec->allow_remote = TRUE;
-  sec->allow_local = FALSE;
-}
-
-static void
-swfdec_resource_loader_target_image (SwfdecResource *instance)
-{
-  SwfdecSpriteMovie *movie = instance->movie;
-
-  if (movie->sprite != NULL)
-    return;
-
-  if (SWFDEC_IS_SWF_DECODER (instance->decoder)) {
-    SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
-    SwfdecSwfDecoder *dec = SWFDEC_SWF_DECODER (instance->decoder);
-    movie->sprite = dec->main_sprite;
-    swfdec_movie_invalidate (SWFDEC_MOVIE (movie));
-    
-    /* if first instance */
-    if (player->loader == instance->loader && dec->use_network &&
-	swfdec_url_has_protocol (swfdec_loader_get_url (instance->loader), "file"))
-      swfdec_resource_allow_network (player);
-  } else if (SWFDEC_IS_FLV_DECODER (instance->decoder)) {
-    /* nothing to do, please move along */
-  } else {
-    g_assert_not_reached ();
-  }
-}
-
-static void
-swfdec_resource_loader_target_open (SwfdecLoaderTarget *target, SwfdecLoader *loader)
-{
-  SwfdecResource *instance = SWFDEC_RESOURCE (target);
-  const char *query;
-
-  query = swfdec_url_get_query (swfdec_loader_get_url (loader));
-  if (query) {
-    SWFDEC_INFO ("set url query movie variables: %s", query);
-    swfdec_movie_set_variables (SWFDEC_MOVIE (instance->movie), query);
-  }
-  if (instance->variables) {
-    SWFDEC_INFO ("set manual movie variables: %s", instance->variables);
-    swfdec_movie_set_variables (SWFDEC_MOVIE (instance->movie), instance->variables);
-  }
-}
-
-static void
-swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *loader)
-{
-  SwfdecResource *instance = SWFDEC_RESOURCE (target);
-  SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (instance->movie)->context);
-  SwfdecDecoder *dec = instance->decoder;
-  SwfdecDecoderClass *klass;
-
-  if (dec == NULL) {
-    if (!swfdec_decoder_can_detect (loader->queue))
-      return;
-    dec = swfdec_decoder_new (player, loader->queue);
-    if (dec == NULL) {
-      SWFDEC_ERROR ("no decoder found");
-      swfdec_loader_set_target (loader, NULL);
-      return;
-    }
-
-    if (SWFDEC_IS_FLV_DECODER (dec)) {
-      swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_FLV);
-      swfdec_flv_decoder_add_movie (SWFDEC_FLV_DECODER (dec), SWFDEC_MOVIE (instance->movie));
-    } else if (SWFDEC_IS_SWF_DECODER (dec)) {
-      swfdec_loader_set_data_type (loader, SWFDEC_LOADER_DATA_SWF);
-      instance->decoder = dec;
-    } else {
-      SWFDEC_FIXME ("implement handling of %s", G_OBJECT_TYPE_NAME (dec));
-      g_object_unref (dec);
-      swfdec_loader_set_target (loader, NULL);
-      return;
-    }
-    /* HACK for flv playback */
-    if (target != loader->target) {
-      swfdec_loader_target_parse (loader->target, loader);
-      return;
-    }
-  }
-  klass = SWFDEC_DECODER_GET_CLASS (dec);
-  g_return_if_fail (klass->parse);
-  while (TRUE) {
-    SwfdecStatus status = klass->parse (dec);
-    switch (status) {
-      case SWFDEC_STATUS_ERROR:
-	SWFDEC_ERROR ("parsing error");
-	swfdec_loader_set_target (loader, NULL);
-	return;
-      case SWFDEC_STATUS_OK:
-	break;
-      case SWFDEC_STATUS_NEEDBITS:
-	return;
-      case SWFDEC_STATUS_IMAGE:
-	swfdec_resource_loader_target_image (instance);
-	break;
-      case SWFDEC_STATUS_INIT:
-	swfdec_player_initialize (player, 
-	    SWFDEC_IS_SWF_DECODER (dec) ? SWFDEC_SWF_DECODER (dec)->version : 7, /* <-- HACK */
-	    dec->rate, dec->width, dec->height);
-	break;
-      case SWFDEC_STATUS_EOF:
-	return;
-      default:
-	g_assert_not_reached ();
-	return;
-    }
-  }
-}
-
-static void
-swfdec_resource_loader_target_init (SwfdecLoaderTargetInterface *iface)
-{
-  iface->get_player = swfdec_resource_loader_target_get_player;
-  iface->open = swfdec_resource_loader_target_open;
-  iface->parse = swfdec_resource_loader_target_parse;
-}
-
-static void
-swfdec_resource_dispose (GObject *object)
-{
-  SwfdecResource *instance = SWFDEC_RESOURCE (object);
-
-  swfdec_loader_set_target (instance->loader, NULL);
-  g_object_unref (instance->loader);
-  if (instance->decoder) {
-    g_object_unref (instance->decoder);
-    instance->decoder = NULL;
-  }
-  g_free (instance->variables);
-  g_hash_table_destroy (instance->exports);
-  g_hash_table_destroy (instance->export_names);
-
-  G_OBJECT_CLASS (swfdec_resource_parent_class)->dispose (object);
-}
-
-static void
-swfdec_resource_class_init (SwfdecResourceClass *klass)
-{
-  GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
-  object_class->dispose = swfdec_resource_dispose;
-}
-
-static void
-swfdec_resource_init (SwfdecResource *instance)
-{
-  instance->exports = g_hash_table_new (swfdec_str_case_hash, swfdec_str_case_equal);
-  instance->export_names = g_hash_table_new (g_direct_hash, g_direct_equal);
-}
-
-SwfdecResource *
-swfdec_resource_new (SwfdecSpriteMovie *movie, SwfdecLoader *loader, const char *variables)
-{
-  SwfdecMovie *mov;
-  SwfdecResource *swf;
-
-  g_return_val_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie), NULL);
-  g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
-
-  mov = SWFDEC_MOVIE (movie);
-  swf = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
-  /* set important variables */
-  swf->variables = g_strdup (variables);
-  swf->movie = movie;
-  if (mov->resource)
-    g_object_unref (mov->resource);
-  mov->resource = swf;
-  /* set loader (that depends on those vars) */
-  swf->loader = g_object_ref (loader);
-  swfdec_loader_set_target (loader, SWFDEC_LOADER_TARGET (swf));
-
-  return swf;
-}
-
-gpointer
-swfdec_resource_get_export (SwfdecResource *instance, const char *name)
-{
-  g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
-  g_return_val_if_fail (name != NULL, NULL);
-
-  return g_hash_table_lookup (instance->exports, name);
-}
-
-const char *
-swfdec_resource_get_export_name (SwfdecResource *instance, SwfdecCharacter *character)
-{
-  g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
-  g_return_val_if_fail (SWFDEC_IS_CHARACTER (character), NULL);
-
-  return g_hash_table_lookup (instance->export_names, character);
-}
-
-static void
-swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character, const char *name)
-{
-  g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
-  g_return_if_fail (SWFDEC_IS_CHARACTER (character));
-  g_return_if_fail (name != NULL);
-
-  g_hash_table_insert (instance->exports, (char *) name, character);
-  g_hash_table_insert (instance->export_names, character, (char *) name);
-}
-
-void
-swfdec_resource_advance (SwfdecResource *instance)
-{
-  SwfdecSwfDecoder *s;
-  GArray *array;
-  guint i;
-
-  g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
-
-  s = SWFDEC_SWF_DECODER (instance->decoder);
-  SWFDEC_LOG ("performing actions for frame %u", instance->parse_frame);
-  if (s->root_actions) {
-    array = s->root_actions[instance->parse_frame];
-  } else {
-    array = NULL;
-  }
-  instance->parse_frame++;
-  if (array == NULL)
-    return;
-  for (i = 0; i < array->len; i++) {
-    SwfdecRootAction *action = &g_array_index (array, SwfdecRootAction, i);
-    switch (action->type) {
-      case SWFDEC_ROOT_ACTION_INIT_SCRIPT:
-	swfdec_as_object_run (SWFDEC_AS_OBJECT (instance->movie), action->data);
-	break;
-      case SWFDEC_ROOT_ACTION_EXPORT:
-	{
-	  SwfdecRootExportData *data = action->data;
-	  swfdec_resource_add_export (instance, data->character, data->name);
-	}
-	break;
-      default:
-	g_assert_not_reached ();
-    }
-  }
-}
-
diff --git a/libswfdec/swfdec_swf_instance.h b/libswfdec/swfdec_swf_instance.h
deleted file mode 100644
index 2c456a0..0000000
--- a/libswfdec/swfdec_swf_instance.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Swfdec
- * Copyright (C) 2006-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
- */
-
-#ifndef _SWFDEC_RESOURCE_H_
-#define _SWFDEC_RESOURCE_H_
-
-#include <libswfdec/swfdec_player.h>
-#include <libswfdec/swfdec_flash_security.h>
-#include <libswfdec/swfdec_sprite_movie.h>
-
-G_BEGIN_DECLS
-
-//typedef struct _SwfdecResource SwfdecResource;
-typedef struct _SwfdecResourceClass SwfdecResourceClass;
-
-#define SWFDEC_TYPE_RESOURCE                    (swfdec_resource_get_type())
-#define SWFDEC_IS_RESOURCE(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_RESOURCE))
-#define SWFDEC_IS_RESOURCE_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_RESOURCE))
-#define SWFDEC_RESOURCE(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_RESOURCE, SwfdecResource))
-#define SWFDEC_RESOURCE_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_RESOURCE, SwfdecResourceClass))
-
-struct _SwfdecResource
-{
-  SwfdecFlashSecurity	flash_security;
-
-  SwfdecSpriteMovie * 	movie;		/* the movie responsible for creating this instance */
-  guint			parse_frame;	/* next frame to parse */
-
-  SwfdecLoader *	loader;		/* the loader providing data for the decoder */
-  SwfdecDecoder *	decoder;	/* decoder that decoded all the stuff used by us */
-  char *		variables;	/* extra variables to be set */
-
-  GHashTable *		exports;	/* string->SwfdecCharacter mapping of exported characters */
-  GHashTable *		export_names;	/* SwfdecCharacter->string mapping of exported characters */
-};
-
-struct _SwfdecResourceClass
-{
-  SwfdecFlashSecurityClass	flash_security_class;
-};
-
-GType		swfdec_resource_get_type	  	(void);
-
-SwfdecResource *
-		swfdec_resource_new			(SwfdecSpriteMovie *  	movie,
-							 SwfdecLoader *		loader,
-							 const char *		variables);
-
-void		swfdec_resource_advance			(SwfdecResource *	instance);
-
-gpointer	swfdec_resource_get_export		(SwfdecResource *	root,
-							 const char *		name);
-const char *	swfdec_resource_get_export_name    	(SwfdecResource *	root,
-							 SwfdecCharacter *	character);
-
-G_END_DECLS
-#endif
commit e5d5472ddd24ed00d54039f853b7ac74eef89ba3
Author: Benjamin Otte <otte at gnome.org>
Date:   Thu Oct 18 12:09:33 2007 +0200

    rename SwfdecSwfInstance to SwfdecResource
    
    also add convenience function swfdec_movie_get_own_resource()

diff --git a/libswfdec/swfdec_as_interpret.c b/libswfdec/swfdec_as_interpret.c
index f3133b9..bd8ae18 100644
--- a/libswfdec/swfdec_as_interpret.c
+++ b/libswfdec/swfdec_as_interpret.c
@@ -268,25 +268,26 @@ swfdec_action_wait_for_frame2 (SwfdecAsContext *cx, guint action, const guint8 *
 static void
 swfdec_action_wait_for_frame (SwfdecAsContext *cx, guint action, const guint8 *data, guint len)
 {
-  SwfdecSpriteMovie *movie;
+  SwfdecMovie *movie;
+  SwfdecResource *resource;
   guint frame, jump, loaded;
 
   if (len != 3) {
     SWFDEC_ERROR ("WaitForFrame action length invalid (is %u, should be 3", len);
     return;
   }
-  if (!SWFDEC_IS_SPRITE_MOVIE (cx->frame->target)) {
+  if (!SWFDEC_IS_MOVIE (cx->frame->target)) {
     SWFDEC_ERROR ("no movie for WaitForFrame");
     return;
   }
 
-  movie = SWFDEC_SPRITE_MOVIE (cx->frame->target);
+  movie = SWFDEC_MOVIE (cx->frame->target);
   frame = data[0] || (data[1] << 8);
   jump = data[2];
-  if (SWFDEC_MOVIE (movie)->swf->movie == movie) {
-    SwfdecDecoder *dec = SWFDEC_MOVIE (movie)->swf->decoder;
+  resource = swfdec_movie_get_own_resource (movie);
+  if (resource) {
+    SwfdecDecoder *dec = resource->decoder;
     loaded = dec->frames_loaded;
-    g_assert (loaded <= movie->n_frames);
     if (loaded == dec->frames_total)
       loaded = G_MAXUINT;
   } else {
diff --git a/libswfdec/swfdec_movie.c b/libswfdec/swfdec_movie.c
index 852f011..f7cef8b 100644
--- a/libswfdec/swfdec_movie.c
+++ b/libswfdec/swfdec_movie.c
@@ -927,9 +927,9 @@ swfdec_movie_dispose (GObject *object)
   g_assert (movie->list == NULL);
 
   SWFDEC_LOG ("disposing movie %s (depth %d)", movie->name, movie->depth);
-  if (movie->swf) {
-    g_object_unref (movie->swf);
-    movie->swf = NULL;
+  if (movie->resource) {
+    g_object_unref (movie->resource);
+    movie->resource = NULL;
   }
   if (movie->events) {
     swfdec_event_list_free (movie->events);
@@ -1258,7 +1258,7 @@ swfdec_movie_new (SwfdecPlayer *player, int depth, SwfdecMovie *parent, SwfdecGr
   /* set essential properties */
   movie->parent = parent;
   if (parent) {
-    movie->swf = g_object_ref (parent->swf);
+    movie->resource = g_object_ref (parent->resource);
     parent->list = g_list_insert_sorted (parent->list, movie, swfdec_movie_compare_depths);
     SWFDEC_DEBUG ("inserting %s %s (depth %d) into %s %p", G_OBJECT_TYPE_NAME (movie), movie->name,
 	movie->depth,  G_OBJECT_TYPE_NAME (parent), parent);
@@ -1524,3 +1524,28 @@ swfdec_depth_classify (int depth)
     return SWFDEC_DEPTH_CLASS_RESERVED;
   return SWFDEC_DEPTH_CLASS_EMPTY;
 }
+
+/**
+ * swfdec_movie_get_own_resource:
+ * @movie: movie to query
+ *
+ * Queries the movie for his own resource. A movie only has its own resource if
+ * it contains data loaded with the loadMovie() function, or if it is the root
+ * movie.
+ *
+ * Returns: The own resource of @movie or %NULL
+ **/
+SwfdecResource *
+swfdec_movie_get_own_resource (SwfdecMovie *movie)
+{
+  g_return_val_if_fail (SWFDEC_IS_MOVIE (movie), NULL);
+
+  if (!SWFDEC_IS_SPRITE_MOVIE (movie))
+    return NULL;
+
+  if (SWFDEC_MOVIE (movie->resource->movie) != movie)
+    return NULL;
+
+  return movie->resource;
+}
+
diff --git a/libswfdec/swfdec_movie.h b/libswfdec/swfdec_movie.h
index 0ea66aa..f5f6887 100644
--- a/libswfdec/swfdec_movie.h
+++ b/libswfdec/swfdec_movie.h
@@ -114,7 +114,7 @@ struct _SwfdecMovie {
 
   /* parenting information */
   SwfdecMovie *		parent;			/* movie that contains us or NULL for root movies */
-  SwfdecSwfInstance *	swf;			/* the instance that created us */
+  SwfdecResource *	resource;     		/* the resource that created us */
 
   /* positioning - the values are applied in this order */
   SwfdecRect		extents;		/* the extents occupied after transform is applied */
@@ -272,6 +272,7 @@ void		swfdec_movie_remove_variable_listener (SwfdecMovie *	movie,
 						 SwfdecAsObject *	object,
 						 const char *		name,
 						 const SwfdecMovieVariableListenerFunction	function);
+SwfdecResource *swfdec_movie_get_own_resource	(SwfdecMovie *		movie);
 
 G_END_DECLS
 #endif
diff --git a/libswfdec/swfdec_movie_asprops.c b/libswfdec/swfdec_movie_asprops.c
index 517d0ad..3a77906 100644
--- a/libswfdec/swfdec_movie_asprops.c
+++ b/libswfdec/swfdec_movie_asprops.c
@@ -391,7 +391,7 @@ mc_url_get (SwfdecMovie *movie, SwfdecAsValue *rval)
 {
   SWFDEC_AS_VALUE_SET_STRING (rval, swfdec_as_context_get_string (
 	SWFDEC_AS_OBJECT (movie)->context,
-	swfdec_url_get_url (swfdec_loader_get_url (movie->swf->loader))));
+	swfdec_url_get_url (swfdec_loader_get_url (movie->resource->loader))));
 }
 
 struct {
diff --git a/libswfdec/swfdec_player.c b/libswfdec/swfdec_player.c
index e4e8eee..f70f438 100644
--- a/libswfdec/swfdec_player.c
+++ b/libswfdec/swfdec_player.c
@@ -1643,7 +1643,7 @@ swfdec_player_add_level_from_loader (SwfdecPlayer *player, guint depth,
   name = swfdec_as_context_give_string (SWFDEC_AS_CONTEXT (player), g_strdup_printf ("_level%u", depth));
   movie = swfdec_movie_new (player, depth - 16384, NULL, NULL, name);
   movie->name = SWFDEC_AS_STR_EMPTY;
-  swfdec_swf_instance_new (SWFDEC_SPRITE_MOVIE (movie), loader, variables);
+  swfdec_resource_new (SWFDEC_SPRITE_MOVIE (movie), loader, variables);
   g_object_unref (loader);
   return movie;
 }
diff --git a/libswfdec/swfdec_sound_object.c b/libswfdec/swfdec_sound_object.c
index c464bda..2089eb6 100644
--- a/libswfdec/swfdec_sound_object.c
+++ b/libswfdec/swfdec_sound_object.c
@@ -83,7 +83,7 @@ swfdec_sound_object_get_sound (SwfdecSoundObject *sound, const char *name)
   if (sound->target == NULL)
     return NULL;
 
-  return swfdec_swf_instance_get_export (sound->target->swf, name);
+  return swfdec_resource_get_export (sound->target->resource, name);
 }
 
 /*** AS CODE ***/
diff --git a/libswfdec/swfdec_sprite_movie.c b/libswfdec/swfdec_sprite_movie.c
index 74dd86e..a8df92b 100644
--- a/libswfdec/swfdec_sprite_movie.c
+++ b/libswfdec/swfdec_sprite_movie.c
@@ -61,7 +61,7 @@ swfdec_sprite_movie_run_script (gpointer movie, gpointer data)
 static int
 swfdec_get_clipeventflags (SwfdecMovie *movie, SwfdecBits * bits)
 {
-  if (SWFDEC_SWF_DECODER (movie->swf->decoder)->version <= 5) {
+  if (SWFDEC_SWF_DECODER (movie->resource->decoder)->version <= 5) {
     return swfdec_bits_get_u16 (bits);
   } else {
     return swfdec_bits_get_u32 (bits);
@@ -74,6 +74,7 @@ swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, g
   SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context);
   SwfdecMovie *mov = SWFDEC_MOVIE (movie);
   SwfdecMovie *cur;
+  SwfdecSwfDecoder *dec;
   gboolean has_clip_actions;
   gboolean has_clip_depth;
   gboolean has_name;
@@ -95,7 +96,8 @@ swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, g
   guint blend_mode;
   SwfdecGraphic *graphic;
 
-  version = SWFDEC_SWF_DECODER (mov->swf->decoder)->version;
+  dec = SWFDEC_SWF_DECODER (mov->resource->decoder);
+  version = dec->version;
 
   /* 1) check which stuff is set */
   has_clip_actions = swfdec_bits_getbit (bits);
@@ -236,7 +238,7 @@ swfdec_sprite_movie_perform_place (SwfdecSpriteMovie *movie, SwfdecBits *bits, g
 
   /* 3) perform the actions depending on the set properties */
   cur = swfdec_movie_find (mov, depth);
-  graphic = swfdec_swf_decoder_get_character (SWFDEC_SWF_DECODER (mov->swf->decoder), id);
+  graphic = swfdec_swf_decoder_get_character (dec, id);
   if (move) {
     if (cur == NULL) {
       SWFDEC_INFO ("no movie at depth %d, ignoring move command", depth);
@@ -284,7 +286,7 @@ swfdec_sprite_movie_start_sound (SwfdecMovie *movie, SwfdecBits *bits)
   int id;
 
   id = swfdec_bits_get_u16 (bits);
-  chunk = swfdec_sound_parse_chunk (SWFDEC_SWF_DECODER (movie->swf->decoder), bits, id);
+  chunk = swfdec_sound_parse_chunk (SWFDEC_SWF_DECODER (movie->resource->decoder), bits, id);
   if (chunk) {
     SwfdecAudio *audio = swfdec_audio_event_new_from_chunk (SWFDEC_PLAYER (
 	  SWFDEC_AS_OBJECT (movie)->context), chunk);
@@ -301,7 +303,7 @@ swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, Swf
   SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (mov)->context);
   SwfdecBits bits;
 
-  g_assert (mov->swf);
+  g_assert (mov->resource);
   swfdec_bits_init (&bits, buffer);
 
   SWFDEC_LOG ("%p: executing %uth tag %s in frame %u", movie, movie->next_action - 1, 
@@ -311,7 +313,7 @@ swfdec_sprite_movie_perform_one_action (SwfdecSpriteMovie *movie, guint tag, Swf
       SWFDEC_LOG ("SCRIPT action");
       if (!skip_scripts) {
 	SwfdecScript *script = swfdec_swf_decoder_get_script (
-	    SWFDEC_SWF_DECODER (mov->swf->decoder), buffer->data);
+	    SWFDEC_SWF_DECODER (mov->resource->decoder), buffer->data);
 	g_assert (script);
 	swfdec_player_add_action (player, mov, swfdec_sprite_movie_run_script, script);
       }
@@ -435,10 +437,10 @@ swfdec_sprite_movie_goto (SwfdecSpriteMovie *movie, guint goto_frame)
   while (n) {
     guint tag;
     SwfdecBuffer *buffer;
+    SwfdecResource *resource = swfdec_movie_get_own_resource (mov);
     /* FIXME: These actions should probably just be added to the action queue */
-    if (movie == mov->swf->movie &&
-	mov->swf->parse_frame <= movie->frame)
-      swfdec_swf_instance_advance (mov->swf);
+    if (resource && resource->parse_frame <= movie->frame)
+      swfdec_resource_advance (resource);
     if (!swfdec_sprite_get_action (movie->sprite, movie->next_action, &tag, &buffer))
       break;
     movie->next_action++;
@@ -515,14 +517,14 @@ swfdec_sprite_movie_do_init_movie (SwfdecSpriteMovie *movie)
   SwfdecAsContext *context = SWFDEC_AS_OBJECT (movie)->context;
   SwfdecAsObject *constructor = NULL;
 
-  g_assert (mov->swf != NULL);
+  g_assert (mov->resource != NULL);
 
   if (movie->sprite) {
     const char *name;
 
     g_assert (movie->sprite->parse_frame > 0);
     movie->n_frames = movie->sprite->n_frames;
-    name = swfdec_swf_instance_get_export_name (mov->swf,
+    name = swfdec_resource_get_export_name (mov->resource,
 	SWFDEC_CHARACTER (movie->sprite));
     if (name != NULL) {
       name = swfdec_as_context_get_string (context, name);
@@ -721,7 +723,7 @@ swfdec_sprite_movie_load (SwfdecSpriteMovie *movie, const char *url, SwfdecLoade
   /* FIXME: load relative to other movie? */
   loader = swfdec_player_load (SWFDEC_PLAYER (SWFDEC_AS_OBJECT (movie)->context),
       url, request, data);
-  swfdec_swf_instance_new (movie, loader, NULL);
+  swfdec_resource_new (movie, loader, NULL);
   g_object_unref (loader);
 }
 
diff --git a/libswfdec/swfdec_sprite_movie_as.c b/libswfdec/swfdec_sprite_movie_as.c
index d5a9f03..8e566c3 100644
--- a/libswfdec/swfdec_sprite_movie_as.c
+++ b/libswfdec/swfdec_sprite_movie_as.c
@@ -67,11 +67,13 @@ swfdec_sprite_movie_getBytesLoaded (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   SwfdecMovie *movie;
+  SwfdecResource *resource;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
 
-  if (SWFDEC_MOVIE (movie->swf->movie) == movie) {
-    SWFDEC_AS_VALUE_SET_INT (rval, movie->swf->decoder->bytes_loaded);
+  resource = swfdec_movie_get_own_resource (movie);
+  if (resource) {
+    SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_loaded);
   } else {
     SWFDEC_AS_VALUE_SET_INT (rval, 0);
   }
@@ -83,11 +85,13 @@ swfdec_sprite_movie_getBytesTotal (SwfdecAsContext *cx, SwfdecAsObject *object,
     guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
 {
   SwfdecMovie *movie;
+  SwfdecResource *resource;
 
   SWFDEC_AS_CHECK (SWFDEC_TYPE_MOVIE, (gpointer)&movie, "");
 
-  if (SWFDEC_MOVIE (movie->swf->movie) == movie) {
-    SWFDEC_AS_VALUE_SET_INT (rval, movie->swf->decoder->bytes_total);
+  resource = swfdec_movie_get_own_resource (movie);
+  if (resource) {
+    SWFDEC_AS_VALUE_SET_INT (rval, resource->decoder->bytes_total);
   } else {
     SWFDEC_AS_VALUE_SET_INT (rval, 0);
   }
@@ -372,7 +376,7 @@ swfdec_sprite_movie_attachMovie (SwfdecAsContext *cx, SwfdecAsObject *object,
   } else {
     initObject = NULL;
   }
-  sprite = swfdec_swf_instance_get_export (movie->swf, export);
+  sprite = swfdec_resource_get_export (movie->resource, export);
   if (!SWFDEC_IS_SPRITE (sprite)) {
     if (sprite == NULL) {
       SWFDEC_WARNING ("no symbol with name %s exported", export);
diff --git a/libswfdec/swfdec_swf_instance.c b/libswfdec/swfdec_swf_instance.c
index 97e8460..c77df13 100644
--- a/libswfdec/swfdec_swf_instance.c
+++ b/libswfdec/swfdec_swf_instance.c
@@ -1,5 +1,5 @@
 /* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ * Copyright (C) 2006-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
@@ -40,20 +40,20 @@
 #include "swfdec_utils.h"
 
 
-static void swfdec_swf_instance_loader_target_init (SwfdecLoaderTargetInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (SwfdecSwfInstance, swfdec_swf_instance, G_TYPE_OBJECT,
-    G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_LOADER_TARGET, swfdec_swf_instance_loader_target_init))
+static void swfdec_resource_loader_target_init (SwfdecLoaderTargetInterface *iface);
+G_DEFINE_TYPE_WITH_CODE (SwfdecResource, swfdec_resource, SWFDEC_TYPE_FLASH_SECURITY,
+    G_IMPLEMENT_INTERFACE (SWFDEC_TYPE_LOADER_TARGET, swfdec_resource_loader_target_init))
 
 /*** SWFDEC_LOADER_TARGET interface ***/
 
 static SwfdecPlayer *
-swfdec_swf_instance_loader_target_get_player (SwfdecLoaderTarget *target)
+swfdec_resource_loader_target_get_player (SwfdecLoaderTarget *target)
 {
-  return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (SWFDEC_SWF_INSTANCE (target)->movie)->context);
+  return SWFDEC_PLAYER (SWFDEC_AS_OBJECT (SWFDEC_RESOURCE (target)->movie)->context);
 }
 
 static void
-swfdec_swf_instance_allow_network (SwfdecPlayer *player)
+swfdec_resource_allow_network (SwfdecPlayer *player)
 {
   SwfdecFlashSecurity *sec;
 
@@ -68,7 +68,7 @@ swfdec_swf_instance_allow_network (SwfdecPlayer *player)
 }
 
 static void
-swfdec_swf_instance_loader_target_image (SwfdecSwfInstance *instance)
+swfdec_resource_loader_target_image (SwfdecResource *instance)
 {
   SwfdecSpriteMovie *movie = instance->movie;
 
@@ -84,7 +84,7 @@ swfdec_swf_instance_loader_target_image (SwfdecSwfInstance *instance)
     /* if first instance */
     if (player->loader == instance->loader && dec->use_network &&
 	swfdec_url_has_protocol (swfdec_loader_get_url (instance->loader), "file"))
-      swfdec_swf_instance_allow_network (player);
+      swfdec_resource_allow_network (player);
   } else if (SWFDEC_IS_FLV_DECODER (instance->decoder)) {
     /* nothing to do, please move along */
   } else {
@@ -93,9 +93,9 @@ swfdec_swf_instance_loader_target_image (SwfdecSwfInstance *instance)
 }
 
 static void
-swfdec_swf_instance_loader_target_open (SwfdecLoaderTarget *target, SwfdecLoader *loader)
+swfdec_resource_loader_target_open (SwfdecLoaderTarget *target, SwfdecLoader *loader)
 {
-  SwfdecSwfInstance *instance = SWFDEC_SWF_INSTANCE (target);
+  SwfdecResource *instance = SWFDEC_RESOURCE (target);
   const char *query;
 
   query = swfdec_url_get_query (swfdec_loader_get_url (loader));
@@ -110,9 +110,9 @@ swfdec_swf_instance_loader_target_open (SwfdecLoaderTarget *target, SwfdecLoader
 }
 
 static void
-swfdec_swf_instance_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *loader)
+swfdec_resource_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoader *loader)
 {
-  SwfdecSwfInstance *instance = SWFDEC_SWF_INSTANCE (target);
+  SwfdecResource *instance = SWFDEC_RESOURCE (target);
   SwfdecPlayer *player = SWFDEC_PLAYER (SWFDEC_AS_OBJECT (instance->movie)->context);
   SwfdecDecoder *dec = instance->decoder;
   SwfdecDecoderClass *klass;
@@ -159,7 +159,7 @@ swfdec_swf_instance_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoade
       case SWFDEC_STATUS_NEEDBITS:
 	return;
       case SWFDEC_STATUS_IMAGE:
-	swfdec_swf_instance_loader_target_image (instance);
+	swfdec_resource_loader_target_image (instance);
 	break;
       case SWFDEC_STATUS_INIT:
 	swfdec_player_initialize (player, 
@@ -176,17 +176,17 @@ swfdec_swf_instance_loader_target_parse (SwfdecLoaderTarget *target, SwfdecLoade
 }
 
 static void
-swfdec_swf_instance_loader_target_init (SwfdecLoaderTargetInterface *iface)
+swfdec_resource_loader_target_init (SwfdecLoaderTargetInterface *iface)
 {
-  iface->get_player = swfdec_swf_instance_loader_target_get_player;
-  iface->open = swfdec_swf_instance_loader_target_open;
-  iface->parse = swfdec_swf_instance_loader_target_parse;
+  iface->get_player = swfdec_resource_loader_target_get_player;
+  iface->open = swfdec_resource_loader_target_open;
+  iface->parse = swfdec_resource_loader_target_parse;
 }
 
 static void
-swfdec_swf_instance_dispose (GObject *object)
+swfdec_resource_dispose (GObject *object)
 {
-  SwfdecSwfInstance *instance = SWFDEC_SWF_INSTANCE (object);
+  SwfdecResource *instance = SWFDEC_RESOURCE (object);
 
   swfdec_loader_set_target (instance->loader, NULL);
   g_object_unref (instance->loader);
@@ -198,41 +198,41 @@ swfdec_swf_instance_dispose (GObject *object)
   g_hash_table_destroy (instance->exports);
   g_hash_table_destroy (instance->export_names);
 
-  G_OBJECT_CLASS (swfdec_swf_instance_parent_class)->dispose (object);
+  G_OBJECT_CLASS (swfdec_resource_parent_class)->dispose (object);
 }
 
 static void
-swfdec_swf_instance_class_init (SwfdecSwfInstanceClass *klass)
+swfdec_resource_class_init (SwfdecResourceClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  object_class->dispose = swfdec_swf_instance_dispose;
+  object_class->dispose = swfdec_resource_dispose;
 }
 
 static void
-swfdec_swf_instance_init (SwfdecSwfInstance *instance)
+swfdec_resource_init (SwfdecResource *instance)
 {
   instance->exports = g_hash_table_new (swfdec_str_case_hash, swfdec_str_case_equal);
   instance->export_names = g_hash_table_new (g_direct_hash, g_direct_equal);
 }
 
-SwfdecSwfInstance *
-swfdec_swf_instance_new (SwfdecSpriteMovie *movie, SwfdecLoader *loader, const char *variables)
+SwfdecResource *
+swfdec_resource_new (SwfdecSpriteMovie *movie, SwfdecLoader *loader, const char *variables)
 {
   SwfdecMovie *mov;
-  SwfdecSwfInstance *swf;
+  SwfdecResource *swf;
 
   g_return_val_if_fail (SWFDEC_IS_SPRITE_MOVIE (movie), NULL);
   g_return_val_if_fail (SWFDEC_IS_LOADER (loader), NULL);
 
   mov = SWFDEC_MOVIE (movie);
-  swf = g_object_new (SWFDEC_TYPE_SWF_INSTANCE, NULL);
+  swf = g_object_new (SWFDEC_TYPE_RESOURCE, NULL);
   /* set important variables */
   swf->variables = g_strdup (variables);
   swf->movie = movie;
-  if (mov->swf)
-    g_object_unref (mov->swf);
-  mov->swf = swf;
+  if (mov->resource)
+    g_object_unref (mov->resource);
+  mov->resource = swf;
   /* set loader (that depends on those vars) */
   swf->loader = g_object_ref (loader);
   swfdec_loader_set_target (loader, SWFDEC_LOADER_TARGET (swf));
@@ -241,27 +241,27 @@ swfdec_swf_instance_new (SwfdecSpriteMovie *movie, SwfdecLoader *loader, const c
 }
 
 gpointer
-swfdec_swf_instance_get_export (SwfdecSwfInstance *instance, const char *name)
+swfdec_resource_get_export (SwfdecResource *instance, const char *name)
 {
-  g_return_val_if_fail (SWFDEC_IS_SWF_INSTANCE (instance), NULL);
+  g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
   g_return_val_if_fail (name != NULL, NULL);
 
   return g_hash_table_lookup (instance->exports, name);
 }
 
 const char *
-swfdec_swf_instance_get_export_name (SwfdecSwfInstance *instance, SwfdecCharacter *character)
+swfdec_resource_get_export_name (SwfdecResource *instance, SwfdecCharacter *character)
 {
-  g_return_val_if_fail (SWFDEC_IS_SWF_INSTANCE (instance), NULL);
+  g_return_val_if_fail (SWFDEC_IS_RESOURCE (instance), NULL);
   g_return_val_if_fail (SWFDEC_IS_CHARACTER (character), NULL);
 
   return g_hash_table_lookup (instance->export_names, character);
 }
 
 static void
-swfdec_swf_instance_add_export (SwfdecSwfInstance *instance, SwfdecCharacter *character, const char *name)
+swfdec_resource_add_export (SwfdecResource *instance, SwfdecCharacter *character, const char *name)
 {
-  g_return_if_fail (SWFDEC_IS_SWF_INSTANCE (instance));
+  g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
   g_return_if_fail (SWFDEC_IS_CHARACTER (character));
   g_return_if_fail (name != NULL);
 
@@ -270,13 +270,13 @@ swfdec_swf_instance_add_export (SwfdecSwfInstance *instance, SwfdecCharacter *ch
 }
 
 void
-swfdec_swf_instance_advance (SwfdecSwfInstance *instance)
+swfdec_resource_advance (SwfdecResource *instance)
 {
   SwfdecSwfDecoder *s;
   GArray *array;
   guint i;
 
-  g_return_if_fail (SWFDEC_IS_SWF_INSTANCE (instance));
+  g_return_if_fail (SWFDEC_IS_RESOURCE (instance));
 
   s = SWFDEC_SWF_DECODER (instance->decoder);
   SWFDEC_LOG ("performing actions for frame %u", instance->parse_frame);
@@ -297,7 +297,7 @@ swfdec_swf_instance_advance (SwfdecSwfInstance *instance)
       case SWFDEC_ROOT_ACTION_EXPORT:
 	{
 	  SwfdecRootExportData *data = action->data;
-	  swfdec_swf_instance_add_export (instance, data->character, data->name);
+	  swfdec_resource_add_export (instance, data->character, data->name);
 	}
 	break;
       default:
diff --git a/libswfdec/swfdec_swf_instance.h b/libswfdec/swfdec_swf_instance.h
index 89d1cdb..2c456a0 100644
--- a/libswfdec/swfdec_swf_instance.h
+++ b/libswfdec/swfdec_swf_instance.h
@@ -1,5 +1,5 @@
 /* Swfdec
- * Copyright (C) 2006 Benjamin Otte <otte at gnome.org>
+ * Copyright (C) 2006-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
@@ -17,26 +17,27 @@
  * Boston, MA  02110-1301  USA
  */
 
-#ifndef _SWFDEC_SWF_INSTANCE_H_
-#define _SWFDEC_SWF_INSTANCE_H_
+#ifndef _SWFDEC_RESOURCE_H_
+#define _SWFDEC_RESOURCE_H_
 
 #include <libswfdec/swfdec_player.h>
+#include <libswfdec/swfdec_flash_security.h>
 #include <libswfdec/swfdec_sprite_movie.h>
 
 G_BEGIN_DECLS
 
-//typedef struct _SwfdecSwfInstance SwfdecSwfInstance;
-typedef struct _SwfdecSwfInstanceClass SwfdecSwfInstanceClass;
+//typedef struct _SwfdecResource SwfdecResource;
+typedef struct _SwfdecResourceClass SwfdecResourceClass;
 
-#define SWFDEC_TYPE_SWF_INSTANCE                    (swfdec_swf_instance_get_type())
-#define SWFDEC_IS_SWF_INSTANCE(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_SWF_INSTANCE))
-#define SWFDEC_IS_SWF_INSTANCE_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_SWF_INSTANCE))
-#define SWFDEC_SWF_INSTANCE(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_SWF_INSTANCE, SwfdecSwfInstance))
-#define SWFDEC_SWF_INSTANCE_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_SWF_INSTANCE, SwfdecSwfInstanceClass))
+#define SWFDEC_TYPE_RESOURCE                    (swfdec_resource_get_type())
+#define SWFDEC_IS_RESOURCE(obj)                 (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_RESOURCE))
+#define SWFDEC_IS_RESOURCE_CLASS(klass)         (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_RESOURCE))
+#define SWFDEC_RESOURCE(obj)                    (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_RESOURCE, SwfdecResource))
+#define SWFDEC_RESOURCE_CLASS(klass)            (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_RESOURCE, SwfdecResourceClass))
 
-struct _SwfdecSwfInstance
+struct _SwfdecResource
 {
-  GObject		object;
+  SwfdecFlashSecurity	flash_security;
 
   SwfdecSpriteMovie * 	movie;		/* the movie responsible for creating this instance */
   guint			parse_frame;	/* next frame to parse */
@@ -49,23 +50,23 @@ struct _SwfdecSwfInstance
   GHashTable *		export_names;	/* SwfdecCharacter->string mapping of exported characters */
 };
 
-struct _SwfdecSwfInstanceClass
+struct _SwfdecResourceClass
 {
-  GObjectClass		object_class;
+  SwfdecFlashSecurityClass	flash_security_class;
 };
 
-GType		swfdec_swf_instance_get_type	  	(void);
+GType		swfdec_resource_get_type	  	(void);
 
-SwfdecSwfInstance *
-		swfdec_swf_instance_new			(SwfdecSpriteMovie *  	movie,
+SwfdecResource *
+		swfdec_resource_new			(SwfdecSpriteMovie *  	movie,
 							 SwfdecLoader *		loader,
 							 const char *		variables);
 
-void		swfdec_swf_instance_advance		(SwfdecSwfInstance *	instance);
+void		swfdec_resource_advance			(SwfdecResource *	instance);
 
-gpointer	swfdec_swf_instance_get_export		(SwfdecSwfInstance *	root,
+gpointer	swfdec_resource_get_export		(SwfdecResource *	root,
 							 const char *		name);
-const char *	swfdec_swf_instance_get_export_name    	(SwfdecSwfInstance *	root,
+const char *	swfdec_resource_get_export_name    	(SwfdecResource *	root,
 							 SwfdecCharacter *	character);
 
 G_END_DECLS
diff --git a/libswfdec/swfdec_types.h b/libswfdec/swfdec_types.h
index 37a89ea..60193a0 100644
--- a/libswfdec/swfdec_types.h
+++ b/libswfdec/swfdec_types.h
@@ -49,6 +49,7 @@ typedef struct _SwfdecMovie SwfdecMovie;
 typedef struct _SwfdecShape SwfdecShape;
 typedef struct _SwfdecShapeVec SwfdecShapeVec;
 typedef struct _SwfdecRect SwfdecRect;
+typedef struct _SwfdecResource SwfdecResource;
 typedef struct _SwfdecRootSprite SwfdecRootSprite;
 typedef struct _SwfdecScriptable SwfdecScriptable;
 typedef struct _SwfdecSound SwfdecSound;
@@ -57,7 +58,6 @@ typedef struct _SwfdecSprite SwfdecSprite;
 typedef struct _SwfdecSpriteFrame SwfdecSpriteFrame;
 typedef struct _SwfdecSpriteMovie SwfdecSpriteMovie;
 typedef struct _SwfdecSwfDecoder SwfdecSwfDecoder;
-typedef struct _SwfdecSwfInstance SwfdecSwfInstance;
 typedef struct _SwfdecText SwfdecText;
 
 #endif


More information about the Swfdec mailing list