aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmedia/llmediabase.h
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:45:34 -0500
committerJacek Antonelli2008-08-15 23:45:34 -0500
commitcd17687f01420952712a500107e0f93e7ab8d5f8 (patch)
treece48c2b706f2c1176290e39fb555fbdf6648ce01 /linden/indra/llmedia/llmediabase.h
parentSecond Life viewer sources 1.19.0.5 (diff)
downloadmeta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.zip
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.gz
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.bz2
meta-impy-cd17687f01420952712a500107e0f93e7ab8d5f8.tar.xz
Second Life viewer sources 1.19.1.0
Diffstat (limited to 'linden/indra/llmedia/llmediabase.h')
-rw-r--r--linden/indra/llmedia/llmediabase.h313
1 files changed, 220 insertions, 93 deletions
diff --git a/linden/indra/llmedia/llmediabase.h b/linden/indra/llmedia/llmediabase.h
index ae9c8ee..49c6d69 100644
--- a/linden/indra/llmedia/llmediabase.h
+++ b/linden/indra/llmedia/llmediabase.h
@@ -1,6 +1,8 @@
1/** 1/**
2 * @file llmediabase.h 2 * @file llmediabase.h
3 * @brief LLMedia support - base class 3 * @author Callum Prentice
4 * @date 2007-10-22 00:00:00
5 * @brief Abstract class that defines LLMedia public interface
4 * 6 *
5 * $LicenseInfo:firstyear=2005&license=viewergpl$ 7 * $LicenseInfo:firstyear=2005&license=viewergpl$
6 * 8 *
@@ -29,112 +31,237 @@
29 * $/LicenseInfo$ 31 * $/LicenseInfo$
30 */ 32 */
31 33
32// header guard 34#ifndef LLMEDIABASE_H
33#ifndef llmediabase_h 35#define LLMEDIABASE_H
34#define llmediabase_h
35 36
36#include "llstring.h" 37// Per-OS feature switches.
37#include "llmediaemitter.h" 38#if LL_DARWIN
38#include "llmediaobservers.h" 39 #define LL_QUICKTIME_ENABLED 1
39#include "llmediaemitterevents.h" 40 #define LL_LLMOZLIB_ENABLED 1
41#elif LL_WINDOWS
42 #define LL_QUICKTIME_ENABLED 1
43 #define LL_LLMOZLIB_ENABLED 1
44#elif LL_LINUX
45 #define LL_QUICKTIME_ENABLED 0
46 #ifndef LL_LLMOZLIB_ENABLED
47 #define LL_LLMOZLIB_ENABLED 1
48 #endif // def LL_LLMOZLIB_ENABLED
49#elif LL_SOLARIS
50 #define LL_QUICKTIME_ENABLED 0
51 #ifndef LL_LLMOZLIB_ENABLED
52 #define LL_LLMOZLIB_ENABLED 0
53 #endif // def LL_LLMOZLIB_ENABLED
54#endif
55
56#if LL_LLMOZLIB_ENABLED && !defined ( MOZILLA_INTERNAL_API )
57 // Without this, nsTAString.h errors out with:
58 // "Cannot use internal string classes without MOZILLA_INTERNAL_API defined. Use the frozen header nsStringAPI.h instead."
59 // It might be worth our while to figure out if we can use the frozen apis at some point...
60 #define MOZILLA_INTERNAL_API 1
61#endif
62
63#include <string>
64
65class LLMediaObserver;
66class LLMediaImplMakerBase;
40 67
41class LLMediaBase 68class LLMediaBase
42{ 69{
43 public: 70 public:
44 LLMediaBase (); 71 LLMediaBase() {};
45 72 virtual ~LLMediaBase() {};
46 // do the right thing with dtor 73
47 virtual ~LLMediaBase () 74 ////////////////////////////////////////////////////////////////////////////////
48 { 75 // housekeeping
76
77 // local initialization, called by the media manager when creating a source
78 virtual bool init() = 0;
79
80 // undoes everything init() didm called by the media manager when destroying a source
81 virtual bool reset() = 0;
82
83 // accessor for MIME type
84 virtual bool setMimeType( const std::string mime_type ) = 0;
85 virtual std::string getMimeType() const = 0;
86
87 // accessor for intial URL. Note that this may have changed under the hood
88 // so pass back the original URL seeded to this impl
89 virtual std::string getMediaURL() const = 0;
90
91 // ask impl for version string
92 virtual std::string getVersion() = 0;
93
94 // set/clear URL to visit when a 404 page is reached
95 virtual bool set404RedirectUrl( std::string redirect_url ) = 0;
96 virtual bool clr404RedirectUrl() = 0;
97
98 // sets the background color of the browser window
99 virtual bool setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
100
101 // sets the color of the caret in media impls that have one
102 virtual bool setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const = 0;
103
104 ////////////////////////////////////////////////////////////////////////////////
105 // media management
106
107 // needs to be called regularly to make media stream update itself
108 virtual bool updateMedia() = 0;
109
110 // allows you to request a change in media width, height - may fail if media doesn't support size change
111 virtual bool setRequestedMediaSize( int media_width, int media_height ) = 0;
112
113 // gets media width (may change throughout lifetime of media stream) - event emitted when media size changed too
114 virtual int getMediaWidth() const = 0;
115
116 // gets media height (may change throughout lifetime of media stream) - event emitted when media size changed too
117 virtual int getMediaHeight() const = 0;
118
119 // allows you to try to explicitly change media depth - may fail if media doesn't support depth change
120 virtual bool setMediaDepth( int media_depth ) = 0;
121
122 // gets media depth (may change throughout lifetime of media stream) - event emitted when media depth changed too
123 virtual int getMediaDepth() const = 0;
124
125 // gets size of media buffer for current frame (might NOT be the same as media width * height * depth)
126 virtual int getMediaBufferSize() const = 0;
127
128 // returns pointer to raw media pixels
129 virtual unsigned char* getMediaData() = 0;
130
131 // returns the size of the data, which may be different that the size of the media
132 virtual int getMediaDataWidth() const = 0;
133 virtual int getMediaDataHeight() const = 0;
134
135 ////////////////////////////////////////////////////////////////////////////////
136 // texture management
137
138 // gets internal format to use for OpenGL texture
139 virtual int getTextureFormatInternal() const = 0;
140
141 // gets primary format to use for OpenGL texture
142 virtual int getTextureFormatPrimary() const = 0;
143
144 // gets format type to use for OpenGL texture
145 virtual int getTextureFormatType() const = 0;
146
147
148
149
150 ////////////////////////////////////////////////////////////////////////////////
151 // audio
152
153 // set/get control volume from media stream if present
154 virtual bool setVolume( float volume ) = 0;
155 virtual float getVolume() const = 0;
156
157
158 ////////////////////////////////////////////////////////////////////////////////
159 // transport control etc.
160 enum ECommand {
161 COMMAND_NONE = 0,
162 COMMAND_STOP = 1,
163 COMMAND_START = 2,
164 COMMAND_PAUSE = 4,
165 COMMAND_BACK = 5,
166 COMMAND_FORWARD = 6
167 };
168 enum EStatus {
169 STATUS_UNKNOWN = 0,
170 STATUS_INITIALIZING = 1,
171 STATUS_NAVIGATING = 2,
172 STATUS_STARTED = 3,
173 STATUS_STOPPED = 4,
174 STATUS_PAUSED = 6,
175 STATUS_RESETTING = 7
49 }; 176 };
177 virtual bool addCommand( ECommand cmd ) = 0;
178 virtual bool clearCommand() = 0;
179 virtual bool updateCommand() = 0;
180 virtual EStatus getStatus() = 0;
181 virtual bool seek( double time ) = 0;
182 virtual bool setLooping( bool enable) = 0;
183 virtual bool isLooping() = 0;
50 184
51 /////////////////////////////////////////////////////////////////////////////// 185 ////////////////////////////////////////////////////////////////////////////////
52 // public interface: 186 // scaling
53 187
54 /////////////////////////////////////////////////////////////////////////////// 188 // autoscale means try to scale media to size of texture - may fail if media doesn't support size change
55 // different types of supported media 189 virtual bool setAutoScaled( bool auto_scaled ) = 0;
56 enum MediaType { Unknown, QuickTime }; 190 virtual bool isAutoScaled() const = 0;
57 191
58 ///////////////////////////////////////////////////////////////////////////////
59 // factory method based on explicit media type
60 static LLMediaBase* make ( const MediaType mediaTypeIn, S32 width_pixels, S32 height_pixels );
61
62 // Result codes for updateMedia
63 enum
64 {
65 updateMediaNoChanges,
66 updateMediaNeedsUpdate,
67 updateMediaNeedsSizeChange
68 192
69 } updateMediaResult; 193 ////////////////////////////////////////////////////////////////////////////////
194 // mouse and keyboard interaction
195 virtual bool mouseDown( int x_pos, int y_pos ) = 0;
196 virtual bool mouseUp( int x_pos, int y_pos ) = 0;
197 virtual bool mouseMove( int x_pos, int y_pos ) = 0;
198 virtual bool keyPress( int key_code ) = 0;
199 virtual bool scrollByLines( int lines ) = 0;
200 virtual bool focus( bool focus ) = 0;
201 virtual bool unicodeInput( unsigned long uni_char ) = 0;
202 virtual bool mouseLeftDoubleClick( int x_pos, int y_pos ) = 0;
70 203
71 // housekeeping
72 virtual BOOL setBuffer ( U8* bufferIn ) = 0;
73 virtual bool setBufferSize(S32 width_pixels, S32 height_pixels) { return false; }
74 virtual BOOL init ();
75 virtual BOOL load ( const LLString& urlIn );
76 virtual BOOL unload ();
77
78 // media data
79 virtual S32 updateMedia () = 0;
80 virtual U8* getMediaData () = 0;
81 virtual S32 getTextureWidth () const;
82 virtual S32 getTextureHeight () const;
83 virtual S32 getTextureDepth () const;
84 virtual S32 getTextureFormatInternal () const;
85 virtual S32 getTextureFormatPrimary () const;
86 virtual S32 getTextureFormatType () const;
87 virtual S32 getTextureFormatSwapBytes () const;
88 virtual S32 getMediaWidth () const;
89 virtual S32 getMediaHeight () const;
90 virtual S32 getMediaDepthBytes () const;
91 virtual S32 getMediaBufferSize () const;
92
93 // allow consumers to observe media events
94 virtual BOOL addMediaObserver( LLMediaObserver* observerIn );
95 virtual BOOL remMediaObserver( LLMediaObserver* observerIn );
96
97 // MBW -- XXX -- These don't belong here!
98 // LLMediaEngine should really only deal with LLMediaMovieBase subclasses
99 virtual BOOL stop () { return TRUE; }
100 virtual BOOL play () { return TRUE; }
101 virtual BOOL loop ( S32 howMany ) { return TRUE; }
102 virtual BOOL pause () { return TRUE; }
103 virtual BOOL seek ( F64 time ) { return TRUE; }
104 virtual BOOL setVolume ( F32 volumeIn ) { return TRUE; }
105 virtual BOOL isLoaded () const { return TRUE; }
106 virtual BOOL isPaused () const { return FALSE; }
107 virtual BOOL isPlaying () const { return TRUE; }
108 virtual BOOL isLooping () const { return FALSE; }
109 virtual void setAutoScaled ( BOOL autoScaledIn ) {}
110
111 protected:
112 // event emitter
113 LLMediaEmitter<LLMediaObserver> mMediaEventEmitter;
114 204
115 U32 mBufferChangeCount; // Incremented when the buffer changes 205 ////////////////////////////////////////////////////////////////////////////////
116 U32 mLastBufferChangeCount; // Set to mBufferChangeCount when the buffer is reported as changed 206 // navigation
207 virtual bool navigateTo( const std::string url ) = 0;
208 virtual bool navigateForward() = 0;
209 virtual bool navigateBack() = 0;
210 virtual bool canNavigateForward() = 0;
211 virtual bool canNavigateBack() = 0;
117 212
118 S32 mMediaWidth; 213 ////////////////////////////////////////////////////////////////////////////////
119 S32 mMediaHeight; 214 // caching/cookies
120 S32 mMediaDepthBytes; 215 virtual bool enableCookies( bool enable ) = 0;
121 S32 mMediaRowbytes; 216 virtual bool clearCache() = 0;
122 S32 mTextureWidth; 217 virtual bool clearCookies() = 0;
123 S32 mTextureHeight;
124 S32 mTextureDepth;
125 S32 mTextureFormatInternal;
126 S32 mTextureFormatPrimary;
127 S32 mTextureFormatType;
128 S32 mTextureFormatSwapBytes;
129 218
130 public: 219 ////////////////////////////////////////////////////////////////////////////////
131 220 // proxy
132 // Has memory buffer been updated? (page content change, scroll, movie frame drawn, etc) 221 virtual bool enableProxy(bool enable, std::string proxy_host_name, int proxy_port) = 0;
133 void bufferChanged() { mBufferChangeCount++; } 222
134 bool getBufferChanged() const { return mBufferChangeCount != mLastBufferChangeCount; } 223 ////////////////////////////////////////////////////////////////////////////////
135 void resetBufferChanged() { mLastBufferChangeCount = mBufferChangeCount; } 224 // observer interface
225 virtual bool addObserver( LLMediaObserver* subject ) = 0;
226 virtual bool remObserver( LLMediaObserver* subject ) = 0;
227
228 ////////////////////////////////////////////////////////////////////////////////
229 // factory interface
230 virtual void setImplMaker(LLMediaImplMakerBase* impl_maker) = 0;
136 231
232 ////////////////////////////////////////////////////////////////////////////////
233 // type registry interface
234 virtual bool supportsMediaType(std::string scheme, std::string type) = 0;
137}; 235};
138 236
237//////////////////////////////////////////////////////////////
238// media key codes - (mirroring mozilla's values)
239const unsigned long LL_MEDIA_KEY_BACKSPACE = 0x08;
240const unsigned long LL_MEDIA_KEY_TAB = 0x09;
241const unsigned long LL_MEDIA_KEY_RETURN = 0x0D;
242const unsigned long LL_MEDIA_KEY_PAD_RETURN = 0x0E;
243const unsigned long LL_MEDIA_KEY_ESCAPE = 0x1B;
244const unsigned long LL_MEDIA_KEY_PAGE_UP = 0x21;
245const unsigned long LL_MEDIA_KEY_PAGE_DOWN = 0x22;
246const unsigned long LL_MEDIA_KEY_END = 0x23;
247const unsigned long LL_MEDIA_KEY_HOME = 0x24;
248const unsigned long LL_MEDIA_KEY_LEFT = 0x25;
249const unsigned long LL_MEDIA_KEY_UP = 0x26;
250const unsigned long LL_MEDIA_KEY_RIGHT = 0x27;
251const unsigned long LL_MEDIA_KEY_DOWN = 0x28;
252const unsigned long LL_MEDIA_KEY_INSERT = 0x2D;
253const unsigned long LL_MEDIA_KEY_DELETE = 0x2E;
254
255//////////////////////////////////////////////////////////////
256// media frame buffer types - (mirroring GL values)
257const int LL_MEDIA_UNSIGNED_BYTE = 0x1401;
258const int LL_MEDIA_RGB = 0x1907;
259const int LL_MEDIA_RGBA = 0x1908;
260const int LL_MEDIA_RGB8 = 0x8051;
261const int LL_MEDIA_UNSIGNED_INT_8_8_8_8 = 0x8035;
262const int LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV = 0x8367;
263const int LL_MEDIA_BGR = 0x80E0;
264const int LL_MEDIA_BGRA = 0x80E1;
265
139 266
140#endif // llmediabase_h 267#endif // LLMEDIABASE_H