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