Fixed web browser thanks to ArminW/Imprudence
This commit is contained in:
180
indra/media_plugins/quicktime/media_plugin_quicktime.cpp
Normal file → Executable file
180
indra/media_plugins/quicktime/media_plugin_quicktime.cpp
Normal file → Executable file
@@ -1,33 +1,29 @@
|
||||
/**
|
||||
/**
|
||||
* @file media_plugin_quicktime.cpp
|
||||
* @brief QuickTime plugin for LLMedia API plugin system
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2008-2009, 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://secondlifegrid.net/programs/open_source/licensing/gplv2
|
||||
* Copyright (C) 2010, Linden Research, Inc.
|
||||
*
|
||||
* 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://secondlifegrid.net/programs/open_source/licensing/flossexception
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
* 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.
|
||||
*
|
||||
* ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
|
||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
||||
* COMPLETENESS OR PERFORMANCE.
|
||||
* 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"
|
||||
@@ -102,14 +98,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)));
|
||||
}
|
||||
|
||||
|
||||
sendMessage(message);
|
||||
}
|
||||
|
||||
@@ -117,16 +113,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;
|
||||
@@ -145,25 +141,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);
|
||||
@@ -202,7 +200,7 @@ private:
|
||||
SetMovieDrawingCompleteProc( mMovieHandle, movieDrawingCallWhenChanged, movieDrawingCompleteCallback, ( long )this );
|
||||
|
||||
setStatus(STATUS_LOADED);
|
||||
|
||||
|
||||
sizeChanged();
|
||||
};
|
||||
|
||||
@@ -239,7 +237,7 @@ private:
|
||||
DisposeGWorld( mGWorldHandle );
|
||||
mGWorldHandle = NULL;
|
||||
};
|
||||
|
||||
|
||||
setStatus(STATUS_NONE);
|
||||
|
||||
return true;
|
||||
@@ -249,7 +247,7 @@ private:
|
||||
{
|
||||
unload();
|
||||
load( url );
|
||||
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
@@ -257,7 +255,7 @@ private:
|
||||
{
|
||||
if ( ! mMovieHandle )
|
||||
return false;
|
||||
|
||||
|
||||
// Check to see whether the movie's natural size has updated
|
||||
{
|
||||
int width, height;
|
||||
@@ -275,14 +273,14 @@ 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)
|
||||
@@ -314,7 +312,7 @@ private:
|
||||
{
|
||||
DisposeGWorld( old_gworld_handle );
|
||||
}
|
||||
|
||||
|
||||
// Set up the movie display matrix
|
||||
{
|
||||
// scale movie to fit rect and invert vertically to match opengl image format
|
||||
@@ -327,7 +325,7 @@ private:
|
||||
ScaleMatrix( &transform, X2Fix( scaleX ), X2Fix( scaleY ), X2Fix( centerX ), X2Fix( centerY ) );
|
||||
SetMovieMatrix( mMovieHandle, &transform );
|
||||
}
|
||||
|
||||
|
||||
// update movie controller
|
||||
if ( mMovieController )
|
||||
{
|
||||
@@ -345,7 +343,6 @@ private:
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static Boolean mcActionFilterCallBack( MovieController mc, short action, void *params, long ref )
|
||||
{
|
||||
Boolean result = false;
|
||||
@@ -355,9 +352,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.
|
||||
@@ -386,6 +383,7 @@ private:
|
||||
// self->updateQuickTime();
|
||||
// TODO ^^^
|
||||
|
||||
|
||||
if ( self->mWidth > 0 && self->mHeight > 0 )
|
||||
self->setDirty( 0, 0, self->mWidth, self->mHeight );
|
||||
|
||||
@@ -434,7 +432,7 @@ private:
|
||||
MCDoAction( mMovieController, mcActionPlay, (void*)rate );
|
||||
rewind();
|
||||
};
|
||||
|
||||
|
||||
MCDoAction( mMovieController, mcActionPrerollAndPlay, (void*)getPlayRate() );
|
||||
MCDoAction( mMovieController, mcActionSetVolume, (void*)mCurVolume );
|
||||
setStatus(STATUS_PLAYING);
|
||||
@@ -462,7 +460,7 @@ private:
|
||||
if ( mCommand == COMMAND_PAUSE )
|
||||
{
|
||||
if ( mStatus == STATUS_PLAYING )
|
||||
{
|
||||
{
|
||||
if ( GetMovieLoadState( mMovieHandle ) >= kMovieLoadStatePlaythroughOK )
|
||||
{
|
||||
Fixed rate = X2Fix( 0.0 );
|
||||
@@ -495,7 +493,7 @@ private:
|
||||
void getMovieNaturalSize(int *movie_width, int *movie_height)
|
||||
{
|
||||
Rect rect;
|
||||
|
||||
|
||||
GetMovieNaturalBoundsRect( mMovieHandle, &rect );
|
||||
|
||||
int width = ( rect.right - rect.left );
|
||||
@@ -518,7 +516,7 @@ private:
|
||||
*movie_width = width;
|
||||
*movie_height = height;
|
||||
}
|
||||
|
||||
|
||||
void updateQuickTime(int milliseconds)
|
||||
{
|
||||
if ( ! mMovieHandle )
|
||||
@@ -721,8 +719,8 @@ private:
|
||||
return false;
|
||||
|
||||
// allocate some space and grab it
|
||||
UInt8* item_data = new UInt8[size + 1];
|
||||
memset(item_data, 0, (size + 1) * sizeof(UInt8));
|
||||
UInt8* item_data = new UInt8[ size + 1 ];
|
||||
memset( item_data, 0, ( size + 1 ) * sizeof( UInt8 ) );
|
||||
result = QTMetaDataGetItemValue( media_data_ref, item, item_data, size, NULL );
|
||||
if ( noErr != result )
|
||||
{
|
||||
@@ -856,42 +854,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));
|
||||
}
|
||||
@@ -905,8 +873,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
|
||||
@@ -929,9 +895,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);
|
||||
}
|
||||
@@ -952,7 +918,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");
|
||||
@@ -988,9 +988,9 @@ void MediaPluginQuickTime::receiveMessage(const char *message_string)
|
||||
mTextureHeight = texture_height;
|
||||
|
||||
mMediaSizeChanging = false;
|
||||
|
||||
|
||||
sizeChanged();
|
||||
|
||||
|
||||
update();
|
||||
};
|
||||
};
|
||||
@@ -999,14 +999,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);
|
||||
@@ -1099,7 +1099,7 @@ MediaPluginQuickTime::~MediaPluginQuickTime()
|
||||
|
||||
void MediaPluginQuickTime::receiveMessage(const char *message_string)
|
||||
{
|
||||
// no-op
|
||||
// no-op
|
||||
}
|
||||
|
||||
// We're building without quicktime enabled. Just refuse to initialize.
|
||||
|
||||
Reference in New Issue
Block a user