Example Media Plugin - useless but unbroken
This commit is contained in:
@@ -14,7 +14,7 @@ include(PluginAPI)
|
|||||||
include(MediaPluginBase)
|
include(MediaPluginBase)
|
||||||
include(FindOpenGL)
|
include(FindOpenGL)
|
||||||
|
|
||||||
#include(ExamplePlugin)
|
include(ExamplePlugin)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${LLPLUGIN_INCLUDE_DIRS}
|
${LLPLUGIN_INCLUDE_DIRS}
|
||||||
@@ -29,13 +29,13 @@ include_directories(
|
|||||||
|
|
||||||
### media_plugin_example
|
### media_plugin_example
|
||||||
|
|
||||||
if(NOT CMAKE_SIZEOF_VOID_P MATCHES 4)
|
if(NOT WORD_SIZE EQUAL 32)
|
||||||
if(WINDOWS)
|
if(WINDOWS)
|
||||||
add_definitions(/FIXED:NO)
|
add_definitions(/FIXED:NO)
|
||||||
else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
|
else(WINDOWS) # not windows therefore gcc LINUX and DARWIN
|
||||||
add_definitions(-fPIC)
|
add_definitions(-fPIC)
|
||||||
endif(WINDOWS)
|
endif(WINDOWS)
|
||||||
endif (NOT CMAKE_SIZEOF_VOID_P MATCHES 4)
|
endif(NOT WORD_SIZE EQUAL 32)
|
||||||
|
|
||||||
set(media_plugin_example_SOURCE_FILES
|
set(media_plugin_example_SOURCE_FILES
|
||||||
media_plugin_example.cpp
|
media_plugin_example.cpp
|
||||||
|
|||||||
@@ -3,33 +3,26 @@
|
|||||||
* @brief Example plugin for LLMedia API plugin system
|
* @brief Example plugin for LLMedia API plugin system
|
||||||
*
|
*
|
||||||
* @cond
|
* @cond
|
||||||
* $LicenseInfo:firstyear=2008&license=viewergpl$
|
* $LicenseInfo:firstyear=2008&license=viewerlgpl$
|
||||||
*
|
|
||||||
* Copyright (c) 2008-2010, Linden Research, Inc.
|
|
||||||
*
|
|
||||||
* Second Life Viewer Source Code
|
* Second Life Viewer Source Code
|
||||||
* The source code in this file ("Source Code") is provided by Linden Lab
|
* Copyright (C) 2010, Linden Research, Inc.
|
||||||
* 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
|
* This library is free software; you can redistribute it and/or
|
||||||
* it is applied to this Source Code. View the full text of the exception
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
* in the file doc/FLOSS-exception.txt in this software distribution, or
|
* License as published by the Free Software Foundation;
|
||||||
* online at
|
* version 2.1 of the License only.
|
||||||
* http://secondlife.com/developers/opensource/flossexception
|
|
||||||
*
|
*
|
||||||
* By copying, modifying or distributing this software, you acknowledge
|
* This library is distributed in the hope that it will be useful,
|
||||||
* that you have read and understood your obligations described above,
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* and agree to abide by those obligations.
|
* 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
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
* WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
|
* License along with this library; if not, write to the Free Software
|
||||||
* COMPLETENESS OR PERFORMANCE.
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
|
||||||
* $/LicenseInfo$
|
* $/LicenseInfo$
|
||||||
*
|
|
||||||
* @endcond
|
* @endcond
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -100,226 +93,150 @@ MediaPluginExample::~MediaPluginExample()
|
|||||||
//
|
//
|
||||||
void MediaPluginExample::receiveMessage( const char* message_string )
|
void MediaPluginExample::receiveMessage( const char* message_string )
|
||||||
{
|
{
|
||||||
|
// std::cerr << "MediaPluginWebKit::receiveMessage: received message: \"" << message_string << "\"" << std::endl;
|
||||||
LLPluginMessage message_in;
|
LLPluginMessage message_in;
|
||||||
|
|
||||||
if ( message_in.parse( message_string ) >= 0 )
|
if(message_in.parse(message_string) >= 0)
|
||||||
{
|
{
|
||||||
std::string message_class = message_in.getClass();
|
std::string message_class = message_in.getClass();
|
||||||
std::string message_name = message_in.getName();
|
std::string message_name = message_in.getName();
|
||||||
|
if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE)
|
||||||
if ( message_class == LLPLUGIN_MESSAGE_CLASS_BASE )
|
|
||||||
{
|
{
|
||||||
if ( message_name == "init" )
|
if(message_name == "init")
|
||||||
{
|
{
|
||||||
LLPluginMessage message( "base", "init_response" );
|
LLPluginMessage message("base", "init_response");
|
||||||
LLSD versions = LLSD::emptyMap();
|
LLSD versions = LLSD::emptyMap();
|
||||||
versions[ LLPLUGIN_MESSAGE_CLASS_BASE ] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION;
|
versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION;
|
||||||
versions[ LLPLUGIN_MESSAGE_CLASS_MEDIA ] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION;
|
versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION;
|
||||||
versions[ LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER ] = LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER_VERSION;
|
versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER] = LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER_VERSION;
|
||||||
message.setValueLLSD( "versions", versions );
|
message.setValueLLSD("versions", versions);
|
||||||
|
|
||||||
std::string plugin_version = "Example media plugin, Example Version 1.0.0.0";
|
std::string plugin_version = "Example plugin 1.0..0";
|
||||||
message.setValue( "plugin_version", plugin_version );
|
message.setValue("plugin_version", plugin_version);
|
||||||
sendMessage( message );
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
else
|
else if(message_name == "idle")
|
||||||
if ( message_name == "idle" )
|
|
||||||
{
|
{
|
||||||
// no response is necessary here.
|
// no response is necessary here.
|
||||||
F64 time = message_in.getValueReal( "time" );
|
F64 time = message_in.getValueReal("time");
|
||||||
|
|
||||||
// Convert time to milliseconds for update()
|
// Convert time to milliseconds for update()
|
||||||
update( time );
|
update((int)(time * 1000.0f));
|
||||||
}
|
}
|
||||||
else
|
else if(message_name == "cleanup")
|
||||||
if ( message_name == "cleanup" )
|
|
||||||
{
|
{
|
||||||
// clean up here
|
|
||||||
}
|
}
|
||||||
else
|
else if(message_name == "shm_added")
|
||||||
if ( message_name == "shm_added" )
|
|
||||||
{
|
{
|
||||||
SharedSegmentInfo info;
|
SharedSegmentInfo info;
|
||||||
info.mAddress = message_in.getValuePointer( "address" );
|
info.mAddress = message_in.getValuePointer("address");
|
||||||
info.mSize = ( size_t )message_in.getValueS32( "size" );
|
info.mSize = (size_t)message_in.getValueS32("size");
|
||||||
std::string name = message_in.getValue( "name" );
|
std::string name = message_in.getValue("name");
|
||||||
|
|
||||||
mSharedSegments.insert( SharedSegmentMap::value_type( name, info ) );
|
mSharedSegments.insert(SharedSegmentMap::value_type(name, info));
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else if(message_name == "shm_remove")
|
||||||
if ( message_name == "shm_remove" )
|
|
||||||
{
|
{
|
||||||
std::string name = message_in.getValue( "name" );
|
std::string name = message_in.getValue("name");
|
||||||
|
|
||||||
SharedSegmentMap::iterator iter = mSharedSegments.find( name );
|
SharedSegmentMap::iterator iter = mSharedSegments.find(name);
|
||||||
if( iter != mSharedSegments.end() )
|
if(iter != mSharedSegments.end())
|
||||||
{
|
{
|
||||||
if ( mPixels == iter->second.mAddress )
|
if(mPixels == iter->second.mAddress)
|
||||||
{
|
{
|
||||||
// This is the currently active pixel buffer.
|
// This is the currently active pixel buffer. Make sure we stop drawing to it.
|
||||||
// Make sure we stop drawing to it.
|
|
||||||
mPixels = NULL;
|
mPixels = NULL;
|
||||||
mTextureSegmentName.clear();
|
mTextureSegmentName.clear();
|
||||||
};
|
}
|
||||||
mSharedSegments.erase( iter );
|
mSharedSegments.erase(iter);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//std::cerr << "MediaPluginExample::receiveMessage: unknown shared memory region!" << std::endl;
|
// std::cerr << "MediaPluginWebKit::receiveMessage: unknown shared memory region!" << std::endl;
|
||||||
};
|
}
|
||||||
|
|
||||||
// Send the response so it can be cleaned up.
|
// Send the response so it can be cleaned up.
|
||||||
LLPluginMessage message( "base", "shm_remove_response" );
|
LLPluginMessage message("base", "shm_remove_response");
|
||||||
message.setValue( "name", name );
|
message.setValue("name", name);
|
||||||
sendMessage( message );
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//std::cerr << "MediaPluginExample::receiveMessage: unknown base message: " << message_name << std::endl;
|
// std::cerr << "MediaPluginWebKit::receiveMessage: unknown base message: " << message_name << std::endl;
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
if ( message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA )
|
else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA)
|
||||||
{
|
{
|
||||||
if ( message_name == "init" )
|
if(message_name == "init")
|
||||||
{
|
{
|
||||||
// Plugin gets to decide the texture parameters to use.
|
// Plugin gets to decide the texture parameters to use.
|
||||||
LLPluginMessage message( LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params" );
|
mDepth = 4;
|
||||||
message.setValueS32( "default_width", mWidth );
|
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params");
|
||||||
message.setValueS32( "default_height", mHeight );
|
message.setValueS32("default_width", 1024);
|
||||||
message.setValueS32( "depth", mDepth );
|
message.setValueS32("default_height", 1024);
|
||||||
message.setValueU32( "internalformat", GL_RGBA );
|
message.setValueS32("depth", mDepth);
|
||||||
message.setValueU32( "format", GL_RGBA );
|
message.setValueU32("internalformat", GL_RGBA);
|
||||||
message.setValueU32( "type", GL_UNSIGNED_BYTE );
|
message.setValueU32("format", GL_RGBA);
|
||||||
message.setValueBoolean( "coords_opengl", false );
|
message.setValueU32("type", GL_UNSIGNED_BYTE);
|
||||||
sendMessage( message );
|
message.setValueBoolean("coords_opengl", true);
|
||||||
|
sendMessage(message);
|
||||||
}
|
}
|
||||||
else if ( message_name == "size_change" )
|
else if(message_name == "size_change")
|
||||||
{
|
{
|
||||||
std::string name = message_in.getValue( "name" );
|
std::string name = message_in.getValue("name");
|
||||||
S32 width = message_in.getValueS32( "width" );
|
S32 width = message_in.getValueS32("width");
|
||||||
S32 height = message_in.getValueS32( "height" );
|
S32 height = message_in.getValueS32("height");
|
||||||
S32 texture_width = message_in.getValueS32( "texture_width" );
|
S32 texture_width = message_in.getValueS32("texture_width");
|
||||||
S32 texture_height = message_in.getValueS32( "texture_height" );
|
S32 texture_height = message_in.getValueS32("texture_height");
|
||||||
|
|
||||||
if ( ! name.empty() )
|
if(!name.empty())
|
||||||
{
|
{
|
||||||
// Find the shared memory region with this name
|
// Find the shared memory region with this name
|
||||||
SharedSegmentMap::iterator iter = mSharedSegments.find( name );
|
SharedSegmentMap::iterator iter = mSharedSegments.find(name);
|
||||||
if ( iter != mSharedSegments.end() )
|
if(iter != mSharedSegments.end())
|
||||||
{
|
{
|
||||||
mPixels = ( unsigned char* )iter->second.mAddress;
|
mPixels = (unsigned char*)iter->second.mAddress;
|
||||||
mWidth = width;
|
mWidth = width;
|
||||||
mHeight = height;
|
mHeight = height;
|
||||||
|
|
||||||
mTextureWidth = texture_width;
|
mTextureWidth = texture_width;
|
||||||
mTextureHeight = texture_height;
|
mTextureHeight = texture_height;
|
||||||
|
|
||||||
init();
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
LLPluginMessage message( LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response" );
|
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response");
|
||||||
message.setValue( "name", name );
|
message.setValue("name", name);
|
||||||
message.setValueS32( "width", width );
|
message.setValueS32("width", width);
|
||||||
message.setValueS32( "height", height );
|
message.setValueS32("height", height);
|
||||||
message.setValueS32( "texture_width", texture_width );
|
message.setValueS32("texture_width", texture_width);
|
||||||
message.setValueS32( "texture_height", texture_height );
|
message.setValueS32("texture_height", texture_height);
|
||||||
sendMessage( message );
|
sendMessage(message);
|
||||||
}
|
|
||||||
else
|
|
||||||
if ( message_name == "load_uri" )
|
|
||||||
{
|
|
||||||
std::string uri = message_in.getValue( "uri" );
|
|
||||||
if ( ! uri.empty() )
|
|
||||||
{
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if ( message_name == "mouse_event" )
|
|
||||||
{
|
|
||||||
std::string event = message_in.getValue( "event" );
|
|
||||||
S32 button = message_in.getValueS32( "button" );
|
|
||||||
|
|
||||||
// left mouse button
|
}
|
||||||
if ( button == 0 )
|
else if(message_name == "load_uri")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else if(message_name == "mouse_event")
|
||||||
|
{
|
||||||
|
std::string event = message_in.getValue("event");
|
||||||
|
if(event == "down")
|
||||||
{
|
{
|
||||||
int mouse_x = message_in.getValueS32( "x" );
|
|
||||||
int mouse_y = message_in.getValueS32( "y" );
|
|
||||||
std::string modifiers = message_in.getValue( "modifiers" );
|
|
||||||
|
|
||||||
if ( event == "move" )
|
}
|
||||||
|
else if(event == "up")
|
||||||
{
|
{
|
||||||
if ( mMouseButtonDown )
|
}
|
||||||
write_pixel( mouse_x, mouse_y, rand() % 0x80 + 0x80, rand() % 0x80 + 0x80, rand() % 0x80 + 0x80 );
|
else if(event == "double_click")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if ( event == "down" )
|
|
||||||
{
|
{
|
||||||
mMouseButtonDown = true;
|
// std::cerr << "MediaPluginWebKit::receiveMessage: unknown message class: " << message_class << std::endl;
|
||||||
}
|
|
||||||
else
|
|
||||||
if ( event == "up" )
|
|
||||||
{
|
|
||||||
mMouseButtonDown = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if ( event == "double_click" )
|
|
||||||
{
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else
|
|
||||||
if ( message_name == "key_event" )
|
|
||||||
{
|
|
||||||
std::string event = message_in.getValue( "event" );
|
|
||||||
S32 key = message_in.getValueS32( "key" );
|
|
||||||
std::string modifiers = message_in.getValue( "modifiers" );
|
|
||||||
|
|
||||||
if ( event == "down" )
|
|
||||||
{
|
|
||||||
if ( key == ' ')
|
|
||||||
{
|
|
||||||
mLastUpdateTime = 0;
|
|
||||||
update( 0.0f );
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//std::cerr << "MediaPluginExample::receiveMessage: unknown media message: " << message_string << std::endl;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if ( message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER )
|
|
||||||
{
|
|
||||||
if ( message_name == "browse_reload" )
|
|
||||||
{
|
|
||||||
mLastUpdateTime = 0;
|
|
||||||
mFirstTime = true;
|
|
||||||
mStopAction = false;
|
|
||||||
update( 0.0f );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
if ( message_name == "browse_stop" )
|
|
||||||
{
|
|
||||||
for( int n = 0; n < ENumObjects; ++n )
|
|
||||||
mXInc[ n ] = mYInc[ n ] = 0;
|
|
||||||
|
|
||||||
mStopAction = true;
|
|
||||||
update( 0.0f );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//std::cerr << "MediaPluginExample::receiveMessage: unknown media_browser message: " << message_string << std::endl;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
//std::cerr << "MediaPluginExample::receiveMessage: unknown message class: " << message_class << std::endl;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
@@ -492,3 +409,4 @@ int init_media_plugin( LLPluginInstance::sendMessageFunction host_send_func,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user