diff options
Diffstat (limited to 'indra/llplugin/llpluginclassmedia.cpp')
-rw-r--r-- | indra/llplugin/llpluginclassmedia.cpp | 90 |
1 files changed, 80 insertions, 10 deletions
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp index 7299ede22d..457c074ef1 100644 --- a/indra/llplugin/llpluginclassmedia.cpp +++ b/indra/llplugin/llpluginclassmedia.cpp @@ -112,6 +112,8 @@ void LLPluginClassMedia::reset() mLowPrioritySizeLimit = LOW_PRIORITY_TEXTURE_SIZE_DEFAULT; mAllowDownsample = false; mPadding = 0; + mLastMouseX = 0; + mLastMouseY = 0; mStatus = LLPluginClassMediaOwner::MEDIA_NONE; mSleepTime = 1.0f / 100.0f; mCanCut = false; @@ -133,6 +135,7 @@ void LLPluginClassMedia::reset() mCurrentTime = 0.0f; mDuration = 0.0f; mCurrentRate = 0.0f; + mLoadedDuration = 0.0f; } void LLPluginClassMedia::idle(void) @@ -411,8 +414,20 @@ std::string LLPluginClassMedia::translateModifiers(MASK modifiers) return result; } -void LLPluginClassMedia::mouseEvent(EMouseEventType type, int x, int y, MASK modifiers) +void LLPluginClassMedia::mouseEvent(EMouseEventType type, int button, int x, int y, MASK modifiers) { + if(type == MOUSE_EVENT_MOVE) + { + if((x == mLastMouseX) && (y == mLastMouseY)) + { + // Don't spam unnecessary mouse move events. + return; + } + + mLastMouseX = x; + mLastMouseY = y; + } + LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "mouse_event"); std::string temp; switch(type) @@ -424,6 +439,8 @@ void LLPluginClassMedia::mouseEvent(EMouseEventType type, int x, int y, MASK mod } message.setValue("event", temp); + message.setValueS32("button", button); + message.setValueS32("x", x); // Incoming coordinates are OpenGL-style ((0,0) = lower left), so flip them here if the plugin has requested it. @@ -514,11 +531,12 @@ void LLPluginClassMedia::scrollEvent(int x, int y, MASK modifiers) sendMessage(message); } -bool LLPluginClassMedia::textInput(const std::string &text) +bool LLPluginClassMedia::textInput(const std::string &text, MASK modifiers) { LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "text_event"); message.setValue("text", text); + message.setValue("modifiers", translateModifiers(modifiers)); sendMessage(message); @@ -534,6 +552,23 @@ void LLPluginClassMedia::loadURI(const std::string &uri) sendMessage(message); } +const char* LLPluginClassMedia::priorityToString(EPriority priority) +{ + const char* result = "UNKNOWN"; + switch(priority) + { + case PRIORITY_UNLOADED: result = "unloaded"; break; + case PRIORITY_STOPPED: result = "stopped"; break; + case PRIORITY_HIDDEN: result = "hidden"; break; + case PRIORITY_SLIDESHOW: result = "slideshow"; break; + case PRIORITY_LOW: result = "low"; break; + case PRIORITY_NORMAL: result = "normal"; break; + case PRIORITY_HIGH: result = "high"; break; + } + + return result; +} + void LLPluginClassMedia::setPriority(EPriority priority) { if(mPriority != priority) @@ -542,35 +577,28 @@ void LLPluginClassMedia::setPriority(EPriority priority) LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "set_priority"); - std::string priority_string; + std::string priority_string = priorityToString(priority); switch(priority) { case PRIORITY_UNLOADED: - priority_string = "unloaded"; mSleepTime = 1.0f; break; case PRIORITY_STOPPED: - priority_string = "stopped"; mSleepTime = 1.0f; break; case PRIORITY_HIDDEN: - priority_string = "hidden"; mSleepTime = 1.0f; break; case PRIORITY_SLIDESHOW: - priority_string = "slideshow"; mSleepTime = 1.0f; break; case PRIORITY_LOW: - priority_string = "low"; mSleepTime = 1.0f / 50.0f; break; case PRIORITY_NORMAL: - priority_string = "normal"; mSleepTime = 1.0f / 100.0f; break; case PRIORITY_HIGH: - priority_string = "high"; mSleepTime = 1.0f / 100.0f; break; } @@ -705,6 +733,7 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) bool time_duration_updated = false; + int previous_percent = mProgressPercent; if(message.hasValue("current_time")) { @@ -722,11 +751,32 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) mCurrentRate = message.getValueReal("current_rate"); } + if(message.hasValue("loaded_duration")) + { + mLoadedDuration = message.getValueReal("loaded_duration"); + time_duration_updated = true; + } + else + { + // If the message doesn't contain a loaded_duration param, assume it's equal to duration + mLoadedDuration = mDuration; + } + + // Calculate a percentage based on the loaded duration and total duration. + if(mDuration != 0.0f) // Don't divide by zero. + { + mProgressPercent = (int)((mLoadedDuration * 100.0f)/mDuration); + } + if(time_duration_updated) { mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_TIME_DURATION_UPDATED); } + if(previous_percent != mProgressPercent) + { + mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_PROGRESS_UPDATED); + } } else if(message_name == "media_status") { @@ -754,6 +804,10 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) { mStatus = LLPluginClassMediaOwner::MEDIA_PAUSED; } + else if(status == "done") + { + mStatus = LLPluginClassMediaOwner::MEDIA_DONE; + } else { // empty string or any unknown string @@ -812,6 +866,11 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) mCanPaste = message.getValueBoolean("paste"); } } + else if(message_name == "name_text") + { + mMediaName = message.getValue("name"); + mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_NAME_CHANGED); + } else { LL_WARNS("Plugin") << "Unknown " << message_name << " class message: " << message_name << LL_ENDL; @@ -884,6 +943,12 @@ void LLPluginClassMedia::receivePluginMessage(const LLPluginMessage &message) } /* virtual */ +void LLPluginClassMedia::pluginLaunchFailed() +{ + mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_PLUGIN_FAILED_LAUNCH); +} + +/* virtual */ void LLPluginClassMedia::pluginDied() { mediaEvent(LLPluginClassMediaOwner::MEDIA_EVENT_PLUGIN_FAILED); @@ -1078,6 +1143,11 @@ void LLPluginClassMedia::setVolume(float volume) } } +float LLPluginClassMedia::getVolume() +{ + return mRequestedVolume; +} + void LLPluginClassMedia::initializeUrlHistory(const LLSD& url_history) { // Send URL history to plugin |