2 * Copyright (C) 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.
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
24 #include "swfdec_loadertarget.h"
25 #include "swfdec_debug.h"
26 #include "swfdec_loader_internal.h"
27 #include "swfdec_player_internal.h"
28 #include "swfdec_swf_decoder.h" /* HACK */
31 swfdec_loader_target_base_init (gpointer g_class
)
33 static gboolean initialized
= FALSE
;
35 if (G_UNLIKELY (!initialized
)) {
41 swfdec_loader_target_get_type (void)
43 static GType loader_target_type
= 0;
45 if (!loader_target_type
) {
46 static const GTypeInfo loader_target_info
= {
47 sizeof (SwfdecLoaderTargetInterface
),
48 swfdec_loader_target_base_init
,
58 loader_target_type
= g_type_register_static (G_TYPE_INTERFACE
,
59 "SwfdecLoaderTarget", &loader_target_info
, 0);
60 g_type_interface_add_prerequisite (loader_target_type
, G_TYPE_OBJECT
);
63 return loader_target_type
;
67 swfdec_loader_target_get_player (SwfdecLoaderTarget
*target
)
69 SwfdecLoaderTargetInterface
*iface
;
71 g_return_val_if_fail (SWFDEC_IS_LOADER_TARGET (target
), NULL
);
73 iface
= SWFDEC_LOADER_TARGET_GET_INTERFACE (target
);
74 g_assert (iface
->get_player
!= NULL
);
75 return iface
->get_player (target
);
79 swfdec_loader_target_open (SwfdecLoaderTarget
*target
, SwfdecLoader
*loader
)
81 SwfdecLoaderTargetInterface
*iface
;
83 g_return_if_fail (SWFDEC_IS_LOADER_TARGET (target
));
84 g_return_if_fail (SWFDEC_IS_LOADER (loader
));
86 SWFDEC_LOG ("opening %p (state %u)", loader
, loader
->state
);
88 iface
= SWFDEC_LOADER_TARGET_GET_INTERFACE (target
);
90 iface
->open (target
, loader
);
94 swfdec_loader_target_parse (SwfdecLoaderTarget
*target
, SwfdecLoader
*loader
)
96 SwfdecLoaderTargetInterface
*iface
;
98 g_return_if_fail (SWFDEC_IS_LOADER_TARGET (target
));
99 g_return_if_fail (SWFDEC_IS_LOADER (loader
));
101 SWFDEC_LOG ("parsing %p (state %u)", loader
, loader
->state
);
103 iface
= SWFDEC_LOADER_TARGET_GET_INTERFACE (target
);
105 iface
->parse (target
, loader
);
109 swfdec_loader_target_eof (SwfdecLoaderTarget
*target
, SwfdecLoader
*loader
)
111 SwfdecLoaderTargetInterface
*iface
;
113 g_return_if_fail (SWFDEC_IS_LOADER_TARGET (target
));
114 g_return_if_fail (SWFDEC_IS_LOADER (loader
));
116 SWFDEC_LOG ("eof on %p (state %u)", loader
, loader
->state
);
118 iface
= SWFDEC_LOADER_TARGET_GET_INTERFACE (target
);
120 iface
->eof (target
, loader
);
124 swfdec_loader_target_error (SwfdecLoaderTarget
*target
, SwfdecLoader
*loader
)
126 SwfdecLoaderTargetInterface
*iface
;
128 g_return_if_fail (SWFDEC_IS_LOADER_TARGET (target
));
129 g_return_if_fail (SWFDEC_IS_LOADER (loader
));
131 SWFDEC_LOG ("error on %p (state %u)", loader
, loader
->state
);
133 iface
= SWFDEC_LOADER_TARGET_GET_INTERFACE (target
);
135 iface
->error (target
, loader
);