Bug 22803 - Make header conform to implementation
[swfdec.git] / swfdec / swfdec_video_movie_as.c
blob57ec895a6461105d25400ee8024dabb40c1c88d7
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_video.h"
25 #include "swfdec_as_internal.h"
26 #include "swfdec_as_strings.h"
27 #include "swfdec_debug.h"
28 #include "swfdec_net_stream.h"
29 #include "swfdec_player_internal.h"
30 #include "swfdec_sandbox.h"
32 SWFDEC_AS_NATIVE (667, 1, swfdec_video_attach_video)
33 void
34 swfdec_video_attach_video (SwfdecAsContext *cx, SwfdecAsObject *object,
35 guint argc, SwfdecAsValue *argv, SwfdecAsValue *rval)
37 SwfdecVideoMovie *video;
38 SwfdecAsObject *o;
40 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "O", &o);
42 if (o == NULL || !SWFDEC_IS_VIDEO_PROVIDER (o->relay)) {
43 SWFDEC_WARNING ("calling attachVideo without a NetStream object");
44 swfdec_video_movie_set_provider (video, NULL);
45 return;
48 swfdec_video_movie_set_provider (video, SWFDEC_VIDEO_PROVIDER (o->relay));
51 SWFDEC_AS_NATIVE (667, 2, swfdec_video_clear)
52 void
53 swfdec_video_clear (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
54 SwfdecAsValue *argv, SwfdecAsValue *rval)
56 SwfdecVideoMovie *video;
58 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "");
60 swfdec_video_movie_clear (video);
63 static void
64 swfdec_video_get_width (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
65 SwfdecAsValue *argv, SwfdecAsValue *rval)
67 SwfdecVideoMovie *video;
68 guint w;
70 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "");
72 if (video->provider) {
73 w = swfdec_video_provider_get_width (video->provider);
74 } else {
75 w = 0;
77 *rval = swfdec_as_value_from_integer (cx, w);
80 static void
81 swfdec_video_get_height (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
82 SwfdecAsValue *argv, SwfdecAsValue *rval)
84 SwfdecVideoMovie *video;
85 guint h;
87 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE, &video, "");
89 if (video->provider) {
90 h = swfdec_video_provider_get_height (video->provider);
91 } else {
92 h = 0;
94 *rval = swfdec_as_value_from_integer (cx, h);
97 static void
98 swfdec_video_get_deblocking (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
99 SwfdecAsValue *argv, SwfdecAsValue *rval)
101 SWFDEC_STUB ("Video.deblocking (get)");
102 *rval = swfdec_as_value_from_integer (cx, 0);
105 static void
106 swfdec_video_set_deblocking (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
107 SwfdecAsValue *argv, SwfdecAsValue *rval)
109 SWFDEC_STUB ("Video.deblocking (set)");
112 static void
113 swfdec_video_get_smoothing (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
114 SwfdecAsValue *argv, SwfdecAsValue *rval)
116 SWFDEC_STUB ("Video.smoothing (get)");
117 SWFDEC_AS_VALUE_SET_BOOLEAN (rval, TRUE);
120 static void
121 swfdec_video_set_smoothing (SwfdecAsContext *cx, SwfdecAsObject *object, guint argc,
122 SwfdecAsValue *argv, SwfdecAsValue *rval)
124 SWFDEC_STUB ("Video.smoothing (set)");
127 void
128 swfdec_video_movie_init_properties (SwfdecAsContext *cx)
130 SwfdecAsValue val;
131 SwfdecAsObject *video, *proto;
133 // FIXME: We should only initialize if the prototype Object has not been
134 // initialized by any object's constructor with native properties
135 // (TextField, TextFormat, XML, XMLNode at least)
137 g_return_if_fail (SWFDEC_IS_AS_CONTEXT (cx));
139 swfdec_as_object_get_variable (cx->global, SWFDEC_AS_STR_Video, &val);
140 if (!SWFDEC_AS_VALUE_IS_OBJECT (val))
141 return;
142 video = SWFDEC_AS_VALUE_GET_OBJECT (val);
144 swfdec_as_object_get_variable (video, SWFDEC_AS_STR_prototype, &val);
145 if (!SWFDEC_AS_VALUE_IS_OBJECT (val))
146 return;
147 proto = SWFDEC_AS_VALUE_GET_OBJECT (val);
149 swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_width,
150 swfdec_video_get_width, NULL);
151 swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_height,
152 swfdec_video_get_height, NULL);
153 swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_deblocking,
154 swfdec_video_get_deblocking, swfdec_video_set_deblocking);
155 swfdec_as_object_add_native_variable (proto, SWFDEC_AS_STR_smoothing,
156 swfdec_video_get_smoothing, swfdec_video_set_smoothing);