this is a FIXME
[swfdec.git] / swfdec / swfdec_stream_target.c
blob4b96ef0d22653a52f36238e3daa239ebe242a805
1 /* Swfdec
2 * Copyright (C) 2007-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.
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 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
24 #include "swfdec_stream_target.h"
25 #include "swfdec_debug.h"
26 #include "swfdec_loader_internal.h"
27 #include "swfdec_player_internal.h"
29 static void
30 swfdec_stream_target_base_init (gpointer g_class)
32 static gboolean initialized = FALSE;
34 if (G_UNLIKELY (!initialized)) {
35 initialized = TRUE;
39 GType
40 swfdec_stream_target_get_type (void)
42 static GType stream_target_type = 0;
44 if (!stream_target_type) {
45 static const GTypeInfo stream_target_info = {
46 sizeof (SwfdecStreamTargetInterface),
47 swfdec_stream_target_base_init,
48 NULL,
49 NULL,
50 NULL,
51 NULL,
54 NULL,
57 stream_target_type = g_type_register_static (G_TYPE_INTERFACE,
58 "SwfdecStreamTarget", &stream_target_info, 0);
59 g_type_interface_add_prerequisite (stream_target_type, G_TYPE_OBJECT);
62 return stream_target_type;
65 SwfdecPlayer *
66 swfdec_stream_target_get_player (SwfdecStreamTarget *target)
68 SwfdecStreamTargetInterface *iface;
70 g_return_val_if_fail (SWFDEC_IS_STREAM_TARGET (target), NULL);
72 iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
73 g_assert (iface->get_player != NULL);
74 return iface->get_player (target);
77 void
78 swfdec_stream_target_open (SwfdecStreamTarget *target, SwfdecStream *stream)
80 SwfdecStreamTargetInterface *iface;
82 g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
83 g_return_if_fail (SWFDEC_IS_STREAM (stream));
85 SWFDEC_LOG ("opening %s", swfdec_stream_describe (stream));
87 iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
88 if (iface->open)
89 iface->open (target, stream);
92 gboolean
93 swfdec_stream_target_parse (SwfdecStreamTarget *target, SwfdecStream *stream)
95 SwfdecStreamTargetInterface *iface;
96 gboolean call_again;
98 g_return_val_if_fail (SWFDEC_IS_STREAM_TARGET (target), FALSE);
99 g_return_val_if_fail (SWFDEC_IS_STREAM (stream), FALSE);
101 SWFDEC_LOG ("parsing %s", swfdec_stream_describe (stream));
103 iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
104 if (iface->parse)
105 call_again = iface->parse (target, stream);
106 else
107 call_again = FALSE;
109 return call_again;
112 void
113 swfdec_stream_target_close (SwfdecStreamTarget *target, SwfdecStream *stream)
115 SwfdecStreamTargetInterface *iface;
117 g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
118 g_return_if_fail (SWFDEC_IS_STREAM (stream));
120 SWFDEC_LOG ("close on %s", swfdec_stream_describe (stream));
122 iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
123 if (iface->close)
124 iface->close (target, stream);
127 void
128 swfdec_stream_target_error (SwfdecStreamTarget *target, SwfdecStream *stream)
130 SwfdecStreamTargetInterface *iface;
132 g_return_if_fail (SWFDEC_IS_STREAM_TARGET (target));
133 g_return_if_fail (SWFDEC_IS_STREAM (stream));
135 SWFDEC_LOG ("error on %s", swfdec_stream_describe (stream));
137 iface = SWFDEC_STREAM_TARGET_GET_INTERFACE (target);
138 if (iface->error)
139 iface->error (target, stream);