llmediabase.h

Go to the documentation of this file.
00001 
00034 #ifndef LLMEDIABASE_H
00035 #define LLMEDIABASE_H
00036 
00037 // Per-OS feature switches.
00038 #if LL_DARWIN
00039         #define LL_QUICKTIME_ENABLED            1
00040         #define LL_LLMOZLIB_ENABLED                     1
00041 #elif LL_WINDOWS
00042         #define LL_QUICKTIME_ENABLED            1
00043         #define LL_LLMOZLIB_ENABLED                     1
00044 #elif LL_LINUX
00045         #define LL_QUICKTIME_ENABLED            0
00046         #ifndef LL_LLMOZLIB_ENABLED
00047                 #define LL_LLMOZLIB_ENABLED             1
00048         #endif // def LL_LLMOZLIB_ENABLED
00049 #elif LL_SOLARIS
00050         #define LL_QUICKTIME_ENABLED            0
00051         #ifndef LL_LLMOZLIB_ENABLED
00052                 #define LL_LLMOZLIB_ENABLED             0
00053         #endif // def LL_LLMOZLIB_ENABLED
00054 #endif
00055 
00056 #if LL_LLMOZLIB_ENABLED && !defined ( MOZILLA_INTERNAL_API )
00057         // Without this, nsTAString.h errors out with:
00058         // "Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead."
00059         // It might be worth our while to figure out if we can use the frozen apis at some point...
00060         #define MOZILLA_INTERNAL_API 1
00061 #endif
00062 
00063 #include <string>
00064 
00065 class LLMediaObserver;
00066 class LLMediaImplMakerBase;
00067 
00068 class LLMediaBase
00069 {
00070         public:
00071                 LLMediaBase() {};
00072                 virtual ~LLMediaBase() {};
00073 
00075                 // housekeeping
00076 
00077                 // local initialization, called by the media manager when creating a source
00078                 virtual bool init() = 0;
00079 
00080                 // undoes everything init() didm called by the media manager when destroying a source
00081                 virtual bool reset() = 0;
00082 
00083                 // accessor for MIME type
00084                 virtual bool setMimeType( const std::string mime_type ) = 0;
00085                 virtual std::string getMimeType() const = 0;
00086 
00087                 // accessor for intial URL.  Note that this may have changed under the hood
00088                 // so pass back the original URL seeded to this impl
00089                 virtual std::string getMediaURL() const = 0;
00090 
00091                 // ask impl for version string
00092                 virtual std::string getVersion() = 0;
00093 
00094                 // set/clear URL to visit when a 404 page is reached
00095                 virtual bool set404RedirectUrl( std::string redirect_url ) = 0;
00096                 virtual bool clr404RedirectUrl() = 0;
00097 
00098                 // sets the background color of the browser window
00099                 virtual bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
00100 
00101                 // sets the color of the caret in media impls that have one
00102                 virtual bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
00103 
00105                 // media management
00106 
00107                 // needs to be called regularly to make media stream update itself
00108                 virtual bool updateMedia() = 0;
00109 
00110                 // allows you to request a change in media width, height - may fail if media doesn't support size change
00111                 virtual bool setRequestedMediaSize( int media_width, int media_height ) = 0;
00112 
00113                 // gets media width (may change throughout lifetime of media stream) - event emitted when media size changed too
00114                 virtual int getMediaWidth() const = 0;
00115 
00116                 // gets media height (may change throughout lifetime of media stream) - event emitted when media size changed too
00117                 virtual int getMediaHeight() const = 0;
00118 
00119                 // allows you to try to explicitly change media depth - may fail if media doesn't support depth change
00120                 virtual bool setMediaDepth( int media_depth ) = 0;
00121 
00122                 // gets media depth (may change throughout lifetime of media stream) - event emitted when media depth changed too
00123                 virtual int getMediaDepth() const = 0;
00124 
00125                 // gets size of media buffer for current frame (might NOT be the same as media width * height * depth)
00126                 virtual int getMediaBufferSize() const = 0;
00127 
00128                 // returns pointer to raw media pixels
00129                 virtual unsigned char* getMediaData() = 0;
00130 
00131                 // returns the size of the data, which may be different that the size of the media
00132                 virtual int getMediaDataWidth() const = 0;
00133                 virtual int getMediaDataHeight() const = 0;
00134 
00136                 // texture management
00137 
00138                 // gets internal format to use for OpenGL texture
00139                 virtual int getTextureFormatInternal() const = 0;
00140 
00141                 // gets primary format to use for OpenGL texture
00142                 virtual int getTextureFormatPrimary() const = 0;
00143 
00144                 // gets format type to use for OpenGL texture
00145                 virtual int getTextureFormatType() const = 0;
00146 
00147 
00148 
00149 
00151                 // audio
00152 
00153                 // set/get control volume from media stream if present
00154                 virtual bool setVolume( float volume ) = 0;
00155                 virtual float getVolume() const = 0;
00156 
00157 
00159                 // transport control etc.
00160                 enum ECommand {
00161                         COMMAND_NONE    = 0,
00162                         COMMAND_STOP    = 1,
00163                         COMMAND_START   = 2,
00164                         COMMAND_PAUSE   = 4,
00165                         COMMAND_BACK    = 5,
00166                         COMMAND_FORWARD = 6
00167                 };
00168                 enum EStatus {
00169                         STATUS_UNKNOWN          = 0,
00170                         STATUS_INITIALIZING     = 1,
00171                         STATUS_NAVIGATING       = 2,
00172                         STATUS_STARTED          = 3,
00173                         STATUS_STOPPED          = 4,
00174                         STATUS_PAUSED           = 6,
00175                         STATUS_RESETTING        = 7
00176                 };
00177                 virtual bool addCommand( ECommand cmd ) = 0;
00178                 virtual bool clearCommand() = 0;
00179                 virtual bool updateCommand() = 0;
00180                 virtual EStatus getStatus() = 0;
00181                 virtual bool seek( double time ) = 0;
00182                 virtual bool setLooping( bool enable) = 0;
00183                 virtual bool isLooping() = 0;
00184 
00186                 // scaling
00187 
00188                 // autoscale means try to scale media to size of texture - may fail if media doesn't support size change
00189                 virtual bool setAutoScaled( bool auto_scaled ) = 0;
00190                 virtual bool isAutoScaled() const = 0;
00191 
00192 
00194                 // mouse and keyboard interaction
00195                 virtual bool mouseDown( int x_pos, int y_pos ) = 0;
00196                 virtual bool mouseUp( int x_pos, int y_pos ) = 0;
00197                 virtual bool mouseMove( int x_pos, int y_pos ) = 0;
00198                 virtual bool keyPress( int key_code ) = 0;
00199                 virtual bool scrollByLines( int lines ) = 0;
00200                 virtual bool focus( bool focus ) = 0;
00201                 virtual bool unicodeInput( unsigned long uni_char ) = 0;
00202                 virtual bool mouseLeftDoubleClick( int x_pos, int y_pos ) = 0;
00203 
00204                 
00206                 // navigation
00207                 virtual bool navigateTo( const std::string url ) = 0;
00208                 virtual bool navigateForward() = 0;
00209                 virtual bool navigateBack() = 0;
00210                 virtual bool canNavigateForward() = 0;
00211                 virtual bool canNavigateBack() = 0;
00212                 
00214                 // caching/cookies
00215                 virtual bool enableCookies( bool enable ) = 0;
00216                 virtual bool clearCache() = 0;
00217                 virtual bool clearCookies() = 0;
00218 
00220                 // proxy
00221                 virtual bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port) = 0;
00222 
00224                 // observer interface
00225                 virtual bool addObserver( LLMediaObserver* subject ) = 0;
00226                 virtual bool remObserver( LLMediaObserver* subject ) = 0;
00227 
00229                 // factory interface
00230                 virtual void setImplMaker(LLMediaImplMakerBase* impl_maker) = 0;
00231 
00233                 // type registry interface
00234                 virtual bool supportsMediaType(std::string scheme, std::string type) = 0;
00235 };
00236 
00238 // media key codes - (mirroring mozilla's values)
00239 const unsigned long LL_MEDIA_KEY_BACKSPACE             = 0x08;
00240 const unsigned long LL_MEDIA_KEY_TAB                   = 0x09;
00241 const unsigned long LL_MEDIA_KEY_RETURN                = 0x0D;
00242 const unsigned long LL_MEDIA_KEY_PAD_RETURN            = 0x0E;
00243 const unsigned long LL_MEDIA_KEY_ESCAPE                = 0x1B;
00244 const unsigned long LL_MEDIA_KEY_PAGE_UP               = 0x21;
00245 const unsigned long LL_MEDIA_KEY_PAGE_DOWN             = 0x22;
00246 const unsigned long LL_MEDIA_KEY_END                   = 0x23;
00247 const unsigned long LL_MEDIA_KEY_HOME                  = 0x24;
00248 const unsigned long LL_MEDIA_KEY_LEFT                  = 0x25;
00249 const unsigned long LL_MEDIA_KEY_UP                    = 0x26;
00250 const unsigned long LL_MEDIA_KEY_RIGHT                 = 0x27;
00251 const unsigned long LL_MEDIA_KEY_DOWN                  = 0x28;
00252 const unsigned long LL_MEDIA_KEY_INSERT                = 0x2D;
00253 const unsigned long LL_MEDIA_KEY_DELETE                = 0x2E;
00254 
00256 // media frame buffer types - (mirroring GL values)
00257 const int LL_MEDIA_UNSIGNED_BYTE                      = 0x1401;
00258 const int LL_MEDIA_RGB                                = 0x1907;
00259 const int LL_MEDIA_RGBA                               = 0x1908;
00260 const int LL_MEDIA_RGB8                               = 0x8051;
00261 const int LL_MEDIA_UNSIGNED_INT_8_8_8_8               = 0x8035;
00262 const int LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV           = 0x8367;
00263 const int LL_MEDIA_BGR                                = 0x80E0;
00264 const int LL_MEDIA_BGRA                               = 0x80E1;
00265 
00266 
00267 #endif  // LLMEDIABASE_H

Generated on Fri May 16 08:32:20 2008 for SecondLife by  doxygen 1.5.5