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_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
)
34 swfdec_video_attach_video (SwfdecAsContext
*cx
, SwfdecAsObject
*object
,
35 guint argc
, SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
37 SwfdecVideoMovie
*video
;
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
);
48 swfdec_video_movie_set_provider (video
, SWFDEC_VIDEO_PROVIDER (o
->relay
));
51 SWFDEC_AS_NATIVE (667, 2, swfdec_video_clear
)
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
);
64 swfdec_video_get_width (SwfdecAsContext
*cx
, SwfdecAsObject
*object
, guint argc
,
65 SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
67 SwfdecVideoMovie
*video
;
70 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE
, &video
, "");
72 if (video
->provider
) {
73 w
= swfdec_video_provider_get_width (video
->provider
);
77 *rval
= swfdec_as_value_from_integer (cx
, w
);
81 swfdec_video_get_height (SwfdecAsContext
*cx
, SwfdecAsObject
*object
, guint argc
,
82 SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
84 SwfdecVideoMovie
*video
;
87 SWFDEC_AS_CHECK (SWFDEC_TYPE_VIDEO_MOVIE
, &video
, "");
89 if (video
->provider
) {
90 h
= swfdec_video_provider_get_height (video
->provider
);
94 *rval
= swfdec_as_value_from_integer (cx
, h
);
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);
106 swfdec_video_set_deblocking (SwfdecAsContext
*cx
, SwfdecAsObject
*object
, guint argc
,
107 SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
109 SWFDEC_STUB ("Video.deblocking (set)");
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
);
121 swfdec_video_set_smoothing (SwfdecAsContext
*cx
, SwfdecAsObject
*object
, guint argc
,
122 SwfdecAsValue
*argv
, SwfdecAsValue
*rval
)
124 SWFDEC_STUB ("Video.smoothing (set)");
128 swfdec_video_movie_init_properties (SwfdecAsContext
*cx
)
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
))
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
))
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
);