summaryrefslogtreecommitdiff
path: root/indra/media_plugins/quicktime/media_plugin_quicktime.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/media_plugins/quicktime/media_plugin_quicktime.cpp')
-rwxr-xr-x[-rw-r--r--]indra/media_plugins/quicktime/media_plugin_quicktime.cpp421
1 files changed, 254 insertions, 167 deletions
diff --git a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp
index 556865f771..ff1ed8bfbc 100644..100755
--- a/indra/media_plugins/quicktime/media_plugin_quicktime.cpp
+++ b/indra/media_plugins/quicktime/media_plugin_quicktime.cpp
@@ -1,55 +1,56 @@
-/**
+/**
* @file media_plugin_quicktime.cpp
* @brief QuickTime plugin for LLMedia API plugin system
*
- * $LicenseInfo:firstyear=2008&license=viewergpl$
- *
- * Copyright (c) 2008, Linden Research, Inc.
- *
+ * @cond
+ * $LicenseInfo:firstyear=2008&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlife.com/developers/opensource/gplv2
- *
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at http://secondlife.com/developers/opensource/flossexception
- *
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
- *
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
+ * @endcond
*/
#include "linden_common.h"
#include "llgl.h"
-
+
#include "llplugininstance.h"
#include "llpluginmessage.h"
#include "llpluginmessageclasses.h"
#include "media_plugin_base.h"
-
+
#if LL_QUICKTIME_ENABLED
-
+
#if defined(LL_DARWIN)
- #include <QuickTime/QuickTime.h>
+#include <QuickTime/QuickTime.h>
#elif defined(LL_WINDOWS)
- #include "MacTypes.h"
- #include "QTML.h"
- #include "Movies.h"
- #include "QDoffscreen.h"
- #include "FixMath.h"
+#include "llwin32headers.h"
+#include "MacTypes.h"
+#include "QTML.h"
+#include "Movies.h"
+#include "QDoffscreen.h"
+#include "FixMath.h"
+#include "QTLoadLibraryUtils.h"
#endif
+
+
// TODO: Make sure that the only symbol exported from this library is LLPluginInitEntryPoint
////////////////////////////////////////////////////////////////////////////////
//
@@ -71,11 +72,14 @@ private:
int mCurVolume;
bool mMediaSizeChanging;
bool mIsLooping;
+ std::string mMovieTitle;
+ bool mReceivedTitle;
const int mMinWidth;
const int mMaxWidth;
const int mMinHeight;
const int mMaxHeight;
F64 mPlayRate;
+ std::string mNavigateURL;
enum ECommand {
COMMAND_NONE,
@@ -97,15 +101,14 @@ private:
message.setValueS32("top", top);
message.setValueS32("right", right);
message.setValueS32("bottom", bottom);
-
+
if(mMovieHandle)
{
message.setValueReal("current_time", getCurrentTime());
message.setValueReal("duration", getDuration());
message.setValueReal("current_rate", Fix2X(GetMovieRate(mMovieHandle)));
- message.setValueReal("loaded_duration", getLoadedDuration());
}
-
+
sendMessage(message);
}
@@ -113,16 +116,16 @@ private:
static Rect rectFromSize(int width, int height)
{
Rect result;
-
+
result.left = 0;
result.top = 0;
result.right = width;
result.bottom = height;
-
+
return result;
}
-
+
Fixed getPlayRate(void)
{
Fixed result;
@@ -141,25 +144,27 @@ private:
{
result = X2Fix(mPlayRate);
}
-
+
return result;
}
-
+
void load( const std::string url )
{
+
if ( url.empty() )
return;
-
+
// Stop and unload any existing movie before starting another one.
unload();
-
+
setStatus(STATUS_LOADING);
-
+
//In case std::string::c_str() makes a copy of the url data,
//make sure there is memory to hold it before allocating memory for handle.
//if fails, NewHandleClear(...) should return NULL.
const char* url_string = url.c_str() ;
Handle handle = NewHandleClear( ( Size )( url.length() + 1 ) );
+
if ( NULL == handle || noErr != MemError() || NULL == *handle )
{
setStatus(STATUS_ERROR);
@@ -175,6 +180,11 @@ private:
setStatus(STATUS_ERROR);
return;
};
+
+ mNavigateURL = url;
+ LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_begin");
+ message.setValue("uri", mNavigateURL);
+ sendMessage(message);
// do pre-roll actions (typically fired for streaming movies but not always)
PrePrerollMovie( mMovieHandle, 0, getPlayRate(), moviePrePrerollCompleteCallback, ( void * )this );
@@ -193,12 +203,15 @@ private:
SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, movieDrawingCompleteCallback, ( long )this );
setStatus(STATUS_LOADED);
-
+
sizeChanged();
};
bool unload()
{
+ // new movie and have to get title again
+ mReceivedTitle = false;
+
if ( mMovieHandle )
{
StopMovie( mMovieHandle );
@@ -222,12 +235,8 @@ private:
mMovieHandle = NULL;
};
- if ( mGWorldHandle )
- {
- DisposeGWorld( mGWorldHandle );
- mGWorldHandle = NULL;
- };
-
+ mGWorldHandle = NULL;
+
setStatus(STATUS_NONE);
return true;
@@ -237,7 +246,7 @@ private:
{
unload();
load( url );
-
+
return true;
};
@@ -245,7 +254,7 @@ private:
{
if ( ! mMovieHandle )
return false;
-
+
// Check to see whether the movie's natural size has updated
{
int width, height;
@@ -263,20 +272,19 @@ private:
//std::cerr << "<--- Sending size change request to application with name: " << mTextureSegmentName << " - size is " << width << " x " << height << std::endl;
}
}
-
+
+
// sanitize destination size
Rect dest_rect = rectFromSize(mWidth, mHeight);
// media depth won't change
int depth_bits = mDepth * 8;
long rowbytes = mDepth * mTextureWidth;
-
- GWorldPtr old_gworld_handle = mGWorldHandle;
if(mPixels != NULL)
{
// We have pixels. Set up a GWorld pointing at the texture.
- OSErr result = NewGWorldFromPtr( &mGWorldHandle, depth_bits, &dest_rect, NULL, NULL, 0, (Ptr)mPixels, rowbytes);
+ OSErr result = QTNewGWorldFromPtr( &mGWorldHandle, depth_bits, &dest_rect, NULL, NULL, 0, (Ptr)mPixels, rowbytes);
if ( noErr != result )
{
// TODO: unrecoverable?? throw exception? return something?
@@ -287,7 +295,7 @@ private:
{
// We don't have pixels. Create a fake GWorld we can point the movie at when it's not safe to render normally.
Rect tempRect = rectFromSize(1, 1);
- OSErr result = NewGWorld( &mGWorldHandle, depth_bits, &tempRect, NULL, NULL, 0);
+ OSErr result = QTNewGWorld( &mGWorldHandle, depth_bits, &tempRect, NULL, NULL, 0);
if ( noErr != result )
{
// TODO: unrecoverable?? throw exception? return something?
@@ -295,14 +303,8 @@ private:
}
}
- SetMovieGWorld( mMovieHandle, mGWorldHandle, GetGWorldDevice( mGWorldHandle ) );
-
- // If the GWorld was already set up, delete it.
- if(old_gworld_handle != NULL)
- {
- DisposeGWorld( old_gworld_handle );
- }
-
+ SetMovieGWorld( mMovieHandle, mGWorldHandle, NULL );
+
// Set up the movie display matrix
{
// scale movie to fit rect and invert vertically to match opengl image format
@@ -315,7 +317,7 @@ private:
ScaleMatrix( &transform, X2Fix( scaleX ), X2Fix( scaleY ), X2Fix( centerX ), X2Fix( centerY ) );
SetMovieMatrix( mMovieHandle, &transform );
}
-
+
// update movie controller
if ( mMovieController )
{
@@ -333,7 +335,6 @@ private:
return true;
}
-
static Boolean mcActionFilterCallBack( MovieController mc, short action, void *params, long ref )
{
Boolean result = false;
@@ -343,9 +344,9 @@ private:
switch( action )
{
// handle window resizing
- case mcActionControllerSizeChanged:
+ case mcActionControllerSizeChanged:
// Ensure that the movie draws correctly at the new size
- self->sizeChanged();
+ self->sizeChanged();
break;
// Block any movie controller actions that open URLs.
@@ -374,6 +375,7 @@ private:
// self->updateQuickTime();
// TODO ^^^
+
if ( self->mWidth > 0 && self->mHeight > 0 )
self->setDirty( 0, 0, self->mWidth, self->mHeight );
@@ -382,11 +384,18 @@ private:
static void moviePrePrerollCompleteCallback( Movie movie, OSErr preroll_err, void *ref )
{
- //MediaPluginQuickTime* self = ( MediaPluginQuickTime* )ref;
+ MediaPluginQuickTime* self = ( MediaPluginQuickTime* )ref;
// TODO:
//LLMediaEvent event( self );
//self->mEventEmitter.update( &LLMediaObserver::onMediaPreroll, event );
+
+ // Send a "navigate complete" event.
+ LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER, "navigate_complete");
+ message.setValue("uri", self->mNavigateURL);
+ message.setValueS32("result_code", 200);
+ message.setValue("result_string", "OK");
+ self->sendMessage(message);
};
@@ -400,7 +409,7 @@ private:
{
if ( mCommand == COMMAND_PLAY )
{
- if ( mStatus == STATUS_LOADED || mStatus == STATUS_PAUSED || mStatus == STATUS_PLAYING )
+ if ( mStatus == STATUS_LOADED || mStatus == STATUS_PAUSED || mStatus == STATUS_PLAYING || mStatus == STATUS_DONE )
{
long state = GetMovieLoadState( mMovieHandle );
@@ -415,7 +424,7 @@ private:
MCDoAction( mMovieController, mcActionPlay, (void*)rate );
rewind();
};
-
+
MCDoAction( mMovieController, mcActionPrerollAndPlay, (void*)getPlayRate() );
MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
setStatus(STATUS_PLAYING);
@@ -426,7 +435,7 @@ private:
else
if ( mCommand == COMMAND_STOP )
{
- if ( mStatus == STATUS_PLAYING || mStatus == STATUS_PAUSED )
+ if ( mStatus == STATUS_PLAYING || mStatus == STATUS_PAUSED || mStatus == STATUS_DONE )
{
if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
{
@@ -443,7 +452,7 @@ private:
if ( mCommand == COMMAND_PAUSE )
{
if ( mStatus == STATUS_PLAYING )
- {
+ {
if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
{
Fixed rate = X2Fix( 0.0 );
@@ -476,7 +485,7 @@ private:
void getMovieNaturalSize(int *movie_width, int *movie_height)
{
Rect rect;
-
+
GetMovieNaturalBoundsRect( mMovieHandle, &rect );
int width = ( rect.right - rect.left );
@@ -499,7 +508,7 @@ private:
*movie_width = width;
*movie_height = height;
}
-
+
void updateQuickTime(int milliseconds)
{
if ( ! mMovieHandle )
@@ -508,11 +517,17 @@ private:
if ( ! mMovieController )
return;
- // service QuickTime
- // Calling it this way doesn't have good behavior on Windows...
-// MoviesTask( mMovieHandle, milliseconds );
- // This was the original, but I think using both MoviesTask and MCIdle is redundant. Trying with only MCIdle.
-// MoviesTask( mMovieHandle, 0 );
+ // this wasn't required in 1.xx viewer but we have to manually
+ // work the Windows message pump now
+ #if defined( LL_WINDOWS )
+ MSG msg;
+ while ( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
+ {
+ GetMessage( &msg, NULL, 0, 0 );
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ };
+ #endif
MCIdle( mMovieController );
@@ -525,11 +540,14 @@ private:
// update state machine
processState();
- // special code for looping - need to rewind at the end of the movie
- if ( mIsLooping )
+ // see if title arrived and if so, update member variable with contents
+ checkTitle();
+
+ // QT call to see if we are at the end - can't do with controller
+ if ( IsMovieDone( mMovieHandle ) )
{
- // QT call to see if we are at the end - can't do with controller
- if ( IsMovieDone( mMovieHandle ) )
+ // special code for looping - need to rewind at the end of the movie
+ if ( mIsLooping )
{
// go back to start
rewind();
@@ -542,31 +560,18 @@ private:
// set the volume
MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
};
- };
- };
- };
-
- int getDataWidth() const
- {
- if ( mGWorldHandle )
- {
- int depth = mDepth;
-
- if (depth < 1)
- depth = 1;
-
- // ALWAYS use the row bytes from the PixMap if we have a GWorld because
- // sometimes it's not the same as mMediaDepth * mMediaWidth !
- PixMapHandle pix_map_handle = GetGWorldPixMap( mGWorldHandle );
- return QTGetPixMapHandleRowBytes( pix_map_handle ) / depth;
- }
- else
- {
- // TODO : return LLMediaImplCommon::getaDataWidth();
- return 0;
+ }
+ else
+ {
+ if(mStatus == STATUS_PLAYING)
+ {
+ setStatus(STATUS_DONE);
+ }
+ }
}
- };
+ };
+
void seek( F64 time )
{
if ( mMovieController )
@@ -586,22 +591,22 @@ private:
};
};
- F64 getDuration()
- {
- TimeValue duration = GetMovieDuration( mMovieHandle );
- TimeValue scale = GetMovieTimeScale( mMovieHandle );
+ F64 getLoadedDuration()
+ {
+ TimeValue duration;
+ if(GetMaxLoadedTimeInMovie( mMovieHandle, &duration ) != noErr)
+ {
+ // If GetMaxLoadedTimeInMovie returns an error, return the full duration of the movie.
+ duration = GetMovieDuration( mMovieHandle );
+ }
+ TimeValue scale = GetMovieTimeScale( mMovieHandle );
- return (F64)duration / (F64)scale;
- };
+ return (F64)duration / (F64)scale;
+ };
- F64 getLoadedDuration()
+ F64 getDuration()
{
- TimeValue duration;
- if(GetMaxLoadedTimeInMovie( mMovieHandle, &duration ) != noErr)
- {
- // If GetMaxLoadedTimeInMovie returns an error, return the full duration of the movie.
- duration = GetMovieDuration( mMovieHandle );
- }
+ TimeValue duration = GetMovieDuration( mMovieHandle );
TimeValue scale = GetMovieTimeScale( mMovieHandle );
return (F64)duration / (F64)scale;
@@ -656,6 +661,77 @@ private:
{
};
+ ////////////////////////////////////////////////////////////////////////////////
+ // Grab movie title into mMovieTitle - should be called repeatedly
+ // until it returns true since movie title takes a while to become
+ // available.
+ const bool getMovieTitle()
+ {
+ // grab meta data from movie
+ QTMetaDataRef media_data_ref;
+ OSErr result = QTCopyMovieMetaData( mMovieHandle, &media_data_ref );
+ if ( noErr != result )
+ return false;
+
+ // look up "Display Name" in meta data
+ OSType meta_data_key = kQTMetaDataCommonKeyDisplayName;
+ QTMetaDataItem item = kQTMetaDataItemUninitialized;
+ result = (OSErr)QTMetaDataGetNextItem( media_data_ref, kQTMetaDataStorageFormatWildcard,
+ 0, kQTMetaDataKeyFormatCommon,
+ (const UInt8 *)&meta_data_key,
+ sizeof( meta_data_key ), &item );
+ if ( noErr != result )
+ return false;
+
+ // find the size of the title
+ ByteCount size;
+ result = (OSErr)QTMetaDataGetItemValue( media_data_ref, item, NULL, 0, &size );
+ if ( noErr != result || size <= 0 /*|| size > 1024 FIXME: arbitrary limit */ )
+ return false;
+
+ // allocate some space and grab it
+ UInt8* item_data = new UInt8[ size + 1 ];
+ memset( item_data, 0, ( size + 1 ) * sizeof( UInt8 ) );
+ result = (OSErr)QTMetaDataGetItemValue( media_data_ref, item, item_data, size, NULL );
+ if ( noErr != result )
+ {
+ delete [] item_data;
+ return false;
+ };
+
+ // save it
+ if ( strlen( (char*)item_data ) )
+ mMovieTitle = std::string( (char* )item_data );
+ else
+ mMovieTitle = "";
+
+ // clean up
+ delete [] item_data;
+
+ return true;
+ };
+
+ // called regularly to see if title changed
+ void checkTitle()
+ {
+ // we did already receive title so keep checking
+ if ( ! mReceivedTitle )
+ {
+ // grab title from movie meta data
+ if ( getMovieTitle() )
+ {
+ // pass back to host application
+ LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "name_text");
+ message.setValue("name", mMovieTitle );
+ sendMessage( message );
+
+ // stop looking once we find a title for this movie.
+ // TODO: this may to be reset if movie title changes
+ // during playback but this is okay for now
+ mReceivedTitle = true;
+ };
+ };
+ };
};
MediaPluginQuickTime::MediaPluginQuickTime(
@@ -677,6 +753,8 @@ MediaPluginQuickTime::MediaPluginQuickTime(
mCurVolume = 0x99;
mMediaSizeChanging = false;
mIsLooping = false;
+ mMovieTitle = std::string();
+ mReceivedTitle = false;
mCommand = COMMAND_NONE;
mPlayRate = 0.0f;
mStatus = STATUS_NONE;
@@ -713,22 +791,29 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION;
versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION;
// Normally a plugin would only specify one of these two subclasses, but this is a demo...
-// versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER] = LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER_VERSION;
versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME] = LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME_VERSION;
message.setValueLLSD("versions", versions);
#ifdef LL_WINDOWS
- if ( InitializeQTML( 0L ) != noErr )
+
+ // QuickTime 7.6.4 has an issue (that was not present in 7.6.2) with initializing QuickTime
+ // according to this article: http://lists.apple.com/archives/QuickTime-API/2009/Sep/msg00097.html
+ // The solution presented there appears to work.
+ QTLoadLibrary("qtcf.dll");
+
+ // main initialization for QuickTime - only required on Windows
+ OSErr result = InitializeQTML( 0L );
+ if ( result != noErr )
{
//TODO: If no QT on Windows, this fails - respond accordingly.
- //return false;
}
else
{
-// std::cerr << "QuickTime initialized" << std::endl;
+ //std::cerr << "QuickTime initialized" << std::endl;
};
#endif
+ // required for both Windows and Mac
EnterMovies();
std::string plugin_version = "QuickTime media plugin, QuickTime version ";
@@ -740,42 +825,12 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
plugin_version += codec.str();
message.setValue("plugin_version", plugin_version);
sendMessage(message);
-
- // Plugin gets to decide the texture parameters to use.
- message.setMessage(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
- #if defined(LL_WINDOWS)
- // Values for Windows
- mDepth = 3;
- message.setValueU32("format", GL_RGB);
- message.setValueU32("type", GL_UNSIGNED_BYTE);
-
- // We really want to pad the texture width to a multiple of 32 bytes, but since we're using 3-byte pixels, it doesn't come out even.
- // Padding to a multiple of 3*32 guarantees it'll divide out properly.
- message.setValueU32("padding", 32 * 3);
- #else
- // Values for Mac
- mDepth = 4;
- message.setValueU32("format", GL_BGRA_EXT);
- #ifdef __BIG_ENDIAN__
- message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV );
- #else
- message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8);
- #endif
-
- // Pad texture width to a multiple of 32 bytes, to line up with cache lines.
- message.setValueU32("padding", 32);
- #endif
- message.setValueS32("depth", mDepth);
- message.setValueU32("internalformat", GL_RGB);
- message.setValueBoolean("coords_opengl", true); // true == use OpenGL-style coordinates, false == (0,0) is upper left.
- message.setValueBoolean("allow_downsample", true);
- sendMessage(message);
}
else if(message_name == "idle")
{
// no response is necessary here.
F64 time = message_in.getValueReal("time");
-
+
// Convert time to milliseconds for update()
update((int)(time * 1000.0f));
}
@@ -789,8 +844,6 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
info.mAddress = message_in.getValuePointer("address");
info.mSize = (size_t)message_in.getValueS32("size");
std::string name = message_in.getValue("name");
-
-
// std::cerr << "MediaPluginQuickTime::receiveMessage: shared memory added, name: " << name
// << ", size: " << info.mSize
// << ", address: " << info.mAddress
@@ -813,9 +866,9 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
// This is the currently active pixel buffer. Make sure we stop drawing to it.
mPixels = NULL;
mTextureSegmentName.clear();
-
+
// Make sure the movie GWorld is no longer pointed at the shared segment.
- sizeChanged();
+ sizeChanged();
}
mSharedSegments.erase(iter);
}
@@ -836,7 +889,41 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
}
else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA)
{
- if(message_name == "size_change")
+ if(message_name == "init")
+ {
+ // This is the media init message -- all necessary data for initialization should have been received.
+
+ // Plugin gets to decide the texture parameters to use.
+ LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
+ #if defined(LL_WINDOWS)
+ // Values for Windows
+ mDepth = 3;
+ message.setValueU32("format", GL_RGB);
+ message.setValueU32("type", GL_UNSIGNED_BYTE);
+
+ // We really want to pad the texture width to a multiple of 32 bytes, but since we're using 3-byte pixels, it doesn't come out even.
+ // Padding to a multiple of 3*32 guarantees it'll divide out properly.
+ message.setValueU32("padding", 32 * 3);
+ #else
+ // Values for Mac
+ mDepth = 4;
+ message.setValueU32("format", GL_BGRA_EXT);
+ #ifdef __BIG_ENDIAN__
+ message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV );
+ #else
+ message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8);
+ #endif
+
+ // Pad texture width to a multiple of 32 bytes, to line up with cache lines.
+ message.setValueU32("padding", 32);
+ #endif
+ message.setValueS32("depth", mDepth);
+ message.setValueU32("internalformat", GL_RGB);
+ message.setValueBoolean("coords_opengl", true); // true == use OpenGL-style coordinates, false == (0,0) is upper left.
+ message.setValueBoolean("allow_downsample", true);
+ sendMessage(message);
+ }
+ else if(message_name == "size_change")
{
std::string name = message_in.getValue("name");
S32 width = message_in.getValueS32("width");
@@ -872,9 +959,9 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
mTextureHeight = texture_height;
mMediaSizeChanging = false;
-
+
sizeChanged();
-
+
update();
};
};
@@ -883,14 +970,14 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
{
std::string uri = message_in.getValue("uri");
load( uri );
- sendStatus();
+ sendStatus();
}
else if(message_name == "mouse_event")
{
std::string event = message_in.getValue("event");
S32 x = message_in.getValueS32("x");
S32 y = message_in.getValueS32("y");
-
+
if(event == "down")
{
mouseDown(x, y);
@@ -983,7 +1070,7 @@ MediaPluginQuickTime::~MediaPluginQuickTime()
void MediaPluginQuickTime::receiveMessage(const char *message_string)
{
- // no-op
+ // no-op
}
// We're building without quicktime enabled. Just refuse to initialize.