00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "libflashplugin.h"
00021
00022 #if 0
00023
00024 bool LibFlashPlugin::audioReadSamples( short *output, int channel, long samples, int stream ) {
00025 }
00026
00027
00028 bool LibFlashPlugin::audioReReadSamples( short *output, int channel, long samples, int stream ) {
00029 }
00030
00031
00032 bool LibFlashPlugin::audioReadMonoSamples( short *output, long samples, long& samplesRead, int stream ) {
00033 samplesRead = samples;
00034 }
00035
00036
00037 bool LibFlashPlugin::audioReadStereoSamples( short *output, long samples, long& samplesRead, int stream ) {
00038 }
00039
00040
00041 bool LibFlashPlugin::videoReadFrame( unsigned char **output_rows, int in_x, int in_y, int in_w, int in_h, ColorFormat color_model, int stream ) {
00042 }
00043
00044
00045 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 ) {
00046
00047
00048
00049
00050
00051
00052
00053
00054 }
00055
00056
00057 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 ) {
00058 }
00059
00060
00061 FlashHandle file;
00062 FlashDisplay *fd;
00063
00064 #endif
00065
00066
00067 LibFlashPlugin::LibFlashPlugin() {
00068 file = NULL;
00069 fd = 0;
00070 }
00071 #include <stdio.h>
00072 #include <stdlib.h>
00073 static int readFile(const char *filename, char **buffer, long *size)
00074 {
00075 FILE *in;
00076 char *buf;
00077 long length;
00078
00079 printf("read files\n");
00080
00081 in = fopen(filename,"r");
00082 if (in == 0) {
00083 perror(filename);
00084 return -1;
00085 }
00086 fseek(in,0,SEEK_END);
00087 length = ftell(in);
00088 rewind(in);
00089 buf = (char *)malloc(length);
00090 fread(buf,length,1,in);
00091 fclose(in);
00092
00093 *size = length;
00094 *buffer = buf;
00095
00096 return length;
00097 }
00098
00099 static void showUrl(char *url, char * , void * ) {
00100 printf("get url\n");
00101 printf("GetURL : %s\n", url);
00102 }
00103
00104 static void getSwf(char *url, int level, void *client_data) {
00105 FlashHandle flashHandle = (FlashHandle) client_data;
00106 char *buffer;
00107 long size;
00108
00109 printf("get swf\n");
00110
00111 printf("LoadMovie: %s @ %d\n", url, level);
00112 if (readFile(url, &buffer, &size) > 0) {
00113 FlashParse(flashHandle, level, buffer, size);
00114 }
00115 }
00116
00117 bool LibFlashPlugin::open( const QString& fileName ) {
00118
00119 printf("opening file\n");
00120
00121 delete fd;
00122 fd = new FlashDisplay;
00123 fd->pixels = new int[320*240*4];
00124 fd->width = 200;
00125 fd->bpl = 320*2;
00126 fd->height = 300;
00127 fd->depth = 16;
00128 fd->bpp = 2;
00129 fd->flash_refresh = 25;
00130 fd->clip_x = 0;
00131 fd->clip_y = 0;
00132 fd->clip_width = 0;
00133 fd->clip_height = 0;
00134
00135 char *buffer;
00136 long size;
00137 int status;
00138 struct FlashInfo fi;
00139
00140 if (readFile(fileName.latin1(), &buffer, &size) < 0)
00141 exit(2);
00142
00143 if (!(file = FlashNew()))
00144 exit(1);
00145
00146 do
00147 status = FlashParse(file, 0, buffer, size);
00148 while (status & FLASH_PARSE_NEED_DATA);
00149
00150 free(buffer);
00151 FlashGetInfo(file, &fi);
00152
00153 FlashGraphicInit(file, fd);
00154 #ifdef QT_QWS_DEVFS
00155 FlashSoundInit(file, "/dev/sound/dsp");
00156 #else
00157 FlashSoundInit(file, "/dev/dsp");
00158 #endif
00159 FlashSetGetUrlMethod(file, showUrl, 0);
00160 FlashSetGetSwfMethod(file, getSwf, (void*)file);
00161
00162 printf("opened file\n");
00163 }
00164
00165
00166 bool LibFlashPlugin::audioSetSample( long sample, int stream ) { return TRUE; }
00167 long LibFlashPlugin::audioGetSample( int stream ) { return 0; }
00168
00169
00170 bool LibFlashPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesRead, int stream ) { return FALSE; }
00171
00172
00173
00174
00175 int LibFlashPlugin::videoStreams() { return 1; }
00176 int LibFlashPlugin::videoWidth( int stream ) { return 300; }
00177 int LibFlashPlugin::videoHeight( int stream ) { return 200; }
00178 double LibFlashPlugin::videoFrameRate( int stream ) { return 25.0; }
00179 int LibFlashPlugin::videoFrames( int stream ) { return 1000000; }
00180 bool LibFlashPlugin::videoSetFrame( long frame, int stream ) { return TRUE; }
00181 long LibFlashPlugin::videoGetFrame( int stream ) { return 0; }
00182 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; }
00183 #include <time.h>
00184 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 ) {
00185 struct timeval wd;
00186 FlashEvent fe;
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 long cmd = FLASH_WAKEUP;
00206 FlashExec(file, cmd, 0, &wd);
00207
00208 fe.type = FeRefresh;
00209 cmd = FLASH_EVENT;
00210 FlashExec(file, cmd, &fe, &wd);
00211
00212
00213
00214
00215 memcpy( output_rows[0], (char*)fd->pixels, out_w * out_h * 2 );
00216 }
00217
00218 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; }
00219
00220
00221 double LibFlashPlugin::getTime() { return 0.0; }
00222
00223
00224 bool LibFlashPlugin::setSMP( int cpus ) { return TRUE; }
00225 bool LibFlashPlugin::setMMX( bool useMMX ) { return TRUE; }
00226
00227