1 /* ====================================================================
2  * Copyright (c) 2000-2001 by Soheil Seyfaie. All rights reserved.
3  * This program is free software; you can redistribute it and/or modify
4  * it under the same terms as Perl itself.
5  * ====================================================================
6  *
7  * $Author$
8  * $Id$
9  */
10 
11 
12 #include "EXTERN.h"
13 #include "perl.h"
14 #include "XSUB.h"
15 
16 #include "SWF.h"
17 #include "perl_swf.h"
18 
19 
20 MODULE = SWF::Movie	PACKAGE = SWF::Movie		PREFIX = SWFMovie_
21 PROTOTYPES: ENABLE
22 
23 void
24 destroySWFMovie(movie)
25 	SWF::Movie	movie
26         ALIAS:
27 	SWF::Movie::DESTROY = 1
28 	CODE:
29         S_DEBUG(2, fprintf(stderr, "Movie DESTROY CALLED\n"));
30 	swf_stash_refcnt_dec((SV*)SvRV(ST(0)));
31         destroySWFMovie(movie);
32 
33 SWF::Movie
34 SWFMovie_new(package="SWF::Movie")
35 	char *package
36 	CODE:
37         RETVAL = newSWFMovie();
38         ST(0) = sv_newmortal();
39         sv_setref_pv(ST(0), package, (void*)RETVAL);
40 
41 
42 SWF::Movie
43 newSWFMovieWithVersion(version)
44 	int	version
45 
46 void
47 SWFMovie_setRate(movie, rate)
48 	SWF::Movie	movie
49 	float	rate
50 
51 float
52 SWFMovie_getRate(movie)
53 	SWF::Movie movie
54 
55 void
56 SWFMovie_setDimension(movie, x, y)
57 	SWF::Movie	movie
58 	int	x
59 	int	y
60 
61 void
62 SWFMovie_setNumberOfFrames(movie, frames)
63 	SWF::Movie	movie
64 	int	frames
65 	ALIAS:
66 	SWF::Movie::setFrames = 1
67 
68 void
69 SWFMovie_setBackground(movie, r, g, b)
70 	SWF::Movie	movie
71 	int	r
72 	int	g
73 	int	b
74 
75 void
76 SWFMovie_protect(movie, password=0)
77 	SWF::Movie	movie
78 	char	*password
79 
80 void
81 SWFMovie_nextFrame(movie)
82 	SWF::Movie	movie
83 
84 void
85 SWFMovie_labelFrame(movie, label)
86 	SWF::Movie	movie
87 	char *	label
88 
89 void
90 SWFMovie_namedAnchor(movie, label)
91 	SWF::Movie	movie
92 	char *	label
93 
94 int
95 SWFMovie_xs_output(movie, compresslevel=-1)
96 	SWF::Movie movie
97 	int compresslevel
98 	CODE:
99 	if(compresslevel >= -1)
100 		Ming_setSWFCompression(compresslevel);
101 	RETVAL = SWFMovie_output(movie, fileOutputMethod, stdout);
102 	OUTPUT:
103 	 RETVAL
104 
105 
106 int
107 SWFMovie_save(movie, filename, compresslevel=-1)
108 	SWF::Movie movie
109         char *     filename
110 	int compresslevel
111         PREINIT:
112         FILE    *f;
113 	CODE:
114 	if (!(f = fopen(filename, "wb"))) {
115 		fprintf(stderr, "Unable to open %s\n", filename);
116 		RETVAL=0;	/* to avoid a warning  ("...may be used uninitialized..") */
117 		ST(0) = &sv_undef;
118 	}else{
119 		if(compresslevel >= -1)
120 			Ming_setSWFCompression(compresslevel);
121                 RETVAL = SWFMovie_output(movie, fileOutputMethod, f);
122                 fclose(f);
123 	}
124         OUTPUT:
125         RETVAL
126 
127 void
128 SWFMovie_addExport(movie, block, name)
129 	SWF::Movie movie
130 	SWF::Block block = (SWF__Block) SvIV((SV*)SvRV(ST(1)));
131 	char *name
132 	CODE:
133 	swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1)));
134 	if ( block ) SWFMovie_addExport(movie, block, name);
135 
136 void
137 SWFMovie_writeExports(movie)
138 	SWF::Movie movie
139 
140 SWF::DisplayItem
141 SWFMovie_add(movie, block)
142 	SWF::Movie movie
143 	SWF::Block block = (SWF__Block) SvIV((SV*)SvRV(ST(1)));
144 	CODE:
145 	swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1)));
146 	RETVAL = SWFMovie_add(movie, block);
147 	ST(0) = sv_newmortal();
148 	sv_setref_pv(ST(0), "SWF::DisplayItem", (void*)RETVAL);
149 
150 void
151 SWFMovie_remove(movie, item)
152         SWF::Movie movie
153         SWF::DisplayItem item
154 
155 void
156 SWFMovie_setSoundStream(movie, sound, skip=0.0)
157 	SWF::Movie movie
158 	SWF::SoundStream sound
159 	float skip
160 	CODE:
161 	swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1)));
162 	SWFMovie_setSoundStreamAt(movie, sound, skip);
163 
164 SWF::SoundInstance
165 SWFMovie_startSound(movie, sound)
166 	SWF::Movie movie
167 	SWF::Sound sound
168 	CODE:
169 	swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1)));
170 	RETVAL = SWFMovie_startSound(movie, sound);
171 	ST(0) = sv_newmortal();
172 	sv_setref_pv(ST(0), "SWF::SoundInstance", (void*)RETVAL);
173 
174 void
175 SWFMovie_stopSound(movie, sound)
176 	SWF::Movie movie
177 	SWF::Sound sound
178 	CODE:
179 	SWFMovie_stopSound(movie, sound);
180 
181 void
182 SWFMovie_setNetworkAccess(movie, flag)
183 	SWF::Movie movie
184 	int flag
185 
186 void
187 SWFMovie_addMetadata(movie, xml)
188 	SWF::Movie movie
189 	char *xml
190 
191 void
192 SWFMovie_setScriptLimits(movie, maxRecursion, timeout)
193 	SWF::Movie movie
194 	int maxRecursion
195 	int timeout
196 
197 void
198 SWFMovie_setTabIndex(movie, depth, index)
199 	SWF::Movie movie
200 	int depth
201 	int index
202 
203 SWF::FontCharacter
204 SWFMovie_addFont(movie, font)
205 	SWF::Movie movie
206 	SWF::Font font = (SWF__Font) SvIV((SV*)SvRV(ST(1)));
207 	CODE:
208 	swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(1)));
209 	RETVAL = SWFMovie_addFont(movie, font);
210 	ST(0) = sv_newmortal();
211 	sv_setref_pv(ST(0), "SWF::FontCharacter", (void*)RETVAL);
212 
213 SWF::FontCharacter
214 SWFMovie_importFont(movie, file, name)
215 	SWF::Movie movie
216 	const char *file
217 	const char *name
218 	CODE:
219 	RETVAL = SWFMovie_importFont(movie, file, name);
220 	ST(0) = sv_newmortal();
221 	sv_setref_pv(ST(0), "SWF::FontCharacter", (void*)RETVAL);
222 
223 SWF::Character
224 SWFMovie_importCharacter(movie, url, name)
225 	SWF::Movie movie
226 	const char *url
227 	const char *name
228 	CODE:
229 	RETVAL = SWFMovie_importCharacter(movie, url, name);
230 	ST(0) = sv_newmortal();
231 	sv_setref_pv(ST(0), "SWF::Character", (void*)RETVAL);
232 
233 void
234 SWFMovie_assignSymbol(movie, character, name)
235 	SWF::Movie movie
236 	SWF::Character character = NO_INIT
237 	const char *name
238         CODE:
239         character = (SWF__Character) SvIV((SV*)SvRV(ST(1)));
240 	SWFMovie_assignSymbol(movie, character, name);
241 
242 
243 void
244 SWFMovie_defineScene(movie, offset, name)
245 	SWF::Movie movie
246 	unsigned int offset
247 	const char *name
248 
249 int
250 SWFMovie_replace(movie, item, block)
251 	SWF::Movie movie
252 	SWF::DisplayItem item
253 	SWF::Block block = (SWF__Block) SvIV((SV*)SvRV(ST(2)));
254 	PREINIT:
255 	SWFMovieBlockType ublock;
256 	CODE:
257 	swf_stash_refcnt_inc((SV*)SvRV(ST(0)), (SV*)SvRV(ST(2)));
258 	ublock.block = block;
259 	RETVAL = SWFMovie_replace_internal(movie, item, ublock);
260 	OUTPUT:
261 	 RETVAL
262 
263