2 * Copyright (C) 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_video_provider.h"
25 #include "swfdec_debug.h"
26 #include "swfdec_loader_internal.h"
27 #include "swfdec_player_internal.h"
34 static guint signals
[LAST_SIGNAL
] = { 0, };
37 swfdec_video_provider_base_init (gpointer klass
)
39 static gboolean initialized
= FALSE
;
41 if (G_UNLIKELY (!initialized
)) {
44 signals
[NEW_IMAGE
] = g_signal_new ("new-image", G_TYPE_FROM_CLASS (klass
),
45 G_SIGNAL_RUN_LAST
, 0, NULL
, NULL
, g_cclosure_marshal_VOID__VOID
,
51 swfdec_video_provider_get_type (void)
53 static GType video_provider_type
= 0;
55 if (!video_provider_type
) {
56 static const GTypeInfo video_provider_info
= {
57 sizeof (SwfdecVideoProviderInterface
),
58 swfdec_video_provider_base_init
,
68 video_provider_type
= g_type_register_static (G_TYPE_INTERFACE
,
69 "SwfdecVideoProvider", &video_provider_info
, 0);
70 g_type_interface_add_prerequisite (video_provider_type
, G_TYPE_OBJECT
);
73 return video_provider_type
;
77 swfdec_video_provider_get_image (SwfdecVideoProvider
*provider
,
78 SwfdecRenderer
*renderer
, guint
*width
, guint
*height
)
80 SwfdecVideoProviderInterface
*iface
;
82 g_return_val_if_fail (SWFDEC_IS_VIDEO_PROVIDER (provider
), NULL
);
83 g_return_val_if_fail (SWFDEC_IS_RENDERER (renderer
), NULL
);
84 g_return_val_if_fail (width
!= NULL
, NULL
);
85 g_return_val_if_fail (height
!= NULL
, NULL
);
87 iface
= SWFDEC_VIDEO_PROVIDER_GET_INTERFACE (provider
);
88 g_assert (iface
->get_image
!= NULL
);
89 return iface
->get_image (provider
, renderer
, width
, height
);
93 swfdec_video_provider_get_width (SwfdecVideoProvider
*provider
)
95 SwfdecVideoProviderInterface
*iface
;
98 g_return_val_if_fail (SWFDEC_IS_VIDEO_PROVIDER (provider
), 0);
100 iface
= SWFDEC_VIDEO_PROVIDER_GET_INTERFACE (provider
);
101 g_assert (iface
->get_size
!= NULL
);
102 iface
->get_size (provider
, &w
, &h
);
107 swfdec_video_provider_get_height (SwfdecVideoProvider
*provider
)
109 SwfdecVideoProviderInterface
*iface
;
112 g_return_val_if_fail (SWFDEC_IS_VIDEO_PROVIDER (provider
), 0);
114 iface
= SWFDEC_VIDEO_PROVIDER_GET_INTERFACE (provider
);
115 g_assert (iface
->get_size
!= NULL
);
116 iface
->get_size (provider
, &w
, &h
);
121 swfdec_video_provider_set_ratio (SwfdecVideoProvider
*provider
, guint ratio
)
123 SwfdecVideoProviderInterface
*iface
;
125 g_return_if_fail (SWFDEC_IS_VIDEO_PROVIDER (provider
));
127 iface
= SWFDEC_VIDEO_PROVIDER_GET_INTERFACE (provider
);
128 if (iface
->set_ratio
!= NULL
)
129 iface
->set_ratio (provider
, ratio
);
133 swfdec_video_provider_new_image (SwfdecVideoProvider
*provider
)
135 g_return_if_fail (SWFDEC_IS_VIDEO_PROVIDER (provider
));
136 g_signal_emit (provider
, signals
[NEW_IMAGE
], 0);