185 #include <system_threads.h>
187 #include <internal.h>
188 #include "vrml_parser/CRoutes.h"
189 #include "vrml_parser/Structs.h"
190 #include "main/ProdCon.h"
191 #include "../opengl/OpenGL_Utils.h"
192 #include "../opengl/Textures.h"
193 #include "../opengl/LoadTextures.h"
194 #include "../scenegraph/Component_CubeMapTexturing.h"
197 #include <io_files.h>
202 #include <libFreeWRL.h>
217 #ifdef MOVIETEXTURE_BERKLEYBROWN
218 #include "MPEG_Utils_berkley.c"
219 #elif MOVIETEXTURE_FFMPEG
221 int movie_load_from_file(
char *fname,
void **opaque);
222 double movie_get_duration(
void *opaque);
223 unsigned char *movie_get_frame_by_fraction(
void *opaque,
float fraction,
int *width,
int *height,
int *nchan);
224 unsigned char * movie_get_audio_PCM_buffer(
void *opaque,
int *freq,
int *channels,
int *size,
int *bits);
229 #define LOAD_STABLE 10 //from Component_Sound.c
230 #elif MOVIETEXTURE_LIBMPEG2
257 #ifdef MOVIETEXTURE_STUB
258 res->status = ress_loaded;
260 #elif MOVIETEXTURE_BERKLEYBROWN
262 int x,y,depth,frameCount;
268 mpg_main(res->actual_file, &x,&y,&depth,&frameCount,&ptr);
270 printf (
"have x %d y %d depth %d frameCount %d ptr %d\n",x,y,depth,frameCount,ptr);
278 #elif MOVIETEXTURE_FFMPEG
282 loaded = movie_load_from_file(res->actual_file,&opaque);
283 retval = loaded > -1 ? TRUE : FALSE;
285 int freq,channels,size,bits;
286 unsigned char * pcmbuf;
289 res->status = ress_loaded;
290 res->complete = TRUE;
291 res->status = ress_parsed;
295 node->duration_changed = movie_get_duration(opaque);
296 node->__fw_movie = opaque;
297 node->__loadstatus = LOAD_STABLE;
301 MARK_EVENT (X3D_NODE(node), offsetof(
struct X3D_MovieTexture, duration_changed));
304 pcmbuf = movie_get_audio_PCM_buffer(opaque,&freq,&channels,&size,&bits);
310 printf(
"audio freq %d channels %d size %d bits per channel %d\n",freq,channels,size,bits);
321 if (!alutInitWithoutContext(NULL, NULL))
322 ConsoleMessage(
"ALUT init failed\n");
329 alGenBuffers(1, &albuffer);
347 format = AL_FORMAT_MONO8;
349 format = AL_FORMAT_STEREO8;
352 format = AL_FORMAT_MONO16;
354 format = AL_FORMAT_STEREO16;
357 #ifdef AL_EXT_float32
358 format = AL_FORMAT_MONO_FLOAT32;
360 format = AL_FORMAT_STEREO_FLOAT32;
368 alBufferData(albuffer,format,pcmbuf,size,freq);
371 node->__sourceNumber = albuffer;
378 printf(
"opqaue = %p, loaded=%d \n",opaque,res->status);
380 #elif MOVIETEXTURE_LIBMPEG2
384 int parse_audioclip(
struct X3D_AudioClip *node,
char *bbuffer,
int len);
385 int parse_movie(node,buffer,len){
390 int audio_sourcenumber;
391 audio_sourcenumber = -1;
396 #ifdef MOVIETEXTURE_STUB
397 #elif MOVIETEXTURE_BERKLEYBROWN
398 #elif MOVIETEXTURE_FFMPEG
399 #elif MOVIETEXTURE_LIBMPEG2
401 return audio_sourcenumber;
403 double compute_duration(
int ibuffer);
423 buffer = res->URLrequest;
428 of = res->openned_files;
434 buffer = of->fileData;
435 len = of->fileDataSize;
441 node->__sourceNumber = parse_movie(node,buffer,len);
442 if(node->__sourceNumber > -1) {
443 node->duration_changed = compute_duration(node->__sourceNumber);
444 MARK_EVENT (X3D_NODE(node), offsetof(
struct X3D_MovieTexture, duration_changed));
477 unsigned char *movietexture_get_frame_by_fraction(
struct X3D_Node* node,
float fraction,
int *width,
int *height,
int *nchan){
478 unsigned char* retval = NULL;
479 if(node && node->_nodeType == NODE_MovieTexture){
481 #ifdef MOVIETEXTURE_STUB
482 #elif MOVIETEXTURE_BERKLEYBROWN
483 #elif MOVIETEXTURE_FFMPEG
484 retval = movie_get_frame_by_fraction(movietexture->__fw_movie,fraction,width,height,nchan);
485 #elif MOVIETEXTURE_LIBMPEG2