Our media system has changed, so should the test
This commit is contained in:
0
indra/test_apps/llplugintest/CMakeLists.txt
Normal file → Executable file
0
indra/test_apps/llplugintest/CMakeLists.txt
Normal file → Executable file
0
indra/test_apps/llplugintest/bookmarks.txt
Normal file → Executable file
0
indra/test_apps/llplugintest/bookmarks.txt
Normal file → Executable file
0
indra/test_apps/llplugintest/demo_media_plugin.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/demo_media_plugin.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/demo_media_plugin_2.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/demo_media_plugin_2.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/demo_plugin.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/demo_plugin.cpp
Normal file → Executable file
442
indra/test_apps/llplugintest/llmediaplugintest.cpp
Normal file → Executable file
442
indra/test_apps/llplugintest/llmediaplugintest.cpp
Normal file → Executable file
@@ -2,30 +2,25 @@
|
||||
* @file LLMediaPluginTest.cpp
|
||||
* @brief Primary test application for LLMedia (Separate Process) Plugin system
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2009, Linden Research, Inc.
|
||||
*
|
||||
* $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$
|
||||
*/
|
||||
|
||||
@@ -66,11 +61,11 @@ static void gluiCallbackWrapper( int control_id );
|
||||
static bool isTexture( GLuint texture )
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
|
||||
// glIsTexture will sometimes return false for real textures... do this instead.
|
||||
if(texture != 0)
|
||||
result = true;
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -95,24 +90,24 @@ mediaPanel::~mediaPanel()
|
||||
glDeleteTextures( 1, &mPickTextureHandle );
|
||||
mPickTextureHandle = 0;
|
||||
}
|
||||
|
||||
|
||||
if ( isTexture( mMediaTextureHandle ) )
|
||||
{
|
||||
std::cerr << "remMediaPanel: deleting media texture " << mMediaTextureHandle << std::endl;
|
||||
glDeleteTextures( 1, &mMediaTextureHandle );
|
||||
mMediaTextureHandle = 0;
|
||||
}
|
||||
|
||||
|
||||
if(mPickTexturePixels)
|
||||
{
|
||||
delete mPickTexturePixels;
|
||||
}
|
||||
|
||||
|
||||
if(mMediaSource)
|
||||
{
|
||||
delete mMediaSource;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -128,6 +123,7 @@ LLMediaPluginTest::LLMediaPluginTest( int app_window, int window_width, int wind
|
||||
mCurMouseY( 0 ),
|
||||
mFuzzyMedia( true ),
|
||||
mSelectedPanel( 0 ),
|
||||
mDistanceCameraToSelectedGeometry( 0.0f ),
|
||||
mMediaBrowserControlEnableCookies( 0 ),
|
||||
mMediaBrowserControlBackButton( 0 ),
|
||||
mMediaBrowserControlForwardButton( 0 ),
|
||||
@@ -151,7 +147,7 @@ LLMediaPluginTest::LLMediaPluginTest( int app_window, int window_width, int wind
|
||||
//mBookmarks.push_back( std::pair< std::string, std::string >( "description", "url" ) );
|
||||
|
||||
// read bookmarks from file.
|
||||
// note: uses command in ./CmakeLists.txt which copies bookmmarks file from source directory
|
||||
// note: uses command in ./CmakeLists.txt which copies bookmmarks file from source directory
|
||||
// to app directory (WITHOUT build configuration dir) (this is cwd in Windows within MSVC)
|
||||
// For example, test_apps\llplugintest and not test_apps\llplugintest\Release
|
||||
// This may need to be changed for Mac/Linux builds.
|
||||
@@ -193,7 +189,7 @@ LLMediaPluginTest::LLMediaPluginTest( int app_window, int window_width, int wind
|
||||
// initialize linden lab APR module
|
||||
ll_init_apr();
|
||||
|
||||
// Set up llerror logging
|
||||
// Set up llerror logging
|
||||
{
|
||||
LLError::initForApplication(".");
|
||||
LLError::setDefaultLevel(LLError::LEVEL_INFO);
|
||||
@@ -240,6 +236,9 @@ LLMediaPluginTest::~LLMediaPluginTest()
|
||||
{
|
||||
remMediaPanel( mMediaPanels[ i ] );
|
||||
};
|
||||
|
||||
// Stop the plugin read thread if it's running.
|
||||
LLPluginProcessParent::setUseReadThread(false);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -273,7 +272,7 @@ void LLMediaPluginTest::reshape( int width, int height )
|
||||
void LLMediaPluginTest::bindTexture(GLuint texture, GLint row_length, GLint alignment)
|
||||
{
|
||||
glEnable( GL_TEXTURE_2D );
|
||||
|
||||
|
||||
glBindTexture( GL_TEXTURE_2D, texture );
|
||||
glPixelStorei( GL_UNPACK_ROW_LENGTH, row_length );
|
||||
glPixelStorei( GL_UNPACK_ALIGNMENT, alignment );
|
||||
@@ -285,27 +284,57 @@ bool LLMediaPluginTest::checkGLError(const char *name)
|
||||
{
|
||||
bool result = false;
|
||||
GLenum error = glGetError();
|
||||
|
||||
|
||||
if(error != GL_NO_ERROR)
|
||||
{
|
||||
// For some reason, glGenTextures is returning GL_INVALID_VALUE...
|
||||
std::cout << name << " ERROR 0x" << std::hex << error << std::dec << std::endl;
|
||||
result = true;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void LLMediaPluginTest::drawGeometry( int panel )
|
||||
GLfloat LLMediaPluginTest::distanceToCamera( GLfloat point_x, GLfloat point_y, GLfloat point_z )
|
||||
{
|
||||
GLdouble camera_pos_x = 0.0f;
|
||||
GLdouble camera_pos_y = 0.0f;
|
||||
GLdouble camera_pos_z = 0.0f;
|
||||
|
||||
GLdouble modelMatrix[16];
|
||||
GLdouble projMatrix[16];
|
||||
GLint viewport[4];
|
||||
|
||||
glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
|
||||
glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
|
||||
glGetIntegerv(GL_VIEWPORT, viewport);
|
||||
|
||||
gluUnProject(
|
||||
(viewport[2]-viewport[0])/2 , (viewport[3]-viewport[1])/2,
|
||||
0.0,
|
||||
modelMatrix, projMatrix, viewport,
|
||||
&camera_pos_x, &camera_pos_y, &camera_pos_z );
|
||||
|
||||
GLfloat distance =
|
||||
sqrt( ( camera_pos_x - point_x ) * ( camera_pos_x - point_x ) +
|
||||
( camera_pos_y - point_y ) * ( camera_pos_y - point_y ) +
|
||||
( camera_pos_z - point_z ) * ( camera_pos_z - point_z ) );
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void LLMediaPluginTest::drawGeometry( int panel, bool selected )
|
||||
{
|
||||
// texture coordinates for each panel
|
||||
GLfloat non_opengl_texture_coords[ 8 ] = { 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f };
|
||||
GLfloat opengl_texture_coords[ 8 ] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
||||
|
||||
GLfloat *texture_coords = mMediaPanels[ panel ]->mAppTextureCoordsOpenGL?opengl_texture_coords:non_opengl_texture_coords;
|
||||
|
||||
|
||||
// base coordinates for each panel
|
||||
GLfloat base_vertex_pos[ 8 ] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f };
|
||||
|
||||
@@ -316,31 +345,35 @@ void LLMediaPluginTest::drawGeometry( int panel )
|
||||
const int panel_x = ( panel / num_rows );
|
||||
const int panel_y = ( panel % num_rows );
|
||||
|
||||
const float spacing = 0.1f;
|
||||
// default spacing is small - make it larger if checkbox set - for testing positional audio
|
||||
float spacing = 0.1f;
|
||||
if ( mLargePanelSpacing )
|
||||
spacing = 2.0f;
|
||||
|
||||
const GLfloat offset_x = num_cols * ( 1.0 + spacing ) / 2;
|
||||
const GLfloat offset_y = num_rows * ( 1.0 + spacing ) / 2;
|
||||
|
||||
|
||||
// Adjust for media aspect ratios
|
||||
{
|
||||
{
|
||||
float aspect = 1.0f;
|
||||
|
||||
if(mMediaPanels[ panel ]->mMediaHeight != 0)
|
||||
{
|
||||
aspect = (float)mMediaPanels[ panel ]->mMediaWidth / (float)mMediaPanels[ panel ]->mMediaHeight;
|
||||
}
|
||||
|
||||
|
||||
if(aspect > 1.0f)
|
||||
{
|
||||
// media is wider than it is high -- adjust the top and bottom in
|
||||
for( int corner = 0; corner < 4; ++corner )
|
||||
{
|
||||
float temp = base_vertex_pos[corner * 2 + 1];
|
||||
|
||||
|
||||
if(temp < 0.5f)
|
||||
temp += 0.5 - (0.5f / aspect);
|
||||
else
|
||||
temp -= 0.5 - (0.5f / aspect);
|
||||
|
||||
|
||||
base_vertex_pos[corner * 2 + 1] = temp;
|
||||
}
|
||||
}
|
||||
@@ -350,7 +383,7 @@ void LLMediaPluginTest::drawGeometry( int panel )
|
||||
for( int corner = 0; corner < 4; ++corner )
|
||||
{
|
||||
float temp = base_vertex_pos[corner * 2];
|
||||
|
||||
|
||||
if(temp < 0.5f)
|
||||
temp += 0.5f - (0.5f * aspect);
|
||||
else
|
||||
@@ -371,6 +404,15 @@ void LLMediaPluginTest::drawGeometry( int panel )
|
||||
glVertex3f( x, y, 0.0f );
|
||||
};
|
||||
glEnd();
|
||||
|
||||
// calculate distance to this panel if it's selected
|
||||
if ( selected )
|
||||
{
|
||||
GLfloat point_x = base_vertex_pos[ 0 ] + panel_x * ( 1.0 + spacing ) - offset_x + spacing / 2.0f;
|
||||
GLfloat point_y = base_vertex_pos[ 0 + 1 ] + panel_y * ( 1.0 + spacing ) - offset_y + spacing / 2.0f;
|
||||
GLfloat point_z = 0.0f;
|
||||
mDistanceCameraToSelectedGeometry = distanceToCamera( point_x, point_y, point_z );
|
||||
};
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@@ -403,7 +445,7 @@ void LLMediaPluginTest::draw( int draw_type )
|
||||
if ( draw_type == DrawTypePickTexture )
|
||||
{
|
||||
// only bother with pick if we have something to render
|
||||
// Actually, we need to pick even if we're not ready to render.
|
||||
// Actually, we need to pick even if we're not ready to render.
|
||||
// Otherwise you can't select and remove a panel which has gone bad.
|
||||
//if ( mMediaPanels[ panel ]->mReadyToRender )
|
||||
{
|
||||
@@ -420,7 +462,7 @@ void LLMediaPluginTest::draw( int draw_type )
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
|
||||
// draw geometry using pick texture
|
||||
drawGeometry( panel );
|
||||
drawGeometry( panel, false );
|
||||
|
||||
glMatrixMode( GL_TEXTURE );
|
||||
glPopMatrix();
|
||||
@@ -431,13 +473,13 @@ void LLMediaPluginTest::draw( int draw_type )
|
||||
{
|
||||
bool texture_valid = false;
|
||||
bool plugin_exited = false;
|
||||
|
||||
|
||||
if(mMediaPanels[ panel ]->mMediaSource)
|
||||
{
|
||||
texture_valid = mMediaPanels[ panel ]->mMediaSource->textureValid();
|
||||
plugin_exited = mMediaPanels[ panel ]->mMediaSource->isPluginExited();
|
||||
}
|
||||
|
||||
|
||||
// save texture matrix (changes for each panel)
|
||||
glMatrixMode( GL_TEXTURE );
|
||||
glPushMatrix();
|
||||
@@ -465,14 +507,14 @@ void LLMediaPluginTest::draw( int draw_type )
|
||||
mMediaPanels[ panel ]->mTextureScaleY,
|
||||
1.0f );
|
||||
};
|
||||
|
||||
|
||||
float intensity = plugin_exited?0.25f:1.0f;
|
||||
|
||||
|
||||
// highlight the selected panel
|
||||
if ( mSelectedPanel && ( mMediaPanels[ panel ]->mId == mSelectedPanel->mId ) )
|
||||
{
|
||||
startPanelHighlight( intensity, intensity, 0.0f, 5.0f );
|
||||
drawGeometry( panel );
|
||||
drawGeometry( panel, true );
|
||||
endPanelHighlight();
|
||||
}
|
||||
else
|
||||
@@ -481,21 +523,21 @@ void LLMediaPluginTest::draw( int draw_type )
|
||||
if ( !mMediaPanels[ panel ]->mReadyToRender )
|
||||
{
|
||||
startPanelHighlight( intensity, 0.0f, 0.0f, 2.0f );
|
||||
drawGeometry( panel );
|
||||
drawGeometry( panel, false );
|
||||
endPanelHighlight();
|
||||
}
|
||||
else
|
||||
// just display a border around the media
|
||||
// just display a border around the media
|
||||
{
|
||||
startPanelHighlight( 0.0f, intensity, 0.0f, 2.0f );
|
||||
drawGeometry( panel );
|
||||
drawGeometry( panel, false );
|
||||
endPanelHighlight();
|
||||
};
|
||||
|
||||
|
||||
if ( mMediaPanels[ panel ]->mReadyToRender && texture_valid )
|
||||
{
|
||||
// draw visual geometry
|
||||
drawGeometry( panel );
|
||||
drawGeometry( panel, false );
|
||||
}
|
||||
|
||||
// restore texture matrix (changes for each panel)
|
||||
@@ -551,7 +593,7 @@ void LLMediaPluginTest::idle()
|
||||
// GLUI requires this
|
||||
if ( glutGetWindow() != mAppWindow )
|
||||
glutSetWindow( mAppWindow );
|
||||
|
||||
|
||||
// random creation/destruction of panels enabled?
|
||||
const time_t panel_timeout_time = 5;
|
||||
if ( mRandomPanelCount )
|
||||
@@ -704,7 +746,7 @@ void LLMediaPluginTest::idle()
|
||||
for( int panel_index = 0; panel_index < (int)mMediaPanels.size(); ++panel_index )
|
||||
{
|
||||
mediaPanel *panel = mMediaPanels[ panel_index ];
|
||||
|
||||
|
||||
// call plugins idle function so it can potentially update itself
|
||||
panel->mMediaSource->idle();
|
||||
|
||||
@@ -717,7 +759,7 @@ void LLMediaPluginTest::idle()
|
||||
//std::cout << "texture invalid, skipping update..." << std::endl;
|
||||
}
|
||||
else
|
||||
if ( panel &&
|
||||
if ( panel &&
|
||||
( panel->mMediaWidth != panel->mMediaSource->getWidth() ||
|
||||
panel->mMediaHeight != panel->mMediaSource->getHeight() ) )
|
||||
{
|
||||
@@ -733,7 +775,7 @@ void LLMediaPluginTest::idle()
|
||||
int y_offset = dirty_rect.mBottom;
|
||||
int width = dirty_rect.mRight - dirty_rect.mLeft;
|
||||
int height = dirty_rect.mTop - dirty_rect.mBottom;
|
||||
|
||||
|
||||
if((dirty_rect.mRight <= panel->mTextureWidth) && (dirty_rect.mTop <= panel->mTextureHeight))
|
||||
{
|
||||
// Offset the pixels pointer properly
|
||||
@@ -752,23 +794,23 @@ void LLMediaPluginTest::idle()
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
|
||||
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
|
||||
};
|
||||
|
||||
|
||||
checkGLError("glTexParameteri");
|
||||
|
||||
|
||||
if(panel->mMediaSource->getTextureFormatSwapBytes())
|
||||
{
|
||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, 1);
|
||||
checkGLError("glPixelStorei");
|
||||
}
|
||||
|
||||
|
||||
// draw portion that changes into texture
|
||||
glTexSubImage2D( GL_TEXTURE_2D, 0,
|
||||
x_offset,
|
||||
glTexSubImage2D( GL_TEXTURE_2D, 0,
|
||||
x_offset,
|
||||
y_offset,
|
||||
width,
|
||||
width,
|
||||
height,
|
||||
panel->mMediaSource->getTextureFormatPrimary(),
|
||||
panel->mMediaSource->getTextureFormatType(),
|
||||
panel->mMediaSource->getTextureFormatPrimary(),
|
||||
panel->mMediaSource->getTextureFormatType(),
|
||||
pixels );
|
||||
|
||||
if(checkGLError("glTexSubImage2D"))
|
||||
@@ -788,9 +830,9 @@ void LLMediaPluginTest::idle()
|
||||
glPixelStorei(GL_UNPACK_SWAP_BYTES, 0);
|
||||
checkGLError("glPixelStorei");
|
||||
}
|
||||
|
||||
|
||||
panel->mMediaSource->resetDirty();
|
||||
|
||||
|
||||
panel->mReadyToRender = true;
|
||||
}
|
||||
else
|
||||
@@ -811,8 +853,8 @@ void LLMediaPluginTest::idle()
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void LLMediaPluginTest::windowPosToTexturePos( int window_x, int window_y,
|
||||
int& media_x, int& media_y,
|
||||
void LLMediaPluginTest::windowPosToTexturePos( int window_x, int window_y,
|
||||
int& media_x, int& media_y,
|
||||
int& id )
|
||||
{
|
||||
if ( ! mSelectedPanel )
|
||||
@@ -828,7 +870,7 @@ void LLMediaPluginTest::windowPosToTexturePos( int window_x, int window_y,
|
||||
// OpenGL app == coordinate system this way
|
||||
// NOTE: unrelated to settings in plugin - this
|
||||
// is just for this app
|
||||
mCurMouseY = mWindowHeight - window_y;
|
||||
mCurMouseY = mWindowHeight - window_y;
|
||||
|
||||
// extract x (0..1023, y (0..1023) and id (0..15) from RGB components
|
||||
unsigned long pixel_read_color_bits = ( mPixelReadColor[ 0 ] << 16 ) | ( mPixelReadColor[ 1 ] << 8 ) | mPixelReadColor[ 2 ];
|
||||
@@ -880,14 +922,14 @@ void LLMediaPluginTest::selectPanel( mediaPanel* panel )
|
||||
mSelectedPanel->mMediaSource->setVolume( 0.0f );
|
||||
mSelectedPanel->mMediaSource->setPriority( LLPluginClassMedia::PRIORITY_LOW );
|
||||
};
|
||||
|
||||
|
||||
mSelectedPanel = panel;
|
||||
|
||||
if( mSelectedPanel && mSelectedPanel->mMediaSource )
|
||||
{
|
||||
mSelectedPanel->mMediaSource->setVolume( (float)mMediaTimeControlVolume / 100.0f );
|
||||
mSelectedPanel->mMediaSource->setPriority( LLPluginClassMedia::PRIORITY_NORMAL );
|
||||
|
||||
|
||||
if(!mSelectedPanel->mStartUrl.empty())
|
||||
{
|
||||
mUrlEdit->set_text(const_cast<char*>(mSelectedPanel->mStartUrl.c_str()) );
|
||||
@@ -900,7 +942,7 @@ void LLMediaPluginTest::selectPanel( mediaPanel* panel )
|
||||
mediaPanel* LLMediaPluginTest::findMediaPanel( LLPluginClassMedia* source )
|
||||
{
|
||||
mediaPanel *result = NULL;
|
||||
|
||||
|
||||
for( int panel = 0; panel < (int)mMediaPanels.size(); ++panel )
|
||||
{
|
||||
if ( mMediaPanels[ panel ]->mMediaSource == source )
|
||||
@@ -908,7 +950,24 @@ mediaPanel* LLMediaPluginTest::findMediaPanel( LLPluginClassMedia* source )
|
||||
result = mMediaPanels[ panel ];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
mediaPanel* LLMediaPluginTest::findMediaPanel( const std::string &target_name )
|
||||
{
|
||||
mediaPanel *result = NULL;
|
||||
|
||||
for( int panel = 0; panel < (int)mMediaPanels.size(); ++panel )
|
||||
{
|
||||
if ( mMediaPanels[ panel ]->mTarget == target_name )
|
||||
{
|
||||
result = mMediaPanels[ panel ];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1003,6 +1062,11 @@ void LLMediaPluginTest::gluiCallback( int control_id )
|
||||
}
|
||||
}
|
||||
else
|
||||
if ( control_id == mIdUsePluginReadThread )
|
||||
{
|
||||
LLPluginProcessParent::setUseReadThread(mUsePluginReadThread);
|
||||
}
|
||||
else
|
||||
if ( control_id == mIdControlCrashPlugin )
|
||||
{
|
||||
// send message to plugin and ask it to crash
|
||||
@@ -1066,7 +1130,7 @@ void LLMediaPluginTest::gluiCallback( int control_id )
|
||||
{
|
||||
if ( mSelectedPanel )
|
||||
{
|
||||
// get value from spinner
|
||||
// get value from spinner
|
||||
float seconds_to_seek = mMediaTimeControlSeekSeconds;
|
||||
mSelectedPanel->mMediaSource->seek( seconds_to_seek );
|
||||
mSelectedPanel->mMediaSource->start();
|
||||
@@ -1169,8 +1233,8 @@ void LLMediaPluginTest::keyboard( int key )
|
||||
exit( 0 );
|
||||
};
|
||||
|
||||
mSelectedPanel->mMediaSource->keyEvent( LLPluginClassMedia::KEY_EVENT_DOWN, key, 0 );
|
||||
mSelectedPanel->mMediaSource->keyEvent( LLPluginClassMedia::KEY_EVENT_UP, key, 0 );
|
||||
mSelectedPanel->mMediaSource->keyEvent( LLPluginClassMedia::KEY_EVENT_DOWN, key, 0 , LLSD());
|
||||
mSelectedPanel->mMediaSource->keyEvent( LLPluginClassMedia::KEY_EVENT_UP, key, 0, LLSD());
|
||||
};
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1194,7 +1258,7 @@ void LLMediaPluginTest::mouseButton( int button, int state, int x, int y )
|
||||
windowPosToTexturePos( x, y, media_x, media_y, id );
|
||||
|
||||
// only select a panel if we're on a panel
|
||||
// (HACK: strictly speaking this rules out clicking on
|
||||
// (HACK: strictly speaking this rules out clicking on
|
||||
// the origin of a panel but that's very unlikely)
|
||||
if ( media_x > 0 && media_y > 0 )
|
||||
{
|
||||
@@ -1327,18 +1391,18 @@ void LLMediaPluginTest::makeChrome()
|
||||
mGluiMediaTimeControlWindow->add_column( false );
|
||||
mIdMediaTimeControlVolume = start_id++;
|
||||
GLUI_Spinner* spinner = mGluiMediaTimeControlWindow->add_spinner( "Volume", 2, &mMediaTimeControlVolume, mIdMediaTimeControlVolume, gluiCallbackWrapper);
|
||||
spinner->set_float_limits( 0, 100 );
|
||||
spinner->set_float_limits( 0, 100 );
|
||||
mGluiMediaTimeControlWindow->add_column( true );
|
||||
mIdMediaTimeControlSeekSeconds = start_id++;
|
||||
spinner = mGluiMediaTimeControlWindow->add_spinner( "", 2, &mMediaTimeControlSeekSeconds, mIdMediaTimeControlSeekSeconds, gluiCallbackWrapper);
|
||||
spinner->set_float_limits( 0, 200 );
|
||||
spinner->set_float_limits( 0, 200 );
|
||||
spinner->set_w( 32 );
|
||||
spinner->set_speed( 0.025f );
|
||||
mGluiMediaTimeControlWindow->add_column( false );
|
||||
mIdMediaTimeControlSeek = start_id++;
|
||||
mGluiMediaTimeControlWindow->add_button( "SEEK", mIdMediaTimeControlSeek, gluiCallbackWrapper );
|
||||
mGluiMediaTimeControlWindow->add_column( false );
|
||||
|
||||
|
||||
|
||||
// top window - media controls for "browser" media types (e.g. web browser)
|
||||
mGluiMediaBrowserControlWindow = GLUI_Master.create_glui_subwindow( mAppWindow, GLUI_SUBWINDOW_TOP );
|
||||
@@ -1385,6 +1449,19 @@ void LLMediaPluginTest::makeChrome()
|
||||
mDisableTimeout = 0;
|
||||
glui_window_misc_control->add_checkbox( "Disable plugin timeout", &mDisableTimeout, mIdDisableTimeout, gluiCallbackWrapper );
|
||||
glui_window_misc_control->set_main_gfx_window( mAppWindow );
|
||||
glui_window_misc_control->add_column( true );
|
||||
|
||||
mIdUsePluginReadThread = start_id++;
|
||||
mUsePluginReadThread = 0;
|
||||
glui_window_misc_control->add_checkbox( "Use plugin read thread", &mUsePluginReadThread, mIdUsePluginReadThread, gluiCallbackWrapper );
|
||||
glui_window_misc_control->set_main_gfx_window( mAppWindow );
|
||||
glui_window_misc_control->add_column( true );
|
||||
|
||||
mIdLargePanelSpacing = start_id++;
|
||||
mLargePanelSpacing = 0;
|
||||
glui_window_misc_control->add_checkbox( "Large Panel Spacing", &mLargePanelSpacing, mIdLargePanelSpacing, gluiCallbackWrapper );
|
||||
glui_window_misc_control->set_main_gfx_window( mAppWindow );
|
||||
glui_window_misc_control->add_column( true );
|
||||
|
||||
// bottom window - status
|
||||
mBottomGLUIWindow = GLUI_Master.create_glui_subwindow( mAppWindow, GLUI_SUBWINDOW_BOTTOM );
|
||||
@@ -1449,7 +1526,7 @@ void LLMediaPluginTest::makePickTexture( int id, GLuint* texture_handle, unsigne
|
||||
//
|
||||
std::string LLMediaPluginTest::mimeTypeFromUrl( std::string& url )
|
||||
{
|
||||
// default to web
|
||||
// default to web
|
||||
std::string mime_type = "text/html";
|
||||
|
||||
// we may need a more advanced MIME type accessor later :-)
|
||||
@@ -1479,7 +1556,7 @@ std::string LLMediaPluginTest::pluginNameFromMimeType( std::string& mime_type )
|
||||
else
|
||||
if ( mime_type == "text/html" )
|
||||
plugin_name = "media_plugin_webkit.dylib";
|
||||
|
||||
|
||||
#elif LL_WINDOWS
|
||||
std::string plugin_name( "media_plugin_null.dll" );
|
||||
|
||||
@@ -1506,7 +1583,7 @@ std::string LLMediaPluginTest::pluginNameFromMimeType( std::string& mime_type )
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
mediaPanel* LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
{
|
||||
// Get the plugin filename using the URL
|
||||
std::string mime_type = mimeTypeFromUrl( url );
|
||||
@@ -1523,7 +1600,7 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
// tell the plugin what size we asked for
|
||||
media_source->setSize( media_width, media_height );
|
||||
|
||||
// Use the launcher start and initialize the plugin
|
||||
// Use the launcher start and initialize the plugin
|
||||
#if LL_DARWIN || LL_LINUX
|
||||
std::string launcher_name( "SLPlugin" );
|
||||
#elif LL_WINDOWS
|
||||
@@ -1538,12 +1615,12 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
if (NULL == getcwd( cwd, FILENAME_MAX - 1 ))
|
||||
{
|
||||
std::cerr << "Couldn't get cwd - probably too long - failing to init." << std::endl;
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
std::string user_data_path = std::string( cwd ) + "/";
|
||||
#endif
|
||||
|
||||
media_source->init( launcher_name, plugin_name, false, user_data_path );
|
||||
media_source->setUserDataPath(user_data_path);
|
||||
media_source->init( launcher_name, plugin_name, false );
|
||||
media_source->setDisableTimeout(mDisableTimeout);
|
||||
|
||||
// make a new panel and save parameters
|
||||
@@ -1580,7 +1657,7 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
// id wasn't found so we can use it
|
||||
if ( ! id_exists )
|
||||
{
|
||||
panel->mId = nid;
|
||||
panel->mId = nid;
|
||||
break;
|
||||
};
|
||||
};
|
||||
@@ -1592,7 +1669,7 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
}
|
||||
else
|
||||
{
|
||||
// now we have the ID we can use it to make the
|
||||
// now we have the ID we can use it to make the
|
||||
// pick texture (id is baked into texture pixels)
|
||||
makePickTexture( panel->mId, &panel->mPickTextureHandle, &panel->mPickTexturePixels );
|
||||
|
||||
@@ -1608,6 +1685,8 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
|
||||
std::cout << "Adding new media panel for " << url << "(" << media_width << "x" << media_height << ") with index " << panel->mId << " - total panels = " << mMediaPanels.size() << std::endl;
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -1615,17 +1694,17 @@ void LLMediaPluginTest::addMediaPanel( std::string url )
|
||||
void LLMediaPluginTest::updateMediaPanel( mediaPanel* panel )
|
||||
{
|
||||
// checkGLError("LLMediaPluginTest::updateMediaPanel");
|
||||
|
||||
if ( ! panel )
|
||||
|
||||
if ( ! panel )
|
||||
return;
|
||||
|
||||
|
||||
if(!panel->mMediaSource || !panel->mMediaSource->textureValid())
|
||||
{
|
||||
panel->mReadyToRender = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// take a reference copy of the plugin values since they
|
||||
|
||||
// take a reference copy of the plugin values since they
|
||||
// might change during this lifetime of this function
|
||||
int plugin_media_width = panel->mMediaSource->getWidth();
|
||||
int plugin_media_height = panel->mMediaSource->getHeight();
|
||||
@@ -1633,18 +1712,18 @@ void LLMediaPluginTest::updateMediaPanel( mediaPanel* panel )
|
||||
int plugin_texture_height = panel->mMediaSource->getBitsHeight();
|
||||
|
||||
// If the texture isn't created or the media or texture dimensions changed AND
|
||||
// the sizes are valid then we need to delete the old media texture (if necessary)
|
||||
// the sizes are valid then we need to delete the old media texture (if necessary)
|
||||
// then make a new one.
|
||||
if ((panel->mMediaTextureHandle == 0 ||
|
||||
panel->mMediaWidth != plugin_media_width ||
|
||||
panel->mMediaHeight != plugin_media_height ||
|
||||
panel->mMediaHeight != plugin_media_height ||
|
||||
panel->mTextureWidth != plugin_texture_width ||
|
||||
panel->mTextureHeight != plugin_texture_height) &&
|
||||
( plugin_media_width > 0 && plugin_media_height > 0 &&
|
||||
( plugin_media_width > 0 && plugin_media_height > 0 &&
|
||||
plugin_texture_width > 0 && plugin_texture_height > 0 ) )
|
||||
{
|
||||
std::cout << "Valid media size (" << plugin_media_width << " x " << plugin_media_height
|
||||
<< ") and texture size (" << plugin_texture_width << " x " << plugin_texture_height
|
||||
std::cout << "Valid media size (" << plugin_media_width << " x " << plugin_media_height
|
||||
<< ") and texture size (" << plugin_texture_width << " x " << plugin_texture_height
|
||||
<< ") for panel with ID=" << panel->mId << " - making texture" << std::endl;
|
||||
|
||||
// delete old GL texture
|
||||
@@ -1654,13 +1733,13 @@ void LLMediaPluginTest::updateMediaPanel( mediaPanel* panel )
|
||||
glDeleteTextures( 1, &panel->mMediaTextureHandle );
|
||||
panel->mMediaTextureHandle = 0;
|
||||
}
|
||||
|
||||
|
||||
std::cerr << "before: pick texture is " << panel->mPickTextureHandle << ", media texture is " << panel->mMediaTextureHandle << std::endl;
|
||||
|
||||
|
||||
// make a GL texture based on the dimensions the plugin told us
|
||||
GLuint new_texture = 0;
|
||||
glGenTextures( 1, &new_texture );
|
||||
|
||||
|
||||
checkGLError("glGenTextures");
|
||||
|
||||
std::cout << "glGenTextures returned " << new_texture << std::endl;
|
||||
@@ -1679,7 +1758,7 @@ void LLMediaPluginTest::updateMediaPanel( mediaPanel* panel )
|
||||
|
||||
std::cerr << "after: pick texture is " << panel->mPickTextureHandle << ", media texture is " << panel->mMediaTextureHandle << std::endl;
|
||||
};
|
||||
|
||||
|
||||
// update our record of the media and texture dimensions
|
||||
// NOTE: do this after we we check for sizes changes
|
||||
panel->mMediaWidth = plugin_media_width;
|
||||
@@ -1699,7 +1778,7 @@ void LLMediaPluginTest::updateMediaPanel( mediaPanel* panel )
|
||||
panel->mAppTextureCoordsOpenGL = panel->mMediaSource->getTextureCoordsOpenGL();
|
||||
|
||||
// Check to see if we have enough to render this panel.
|
||||
// If we do, set a flag that the display functions use so
|
||||
// If we do, set a flag that the display functions use so
|
||||
// they only render a panel with media if it's ready.
|
||||
if ( panel->mMediaWidth < 0 ||
|
||||
panel->mMediaHeight < 0 ||
|
||||
@@ -1713,29 +1792,29 @@ void LLMediaPluginTest::updateMediaPanel( mediaPanel* panel )
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
|
||||
mediaPanel* LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
|
||||
{
|
||||
// no media panels so we can't change anything - have to add
|
||||
if ( mMediaPanels.size() == 0 )
|
||||
return;
|
||||
if ( mMediaPanels.size() == 0 )
|
||||
return NULL;
|
||||
|
||||
// sanity check
|
||||
if ( ! panel )
|
||||
return;
|
||||
|
||||
if ( ! panel )
|
||||
return NULL;
|
||||
|
||||
int index;
|
||||
for(index = 0; index < (int)mMediaPanels.size(); index++)
|
||||
{
|
||||
if(mMediaPanels[index] == panel)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if(index >= (int)mMediaPanels.size())
|
||||
{
|
||||
// panel isn't in mMediaPanels
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
std::cout << "Replacing media panel with index " << panel->mId << std::endl;
|
||||
|
||||
int panel_id = panel->mId;
|
||||
@@ -1760,7 +1839,7 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
|
||||
// tell the plugin what size we asked for
|
||||
media_source->setSize( media_width, media_height );
|
||||
|
||||
// Use the launcher start and initialize the plugin
|
||||
// Use the launcher start and initialize the plugin
|
||||
#if LL_DARWIN || LL_LINUX
|
||||
std::string launcher_name( "SLPlugin" );
|
||||
#elif LL_WINDOWS
|
||||
@@ -1775,12 +1854,13 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
|
||||
if (NULL == getcwd( cwd, FILENAME_MAX - 1 ))
|
||||
{
|
||||
std::cerr << "Couldn't get cwd - probably too long - failing to init." << std::endl;
|
||||
return;
|
||||
return NULL;
|
||||
}
|
||||
std::string user_data_path = std::string( cwd ) + "/";
|
||||
#endif
|
||||
|
||||
media_source->init( launcher_name, plugin_name, false, user_data_path );
|
||||
media_source->setUserDataPath(user_data_path);
|
||||
media_source->init( launcher_name, plugin_name, false );
|
||||
media_source->setDisableTimeout(mDisableTimeout);
|
||||
|
||||
// make a new panel and save parameters
|
||||
@@ -1799,12 +1879,12 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
|
||||
panel->mAppTextureCoordsOpenGL = false; // really need an 'undefined' state here too
|
||||
panel->mReadyToRender = false;
|
||||
|
||||
panel->mId = panel_id;
|
||||
|
||||
panel->mId = panel_id;
|
||||
|
||||
// Replace the entry in the panels array
|
||||
mMediaPanels[index] = panel;
|
||||
|
||||
// now we have the ID we can use it to make the
|
||||
// now we have the ID we can use it to make the
|
||||
// pick texture (id is baked into texture pixels)
|
||||
makePickTexture( panel->mId, &panel->mPickTextureHandle, &panel->mPickTexturePixels );
|
||||
|
||||
@@ -1814,13 +1894,15 @@ void LLMediaPluginTest::replaceMediaPanel( mediaPanel* panel, std::string url )
|
||||
// load and start the URL
|
||||
panel->mMediaSource->loadURI( url );
|
||||
panel->mMediaSource->start();
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void LLMediaPluginTest::getRandomMediaSize( int& width, int& height, std::string mime_type )
|
||||
{
|
||||
// Make a new media source with a random size which we'll either
|
||||
// Make a new media source with a random size which we'll either
|
||||
// directly or the media plugin will tell us what it wants later.
|
||||
// Use a random size so we can test support for weird media sizes.
|
||||
// (Almost everything else will get filled in later once the
|
||||
@@ -1829,8 +1911,8 @@ void LLMediaPluginTest::getRandomMediaSize( int& width, int& height, std::string
|
||||
width = ( ( rand() % 170 ) + 30 ) * 4;
|
||||
height = ( ( rand() % 170 ) + 30 ) * 4;
|
||||
|
||||
// adjust this random size if it's a browser so we get
|
||||
// a more useful size for testing..
|
||||
// adjust this random size if it's a browser so we get
|
||||
// a more useful size for testing..
|
||||
if ( mime_type == "text/html" || mime_type == "example/example" )
|
||||
{
|
||||
width = ( ( rand() % 100 ) + 100 ) * 4;
|
||||
@@ -1843,11 +1925,11 @@ void LLMediaPluginTest::getRandomMediaSize( int& width, int& height, std::string
|
||||
void LLMediaPluginTest::remMediaPanel( mediaPanel* panel )
|
||||
{
|
||||
// always leave one panel
|
||||
if ( mMediaPanels.size() == 1 )
|
||||
if ( mMediaPanels.size() == 1 )
|
||||
return;
|
||||
|
||||
// sanity check - don't think this can happen but see above for a case where it might...
|
||||
if ( ! panel )
|
||||
if ( ! panel )
|
||||
return;
|
||||
|
||||
std::cout << "Removing media panel with index " << panel->mId << " - total panels = " << mMediaPanels.size() - 1 << std::endl;
|
||||
@@ -1855,7 +1937,7 @@ void LLMediaPluginTest::remMediaPanel( mediaPanel* panel )
|
||||
if(mSelectedPanel == panel)
|
||||
mSelectedPanel = NULL;
|
||||
|
||||
delete panel;
|
||||
delete panel;
|
||||
|
||||
// remove from storage list
|
||||
for( int i = 0; i < (int)mMediaPanels.size(); ++i )
|
||||
@@ -1867,7 +1949,7 @@ void LLMediaPluginTest::remMediaPanel( mediaPanel* panel )
|
||||
};
|
||||
};
|
||||
|
||||
// select the first panel
|
||||
// select the first panel
|
||||
selectPanel( mMediaPanels[ 0 ] );
|
||||
}
|
||||
|
||||
@@ -1887,26 +1969,28 @@ void LLMediaPluginTest::updateStatusBar()
|
||||
static bool cached_supports_browser_media = true;
|
||||
static bool cached_supports_time_media = false;
|
||||
static int cached_movie_time = -1;
|
||||
static GLfloat cached_distance = -1.0f;
|
||||
|
||||
static std::string cached_plugin_version = "";
|
||||
if (
|
||||
if (
|
||||
cached_id == mSelectedPanel->mId &&
|
||||
cached_media_width == mSelectedPanel->mMediaWidth &&
|
||||
cached_media_height == mSelectedPanel->mMediaHeight &&
|
||||
cached_texture_width == mSelectedPanel->mTextureWidth &&
|
||||
cached_texture_height == mSelectedPanel->mTextureHeight &&
|
||||
cached_supports_browser_media == mSelectedPanel->mMediaSource->pluginSupportsMediaBrowser() &&
|
||||
cached_supports_browser_media == mSelectedPanel->mMediaSource->pluginSupportsMediaBrowser() &&
|
||||
cached_supports_time_media == mSelectedPanel->mMediaSource->pluginSupportsMediaTime() &&
|
||||
cached_plugin_version == mSelectedPanel->mMediaSource->getPluginVersion() &&
|
||||
cached_movie_time == (int)mSelectedPanel->mMediaSource->getCurrentTime()
|
||||
cached_movie_time == (int)mSelectedPanel->mMediaSource->getCurrentTime() &&
|
||||
cached_distance == mDistanceCameraToSelectedGeometry
|
||||
)
|
||||
{
|
||||
// nothing changed so don't spend time in this shitty function
|
||||
// nothing changed so don't spend time here
|
||||
return;
|
||||
};
|
||||
|
||||
std::ostringstream stream( "" );
|
||||
|
||||
|
||||
stream.str( "" );
|
||||
stream.clear();
|
||||
|
||||
@@ -1927,7 +2011,15 @@ void LLMediaPluginTest::updateStatusBar()
|
||||
stream << " x ";
|
||||
stream << std::setw( 4 ) << std::setfill( '0' );
|
||||
stream << mSelectedPanel->mTextureHeight;
|
||||
|
||||
stream << " | ";
|
||||
stream << "Distance: ";
|
||||
stream << std::setw( 6 );
|
||||
stream << std::setprecision( 3 );
|
||||
stream << std::setprecision( 3 );
|
||||
stream << mDistanceCameraToSelectedGeometry;
|
||||
stream << " | ";
|
||||
|
||||
if ( mSelectedPanel->mMediaSource->pluginSupportsMediaBrowser() )
|
||||
stream << "BROWSER";
|
||||
else
|
||||
@@ -2005,7 +2097,7 @@ void LLMediaPluginTest::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e
|
||||
{
|
||||
// Uncomment this to make things much, much quieter.
|
||||
// return;
|
||||
|
||||
|
||||
switch(event)
|
||||
{
|
||||
case MEDIA_EVENT_CONTENT_UPDATED:
|
||||
@@ -2063,13 +2155,45 @@ void LLMediaPluginTest::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e
|
||||
break;
|
||||
|
||||
case MEDIA_EVENT_CLICK_LINK_HREF:
|
||||
std::cerr << "Media event: MEDIA_EVENT_CLICK_LINK_HREF, uri is " << self->getClickURL() << std::endl;
|
||||
{
|
||||
std::cerr << "Media event: MEDIA_EVENT_CLICK_LINK_HREF, uri is " << self->getClickURL() << ", target is " << self->getClickTarget() << std::endl;
|
||||
// retrieve the event parameters
|
||||
std::string url = self->getClickURL();
|
||||
std::string target = self->getClickTarget();
|
||||
|
||||
if(target == "_external")
|
||||
{
|
||||
// this should open in an external browser, but since this is a test app we don't care.
|
||||
}
|
||||
else if(target == "_blank")
|
||||
{
|
||||
// Create a new panel with the specified URL.
|
||||
addMediaPanel(url);
|
||||
}
|
||||
else // other named target
|
||||
{
|
||||
mediaPanel *target_panel = findMediaPanel(target);
|
||||
if(target_panel)
|
||||
{
|
||||
target_panel = replaceMediaPanel(target_panel, url);
|
||||
}
|
||||
else
|
||||
{
|
||||
target_panel = addMediaPanel(url);
|
||||
}
|
||||
|
||||
if(target_panel)
|
||||
{
|
||||
target_panel->mTarget = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case MEDIA_EVENT_CLICK_LINK_NOFOLLOW:
|
||||
std::cerr << "Media event: MEDIA_EVENT_CLICK_LINK_NOFOLLOW, uri is " << self->getClickURL() << std::endl;
|
||||
break;
|
||||
|
||||
|
||||
case MEDIA_EVENT_PLUGIN_FAILED:
|
||||
std::cerr << "Media event: MEDIA_EVENT_PLUGIN_FAILED" << std::endl;
|
||||
break;
|
||||
@@ -2077,6 +2201,40 @@ void LLMediaPluginTest::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent e
|
||||
case MEDIA_EVENT_PLUGIN_FAILED_LAUNCH:
|
||||
std::cerr << "Media event: MEDIA_EVENT_PLUGIN_FAILED_LAUNCH" << std::endl;
|
||||
break;
|
||||
|
||||
case MEDIA_EVENT_CLOSE_REQUEST:
|
||||
std::cerr << "Media event: MEDIA_EVENT_CLOSE_REQUEST" << std::endl;
|
||||
break;
|
||||
|
||||
case MEDIA_EVENT_PICK_FILE_REQUEST:
|
||||
std::cerr << "Media event: MEDIA_EVENT_PICK_FILE_REQUEST" << std::endl;
|
||||
// TODO: display an actual file picker
|
||||
self->sendPickFileResponse("cake");
|
||||
break;
|
||||
|
||||
case MEDIA_EVENT_GEOMETRY_CHANGE:
|
||||
std::cerr << "Media event: MEDIA_EVENT_GEOMETRY_CHANGE, uuid is " << self->getClickUUID()
|
||||
<< ", x = " << self->getGeometryX()
|
||||
<< ", y = " << self->getGeometryY()
|
||||
<< ", width = " << self->getGeometryWidth()
|
||||
<< ", height = " << self->getGeometryHeight()
|
||||
<< std::endl;
|
||||
break;
|
||||
|
||||
case MEDIA_EVENT_AUTH_REQUEST:
|
||||
{
|
||||
//std::cerr << "Media event: MEDIA_EVENT_AUTH_REQUEST, url " << self->getAuthURL() ", realm " << self->getAuthRealm() << std::endl;
|
||||
|
||||
// TODO: display an auth dialog
|
||||
self->sendAuthResponse(false, "", "");
|
||||
}
|
||||
break;
|
||||
|
||||
case MEDIA_EVENT_LINK_HOVERED:
|
||||
{
|
||||
std::cerr << "Media event: MEDIA_EVENT_LINK_HOVERED, hover text is: " << self->getHoverText() << std::endl;
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2195,13 +2353,13 @@ int main( int argc, char* argv[] )
|
||||
glutSetWindow( app_window_handle );
|
||||
|
||||
gApplication = new LLMediaPluginTest( app_window_handle, app_window_width, app_window_height );
|
||||
|
||||
|
||||
// update at approximately 60hz
|
||||
int update_ms = 1000 / 60;
|
||||
|
||||
|
||||
GLUI_Master.set_glutTimerFunc( update_ms, glutIdle, update_ms);
|
||||
|
||||
glutMainLoop();
|
||||
|
||||
|
||||
delete gApplication;
|
||||
}
|
||||
|
||||
58
indra/test_apps/llplugintest/llmediaplugintest.h
Normal file → Executable file
58
indra/test_apps/llplugintest/llmediaplugintest.h
Normal file → Executable file
@@ -2,30 +2,25 @@
|
||||
* @file LLMediaPluginTest.cpp
|
||||
* @brief Primary test application for LLMedia (Separate Process) Plugin system
|
||||
*
|
||||
* $LicenseInfo:firstyear=2008&license=viewergpl$
|
||||
*
|
||||
* Copyright (c) 2009, Linden Research, Inc.
|
||||
*
|
||||
* $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$
|
||||
*/
|
||||
|
||||
@@ -56,6 +51,7 @@ struct mediaPanel
|
||||
int mId;
|
||||
std::string mStartUrl;
|
||||
std::string mMimeType;
|
||||
std::string mTarget;
|
||||
LLPluginClassMedia *mMediaSource;
|
||||
int mMediaWidth;
|
||||
int mMediaHeight;
|
||||
@@ -89,23 +85,24 @@ class LLMediaPluginTest : public LLPluginClassMediaOwner
|
||||
|
||||
void bindTexture(GLuint texture, GLint row_length = 0, GLint alignment = 1);
|
||||
bool checkGLError(const char *name = "OpenGL");
|
||||
void drawGeometry( int panel );
|
||||
void drawGeometry( int panel, bool selected );
|
||||
void startPanelHighlight( float red, float green, float blue, float line_width );
|
||||
void endPanelHighlight();
|
||||
enum { DrawTypePickTexture, DrawTypeMediaTexture };
|
||||
void draw( int draw_type );
|
||||
void windowPosToTexturePos( int window_x, int window_y, int& media_x, int& media_y, int& id );
|
||||
|
||||
void addMediaPanel( std::string url );
|
||||
mediaPanel* addMediaPanel( std::string url );
|
||||
void updateMediaPanel( mediaPanel* panel );
|
||||
void remMediaPanel( mediaPanel* panel );
|
||||
void replaceMediaPanel( mediaPanel* panel, std::string url );
|
||||
mediaPanel* replaceMediaPanel( mediaPanel* panel, std::string url );
|
||||
void getRandomMediaSize( int& width, int& height, std::string mime_type );
|
||||
void navigateToNewURI( std::string uri );
|
||||
void initUrlHistory( std::string uri );
|
||||
void selectPanelById( int id );
|
||||
void selectPanel( mediaPanel* panel );
|
||||
mediaPanel* findMediaPanel( LLPluginClassMedia* panel );
|
||||
mediaPanel* findMediaPanel( const std::string &target_name );
|
||||
void makePickTexture( int id, GLuint* texture_handle, unsigned char** texture_pixels );
|
||||
void makeChrome();
|
||||
void resetView();
|
||||
@@ -113,6 +110,9 @@ class LLMediaPluginTest : public LLPluginClassMediaOwner
|
||||
void dumpPanelInfo();
|
||||
void updateStatusBar();
|
||||
|
||||
GLfloat distanceToCamera( GLfloat point_x, GLfloat point_y, GLfloat point_z );
|
||||
|
||||
|
||||
// Inherited from LLPluginClassMediaOwner
|
||||
/*virtual*/ void handleMediaEvent(LLPluginClassMedia* self, LLPluginClassMediaOwner::EMediaEvent);
|
||||
|
||||
@@ -142,6 +142,8 @@ class LLMediaPluginTest : public LLPluginClassMediaOwner
|
||||
float mViewPos[ 3 ];
|
||||
float mViewRotation[ 16 ];
|
||||
|
||||
float mDistanceCameraToSelectedGeometry;
|
||||
|
||||
int mIdControlAddPanel;
|
||||
int mIdControlRemPanel;
|
||||
|
||||
@@ -159,6 +161,10 @@ class LLMediaPluginTest : public LLPluginClassMediaOwner
|
||||
int mRandomBookmarks;
|
||||
int mIdDisableTimeout;
|
||||
int mDisableTimeout;
|
||||
int mIdUsePluginReadThread;
|
||||
int mUsePluginReadThread;
|
||||
int mIdLargePanelSpacing;
|
||||
int mLargePanelSpacing;
|
||||
int mIdControlCrashPlugin;
|
||||
int mIdControlHangPlugin;
|
||||
int mIdControlExitApp;
|
||||
|
||||
0
indra/test_apps/llplugintest/media_mappings.txt
Normal file → Executable file
0
indra/test_apps/llplugintest/media_mappings.txt
Normal file → Executable file
0
indra/test_apps/llplugintest/media_plugin_test.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/media_plugin_test.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/media_simple_test.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/media_simple_test.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/plugin_host.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/plugin_host.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/plugin_process_launcher.cpp
Normal file → Executable file
0
indra/test_apps/llplugintest/plugin_process_launcher.cpp
Normal file → Executable file
Reference in New Issue
Block a user