back to development
[swfdec.git] / swfdec / swfdec_cached_video.c
blobac6817195f1ffe82c3fd5eec6d1547a0e8fbefb8
1 /* Swfdec
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.
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_cached_video.h"
25 #include "swfdec_debug.h"
27 G_DEFINE_TYPE (SwfdecCachedVideo, swfdec_cached_video, SWFDEC_TYPE_CACHED)
29 static void
30 swfdec_cached_video_dispose (GObject *object)
32 SwfdecCachedVideo *video = SWFDEC_CACHED_VIDEO (object);
34 if (video->surface) {
35 cairo_surface_destroy (video->surface);
36 video->surface = NULL;
39 G_OBJECT_CLASS (swfdec_cached_video_parent_class)->dispose (object);
42 static void
43 swfdec_cached_video_class_init (SwfdecCachedVideoClass * g_class)
45 GObjectClass *object_class = G_OBJECT_CLASS (g_class);
47 object_class->dispose = swfdec_cached_video_dispose;
50 static void
51 swfdec_cached_video_init (SwfdecCachedVideo *cached)
55 SwfdecCachedVideo *
56 swfdec_cached_video_new (cairo_surface_t *surface, gsize size)
58 SwfdecCachedVideo *video;
60 g_return_val_if_fail (surface != NULL, NULL);
61 g_return_val_if_fail (size > 0, NULL);
63 size += sizeof (SwfdecCachedVideo);
64 video = g_object_new (SWFDEC_TYPE_CACHED_VIDEO, "size", size, NULL);
65 video->surface = cairo_surface_reference (surface);
67 return video;
70 cairo_surface_t *
71 swfdec_cached_video_get_surface (SwfdecCachedVideo *video)
73 g_return_val_if_fail (SWFDEC_IS_CACHED_VIDEO (video), NULL);
75 return cairo_surface_reference (video->surface);
78 guint
79 swfdec_cached_video_get_frame (SwfdecCachedVideo *video)
81 g_return_val_if_fail (SWFDEC_IS_CACHED_VIDEO (video), 0);
83 return video->frame;
86 void
87 swfdec_cached_video_set_frame (SwfdecCachedVideo *video, guint frame)
89 g_return_if_fail (SWFDEC_IS_CACHED_VIDEO (video));
91 video->frame = frame;
94 void
95 swfdec_cached_video_get_size (SwfdecCachedVideo *video, guint *width, guint *height)
97 g_return_if_fail (SWFDEC_IS_CACHED_VIDEO (video));
99 if (width)
100 *width = video->width;
101 if (height)
102 *height = video->height;
105 void
106 swfdec_cached_video_set_size (SwfdecCachedVideo *video, guint width, guint height)
108 g_return_if_fail (SWFDEC_IS_CACHED_VIDEO (video));
110 video->width = width;
111 video->height = height;