release 0.8.0
[swfdec.git] / swfdec / swfdec_resource.h
blob8a4e2e5a20bea0c99b2c034a3dd88f3c77463ad8
1 /* Swfdec
2 * Copyright (C) 2006-2007 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.
8 *
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_player.h>
24 #include <swfdec/swfdec_sandbox.h>
25 #include <swfdec/swfdec_sprite_movie.h>
27 G_BEGIN_DECLS
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))
38 typedef enum {
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 SwfdecAsObject 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 SwfdecSpriteMovie * movie; /* the movie responsible for creating this instance */
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 SwfdecAsObjectClass 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,
82 const char * name);
83 gpointer swfdec_resource_get_export (SwfdecResource * root,
84 const char * name);
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,
90 const char * url,
91 SwfdecBuffer * buffer,
92 SwfdecMovieClipLoader *loader);
93 void swfdec_resource_load (SwfdecPlayer * player,
94 const char * target,
95 const char * url,
96 SwfdecBuffer * buffer);
99 G_END_DECLS
100 #endif