OSDN Git Service

stop using trunk directory in rectool
[rec10/rec10-git.git] / tstools / DtsEdit / src / gpac / internal / swf_dev.h
1 /*\r
2  *                      GPAC - Multimedia Framework C SDK\r
3  *\r
4  *                      Copyright (c) Jean Le Feuvre 2000-2005\r
5  *                                      All rights reserved\r
6  *\r
7  *  This file is part of GPAC / Scene Management sub-project\r
8  *\r
9  *  GPAC is free software; you can redistribute it and/or modify\r
10  *  it under the terms of the GNU Lesser General Public License as published by\r
11  *  the Free Software Foundation; either version 2, or (at your option)\r
12  *  any later version.\r
13  *   \r
14  *  GPAC is distributed in the hope that it will be useful,\r
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
17  *  GNU Lesser General Public License for more details.\r
18  *   \r
19  *  You should have received a copy of the GNU Lesser General Public\r
20  *  License along with this library; see the file COPYING.  If not, write to\r
21  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. \r
22  *\r
23  */\r
24 \r
25 #ifndef _GF_SWF_DEV_H_\r
26 #define _GF_SWF_DEV_H_\r
27 \r
28 #include <gpac/scene_manager.h>\r
29 #include <gpac/color.h>\r
30 \r
31 #define SWF_TWIP_SCALE                          (1/20.0f)\r
32 \r
33 \r
34 typedef struct SWFReader SWFReader;\r
35 typedef struct SWFSound SWFSound;\r
36 typedef struct SWFText SWFText;\r
37 typedef struct SWFEditText SWFEditText;\r
38 typedef struct SWF_Button SWF_Button;\r
39 typedef struct SWFShape SWFShape;\r
40 typedef struct SWFFont SWFFont;\r
41 typedef struct SWFAction SWFAction;\r
42 \r
43 enum\r
44 {\r
45         SWF_PLACE ,\r
46         SWF_REPLACE,\r
47         SWF_MOVE,\r
48 };\r
49 \r
50 \r
51 struct SWFReader\r
52 {\r
53         GF_SceneLoader *load;\r
54         FILE *input;\r
55 \r
56         char *localPath;\r
57         /*file header*/\r
58         u32 length;\r
59         char *mem;\r
60         u32 frame_rate;\r
61         u32 frame_count;\r
62         Fixed width, height;\r
63         Bool has_interact, no_as;\r
64 \r
65         /*copy of the swf import flags*/        \r
66         u32 flags;\r
67 \r
68         /*bit reader*/\r
69         GF_BitStream *bs;\r
70         GF_Err ioerr;   \r
71         \r
72         u32 current_frame;\r
73 \r
74         /*current tag*/\r
75         u32 tag, size;\r
76 \r
77         GF_List *display_list;\r
78         u32 max_depth;\r
79 \r
80         /*defined fonts*/\r
81         GF_List *fonts;\r
82 \r
83         /*define sounds*/\r
84         GF_List *sounds;\r
85 \r
86         /*the one and only sound stream for current timeline*/\r
87         SWFSound *sound_stream;\r
88 \r
89         /*when creating sprites: \r
90                 1- all BIFS AUs in sprites are random access\r
91                 2- depth is ignored in Sprites\r
92         */\r
93         u32 current_sprite_id;\r
94 \r
95         /*the parser can decide to remove nearly aligned pppoints in lineTo sequences*/\r
96         /*flatten limit - 0 means no flattening*/\r
97         Fixed flat_limit;\r
98         /*number of points removed*/\r
99         u32 flatten_points;\r
100 \r
101         u8 *jpeg_hdr;\r
102         u32 jpeg_hdr_size;\r
103 \r
104 \r
105         /*callback functions for translator*/\r
106         GF_Err (*set_backcol)(SWFReader *read, u32 xrgb);\r
107         GF_Err (*show_frame)(SWFReader *read);\r
108 \r
109         /*checks if display list is large enough - returns 1 if yes, 0 otherwise (and allocate space)*/\r
110         Bool (*allocate_depth)(SWFReader *read, u32 depth); \r
111         GF_Err (*place_obj)(SWFReader *read, u32 depth, u32 ID, u32 prev_id, u32 type, GF_Matrix2D *mat, GF_ColorMatrix *cmat, GF_Matrix2D *prev_mat, GF_ColorMatrix *prev_cmat);\r
112         GF_Err (*remove_obj)(SWFReader *read, u32 depth, u32 ID);\r
113 \r
114         GF_Err (*define_shape)(SWFReader *read, SWFShape *shape, SWFFont *parent_font, Bool last_sub_shape);\r
115         GF_Err (*define_sprite)(SWFReader *read, u32 nb_frames);\r
116         GF_Err (*define_text)(SWFReader *read, SWFText *text);\r
117         GF_Err (*define_edit_text)(SWFReader *read, SWFEditText *text);\r
118         /*@button is NULL to signal end of button declaration, non-null otherwise. "action" callback will be \r
119         called inbetween*/\r
120         GF_Err (*define_button)(SWFReader *read, SWF_Button *button);\r
121 \r
122         GF_Err (*setup_image)(SWFReader *read, u32 ID, char *fileName);\r
123         /*called whenever a sound is found. For soundstreams, called twice, once on the header (declaration), \r
124         and one on the first soundstream block for offset signaling*/\r
125         GF_Err (*setup_sound)(SWFReader *read, SWFSound *snd, Bool soundstream_first_block);\r
126         GF_Err (*start_sound)(SWFReader *read, SWFSound *snd, Bool stop);\r
127         /*performs an action, returns 0 if action not supported*/\r
128         Bool (*action)(SWFReader *read, SWFAction *act);\r
129 \r
130         void (*finalize)(SWFReader *read);\r
131 \r
132 \r
133         /* <BIFS conversion state> */\r
134 \r
135         /*all simple appearances (no texture)*/\r
136         GF_List *apps;\r
137 \r
138         GF_List *buttons;\r
139 \r
140         /*current BIFS stream*/\r
141         GF_StreamContext *bifs_es;\r
142         GF_AUContext *bifs_au;\r
143 \r
144         GF_StreamContext *bifs_dict_es;\r
145         GF_AUContext *bifs_dict_au;\r
146 \r
147         /*for sound insert*/\r
148         GF_Node *root;\r
149 \r
150         /*current OD AU*/\r
151         GF_StreamContext *od_es;\r
152         GF_AUContext *od_au;\r
153 \r
154         GF_Node *cur_shape;\r
155         u16 prev_od_id, prev_es_id;\r
156 \r
157         u32 wait_frame;\r
158         SWF_Button *btn;\r
159         GF_List *btn_over, *btn_not_over, *btn_active, *btn_not_active;\r
160 \r
161         /* </BIFS conversion state> */\r
162 };\r
163 \r
164 \r
165 void swf_report(SWFReader *read, GF_Err e, char *format, ...);\r
166 SWFFont *swf_find_font(SWFReader *read, u32 fontID);\r
167 GF_Err swf_parse_sprite(SWFReader *read);\r
168 \r
169 \r
170 GF_Err swf_to_bifs_init(SWFReader *read);\r
171 \r
172 \r
173 \r
174 typedef struct\r
175 {\r
176         Fixed x, y;\r
177         Fixed w, h;\r
178 } SWFRec;\r
179 \r
180 typedef struct\r
181 {\r
182         /*0: not defined, otherwise index of shape*/\r
183         u32 nbType;\r
184         /*0: moveTo, 1: lineTo, 2: quad curveTo*/\r
185         u32 *types;\r
186         SFVec2f *pts;\r
187         u32 nbPts;\r
188         /*used by SWF->BIFS for IndexedCurveSet*/\r
189         u32 *idx;\r
190 } SWFPath;\r
191 \r
192 typedef struct\r
193 {\r
194         u32 type;\r
195         u32 solid_col;\r
196         u32 nbGrad;\r
197         u32 *grad_col;\r
198         u8 *grad_ratio;\r
199         GF_Matrix2D mat;\r
200         u32 img_id;\r
201         Fixed width;\r
202 \r
203         SWFPath *path;\r
204 } SWFShapeRec;\r
205 \r
206 struct SWFShape \r
207 {\r
208         GF_List *fill_left, *fill_right, *lines;\r
209         u32 ID;\r
210         SWFRec rc;\r
211 };\r
212 \r
213 /*SWF font object*/\r
214 struct SWFFont\r
215 {\r
216         u32 fontID;\r
217         u32 nbGlyphs;\r
218         GF_List *glyphs;\r
219 \r
220         /*the following may all be overridden by a DefineFontInfo*/\r
221 \r
222         /*index -> glyph code*/\r
223         u16 *glyph_codes;\r
224         /*index -> glyph advance*/\r
225         s16 *glyph_adv;\r
226 \r
227         /*font flags (SWF 3.0)*/\r
228         Bool has_layout;\r
229         Bool has_shiftJIS;\r
230         Bool is_unicode, is_ansi;\r
231         Bool is_bold, is_italic;\r
232         s16 ascent, descent, leading;\r
233 \r
234         /*font familly*/\r
235         char *fontName;\r
236 };\r
237 \r
238 /*chunk of text with the same aspect (font, col)*/\r
239 typedef struct\r
240 {\r
241         u32 fontID;\r
242         u32 col;\r
243         /*font size*/\r
244         u32 fontSize;\r
245         /*origin point in local metrics*/\r
246         Fixed orig_x, orig_y;\r
247 \r
248         u32 nbGlyphs;\r
249         u32 *indexes;\r
250         Fixed *dx;\r
251 } SWFGlyphRec;\r
252 \r
253 struct SWFText\r
254 {\r
255         u32 ID;\r
256         GF_Matrix2D mat;\r
257         GF_List *text;\r
258 };\r
259 \r
260 struct SWFEditText \r
261 {\r
262         u32 ID;\r
263         char *init_value;\r
264         SWFRec bounds;\r
265         Bool word_wrap, multiline, password, read_only, auto_size, no_select, html, outlines, has_layout, border;\r
266         u32 color;\r
267         Fixed max_length, font_height;\r
268         u32 fontID;\r
269 \r
270         u32 align;\r
271         Fixed left, right, indent, leading;\r
272 };\r
273 \r
274 \r
275 enum\r
276 {\r
277         SWF_SND_UNCOMP = 0,\r
278         SWF_SND_ADPCM,\r
279         SWF_SND_MP3\r
280 };\r
281 \r
282 struct SWFSound\r
283 {\r
284         u32 ID;\r
285         u8 format;\r
286         /*0: 5.5k - 1: 11k - 2: 22k - 3: 44k*/\r
287         u8 sound_rate;\r
288         u8 bits_per_sample;\r
289         Bool stereo;\r
290         u16 sample_count;\r
291         u32 frame_delay_ms;\r
292 \r
293         /*IO*/\r
294         FILE *output;\r
295         char *szFileName;\r
296 \r
297         /*set when sound is setup (OD inserted)*/\r
298         Bool is_setup;\r
299 };\r
300 \r
301 typedef struct \r
302 {\r
303         /*interaction states*/\r
304         Bool hitTest, down, over, up;\r
305         u32 character_id;\r
306         u16 depth;\r
307         GF_Matrix2D mx;\r
308         GF_ColorMatrix cmx;\r
309         Bool skip;\r
310 } SWF_ButtonRecord;\r
311 \r
312 \r
313 struct SWF_Button \r
314 {\r
315         u32 count;\r
316         SWF_ButtonRecord buttons[40];\r
317         u32 ID;\r
318 };\r
319 \r
320 /*AS codes.*/\r
321 enum\r
322 {\r
323         GF_SWF_AS3_GOTO_FRAME,\r
324         GF_SWF_AS3_GET_URL,\r
325         GF_SWF_AS3_NEXT_FRAME,\r
326         GF_SWF_AS3_PREV_FRAME,\r
327         GF_SWF_AS3_PLAY,\r
328         GF_SWF_AS3_STOP,\r
329         GF_SWF_AS3_TOGGLE_QUALITY,\r
330         GF_SWF_AS3_STOP_SOUNDS,\r
331         GF_SWF_AS3_WAIT_FOR_FRAME,\r
332         GF_SWF_AS3_SET_TARGET,\r
333         GF_SWF_AS3_GOTO_LABEL,\r
334 };\r
335 \r
336 enum\r
337 {\r
338         GF_SWF_COND_IDLE_TO_OVERDOWN = 1,\r
339         GF_SWF_COND_OUTDOWN_TO_IDLE = 1<<1,\r
340         GF_SWF_COND_OUTDOWN_TO_OVERDOWN = 1<<2,\r
341         GF_SWF_COND_OVERDOWN_TO_OUTDOWN = 1<<3,\r
342         GF_SWF_COND_OVERDOWN_TO_OUTUP = 1<<4,\r
343         GF_SWF_COND_OVERUP_TO_OVERDOWN = 1<<5,\r
344         GF_SWF_COND_OVERUP_TO_IDLE = 1<<6,\r
345         GF_SWF_COND_IDLE_TO_OVERUP = 1<<7,\r
346         GF_SWF_COND_OVERDOWN_TO_IDLE = 1<<8,\r
347 };\r
348 \r
349 struct SWFAction\r
350 {\r
351         u32 type;\r
352         u32 frame_number;\r
353         u32 button_mask, button_key;\r
354         /*target (geturl/set_target), label (goto_frame)*/\r
355         char *target;\r
356         char *url;\r
357 };\r
358 \r
359 \r
360 \r
361 #endif /*_GF_SWF_DEV_H_*/\r