00001 00032 // header guard 00033 #ifndef llmediabase_h 00034 #define llmediabase_h 00035 00036 #include "llstring.h" 00037 #include "llmediaemitter.h" 00038 #include "llmediaobservers.h" 00039 #include "llmediaemitterevents.h" 00040 00041 class LLMediaBase 00042 { 00043 public: 00044 LLMediaBase (); 00045 00046 // do the right thing with dtor 00047 virtual ~LLMediaBase () 00048 { 00049 }; 00050 00052 // public interface: 00053 00055 // different types of supported media 00056 enum MediaType { Unknown, QuickTime }; 00057 00059 // factory method based on explicit media type 00060 static LLMediaBase* make ( const MediaType mediaTypeIn, S32 width_pixels, S32 height_pixels ); 00061 00062 // Result codes for updateMedia 00063 enum 00064 { 00065 updateMediaNoChanges, 00066 updateMediaNeedsUpdate, 00067 updateMediaNeedsSizeChange 00068 00069 } updateMediaResult; 00070 00071 // housekeeping 00072 virtual BOOL setBuffer ( U8* bufferIn ) = 0; 00073 virtual bool setBufferSize(S32 width_pixels, S32 height_pixels) { return false; } 00074 virtual BOOL init (); 00075 virtual BOOL load ( const LLString& urlIn ); 00076 virtual BOOL unload (); 00077 00078 // media data 00079 virtual S32 updateMedia () = 0; 00080 virtual U8* getMediaData () = 0; 00081 virtual S32 getTextureWidth () const; 00082 virtual S32 getTextureHeight () const; 00083 virtual S32 getTextureDepth () const; 00084 virtual S32 getTextureFormatInternal () const; 00085 virtual S32 getTextureFormatPrimary () const; 00086 virtual S32 getTextureFormatType () const; 00087 virtual S32 getTextureFormatSwapBytes () const; 00088 virtual S32 getMediaWidth () const; 00089 virtual S32 getMediaHeight () const; 00090 virtual S32 getMediaDepthBytes () const; 00091 virtual S32 getMediaBufferSize () const; 00092 00093 // allow consumers to observe media events 00094 virtual BOOL addMediaObserver( LLMediaObserver* observerIn ); 00095 virtual BOOL remMediaObserver( LLMediaObserver* observerIn ); 00096 00097 // MBW -- XXX -- These don't belong here! 00098 // LLMediaEngine should really only deal with LLMediaMovieBase subclasses 00099 virtual BOOL stop () { return TRUE; } 00100 virtual BOOL play () { return TRUE; } 00101 virtual BOOL loop ( S32 howMany ) { return TRUE; } 00102 virtual BOOL pause () { return TRUE; } 00103 virtual BOOL seek ( F64 time ) { return TRUE; } 00104 virtual BOOL setVolume ( F32 volumeIn ) { return TRUE; } 00105 virtual BOOL isLoaded () const { return TRUE; } 00106 virtual BOOL isPaused () const { return FALSE; } 00107 virtual BOOL isPlaying () const { return TRUE; } 00108 virtual BOOL isLooping () const { return FALSE; } 00109 virtual void setAutoScaled ( BOOL autoScaledIn ) {} 00110 00111 protected: 00112 // event emitter 00113 LLMediaEmitter<LLMediaObserver> mMediaEventEmitter; 00114 00115 U32 mBufferChangeCount; // Incremented when the buffer changes 00116 U32 mLastBufferChangeCount; // Set to mBufferChangeCount when the buffer is reported as changed 00117 00118 S32 mMediaWidth; 00119 S32 mMediaHeight; 00120 S32 mMediaDepthBytes; 00121 S32 mMediaRowbytes; 00122 S32 mTextureWidth; 00123 S32 mTextureHeight; 00124 S32 mTextureDepth; 00125 S32 mTextureFormatInternal; 00126 S32 mTextureFormatPrimary; 00127 S32 mTextureFormatType; 00128 S32 mTextureFormatSwapBytes; 00129 00130 public: 00131 00132 // Has memory buffer been updated? (page content change, scroll, movie frame drawn, etc) 00133 void bufferChanged() { mBufferChangeCount++; } 00134 bool getBufferChanged() const { return mBufferChangeCount != mLastBufferChangeCount; } 00135 void resetBufferChanged() { mLastBufferChangeCount = mBufferChangeCount; } 00136 00137 }; 00138 00139 00140 #endif // llmediabase_h