author | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-01-25 22:14:26 (UTC) |
commit | 15318cad33835e4e2dc620d033e43cd930676cdd (patch) (unidiff) | |
tree | c2fa0399a2c47fda8e2cd0092c73a809d17f68eb /core/multimedia/opieplayer/libflash/libflashplugin.cpp | |
download | opie-15318cad33835e4e2dc620d033e43cd930676cdd.zip opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.gz opie-15318cad33835e4e2dc620d033e43cd930676cdd.tar.bz2 |
Initial revision
Diffstat (limited to 'core/multimedia/opieplayer/libflash/libflashplugin.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/libflash/libflashplugin.cpp | 223 |
1 files changed, 223 insertions, 0 deletions
diff --git a/core/multimedia/opieplayer/libflash/libflashplugin.cpp b/core/multimedia/opieplayer/libflash/libflashplugin.cpp new file mode 100644 index 0000000..538c695 --- a/dev/null +++ b/core/multimedia/opieplayer/libflash/libflashplugin.cpp | |||
@@ -0,0 +1,223 @@ | |||
1 | /********************************************************************** | ||
2 | ** Copyright (C) 2001 Trolltech AS. All rights reserved. | ||
3 | ** | ||
4 | ** This file is part of Qtopia Environment. | ||
5 | ** | ||
6 | ** This file may be distributed and/or modified under the terms of the | ||
7 | ** GNU General Public License version 2 as published by the Free Software | ||
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
9 | ** packaging of this file. | ||
10 | ** | ||
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
13 | ** | ||
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
15 | ** | ||
16 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
17 | ** not clear to you. | ||
18 | ** | ||
19 | **********************************************************************/ | ||
20 | #include "libflashplugin.h" | ||
21 | |||
22 | #if 0 | ||
23 | |||
24 | bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { | ||
25 | } | ||
26 | |||
27 | |||
28 | bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { | ||
29 | } | ||
30 | |||
31 | |||
32 | bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { | ||
33 | samplesRead = samples; | ||
34 | } | ||
35 | |||
36 | |||
37 | bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { | ||
38 | } | ||
39 | |||
40 | |||
41 | bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) { | ||
42 | } | ||
43 | |||
44 | |||
45 | bool LibFlashPlugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) { | ||
46 | /* | ||
47 | int format = MPEG3_RGB565; | ||
48 | switch ( color_model ) { | ||
49 | case RGB565:format = MPEG3_RGB565; break; | ||
50 | case RGBA8888:format = MPEG3_RGBA8888; break; | ||
51 | case BGRA8888:format = MPEG3_BGRA8888; break; | ||
52 | } | ||
53 | */ | ||
54 | } | ||
55 | |||
56 | |||
57 | bool LibFlashPlugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) { | ||
58 | } | ||
59 | |||
60 | |||
61 | FlashHandle file; | ||
62 | FlashDisplay *fd; | ||
63 | |||
64 | #endif | ||
65 | |||
66 | |||
67 | LibFlashPlugin::LibFlashPlugin() { | ||
68 | file = NULL; | ||
69 | fd = 0; | ||
70 | } | ||
71 | #include <stdio.h> | ||
72 | #include <stdlib.h> | ||
73 | static int readFile(const char *filename, char **buffer, long *size) | ||
74 | { | ||
75 | FILE *in; | ||
76 | char *buf; | ||
77 | long length; | ||
78 | |||
79 | printf("read files\n"); | ||
80 | |||
81 | in = fopen(filename,"r"); | ||
82 | if (in == 0) { | ||
83 | perror(filename); | ||
84 | return -1; | ||
85 | } | ||
86 | fseek(in,0,SEEK_END); | ||
87 | length = ftell(in); | ||
88 | rewind(in); | ||
89 | buf = (char *)malloc(length); | ||
90 | fread(buf,length,1,in); | ||
91 | fclose(in); | ||
92 | |||
93 | *size = length; | ||
94 | *buffer = buf; | ||
95 | |||
96 | return length; | ||
97 | } | ||
98 | |||
99 | static void showUrl(char *url, char * /*target*/, void * /*client_data*/) { | ||
100 | printf("get url\n"); | ||
101 | printf("GetURL : %s\n", url); | ||
102 | } | ||
103 | |||
104 | static void getSwf(char *url, int level, void *client_data) { | ||
105 | FlashHandle flashHandle = (FlashHandle) client_data; | ||
106 | char *buffer; | ||
107 | long size; | ||
108 | |||
109 | printf("get swf\n"); | ||
110 | |||
111 | printf("LoadMovie: %s @ %d\n", url, level); | ||
112 | if (readFile(url, &buffer, &size) > 0) { | ||
113 | FlashParse(flashHandle, level, buffer, size); | ||
114 | } | ||
115 | } | ||
116 | |||
117 | bool LibFlashPlugin::open( const QString& fileName ) { | ||
118 | |||
119 | printf("opening file\n"); | ||
120 | |||
121 | delete fd; | ||
122 | fd = new FlashDisplay; | ||
123 | fd->pixels = new int[320*240*4]; | ||
124 | fd->width = 200; | ||
125 | fd->bpl = 320*2; | ||
126 | fd->height = 300; | ||
127 | fd->depth = 16; | ||
128 | fd->bpp = 2; | ||
129 | fd->flash_refresh = 25; | ||
130 | fd->clip_x = 0; | ||
131 | fd->clip_y = 0; | ||
132 | fd->clip_width = 0; | ||
133 | fd->clip_height = 0; | ||
134 | |||
135 | char *buffer; | ||
136 | long size; | ||
137 | int status; | ||
138 | struct FlashInfo fi; | ||
139 | |||
140 | if (readFile(fileName.latin1(), &buffer, &size) < 0) | ||
141 | exit(2); | ||
142 | |||
143 | if (!(file = FlashNew())) | ||
144 | exit(1); | ||
145 | |||
146 | do | ||
147 | status = FlashParse(file, 0, buffer, size); | ||
148 | while (status & FLASH_PARSE_NEED_DATA); | ||
149 | |||
150 | free(buffer); | ||
151 | FlashGetInfo(file, &fi); | ||
152 | //FlashSettings(flashHandle, PLAYER_LOOP); | ||
153 | FlashGraphicInit(file, fd); | ||
154 | FlashSoundInit(file, "/dev/dsp"); | ||
155 | FlashSetGetUrlMethod(file, showUrl, 0); | ||
156 | FlashSetGetSwfMethod(file, getSwf, (void*)file); | ||
157 | |||
158 | printf("opened file\n"); | ||
159 | } | ||
160 | |||
161 | // If decoder doesn't support audio then return 0 here | ||
162 | bool LibFlashPlugin::audioSetSample( long sample, int stream ) { return TRUE; } | ||
163 | long LibFlashPlugin::audioGetSample( int stream ) { return 0; } | ||
164 | //bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) { return TRUE; } | ||
165 | //bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) { return FALSE; } | ||
166 | bool LibFlashPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) { return FALSE; } | ||
167 | //bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; } | ||
168 | //bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) { return TRUE; } | ||
169 | |||
170 | // If decoder doesn't support video then return 0 here | ||
171 | int LibFlashPlugin::videoStreams() { return 1; } | ||
172 | int LibFlashPlugin::videoWidth( int stream ) { return 300; } | ||
173 | int LibFlashPlugin::videoHeight( int stream ) { return 200; } | ||
174 | double LibFlashPlugin::videoFrameRate( int stream ) { return 25.0; } | ||
175 | int LibFlashPlugin::videoFrames( int stream ) { return 1000000; } | ||
176 | bool LibFlashPlugin::videoSetFrame( long frame, int stream ) { return TRUE; } | ||
177 | long LibFlashPlugin::videoGetFrame( int stream ) { return 0; } | ||
178 | bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) { return TRUE; } | ||
179 | #include <time.h> | ||
180 | bool LibFlashPlugin::videoReadScaledFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, int out_w, int out_h, ColorFormat color_model, int stream ) { | ||
181 | struct timeval wd; | ||
182 | FlashEvent fe; | ||
183 | |||
184 | /* | ||
185 | delete fd; | ||
186 | fd = new FlashDisplay; | ||
187 | fd->pixels = output_rows[0]; | ||
188 | fd->width = 300; // out_w; | ||
189 | fd->bpl = 640; // out_w*2; | ||
190 | fd->height = 200;//out_h; | ||
191 | fd->depth = 16; | ||
192 | fd->bpp = 2; | ||
193 | fd->flash_refresh = 50; | ||
194 | fd->clip_x = 0;//in_x; | ||
195 | fd->clip_y = 0;//in_y; | ||
196 | fd->clip_width = 300;//in_w; | ||
197 | fd->clip_height = 200;//in_h; | ||
198 | FlashGraphicInit(file, fd); | ||
199 | */ | ||
200 | |||
201 | long cmd = FLASH_WAKEUP; | ||
202 | FlashExec(file, cmd, 0, &wd); | ||
203 | |||
204 | fe.type = FeRefresh; | ||
205 | cmd = FLASH_EVENT; | ||
206 | FlashExec(file, cmd, &fe, &wd); | ||
207 | /* | ||
208 | for (int i = 0; i < out_h; i++) | ||
209 | memcpy( output_rows[i], (char*)fd->pixels + i*fd->bpl, QMIN( fd->width * fd->bpp, out_w * fd->bpp ) ); | ||
210 | */ | ||
211 | memcpy( output_rows[0], (char*)fd->pixels, out_w * out_h * 2 ); | ||
212 | } | ||
213 | |||
214 | bool LibFlashPlugin::videoReadYUVFrame( char *y_output, char *u_output, char *v_output, int in_x, int in_y, int in_w, int in_h, int stream ) { return TRUE; } | ||
215 | |||
216 | // Profiling | ||
217 | double LibFlashPlugin::getTime() { return 0.0; } | ||
218 | |||
219 | // Ignore if these aren't supported | ||
220 | bool LibFlashPlugin::setSMP( int cpus ) { return TRUE; } | ||
221 | bool LibFlashPlugin::setMMX( bool useMMX ) { return TRUE; } | ||
222 | |||
223 | |||