diff options
Diffstat (limited to 'linden/indra/llmedia/llmediaimplcommon.cpp')
-rw-r--r-- | linden/indra/llmedia/llmediaimplcommon.cpp | 552 |
1 files changed, 0 insertions, 552 deletions
diff --git a/linden/indra/llmedia/llmediaimplcommon.cpp b/linden/indra/llmedia/llmediaimplcommon.cpp deleted file mode 100644 index 166e86d..0000000 --- a/linden/indra/llmedia/llmediaimplcommon.cpp +++ /dev/null | |||
@@ -1,552 +0,0 @@ | |||
1 | /** | ||
2 | * @file llmediaimplcommon.cpp | ||
3 | * @brief Common impl functionality | ||
4 | * | ||
5 | * $LicenseInfo:firstyear=2007&license=viewergpl$ | ||
6 | * | ||
7 | * Copyright (c) 2007-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 | #include "llmediaimplcommon.h" | ||
34 | #include "llmediaemitter.h" | ||
35 | #include "llmediaimplfactory.h" | ||
36 | #include "llmediaobserver.h" | ||
37 | |||
38 | #ifdef WIN32 | ||
39 | // platform specific includes needed before OpenGL header | ||
40 | #include <windows.h> | ||
41 | #include <GL/gl.h> | ||
42 | #elif defined(__APPLE__) | ||
43 | // framework-style include path when building on the Mac. | ||
44 | #include <OpenGL/gl.h> | ||
45 | #else // Assume this is linux | ||
46 | // Linux, MESA headers, but not necessarily assuming MESA runtime. | ||
47 | // quotes so we get libraries/.../GL/ version | ||
48 | #include "GL/gl.h" | ||
49 | #endif | ||
50 | |||
51 | //////////////////////////////////////////////////////////////////////////////// | ||
52 | // virtual (derives from LLMediaBase) | ||
53 | LLMediaImplCommon::LLMediaImplCommon() : | ||
54 | mMimeType( std::string() ), | ||
55 | mInitialURL( std::string() ), | ||
56 | mImplMaker( NULL ), | ||
57 | mAutoScaled( false ), | ||
58 | mMediaWidth( 0 ), | ||
59 | mMediaPrevWidth( 0 ), | ||
60 | mMediaHeight( 0 ), | ||
61 | mMediaPrevHeight( 0 ), | ||
62 | mMediaDepth( 0 ), | ||
63 | mMediaPrevDepth( 0 ), | ||
64 | mMediaRowSpan( 0 ), | ||
65 | mMediaRequestedWidth( 0 ), | ||
66 | mMediaRequestedHeight( 0 ), | ||
67 | mCommand( LLMediaBase::COMMAND_NONE ), | ||
68 | mStatus( LLMediaBase::STATUS_UNKNOWN ), | ||
69 | mVolume( 0 ), | ||
70 | mLooping( false ), | ||
71 | mDebugLevel( LLMediaBase::DEBUG_LEVEL_NONE ) | ||
72 | { | ||
73 | } | ||
74 | |||
75 | //////////////////////////////////////////////////////////////////////////////// | ||
76 | // virtual (derives from LLMediaBase) | ||
77 | LLMediaImplCommon::~LLMediaImplCommon() | ||
78 | { | ||
79 | } | ||
80 | |||
81 | //////////////////////////////////////////////////////////////////////////////// | ||
82 | // virtual (derives from LLMediaBase) | ||
83 | bool LLMediaImplCommon::init() | ||
84 | { | ||
85 | return false; | ||
86 | } | ||
87 | |||
88 | //////////////////////////////////////////////////////////////////////////////// | ||
89 | // virtual (derives from LLMediaBase) | ||
90 | bool LLMediaImplCommon::reset() | ||
91 | { | ||
92 | return false; | ||
93 | } | ||
94 | |||
95 | //////////////////////////////////////////////////////////////////////////////// | ||
96 | // virtual (derives from LLMediaBase) | ||
97 | bool LLMediaImplCommon::setDebugLevel( LLMediaBase::EDebugLevel level ) | ||
98 | { | ||
99 | mDebugLevel = level; | ||
100 | |||
101 | return true; | ||
102 | } | ||
103 | |||
104 | //////////////////////////////////////////////////////////////////////////////// | ||
105 | // virtual (derives from LLMediaBase) | ||
106 | bool LLMediaImplCommon::setMimeType( const std::string mime_type ) | ||
107 | { | ||
108 | mMimeType = mime_type; | ||
109 | |||
110 | return true; | ||
111 | } | ||
112 | |||
113 | //////////////////////////////////////////////////////////////////////////////// | ||
114 | // virtual (derives from LLMediaBase) | ||
115 | std::string LLMediaImplCommon::getMimeType() const | ||
116 | { | ||
117 | return mMimeType; | ||
118 | } | ||
119 | |||
120 | //////////////////////////////////////////////////////////////////////////////// | ||
121 | // virtual (derives from LLMediaBase) | ||
122 | std::string LLMediaImplCommon::getMediaURL() const | ||
123 | { | ||
124 | return mInitialURL; | ||
125 | } | ||
126 | |||
127 | //////////////////////////////////////////////////////////////////////////////// | ||
128 | // virtual (derives from LLMediaBase) | ||
129 | std::string LLMediaImplCommon::getVersion() | ||
130 | { | ||
131 | return std::string( "" ); | ||
132 | } | ||
133 | |||
134 | //////////////////////////////////////////////////////////////////////////////// | ||
135 | // virtual (derives from LLMediaBase) | ||
136 | bool LLMediaImplCommon::set404RedirectUrl( std::string redirect_url ) | ||
137 | { | ||
138 | return true; | ||
139 | } | ||
140 | |||
141 | //////////////////////////////////////////////////////////////////////////////// | ||
142 | // virtual (derives from LLMediaBase) | ||
143 | bool LLMediaImplCommon::clr404RedirectUrl() | ||
144 | { | ||
145 | return true; | ||
146 | } | ||
147 | |||
148 | //////////////////////////////////////////////////////////////////////////////// | ||
149 | // virtual (derives from LLMediaBase) | ||
150 | bool LLMediaImplCommon::setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const | ||
151 | { | ||
152 | return true; | ||
153 | } | ||
154 | |||
155 | //////////////////////////////////////////////////////////////////////////////// | ||
156 | // virtual (derives from LLMediaBase) | ||
157 | bool LLMediaImplCommon::setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const | ||
158 | { | ||
159 | return true; | ||
160 | } | ||
161 | |||
162 | //////////////////////////////////////////////////////////////////////////////// | ||
163 | // virtual (derives from LLMediaBase) | ||
164 | bool LLMediaImplCommon::updateMedia() | ||
165 | { | ||
166 | return false; | ||
167 | } | ||
168 | |||
169 | //////////////////////////////////////////////////////////////////////////////// | ||
170 | // virtual (derives from LLMediaBase) | ||
171 | unsigned char* LLMediaImplCommon::getMediaData() | ||
172 | { | ||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | //////////////////////////////////////////////////////////////////////////////// | ||
177 | // virtual (derives from LLMediaBase) | ||
178 | int LLMediaImplCommon::getMediaDataWidth() const | ||
179 | { | ||
180 | return getMediaWidth(); | ||
181 | } | ||
182 | |||
183 | //////////////////////////////////////////////////////////////////////////////// | ||
184 | // virtual (derives from LLMediaBase) | ||
185 | int LLMediaImplCommon::getMediaDataHeight() const | ||
186 | { | ||
187 | return getMediaHeight(); | ||
188 | } | ||
189 | |||
190 | |||
191 | //////////////////////////////////////////////////////////////////////////////// | ||
192 | // virtual (derives from LLMediaBase) | ||
193 | bool LLMediaImplCommon::setMediaSize( int media_width, int media_height ) | ||
194 | { | ||
195 | // if nothing changed, don't do anything | ||
196 | if ( ( mMediaWidth == media_width ) && | ||
197 | ( mMediaHeight == media_height ) ) | ||
198 | return false; | ||
199 | |||
200 | // save old values so we can tell elsewhere if media size has changed | ||
201 | mMediaPrevWidth = mMediaWidth; | ||
202 | mMediaPrevHeight = mMediaHeight; | ||
203 | |||
204 | mMediaWidth = media_width; | ||
205 | mMediaHeight = media_height; | ||
206 | |||
207 | // only fire an event if the width changed | ||
208 | LLMediaEvent event( this ); | ||
209 | mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event ); | ||
210 | |||
211 | return true; | ||
212 | } | ||
213 | |||
214 | //////////////////////////////////////////////////////////////////////////////// | ||
215 | // virtual (derives from LLMediaBase) | ||
216 | int LLMediaImplCommon::getMediaWidth() const | ||
217 | { | ||
218 | return mMediaWidth; | ||
219 | } | ||
220 | |||
221 | |||
222 | //////////////////////////////////////////////////////////////////////////////// | ||
223 | // virtual (derives from LLMediaBase) | ||
224 | int LLMediaImplCommon::getMediaHeight() const | ||
225 | { | ||
226 | return mMediaHeight; | ||
227 | } | ||
228 | |||
229 | //////////////////////////////////////////////////////////////////////////////// | ||
230 | // virtual (derives from LLMediaBase) | ||
231 | bool LLMediaImplCommon::setRequestedMediaSize(int width, int height) | ||
232 | { | ||
233 | mMediaRequestedWidth = width; | ||
234 | mMediaRequestedHeight = height; | ||
235 | |||
236 | return true; | ||
237 | } | ||
238 | |||
239 | //////////////////////////////////////////////////////////////////////////////// | ||
240 | // virtual (derives from LLMediaBase) | ||
241 | bool LLMediaImplCommon::setMediaDepth( int media_depth ) | ||
242 | { | ||
243 | // if nothing changed, don't do anything | ||
244 | if ( mMediaDepth == media_depth ) | ||
245 | return false; | ||
246 | |||
247 | // save old values so we can tell elsewhere if media size has changed | ||
248 | mMediaPrevDepth = mMediaDepth; | ||
249 | mMediaDepth = media_depth; | ||
250 | |||
251 | // update value of rowspan too since it's based on media width & depth | ||
252 | mMediaRowSpan = mMediaWidth * mMediaDepth; | ||
253 | |||
254 | // only fire an event if the depth changed | ||
255 | //LLMediaEvent event( this ); | ||
256 | //mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event ); | ||
257 | |||
258 | return true; | ||
259 | } | ||
260 | |||
261 | //////////////////////////////////////////////////////////////////////////////// | ||
262 | // virtual (derives from LLMediaBase) | ||
263 | int LLMediaImplCommon::getMediaDepth() const | ||
264 | { | ||
265 | return mMediaDepth; | ||
266 | } | ||
267 | |||
268 | //////////////////////////////////////////////////////////////////////////////// | ||
269 | // virtual (derives from LLMediaBase) | ||
270 | int LLMediaImplCommon::getMediaBufferSize() const | ||
271 | { | ||
272 | return mMediaRowSpan * mMediaHeight; | ||
273 | } | ||
274 | |||
275 | //////////////////////////////////////////////////////////////////////////////// | ||
276 | // virtual (derives from LLMediaBase) | ||
277 | int LLMediaImplCommon::getTextureFormatInternal() const | ||
278 | { | ||
279 | return LL_MEDIA_RGB; | ||
280 | } | ||
281 | |||
282 | //////////////////////////////////////////////////////////////////////////////// | ||
283 | // virtual (derives from LLMediaBase) | ||
284 | int LLMediaImplCommon::getTextureFormatPrimary() const | ||
285 | { | ||
286 | return LL_MEDIA_RGB; | ||
287 | } | ||
288 | |||
289 | //////////////////////////////////////////////////////////////////////////////// | ||
290 | // virtual (derives from LLMediaBase) | ||
291 | int LLMediaImplCommon::getTextureFormatType() const | ||
292 | { | ||
293 | return LL_MEDIA_UNSIGNED_BYTE; | ||
294 | } | ||
295 | |||
296 | //////////////////////////////////////////////////////////////////////////////// | ||
297 | // virtual (derives from LLMediaBase) | ||
298 | bool LLMediaImplCommon::setVolume( float volume ) | ||
299 | { | ||
300 | mVolume = volume; | ||
301 | |||
302 | return true; | ||
303 | } | ||
304 | |||
305 | //////////////////////////////////////////////////////////////////////////////// | ||
306 | // virtual (derives from LLMediaBase) | ||
307 | float LLMediaImplCommon::getVolume() const | ||
308 | { | ||
309 | return mVolume; | ||
310 | } | ||
311 | |||
312 | //////////////////////////////////////////////////////////////////////////////// | ||
313 | // virtual (derives from LLMediaBase) | ||
314 | bool LLMediaImplCommon::addCommand( LLMediaBase::ECommand cmd ) | ||
315 | { | ||
316 | // eventually will be a std::queue so you can add multiple commands | ||
317 | mCommand = cmd; | ||
318 | |||
319 | return true; | ||
320 | } | ||
321 | |||
322 | //////////////////////////////////////////////////////////////////////////////// | ||
323 | // virtual (derives from LLMediaBase) | ||
324 | bool LLMediaImplCommon::clearCommand() | ||
325 | { | ||
326 | // eventually will be a std::queue so you can add multiple commands | ||
327 | mCommand = LLMediaBase::COMMAND_NONE; | ||
328 | |||
329 | return true; | ||
330 | } | ||
331 | |||
332 | //////////////////////////////////////////////////////////////////////////////// | ||
333 | // virtual (derives from LLMediaBase) | ||
334 | bool LLMediaImplCommon::updateCommand() | ||
335 | { | ||
336 | if ( nextCommand() == LLMediaBase::COMMAND_START ) | ||
337 | { | ||
338 | setStatus( LLMediaBase::STATUS_STARTED ); | ||
339 | clearCommand(); | ||
340 | }; | ||
341 | |||
342 | if ( nextCommand() == LLMediaBase::COMMAND_STOP ) | ||
343 | { | ||
344 | setStatus( LLMediaBase::STATUS_STOPPED ); | ||
345 | clearCommand(); | ||
346 | }; | ||
347 | |||
348 | if ( nextCommand() == LLMediaBase::COMMAND_PAUSE ) | ||
349 | { | ||
350 | setStatus( LLMediaBase::STATUS_PAUSED ); | ||
351 | clearCommand(); | ||
352 | }; | ||
353 | |||
354 | return true; | ||
355 | } | ||
356 | |||
357 | //////////////////////////////////////////////////////////////////////////////// | ||
358 | // non-virtual (only impls use this) | ||
359 | LLMediaBase::ECommand LLMediaImplCommon::nextCommand() | ||
360 | { | ||
361 | return mCommand; | ||
362 | } | ||
363 | |||
364 | //////////////////////////////////////////////////////////////////////////////// | ||
365 | // virtual (derives from LLMediaBase) | ||
366 | LLMediaBase::EStatus LLMediaImplCommon::getStatus() | ||
367 | { | ||
368 | return mStatus; | ||
369 | } | ||
370 | |||
371 | //////////////////////////////////////////////////////////////////////////////// | ||
372 | // non-virtual (only impls set this) | ||
373 | bool LLMediaImplCommon::setStatus( LLMediaBase::EStatus status ) | ||
374 | { | ||
375 | mStatus = status; | ||
376 | |||
377 | return true; | ||
378 | } | ||
379 | |||
380 | //////////////////////////////////////////////////////////////////////////////// | ||
381 | // virtual (derives from LLMediaBase) | ||
382 | bool LLMediaImplCommon::seek( double time ) | ||
383 | { | ||
384 | return false; | ||
385 | } | ||
386 | |||
387 | //////////////////////////////////////////////////////////////////////////////// | ||
388 | // virtual (derives from LLMediaBase) | ||
389 | bool LLMediaImplCommon::navigateTo( const std::string url ) | ||
390 | { | ||
391 | return false; | ||
392 | } | ||
393 | |||
394 | //////////////////////////////////////////////////////////////////////////////// | ||
395 | // virtual (derives from LLMediaBase) | ||
396 | bool LLMediaImplCommon::setAutoScaled( bool auto_scaled ) | ||
397 | { | ||
398 | mAutoScaled = auto_scaled; | ||
399 | |||
400 | return true; | ||
401 | } | ||
402 | |||
403 | //////////////////////////////////////////////////////////////////////////////// | ||
404 | // virtual (derives from LLMediaBase) | ||
405 | bool LLMediaImplCommon::isAutoScaled() const | ||
406 | { | ||
407 | return mAutoScaled; | ||
408 | } | ||
409 | |||
410 | //////////////////////////////////////////////////////////////////////////////// | ||
411 | // virtual (derives from LLMediaBase) | ||
412 | bool LLMediaImplCommon::mouseDown( int x_pos, int y_pos ) | ||
413 | { | ||
414 | return false; | ||
415 | } | ||
416 | |||
417 | //////////////////////////////////////////////////////////////////////////////// | ||
418 | // virtual (derives from LLMediaBase) | ||
419 | bool LLMediaImplCommon::mouseUp( int x_pos, int y_pos ) | ||
420 | { | ||
421 | return false; | ||
422 | } | ||
423 | |||
424 | //////////////////////////////////////////////////////////////////////////////// | ||
425 | // virtual (derives from LLMediaBase) | ||
426 | bool LLMediaImplCommon::mouseMove( int x_pos, int y_pos ) | ||
427 | { | ||
428 | return false; | ||
429 | } | ||
430 | |||
431 | //////////////////////////////////////////////////////////////////////////////// | ||
432 | // virtual (derives from LLMediaBase) | ||
433 | bool LLMediaImplCommon::keyPress( int key_code ) | ||
434 | { | ||
435 | return false; | ||
436 | } | ||
437 | |||
438 | //////////////////////////////////////////////////////////////////////////////// | ||
439 | // virtual (derives from LLMediaBase) | ||
440 | bool LLMediaImplCommon::scrollByLines( int lines ) | ||
441 | { | ||
442 | return false; | ||
443 | } | ||
444 | |||
445 | //////////////////////////////////////////////////////////////////////////////// | ||
446 | // virtual (derives from LLMediaBase) | ||
447 | bool LLMediaImplCommon::focus( bool focus ) | ||
448 | { | ||
449 | return false; | ||
450 | } | ||
451 | |||
452 | //////////////////////////////////////////////////////////////////////////////// | ||
453 | // virtual (derives from LLMediaBase) | ||
454 | bool LLMediaImplCommon::unicodeInput( unsigned long uni_char ) | ||
455 | { | ||
456 | return false; | ||
457 | } | ||
458 | |||
459 | //////////////////////////////////////////////////////////////////////////////// | ||
460 | // virtual (derives from LLMediaBase) | ||
461 | bool LLMediaImplCommon::mouseLeftDoubleClick( int x_pos, int y_pos ) | ||
462 | { | ||
463 | return false; | ||
464 | } | ||
465 | |||
466 | //////////////////////////////////////////////////////////////////////////////// | ||
467 | // virtual (derives from LLMediaBase) | ||
468 | bool LLMediaImplCommon::navigateForward() | ||
469 | { | ||
470 | return false; | ||
471 | } | ||
472 | |||
473 | //////////////////////////////////////////////////////////////////////////////// | ||
474 | // virtual (derives from LLMediaBase) | ||
475 | bool LLMediaImplCommon::navigateBack() | ||
476 | { | ||
477 | return false; | ||
478 | } | ||
479 | |||
480 | //////////////////////////////////////////////////////////////////////////////// | ||
481 | // virtual (derives from LLMediaBase) | ||
482 | bool LLMediaImplCommon::canNavigateForward() | ||
483 | { | ||
484 | return false; | ||
485 | } | ||
486 | |||
487 | //////////////////////////////////////////////////////////////////////////////// | ||
488 | // virtual (derives from LLMediaBase) | ||
489 | bool LLMediaImplCommon::canNavigateBack() | ||
490 | { | ||
491 | return false; | ||
492 | } | ||
493 | |||
494 | //////////////////////////////////////////////////////////////////////////////// | ||
495 | // virtual (derives from LLMediaBase) | ||
496 | bool LLMediaImplCommon::enableCookies( bool enable ) | ||
497 | { | ||
498 | return false; | ||
499 | } | ||
500 | |||
501 | //////////////////////////////////////////////////////////////////////////////// | ||
502 | // virtual (derives from LLMediaBase) | ||
503 | bool LLMediaImplCommon::clearCache() | ||
504 | { | ||
505 | return false; | ||
506 | } | ||
507 | |||
508 | //////////////////////////////////////////////////////////////////////////////// | ||
509 | // virtual (derives from LLMediaBase) | ||
510 | bool LLMediaImplCommon::clearCookies() | ||
511 | { | ||
512 | return false; | ||
513 | } | ||
514 | |||
515 | //////////////////////////////////////////////////////////////////////////////// | ||
516 | // virtual (derives from LLMediaBase) | ||
517 | bool LLMediaImplCommon::enableProxy(bool enable, std::string proxy_host_name, int proxy_port) | ||
518 | { | ||
519 | return false; | ||
520 | } | ||
521 | //////////////////////////////////////////////////////////////////////////////// | ||
522 | // | ||
523 | bool LLMediaImplCommon::addObserver( LLMediaObserver* subject ) | ||
524 | { | ||
525 | return mEventEmitter.addObserver( subject ); | ||
526 | } | ||
527 | |||
528 | //////////////////////////////////////////////////////////////////////////////// | ||
529 | // | ||
530 | bool LLMediaImplCommon::remObserver( LLMediaObserver* subject ) | ||
531 | { | ||
532 | return mEventEmitter.remObserver( subject ); | ||
533 | } | ||
534 | |||
535 | //////////////////////////////////////////////////////////////////////////////// | ||
536 | // | ||
537 | void LLMediaImplCommon::setImplMaker(LLMediaImplMakerBase* impl_maker) | ||
538 | { | ||
539 | mImplMaker = impl_maker; | ||
540 | } | ||
541 | //////////////////////////////////////////////////////////////////////////////// | ||
542 | // | ||
543 | bool LLMediaImplCommon::supportsMediaType(std::string scheme, std::string type) | ||
544 | { | ||
545 | int idx1 = type.find("/"); | ||
546 | int len = (idx1 == std::string::npos) ? 0 : idx1; | ||
547 | std::string category = type.substr(0,len); | ||
548 | |||
549 | return mImplMaker->supportsScheme(scheme) || | ||
550 | mImplMaker->supportsMimeType(type) || | ||
551 | mImplMaker->supportsMimeTypeCategory(category); | ||
552 | } | ||