1 /*
2  *   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3  *   2011 Free Software Foundation, Inc.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (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  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17  *
18  *
19  */
20 
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <ming.h>
24 #include <errno.h>
25 
26 #include "ming_utils.h"
27 
28 #define OUTPUT_VERSION 8
29 #define OUTPUT_FILENAME "StreamSoundTest.swf"
30 
31 void addSoundExport(SWFMovie mo);
32 
33 void
addSoundExport(SWFMovie mo)34 addSoundExport(SWFMovie mo)
35 {
36     SWFSoundStream sounda;
37     SWFInput inp;
38 
39     FILE* f;
40 
41     f = fopen(MEDIADIR"/click.mp3", "r");
42 
43     if (!f) {
44         perror(MEDIADIR"/click.mp3");
45         exit(EXIT_FAILURE);
46     }
47 
48     inp = newSWFInput_file(f);
49 
50     sounda = newSWFSoundStream_fromInput(inp);
51 
52     SWFMovie_setSoundStream(mo, sounda);
53 }
54 
55 int
main(int argc,char ** argv)56 main(int argc, char** argv)
57 {
58 	SWFMovie mo;
59 	const char *srcdir=".";
60 	SWFMovieClip  dejagnuclip;
61     SWFDisplayItem it;
62 
63 
64 	/*********************************************
65 	 *
66 	 * Initialization
67 	 *
68 	 *********************************************/
69 
70 	if ( argc>1 ) srcdir=argv[1];
71 	else
72 	{
73 		fprintf(stderr, "Usage: %s\n", argv[0]);
74 		return 1;
75 	}
76 
77 	puts("Setting things up");
78 
79 	Ming_init();
80     Ming_useSWFVersion(OUTPUT_VERSION);
81 	Ming_setScale(20.0); /* let's talk pixels */
82 
83 	mo = newSWFMovie();
84 	SWFMovie_setRate(mo, 0.5);
85 	SWFMovie_setDimension(mo, 640, 400);
86 
87 	/*********************************************
88 	 *
89 	 * Body
90 	 *
91 	 *********************************************/
92 
93 	dejagnuclip = get_dejagnu_clip((SWFBlock)get_default_font(srcdir), 10,
94             0, 80, 800, 600);
95 	it = SWFMovie_add(mo, (SWFBlock)dejagnuclip);
96 
97     SWFMovie_add(mo, newSWFAction(
98             "_root.onEnterFrame = function() { trace('Frame'); };"
99             ));
100 
101 	SWFMovie_nextFrame(mo);  /* end of frame1 */
102 	addSoundExport(mo);
103 	SWFMovie_nextFrame(mo);  /* end of frame2 */
104 	SWFMovie_nextFrame(mo);  /* end of frame3 */
105 	SWFMovie_nextFrame(mo);  /* end of frame4 */
106 	SWFMovie_nextFrame(mo);  /* end of frame5 */
107 
108 	/*****************************************************
109 	 *
110 	 * Output movie
111 	 *
112 	 *****************************************************/
113 
114 	puts("Saving " OUTPUT_FILENAME );
115 
116 	SWFMovie_save(mo, OUTPUT_FILENAME);
117 
118 	return 0;
119 }
120