aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llplugin/llpluginclassmedia.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xlinden/indra/llplugin/llpluginclassmedia.h388
1 files changed, 388 insertions, 0 deletions
diff --git a/linden/indra/llplugin/llpluginclassmedia.h b/linden/indra/llplugin/llpluginclassmedia.h
new file mode 100755
index 0000000..abb7926
--- /dev/null
+++ b/linden/indra/llplugin/llpluginclassmedia.h
@@ -0,0 +1,388 @@
1/**
2 * @file llpluginclassmedia.h
3 * @brief LLPluginClassMedia handles interaction with a plugin which knows about the "media" message class.
4 *
5 * @cond
6 * $LicenseInfo:firstyear=2008&license=viewergpl$
7 *
8 * Copyright (c) 2008-2010, Linden Research, Inc.
9 *
10 * Second Life Viewer Source Code
11 * The source code in this file ("Source Code") is provided by Linden Lab
12 * to you under the terms of the GNU General Public License, version 2.0
13 * ("GPL"), unless you have obtained a separate licensing agreement
14 * ("Other License"), formally executed by you and Linden Lab. Terms of
15 * the GPL can be found in doc/GPL-license.txt in this distribution, or
16 * online at http://secondlife.com/developers/opensource/gplv2
17 *
18 * There are special exceptions to the terms and conditions of the GPL as
19 * it is applied to this Source Code. View the full text of the exception
20 * in the file doc/FLOSS-exception.txt in this software distribution, or
21 * online at
22 * http://secondlife.com/developers/opensource/flossexception
23 *
24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations.
27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$
32 *
33 * @endcond
34 */
35
36#ifndef LL_LLPLUGINCLASSMEDIA_H
37#define LL_LLPLUGINCLASSMEDIA_H
38
39#include "llgltypes.h"
40#include "llpluginprocessparent.h"
41#include "llrect.h"
42#include "llpluginclassmediaowner.h"
43#include <queue>
44#include "v4color.h"
45
46class LLPluginClassMedia : public LLPluginProcessParentOwner
47{
48 LOG_CLASS(LLPluginClassMedia);
49public:
50 LLPluginClassMedia(LLPluginClassMediaOwner *owner);
51 virtual ~LLPluginClassMedia();
52
53 // local initialization, called by the media manager when creating a source
54 virtual bool init(const std::string &launcher_filename,
55 const std::string &plugin_filename,
56 bool debug);
57
58 // undoes everything init() didm called by the media manager when destroying a source
59 virtual void reset();
60
61 void idle(void);
62
63 // All of these may return 0 or an actual valid value.
64 // Callers need to check the return for 0, and not use the values in that case.
65 int getWidth() const { return (mMediaWidth > 0) ? mMediaWidth : 0; };
66 int getHeight() const { return (mMediaHeight > 0) ? mMediaHeight : 0; };
67 int getNaturalWidth() const { return mNaturalMediaWidth; };
68 int getNaturalHeight() const { return mNaturalMediaHeight; };
69 int getSetWidth() const { return mSetMediaWidth; };
70 int getSetHeight() const { return mSetMediaHeight; };
71 int getBitsWidth() const { return (mTextureWidth > 0) ? mTextureWidth : 0; };
72 int getBitsHeight() const { return (mTextureHeight > 0) ? mTextureHeight : 0; };
73 int getTextureWidth() const;
74 int getTextureHeight() const;
75 int getFullWidth() const { return mFullMediaWidth; };
76 int getFullHeight() const { return mFullMediaHeight; };
77
78 // This may return NULL. Callers need to check for and handle this case.
79 unsigned char* getBitsData();
80
81 // gets the format details of the texture data
82 // These may return 0 if they haven't been set up yet. The caller needs to detect this case.
83 int getTextureDepth() const { return mRequestedTextureDepth; };
84 int getTextureFormatInternal() const { return mRequestedTextureInternalFormat; };
85 int getTextureFormatPrimary() const { return mRequestedTextureFormat; };
86 int getTextureFormatType() const { return mRequestedTextureType; };
87 bool getTextureFormatSwapBytes() const { return mRequestedTextureSwapBytes; };
88 bool getTextureCoordsOpenGL() const { return mRequestedTextureCoordsOpenGL; };
89
90 void setSize(int width, int height);
91 void setAutoScale(bool auto_scale);
92
93 void setBackgroundColor(LLColor4 color) { mBackgroundColor = color; };
94
95 // Returns true if all of the texture parameters (depth, format, size, and texture size) are set up and consistent.
96 // This will initially be false, and will also be false for some time after setSize while the resize is processed.
97 // Note that if this returns true, it is safe to use all the get() functions above without checking for invalid return values
98 // until you call idle() again.
99 bool textureValid(void);
100
101 bool getDirty(LLRect *dirty_rect = NULL);
102 void resetDirty(void);
103
104 typedef enum
105 {
106 MOUSE_EVENT_DOWN,
107 MOUSE_EVENT_UP,
108 MOUSE_EVENT_MOVE,
109 MOUSE_EVENT_DOUBLE_CLICK
110 }EMouseEventType;
111
112 void mouseEvent(EMouseEventType type, int button, int x, int y, MASK modifiers);
113
114 typedef enum
115 {
116 KEY_EVENT_DOWN,
117 KEY_EVENT_UP,
118 KEY_EVENT_REPEAT
119 }EKeyEventType;
120
121 bool keyEvent(EKeyEventType type, int key_code, MASK modifiers, LLSD native_key_data);
122
123 void scrollEvent(int x, int y, MASK modifiers);
124
125 // Text may be unicode (utf8 encoded)
126 bool textInput(const std::string &text, MASK modifiers, LLSD native_key_data);
127
128 void loadURI(const std::string &uri);
129
130 // "Loading" means uninitialized or any state prior to fully running (processing commands)
131 bool isPluginLoading(void) { return mPlugin?mPlugin->isLoading():false; };
132
133 // "Running" means the steady state -- i.e. processing messages
134 bool isPluginRunning(void) { return mPlugin?mPlugin->isRunning():false; };
135
136 // "Exited" means any regular or error state after "Running" (plugin may have crashed or exited normally)
137 bool isPluginExited(void) { return mPlugin?mPlugin->isDone():false; };
138
139 std::string getPluginVersion() { return mPlugin?mPlugin->getPluginVersion():std::string(""); };
140
141 bool getDisableTimeout() { return mPlugin?mPlugin->getDisableTimeout():false; };
142 void setDisableTimeout(bool disable) { if(mPlugin) mPlugin->setDisableTimeout(disable); };
143
144 // Inherited from LLPluginProcessParentOwner
145 /* virtual */ void receivePluginMessage(const LLPluginMessage &message);
146 /* virtual */ void pluginLaunchFailed();
147 /* virtual */ void pluginDied();
148
149
150 typedef enum
151 {
152 PRIORITY_UNLOADED, // media plugin isn't even loaded.
153 PRIORITY_STOPPED, // media is not playing, shouldn't need to update at all.
154 PRIORITY_HIDDEN, // media is not being displayed or is out of view, don't need to do graphic updates, but may still update audio, playhead, etc.
155 PRIORITY_SLIDESHOW, // media is in the far distance, updates very infrequently
156 PRIORITY_LOW, // media is in the distance, may be rendered at reduced size
157 PRIORITY_NORMAL, // normal (default) priority
158 PRIORITY_HIGH // media has user focus and/or is taking up most of the screen
159 }EPriority;
160
161 static const char* priorityToString(EPriority priority);
162 void setPriority(EPriority priority);
163 void setLowPrioritySizeLimit(int size);
164
165 F64 getCPUUsage();
166
167 // Valid after a MEDIA_EVENT_CURSOR_CHANGED event
168 std::string getCursorName() const { return mCursorName; };
169
170 LLPluginClassMediaOwner::EMediaStatus getStatus() const { return mStatus; }
171
172 void cut();
173 bool canCut() const { return mCanCut; };
174
175 void copy();
176 bool canCopy() const { return mCanCopy; };
177
178 void paste();
179 bool canPaste() const { return mCanPaste; };
180
181 // These can be called before init(), and they will be queued and sent before the media init message.
182 void setUserDataPath(const std::string &user_data_path);
183 void setLanguageCode(const std::string &language_code);
184 void setPluginsEnabled(const bool enabled);
185 void setJavascriptEnabled(const bool enabled);
186
187 ///////////////////////////////////
188 // media browser class functions
189 bool pluginSupportsMediaBrowser(void);
190
191 void focus(bool focused);
192 void clear_cache();
193 void clear_cookies();
194 void set_cookies(const std::string &cookies);
195 void enable_cookies(bool enable);
196 void proxy_setup(bool enable, const std::string &host = LLStringUtil::null, int port = 0);
197 void browse_stop();
198 void browse_reload(bool ignore_cache = false);
199 void browse_forward();
200 void browse_back();
201 void set_status_redirect(int code, const std::string &url);
202 void setBrowserUserAgent(const std::string& user_agent);
203
204 // This is valid after MEDIA_EVENT_NAVIGATE_BEGIN or MEDIA_EVENT_NAVIGATE_COMPLETE
205 std::string getNavigateURI() const { return mNavigateURI; };
206
207 // These are valid after MEDIA_EVENT_NAVIGATE_COMPLETE
208 S32 getNavigateResultCode() const { return mNavigateResultCode; };
209 std::string getNavigateResultString() const { return mNavigateResultString; };
210 bool getHistoryBackAvailable() const { return mHistoryBackAvailable; };
211 bool getHistoryForwardAvailable() const { return mHistoryForwardAvailable; };
212
213 // This is valid after MEDIA_EVENT_PROGRESS_UPDATED
214 int getProgressPercent() const { return mProgressPercent; };
215
216 // This is valid after MEDIA_EVENT_STATUS_TEXT_CHANGED
217 std::string getStatusText() const { return mStatusText; };
218
219 // This is valid after MEDIA_EVENT_LOCATION_CHANGED
220 std::string getLocation() const { return mLocation; };
221
222 // This is valid after MEDIA_EVENT_CLICK_LINK_HREF or MEDIA_EVENT_CLICK_LINK_NOFOLLOW
223 std::string getClickURL() const { return mClickURL; };
224
225 // This is valid after MEDIA_EVENT_CLICK_LINK_HREF
226 std::string getClickTarget() const { return mClickTarget; };
227
228 typedef enum
229 {
230 TARGET_NONE, // empty href target string
231 TARGET_BLANK, // target to open link in user's preferred browser
232 TARGET_EXTERNAL, // target to open link in external browser
233 TARGET_OTHER // nonempty and unsupported target type
234 }ETargetType;
235
236 // This is valid after MEDIA_EVENT_CLICK_LINK_HREF
237 ETargetType getClickTargetType() const { return mClickTargetType; };
238
239 std::string getMediaName() const { return mMediaName; };
240 std::string getMediaDescription() const { return mMediaDescription; };
241
242 // Crash the plugin. If you use this outside of a testbed, you will be punished.
243 void crashPlugin();
244
245 // Hang the plugin. If you use this outside of a testbed, you will be punished.
246 void hangPlugin();
247
248 ///////////////////////////////////
249 // media time class functions
250 bool pluginSupportsMediaTime(void);
251 void stop();
252 void start(float rate = 0.0f);
253 void pause();
254 void seek(float time);
255 void setLoop(bool loop);
256 void setVolume(float volume);
257 float getVolume();
258
259 F64 getCurrentTime(void) const { return mCurrentTime; };
260 F64 getDuration(void) const { return mDuration; };
261 F64 getCurrentPlayRate(void) { return mCurrentRate; };
262 F64 getLoadedDuration(void) const { return mLoadedDuration; };
263
264 // Initialize the URL history of the plugin by sending
265 // "init_history" message
266 void initializeUrlHistory(const LLSD& url_history);
267
268protected:
269
270 LLPluginClassMediaOwner *mOwner;
271
272 // Notify this object's owner that an event has occurred.
273 void mediaEvent(LLPluginClassMediaOwner::EMediaEvent event);
274
275 void sendMessage(const LLPluginMessage &message); // Send message internally, either queueing or sending directly.
276 std::queue<LLPluginMessage> mSendQueue; // Used to queue messages while the plugin initializes.
277
278 void setSizeInternal(void);
279
280 bool mTextureParamsReceived; // the mRequestedTexture* fields are only valid when this is true
281 S32 mRequestedTextureDepth;
282 LLGLenum mRequestedTextureInternalFormat;
283 LLGLenum mRequestedTextureFormat;
284 LLGLenum mRequestedTextureType;
285 bool mRequestedTextureSwapBytes;
286 bool mRequestedTextureCoordsOpenGL;
287
288 std::string mTextureSharedMemoryName;
289 size_t mTextureSharedMemorySize;
290
291 // True to scale requested media up to the full size of the texture (i.e. next power of two)
292 bool mAutoScaleMedia;
293
294 // default media size for the plugin, from the texture_params message.
295 int mDefaultMediaWidth;
296 int mDefaultMediaHeight;
297
298 // Size that has been requested by the plugin itself
299 int mNaturalMediaWidth;
300 int mNaturalMediaHeight;
301
302 // Size that has been requested with setSize()
303 int mSetMediaWidth;
304 int mSetMediaHeight;
305
306 // Full calculated media size (before auto-scale and downsample calculations)
307 int mFullMediaWidth;
308 int mFullMediaHeight;
309
310 // Actual media size being set (after auto-scale)
311 int mRequestedMediaWidth;
312 int mRequestedMediaHeight;
313
314 // Texture size calculated from actual media size
315 int mRequestedTextureWidth;
316 int mRequestedTextureHeight;
317
318 // Size that the plugin has acknowledged
319 int mTextureWidth;
320 int mTextureHeight;
321 int mMediaWidth;
322 int mMediaHeight;
323
324 float mRequestedVolume;
325
326 // Priority of this media stream
327 EPriority mPriority;
328 int mLowPrioritySizeLimit;
329
330 bool mAllowDownsample;
331 int mPadding;
332
333
334 LLPluginProcessParent *mPlugin;
335
336 LLRect mDirtyRect;
337
338 std::string translateModifiers(MASK modifiers);
339
340 std::string mCursorName;
341 int mLastMouseX;
342 int mLastMouseY;
343
344 LLPluginClassMediaOwner::EMediaStatus mStatus;
345
346 F64 mSleepTime;
347
348 bool mCanCut;
349 bool mCanCopy;
350 bool mCanPaste;
351
352 std::string mMediaName;
353 std::string mMediaDescription;
354
355 LLColor4 mBackgroundColor;
356
357 /////////////////////////////////////////
358 // media_browser class
359 std::string mNavigateURI;
360 S32 mNavigateResultCode;
361 std::string mNavigateResultString;
362 bool mHistoryBackAvailable;
363 bool mHistoryForwardAvailable;
364 std::string mStatusText;
365 int mProgressPercent;
366 std::string mLocation;
367 std::string mClickURL;
368 std::string mClickTarget;
369 ETargetType mClickTargetType;
370
371 /////////////////////////////////////////
372 // media_time class
373 F64 mCurrentTime;
374 F64 mDuration;
375 F64 mCurrentRate;
376 F64 mLoadedDuration;
377
378//--------------------------------------
379 //debug use only
380 //
381private:
382 bool mDeleteOK ;
383public:
384 void setDeleteOK(bool flag) { mDeleteOK = flag ;}
385//--------------------------------------
386};
387
388#endif // LL_LLPLUGINCLASSMEDIA_H