2 * Copyright (C) 2006-2008 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301 USA
20 #ifndef _SWFDEC_RESOURCE_H_
21 #define _SWFDEC_RESOURCE_H_
23 #include <swfdec/swfdec_gc_object.h>
24 #include <swfdec/swfdec_player.h>
25 #include <swfdec/swfdec_sprite_movie.h>
29 //typedef struct _SwfdecResource SwfdecResource;
30 typedef struct _SwfdecResourceClass SwfdecResourceClass
;
32 #define SWFDEC_TYPE_RESOURCE (swfdec_resource_get_type())
33 #define SWFDEC_IS_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SWFDEC_TYPE_RESOURCE))
34 #define SWFDEC_IS_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), SWFDEC_TYPE_RESOURCE))
35 #define SWFDEC_RESOURCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SWFDEC_TYPE_RESOURCE, SwfdecResource))
36 #define SWFDEC_RESOURCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), SWFDEC_TYPE_RESOURCE, SwfdecResourceClass))
39 SWFDEC_RESOURCE_NEW
= 0, /* no loader set yet, only the call to _load() was done */
40 SWFDEC_RESOURCE_REQUESTED
, /* the URL has been requested, the request was ok, ->loader is set */
41 SWFDEC_RESOURCE_OPENED
, /* onLoadStart has been called */
42 SWFDEC_RESOURCE_COMPLETE
, /* onLoadComplete has been called */
43 SWFDEC_RESOURCE_DONE
/* onLoadInit has been called, clip_loader is unset */
44 } SwfdecResourceState
;
46 struct _SwfdecResource
48 SwfdecGcObject object
;
50 guint version
; /* version of this resource */
51 SwfdecSandbox
* sandbox
; /* sandbox this resource belongs to (only NULL for a short time on very first loader) */
52 SwfdecAsValue movie
; /* the movie responsible for creating this instance or undefined if none */
54 SwfdecLoader
* loader
; /* the loader providing data for the decoder */
55 SwfdecDecoder
* decoder
; /* decoder in use or NULL if broken file */
56 char * variables
; /* extra variables to be set */
58 GHashTable
* exports
; /* string->SwfdecCharacter mapping of exported characters */
59 GHashTable
* export_names
; /* SwfdecCharacter->string mapping of exported characters */
61 /* only used while loading */
62 SwfdecResourceState state
; /* state we're in (for determining callbacks */
63 SwfdecMovie
* target
; /* target path we use for signalling */
64 SwfdecMovieClipLoader
*clip_loader
; /* loader that gets notified about load events */
65 SwfdecSandbox
* clip_loader_sandbox
; /* sandbox used for events on the clip loader */
68 struct _SwfdecResourceClass
70 SwfdecGcObjectClass object_class
;
73 GType
swfdec_resource_get_type (void);
75 SwfdecResource
*swfdec_resource_new (SwfdecPlayer
* player
,
76 SwfdecLoader
* loader
,
77 const char * variables
);
79 gboolean
swfdec_resource_emit_on_load_init (SwfdecResource
* resource
);
80 void swfdec_resource_add_export (SwfdecResource
* instance
,
81 SwfdecCharacter
* character
,
83 gpointer
swfdec_resource_get_export (SwfdecResource
* root
,
85 const char * swfdec_resource_get_export_name (SwfdecResource
* root
,
86 SwfdecCharacter
* character
);
88 gboolean
swfdec_resource_load_movie (SwfdecPlayer
* player
,
89 const SwfdecAsValue
* target
,
91 SwfdecBuffer
* buffer
,
92 SwfdecMovieClipLoader
*loader
);
93 void swfdec_resource_load (SwfdecPlayer
* player
,
96 SwfdecBuffer
* buffer
);