00001
00032 #include "llmediaimplcommon.h"
00033 #include "llmediaemitter.h"
00034 #include "llmediaimplfactory.h"
00035 #include "llmediaobserver.h"
00036
00037 #ifdef WIN32
00038
00039 #include <windows.h>
00040 #include <GL/gl.h>
00041 #elif defined(__APPLE__)
00042
00043 #include <OpenGL/gl.h>
00044 #else // Assume this is linux
00045
00046
00047 #include "GL/gl.h"
00048 #endif
00049
00051
00052 LLMediaImplCommon::LLMediaImplCommon() :
00053 mMimeType( std::string() ),
00054 mInitialURL( std::string() ),
00055 mImplMaker( NULL ),
00056 mAutoScaled( false ),
00057 mMediaWidth( 0 ),
00058 mMediaPrevWidth( 0 ),
00059 mMediaHeight( 0 ),
00060 mMediaPrevHeight( 0 ),
00061 mMediaDepth( 0 ),
00062 mMediaPrevDepth( 0 ),
00063 mMediaRowSpan( 0 ),
00064 mMediaRequestedWidth( 0 ),
00065 mMediaRequestedHeight( 0 ),
00066 mCommand( LLMediaBase::COMMAND_NONE ),
00067 mStatus( LLMediaBase::STATUS_UNKNOWN ),
00068 mVolume( 0 ),
00069 mLooping( false )
00070 {
00071 }
00072
00074
00075 LLMediaImplCommon::~LLMediaImplCommon()
00076 {
00077 }
00078
00080
00081 bool LLMediaImplCommon::init()
00082 {
00083 return false;
00084 }
00085
00087
00088 bool LLMediaImplCommon::reset()
00089 {
00090 return false;
00091 }
00092
00094
00095 bool LLMediaImplCommon::setMimeType( const std::string mime_type )
00096 {
00097 mMimeType = mime_type;
00098
00099 return true;
00100 }
00101
00103
00104 std::string LLMediaImplCommon::getMimeType() const
00105 {
00106 return mMimeType;
00107 }
00108
00110
00111 std::string LLMediaImplCommon::getMediaURL() const
00112 {
00113 return mInitialURL;
00114 }
00115
00117
00118 std::string LLMediaImplCommon::getVersion()
00119 {
00120 return std::string( "" );
00121 }
00122
00124
00125 bool LLMediaImplCommon::set404RedirectUrl( std::string redirect_url )
00126 {
00127 return true;
00128 }
00129
00131
00132 bool LLMediaImplCommon::clr404RedirectUrl()
00133 {
00134 return true;
00135 }
00136
00138
00139 bool LLMediaImplCommon::setBackgroundColor( unsigned int red, unsigned int green, unsigned int blue ) const
00140 {
00141 return true;
00142 }
00143
00145
00146 bool LLMediaImplCommon::setCaretColor( unsigned int red, unsigned int green, unsigned int blue ) const
00147 {
00148 return true;
00149 }
00150
00152
00153 bool LLMediaImplCommon::updateMedia()
00154 {
00155 return false;
00156 }
00157
00159
00160 unsigned char* LLMediaImplCommon::getMediaData()
00161 {
00162 return 0;
00163 }
00164
00166
00167 int LLMediaImplCommon::getMediaDataWidth() const
00168 {
00169 return getMediaWidth();
00170 }
00171
00173
00174 int LLMediaImplCommon::getMediaDataHeight() const
00175 {
00176 return getMediaHeight();
00177 }
00178
00179
00181
00182 bool LLMediaImplCommon::setMediaSize( int media_width, int media_height )
00183 {
00184
00185 if ( ( mMediaWidth == media_width ) &&
00186 ( mMediaHeight == media_height ) )
00187 return false;
00188
00189
00190 mMediaPrevWidth = mMediaWidth;
00191 mMediaPrevHeight = mMediaHeight;
00192
00193 mMediaWidth = media_width;
00194 mMediaHeight = media_height;
00195
00196
00197 LLMediaEvent event( this );
00198 mEventEmitter.update( &LLMediaObserver::onMediaSizeChange, event );
00199
00200 return true;
00201 }
00202
00204
00205 int LLMediaImplCommon::getMediaWidth() const
00206 {
00207 return mMediaWidth;
00208 }
00209
00210
00212
00213 int LLMediaImplCommon::getMediaHeight() const
00214 {
00215 return mMediaHeight;
00216 }
00217
00219
00220 bool LLMediaImplCommon::setRequestedMediaSize(int width, int height)
00221 {
00222 mMediaRequestedWidth = width;
00223 mMediaRequestedHeight = height;
00224
00225 return true;
00226 }
00227
00229
00230 bool LLMediaImplCommon::setMediaDepth( int media_depth )
00231 {
00232
00233 if ( mMediaDepth == media_depth )
00234 return false;
00235
00236
00237 mMediaPrevDepth = mMediaDepth;
00238 mMediaDepth = media_depth;
00239
00240
00241 mMediaRowSpan = mMediaWidth * mMediaDepth;
00242
00243
00244
00245
00246
00247 return true;
00248 }
00249
00251
00252 int LLMediaImplCommon::getMediaDepth() const
00253 {
00254 return mMediaDepth;
00255 }
00256
00258
00259 int LLMediaImplCommon::getMediaBufferSize() const
00260 {
00261 return mMediaRowSpan * mMediaHeight;
00262 }
00263
00265
00266 int LLMediaImplCommon::getTextureFormatInternal() const
00267 {
00268 return LL_MEDIA_RGB;
00269 }
00270
00272
00273 int LLMediaImplCommon::getTextureFormatPrimary() const
00274 {
00275 return LL_MEDIA_RGB;
00276 }
00277
00279
00280 int LLMediaImplCommon::getTextureFormatType() const
00281 {
00282 return LL_MEDIA_UNSIGNED_BYTE;
00283 }
00284
00286
00287 bool LLMediaImplCommon::setVolume( float volume )
00288 {
00289 mVolume = volume;
00290
00291 return true;
00292 }
00293
00295
00296 float LLMediaImplCommon::getVolume() const
00297 {
00298 return mVolume;
00299 }
00300
00302
00303 bool LLMediaImplCommon::addCommand( LLMediaBase::ECommand cmd )
00304 {
00305
00306 mCommand = cmd;
00307
00308 return true;
00309 }
00310
00312
00313 bool LLMediaImplCommon::clearCommand()
00314 {
00315
00316 mCommand = LLMediaBase::COMMAND_NONE;
00317
00318 return true;
00319 }
00320
00322
00323 bool LLMediaImplCommon::updateCommand()
00324 {
00325 if ( nextCommand() == LLMediaBase::COMMAND_START )
00326 {
00327 setStatus( LLMediaBase::STATUS_STARTED );
00328 clearCommand();
00329 };
00330
00331 if ( nextCommand() == LLMediaBase::COMMAND_STOP )
00332 {
00333 setStatus( LLMediaBase::STATUS_STOPPED );
00334 clearCommand();
00335 };
00336
00337 if ( nextCommand() == LLMediaBase::COMMAND_PAUSE )
00338 {
00339 setStatus( LLMediaBase::STATUS_PAUSED );
00340 clearCommand();
00341 };
00342
00343 return true;
00344 }
00345
00347
00348 LLMediaBase::ECommand LLMediaImplCommon::nextCommand()
00349 {
00350 return mCommand;
00351 }
00352
00354
00355 LLMediaBase::EStatus LLMediaImplCommon::getStatus()
00356 {
00357 return mStatus;
00358 }
00359
00361
00362 bool LLMediaImplCommon::setStatus( LLMediaBase::EStatus status )
00363 {
00364 mStatus = status;
00365
00366 return true;
00367 }
00368
00370
00371 bool LLMediaImplCommon::seek( double time )
00372 {
00373 return false;
00374 }
00375
00377
00378 bool LLMediaImplCommon::navigateTo( const std::string url )
00379 {
00380 return false;
00381 }
00382
00384
00385 bool LLMediaImplCommon::setAutoScaled( bool auto_scaled )
00386 {
00387 mAutoScaled = auto_scaled;
00388
00389 return true;
00390 }
00391
00393
00394 bool LLMediaImplCommon::isAutoScaled() const
00395 {
00396 return mAutoScaled;
00397 }
00398
00400
00401 bool LLMediaImplCommon::mouseDown( int x_pos, int y_pos )
00402 {
00403 return false;
00404 }
00405
00407
00408 bool LLMediaImplCommon::mouseUp( int x_pos, int y_pos )
00409 {
00410 return false;
00411 }
00412
00414
00415 bool LLMediaImplCommon::mouseMove( int x_pos, int y_pos )
00416 {
00417 return false;
00418 }
00419
00421
00422 bool LLMediaImplCommon::keyPress( int key_code )
00423 {
00424 return false;
00425 }
00426
00428
00429 bool LLMediaImplCommon::scrollByLines( int lines )
00430 {
00431 return false;
00432 }
00433
00435
00436 bool LLMediaImplCommon::focus( bool focus )
00437 {
00438 return false;
00439 }
00440
00442
00443 bool LLMediaImplCommon::unicodeInput( unsigned long uni_char )
00444 {
00445 return false;
00446 }
00447
00449
00450 bool LLMediaImplCommon::mouseLeftDoubleClick( int x_pos, int y_pos )
00451 {
00452 return false;
00453 }
00454
00456
00457 bool LLMediaImplCommon::navigateForward()
00458 {
00459 return false;
00460 }
00461
00463
00464 bool LLMediaImplCommon::navigateBack()
00465 {
00466 return false;
00467 }
00468
00470
00471 bool LLMediaImplCommon::canNavigateForward()
00472 {
00473 return false;
00474 }
00475
00477
00478 bool LLMediaImplCommon::canNavigateBack()
00479 {
00480 return false;
00481 }
00482
00484
00485 bool LLMediaImplCommon::enableCookies( bool enable )
00486 {
00487 return false;
00488 }
00489
00491
00492 bool LLMediaImplCommon::clearCache()
00493 {
00494 return false;
00495 }
00496
00498
00499 bool LLMediaImplCommon::clearCookies()
00500 {
00501 return false;
00502 }
00503
00505
00506 bool LLMediaImplCommon::enableProxy(bool enable, std::string proxy_host_name, int proxy_port)
00507 {
00508 return false;
00509 }
00511
00512 bool LLMediaImplCommon::addObserver( LLMediaObserver* subject )
00513 {
00514 return mEventEmitter.addObserver( subject );
00515 }
00516
00518
00519 bool LLMediaImplCommon::remObserver( LLMediaObserver* subject )
00520 {
00521 return mEventEmitter.remObserver( subject );
00522 }
00523
00525
00526 void LLMediaImplCommon::setImplMaker(LLMediaImplMakerBase* impl_maker)
00527 {
00528 mImplMaker = impl_maker;
00529 }
00531
00532 bool LLMediaImplCommon::supportsMediaType(std::string scheme, std::string type)
00533 {
00534 int idx1 = type.find("/");
00535 int len = (idx1 == std::string::npos) ? 0 : idx1;
00536 std::string category = type.substr(0,len);
00537
00538 return mImplMaker->supportsScheme(scheme) ||
00539 mImplMaker->supportsMimeType(type) ||
00540 mImplMaker->supportsMimeTypeCategory(category);
00541 }