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