summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/libflash/flash.cc
authorkergoth <kergoth>2002-01-25 22:14:26 (UTC)
committer kergoth <kergoth>2002-01-25 22:14:26 (UTC)
commit15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff)
treec2fa0399a2c47fda8e2cd0092c73a809d17f68eb /core/multimedia/opieplayer/libflash/flash.cc
downloadopie-15318cad33835e4e2dc620d033e43cd930676cdd.zip
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz
opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2
Initial revision
Diffstat (limited to 'core/multimedia/opieplayer/libflash/flash.cc') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libflash/flash.cc275
1 files changed, 275 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libflash/flash.cc b/core/multimedia/opieplayer/libflash/flash.cc
new file mode 100644
index 0000000..75d351c
--- a/dev/null
+++ b/core/multimedia/opieplayer/libflash/flash.cc
@@ -0,0 +1,275 @@
1/////////////////////////////////////////////////////////////
2// Flash Plugin and Player
3// Copyright (C) 1998,1999 Olivier Debon
4//
5// This program is free software; you can redistribute it and/or
6// modify it under the terms of the GNU General Public License
7// as published by the Free Software Foundation; either version 2
8// of the License, or (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18//
19///////////////////////////////////////////////////////////////
20// Author : Olivier Debon <odebon@club-internet.fr>
21//
22
23#include "swf.h"
24#include "graphic16.h"
25#include "graphic24.h"
26#include "graphic32.h"
27
28#ifdef RCSID
29static char *rcsid = "$Id$";
30#endif
31
32// Interface with standard C
33extern "C" {
34
35FlashHandle
36FlashNew()
37{
38 FlashMovie *fh;
39
40 fh = new FlashMovie;
41
42 fh->main = new CInputScript;
43
44 return (FlashHandle)fh;
45}
46
47int
48FlashParse(FlashHandle flashHandle, int level, char *data, long size)
49{
50 FlashMovie *fh;
51 CInputScript *script;
52 int status = FLASH_PARSE_ERROR;
53
54 fh = (FlashMovie *)flashHandle;
55
56 for(script = fh->main; script != NULL; script = script->next) {
57 if (script->level == level) {
58 status = script->ParseData(fh, data, size);
59
60 if (status & FLASH_PARSE_START) {
61 fh->msPerFrame = 1000/fh->main->frameRate;
62 script->program->rewindMovie();
63 }
64 break;
65 }
66 }
67
68 return status;
69}
70
71void
72FlashGetInfo(FlashHandle flashHandle, struct FlashInfo *fi)
73{
74 FlashMovie *fh;
75
76 fh = (FlashMovie *)flashHandle;
77
78 fi->version = fh->main->m_fileVersion;
79 fi->frameRate = fh->main->frameRate;
80 fi->frameCount = fh->main->frameCount;
81 fi->frameWidth = fh->main->frameRect.xmax - fh->main->frameRect.xmin;
82 fi->frameHeight = fh->main->frameRect.ymax - fh->main->frameRect.ymin;
83}
84
85long FlashGraphicInit(FlashHandle flashHandle, FlashDisplay *fd)
86{
87 FlashMovie *fh;
88
89 fh = (FlashMovie *)flashHandle;
90
91 switch (fd->bpp) {
92 case 4:
93 fh->gd = new GraphicDevice32(fd);
94 break;
95 case 3:
96 fh->gd = new GraphicDevice24(fd);
97 break;
98 case 2:
99 fh->gd = new GraphicDevice16(fd);
100 break;
101 default:
102 fprintf(stderr, "Unsupported depth\n");
103 }
104
105 fh->gd->setMovieDimension(fh->main->frameRect.xmax - fh->main->frameRect.xmin,
106 fh->main->frameRect.ymax - fh->main->frameRect.ymin);
107
108 return 1;// Ok
109}
110
111void
112FlashSoundInit(FlashHandle flashHandle, char *device)
113{
114 FlashMovie *fh;
115
116 fh = (FlashMovie *)flashHandle;
117
118 fh->sm = new SoundMixer(device);
119}
120
121void
122FlashZoom(FlashHandle flashHandle, int zoom)
123{
124 FlashMovie *fh;
125
126 fh = (FlashMovie *)flashHandle;
127
128 fh->gd->setMovieZoom(zoom);
129}
130
131void
132FlashOffset(FlashHandle flashHandle, int x, int y)
133{
134 FlashMovie *fh;
135
136 fh = (FlashMovie *)flashHandle;
137
138 fh->gd->setMovieOffset(x,y);
139}
140
141long
142FlashExec(FlashHandle flashHandle, long flag,
143 FlashEvent *fe, struct timeval *wakeDate)
144{
145 FlashMovie *fh;
146 long wakeUp = 0;
147
148 fh = (FlashMovie *)flashHandle;
149
150 if (fh->main == NULL) return 0; // Not ready
151 if (fh->main->program == NULL) return 0; // Not ready
152 if (fh->main->program->nbFrames == 0) return 0; // Still not ready
153 if (fh->gd == 0) return 0;
154
155 switch (flag & FLASH_CMD_MASK) {
156 case FLASH_STOP:
157 fh->main->program->pauseMovie();
158 wakeUp = 0;
159 break;
160 case FLASH_CONT:
161 fh->main->program->continueMovie();
162 wakeUp = FLASH_STATUS_WAKEUP;
163 break;
164 case FLASH_REWIND:
165 fh->main->program->rewindMovie();
166 wakeUp = 0;
167 break;
168 case FLASH_STEP:
169 fh->main->program->nextStepMovie();
170 wakeUp = 0;
171 break;
172 }
173
174 if (flag & FLASH_WAKEUP) {
175 // Compute next wakeup time
176 gettimeofday(wakeDate,0);
177 wakeDate->tv_usec += fh->msPerFrame*1000;
178 if (wakeDate->tv_usec > 1000000) {
179 wakeDate->tv_usec -= 1000000;
180 wakeDate->tv_sec++;
181 }
182
183 // Play frame
184 wakeUp = fh->processMovie(fh->gd, fh->sm);
185 }
186
187 if (checkFlashTimer(&fh->scheduledTime)) {
188 if (fh->handleEvent(fh->gd, fh->sm, &fh->scheduledEvent)) {
189 wakeUp = 1;
190 }
191
192 setFlashTimer(&fh->scheduledTime, -1);
193 }
194
195 if (flag & FLASH_EVENT) {
196 wakeUp = fh->handleEvent(fh->gd, fh->sm, fe);
197 if (wakeUp) {
198 /* Wake up at once, except for mouse move (40 ms after) */
199 gettimeofday(wakeDate,0);
200 if (fe->type == FeMouseMove) {
201 wakeDate->tv_usec += 40*1000;
202 if (wakeDate->tv_usec > 1000000) {
203 wakeDate->tv_usec -= 1000000;
204 wakeDate->tv_sec++;
205 }
206 }
207 }
208 }
209
210 return wakeUp || (fh->scheduledTime.tv_sec != -1);
211}
212
213void FlashSetGetSwfMethod(FlashHandle flashHandle, void (*getSwf)(char *url, int level, void *clientData), void *clientData)
214{
215 FlashMovie *fh;
216
217 fh = (FlashMovie *)flashHandle;
218
219 fh->getSwf = getSwf;
220 fh->getSwfClientData = clientData;
221}
222
223
224void
225FlashSetCursorOnOffMethod(FlashHandle flashHandle, void (*cursorOnOff)(int , void *), void *clientData)
226{
227 FlashMovie *fh;
228
229 fh = (FlashMovie *)flashHandle;
230
231 fh->cursorOnOff = cursorOnOff;
232 fh->cursorOnOffClientData = clientData;
233}
234
235void
236FlashSetGetUrlMethod(FlashHandle flashHandle, void (*getUrl)(char *, char *, void *), void *clientData)
237{
238 FlashMovie *fh;
239
240 fh = (FlashMovie *)flashHandle;
241
242 fh->getUrl = getUrl;
243 fh->getUrlClientData = clientData;
244}
245
246void
247FlashClose(FlashHandle flashHandle)
248{
249 FlashMovie *fh;
250
251 fh = (FlashMovie *)flashHandle;
252
253 delete fh;
254}
255
256void
257FlashSettings(FlashHandle flashHandle, long settings)
258{
259 FlashMovie *fh;
260
261 fh = (FlashMovie *)flashHandle;
262
263 fh->main->program->modifySettings( settings );
264}
265
266int shape_size,shape_nb,shaperecord_size,shaperecord_nb,style_size,style_nb;
267
268void flash_dump(void)
269{
270 printf("flash: shape_size=%d (nb=%d)\n",shape_size,shape_nb);
271 printf("flash: shaperecord_size=%d (nb=%d)\n",shaperecord_size,shaperecord_nb);
272 printf("flash: style_size=%d (nb=%d)\n",style_size,style_nb);
273}
274
275}; /* end of extern C */