big merge from master, fix rpm creation, drop fetching swfdec
[gnash.git] / testsuite / misc-ming.all / streamingSoundTest1.c
blob2b9026282d322232f402a11f81308dfb75aff103
1 /*
2 * Copyright (C) 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program 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
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
20 * Test for streaming sound
25 #include <stdlib.h>
26 #include <stdio.h>
27 #include <sys/types.h>
28 #include <sys/stat.h>
29 #include <unistd.h>
31 #include <ming.h>
33 #include "ming_utils.h"
35 #define OUTPUT_VERSION 6
36 #define OUTPUT_FILENAME "streamingSoundTest1.swf"
39 int
40 main(int argc, char** argv)
42 SWFMovie mo;
43 SWFMovieClip mc;
44 SWFSoundStream ss;
45 FILE* sound_f;
46 const char* sound_filename;
47 SWFDisplayItem it;
48 struct stat statbuf;
50 if ( argc>1 ) {
51 sound_filename=argv[1];
52 } else {
53 sound_filename="sound1.mp3";
56 sound_f = fopen(sound_filename, "r");
57 if ( ! sound_f ) {
58 perror(sound_filename);
59 return EXIT_FAILURE;
62 printf("Using sound file %s\n", sound_filename);
64 if ( -1 == fstat(fileno(sound_f), &statbuf) )
66 perror("fstat");
67 return EXIT_FAILURE;
69 if ( S_ISDIR(statbuf.st_mode) )
71 fprintf(stderr, "%s is a directory, we need a file\n", sound_filename);
72 return EXIT_FAILURE;
75 Ming_init();
76 Ming_useSWFVersion (OUTPUT_VERSION);
78 mo = newSWFMovie();
79 SWFMovie_setDimension(mo, 100, 100);
80 SWFMovie_setRate(mo, 1);
82 ss = newSWFSoundStream(sound_f);
84 mc = newSWFMovieClip();
85 SWFMovieClip_setSoundStream(mc, ss, 1);
86 SWFMovieClip_nextFrame(mc);
88 it = SWFMovie_add(mo, mc);
89 SWFMovie_nextFrame(mo);
90 SWFMovie_nextFrame(mo);
91 SWFMovie_nextFrame(mo);
92 SWFMovie_nextFrame(mo);
93 SWFMovie_nextFrame(mo);
94 SWFMovie_nextFrame(mo);
95 SWFMovie_nextFrame(mo);
96 SWFMovie_nextFrame(mo);
98 //Output movie
99 puts("Saving " OUTPUT_FILENAME );
100 SWFMovie_save(mo, OUTPUT_FILENAME);
102 return EXIT_SUCCESS;