00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef _SO_VRML_MOVIE_TEXTURE
00050 #define _SO_VRML_MOVIE_TEXTURE
00051
00052 #include <Inventor/VRMLnodes/SoVRMLTexture.h>
00053 #include <Inventor/fields/SoSFFloat.h>
00054 #include <Inventor/fields/SoSFTime.h>
00055 #include <Inventor/fields/SoSFImage.h>
00056 #include <Inventor/fields/SoSFColor.h>
00057 #include <Inventor/fields/SoSFEnum.h>
00058 #include <Inventor/fields/SoSFBool.h>
00059 #include <Inventor/fields/SoSFInt32.h>
00060 #include <Inventor/fields/SoSFBool.h>
00061 #include <Inventor/fields/SoMFString.h>
00062 #include <Inventor/fields/SoMFFilePathString.h>
00063 #include <Inventor/nodes/SoNode.h>
00064
00065 #include <Inventor/threads/SbThread.h>
00066 #include <Inventor/threads/SbThreadStorage.h>
00067 #include <Inventor/caches/SoGLTexCacheList.h>
00068 #include <Inventor/sys/SoGLType.h>
00069
00070
00071 #if defined(OIV_IGNORE_VRML_DEPRECATED)
00072 #include <SoDeprecationRules.h>
00073 #pragma push_macro("SoDEPRECATED_CLASS")
00074 #pragma push_macro("SoDEPRECATED_TYPEDEF")
00075 #undef SoDEPRECATED_CLASS
00076 #undef SoDEPRECATED_TYPEDEF
00077 #define SoDEPRECATED_CLASS(x,y)
00078 #define SoDEPRECATED_TYPEDEF(x,y)
00079 #endif
00080
00081 class SoState ;
00082 class SoSensor;
00083 class SoTimerSensor;
00084 class SoAlarmSensor;
00085 class SoFieldSensor;
00086 class SoGLDisplayList;
00087 class SoMPEG2Decoder;
00088 class SoAVIDecoder;
00089 class SoWebCamDecoder;
00090 class SoVideoDecoder;
00091 class SoVRMLMovieTexture;
00092 class SbThreadRWMutex;
00093 class SoSoundDecoder;
00094
00095 #ifdef _MSC_VER
00096 #pragma warning( push )
00097 #pragma warning(disable:4251)
00098
00099 #endif
00100
00103 typedef SoDEPRECATED SbBool VRMLMoviePrequalifyFileCallback(const SbString &, void *, SoVRMLMovieTexture *);
00104
00105 typedef SoDEPRECATED int SoMovieType ;
00106 class SoDEPRECATED SoVRMLMovieTexture : public SoVRMLTexture {
00279
00280 SO_NODE_HEADER(SoVRMLMovieTexture);
00281
00282 public:
00283
00285 enum Model {
00289 MODULATE = GL_MODULATE,
00290
00300 DECAL = GL_DECAL,
00301
00305 BLEND = GL_BLEND,
00306
00310 REPLACE = GL_REPLACE
00311 };
00312
00316 SoVRMLMovieTexture();
00317
00318
00325 SoSFBool loop;
00326
00331 SoSFFloat speed;
00332
00337 SoSFTime startTime;
00338
00346 SoSFTime stopTime;
00358 SoSFTime pauseTime;
00370 SoSFTime resumeTime;
00371
00379 SoMFFilePathString url;
00380
00393 SoSFFloat alpha;
00394
00407 SoSFEnum model;
00408
00420 SoSFColor blendColor;
00421
00443 SoSFBool scaleTexCoord;
00444
00448 SoSFTime duration_changed;
00449
00453 SoSFBool isActive;
00454
00458 SoSFBool isPaused;
00459
00463 SoSFTime elapsedTime;
00464
00475 void setVideoCaptureFormat(int32_t width, int32_t height, int32_t framePerSec) ;
00480 static void setPrequalifyFileCallBack(VRMLMoviePrequalifyFileCallback *, void *);
00485 void allowPrequalifyFile(SbBool);
00486
00487
00488
00489 private:
00490
00491 virtual void GLRender(SoGLRenderAction *action);
00492
00493 private:
00494
00495 const SbString & getOverrideURL() { return overrideURL; }
00496 void setOverrideURL(const SbString &path) { overrideURL = path; }
00497
00498 SoSFInt32 soundDecoded;
00499
00500
00501
00502
00503
00504
00505
00506 static void initClass();
00507 static void exitClass();
00508
00509
00510 void shoudDecodeSound(SbBool decodeSound) ;
00511
00512
00513 SoSoundDecoder* getSoundDecoder() ;
00514
00515 private:
00516 virtual ~SoVRMLMovieTexture();
00517
00518 private:
00519 SbString overrideURL;
00520 static VRMLMoviePrequalifyFileCallback *prequalifyFileCB;
00521 static void *prequalifyFileCB_udata;
00522
00523 SbBool prequalifyFileFlag;
00524
00525 SoFieldSensor *filenameSensor;
00526 SoFieldSensor *loopChangedSensor;
00527 SoFieldSensor *startChangedSensor;
00528 SoFieldSensor *endChangedSensor;
00529 SoFieldSensor *speedChangedSensor;
00530 SoFieldSensor *wrapSChangedSensor;
00531 SoFieldSensor *wrapTChangedSensor;
00532 SoFieldSensor *scaleChangedSensor;
00533
00534 SoAlarmSensor *startSensor;
00535 SoAlarmSensor *endSensor;
00536 SoTimerSensor *grabSensor;
00537
00538
00539 SoTimerSensor *displaySensor;
00540
00541 static void filenameChangedCB(void *, SoSensor *);
00542 static void loopChangedCB(void *data, SoSensor *);
00543 static void startVideoCB(void *data, SoSensor *);
00544 static void endChangedCB(void *data, SoSensor *);
00545 static void speedChangedCB(void *data, SoSensor *);
00546 static void scaleChangedCB(void *data, SoSensor *);
00547
00548 static void wrapChangedCB(void *data, SoSensor *);
00549 static void endVideoCB(void *data, SoSensor *);
00550 static void startChangedCB(void *data, SoSensor *);
00551 static void grabNewFrame(void *data, SoSensor *);
00552 static void displayNewFrame(void *data, SoSensor *);
00553
00554 void configStartTimeSensor() ;
00555 void configStopTimeSensor() ;
00556 void prepareVideoToBePlayed() ;
00557 void setGLTextureImageElement(SoState *state) ;
00558
00559 void invalidateRenderList();
00560
00561
00562 SbThreadStorage< SoGLTexCacheList* > m_texList;
00563
00564
00565 SbThreadRWMutex *m_mutex;
00566 SbThread *m_thread;
00567 static void *grab(void *data);
00568 SbBool createThread();
00569
00570
00571 int m_hasTransparency;
00572 int m_num_components;
00573
00574 void openVideo();
00575 void closeVideo(SbBool close_file = FALSE);
00576 void displayFrame();
00577 void init();
00578
00579 SbVec2s m_size_video;
00580 SbVec3f m_scale_vec;
00581 SbVec2i32 m_size_scale;
00582
00583 unsigned char *m_video_buf;
00584 unsigned char *m_scale_buf;
00585 unsigned char *m_alpha_buf;
00586
00587 SbTime m_startRealTime;
00588 int m_dispFrame;
00589 int m_cptFrame;
00590
00591
00592 SbBool m_soundPlayed ;
00593 SbBool m_shouldDecodeSound;
00594 SbBool m_END_VIDEO;
00595 SbBool m_ADVANCE;
00596 SbBool m_ONCE;
00597 SbBool m_FIRST_TRAVERSAL;
00598 SbBool m_STOP_GRAB;
00599 SbBool m_FIRST ;
00600 SbBool m_URL;
00601 SbBool m_START;
00602 SbBool m_CLOSED;
00603 SbBool m_SCALED;
00604 SbBool m_SCALE_SIZED;
00605 SbBool m_BUFFER;
00606 SbBool m_CLOSED_FILE;
00607
00608 int m_late ;
00609
00610 SoMovieType checkFileType( const SbString& );
00611 SoMovieType m_movieType;
00612
00613 static SbString basePath;
00614 static SbBool basePathSet;
00615
00616
00617 SoMPEG2Decoder *m_mpeg;
00618 SoAVIDecoder *m_avi;
00619 SoWebCamDecoder *m_webcam;
00620
00621
00622 SoVideoDecoder *m_video;
00623
00624
00625 SoSFEnum m_wrapS,m_wrapT;
00626
00627
00628 int32_t m_videoCapWidth ;
00629 int32_t m_videoCapHeight ;
00630 int32_t m_videoCapFPS ;
00631
00632 int m_numRenderCaches;
00633 };
00634
00635 #ifdef _MSC_VER
00636 #pragma warning( pop )
00637
00638 #endif
00639
00640
00641 #if defined(OIV_IGNORE_VRML_DEPRECATED)
00642 #pragma pop_macro("SoDEPRECATED_TYPEDEF")
00643 #pragma pop_macro("SoDEPRECATED_CLASS")
00644 #endif
00645
00646 #endif
00647