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.
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_stream_target.h"
25 #include "swfdec_debug.h"
26 #include "swfdec_loader_internal.h"
27 #include "swfdec_player_internal.h"
30 swfdec_stream_target_base_init (gpointer g_class
)
32 static gboolean initialized
= FALSE
;
34 if (G_UNLIKELY (!initialized
)) {
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
,
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
;
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
);
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
);
89 iface
->open (target
, stream
);
93 swfdec_stream_target_parse (SwfdecStreamTarget
*target
, SwfdecStream
*stream
)
95 SwfdecStreamTargetInterface
*iface
;
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
);
105 call_again
= iface
->parse (target
, stream
);
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
);
124 iface
->close (target
, stream
);
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
);
139 iface
->error (target
, stream
);