diff options
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rw-r--r-- | indra/newview/llviewermedia.cpp | 400 |
1 files changed, 237 insertions, 163 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 41b4dc01e8..42dabdec0d 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -50,6 +50,7 @@ #include "llvoavatar.h" #include "llvoavatarself.h" #include "llviewerregion.h" +#include "llwebprofile.h" #include "llwebsharing.h" // For LLWebSharing::setOpenIDCookie(), *TODO: find a better way to do this! #include "llfilepicker.h" #include "llnotifications.h" @@ -66,9 +67,8 @@ //#include "llfirstuse.h" #include "llviewernetwork.h" #include "llwindow.h" +#include "llvieweraudio.h" - -#include "llfloatermediabrowser.h" // for handling window close requests and geometry change requests in media browser windows. #include "llfloaterwebcontent.h" // for handling window close requests and geometry change requests in media browser windows. #include <boost/bind.hpp> // for SkinFolder listener @@ -319,6 +319,10 @@ public: std::string cookie = content["set-cookie"].asString(); LLViewerMedia::getCookieStore()->setCookiesFromHost(cookie, mHost); + + // Set cookie for snapshot publishing. + std::string auth_cookie = cookie.substr(0, cookie.find(";")); // strip path + LLWebProfile::setAuthCookie(auth_cookie); } void completedRaw( @@ -782,6 +786,12 @@ static bool proximity_comparitor(const LLViewerMediaImpl* i1, const LLViewerMedi } static LLFastTimer::DeclareTimer FTM_MEDIA_UPDATE("Update Media"); +static LLFastTimer::DeclareTimer FTM_MEDIA_SPARE_IDLE("Spare Idle"); +static LLFastTimer::DeclareTimer FTM_MEDIA_UPDATE_INTEREST("Update/Interest"); +static LLFastTimer::DeclareTimer FTM_MEDIA_SORT("Sort"); +static LLFastTimer::DeclareTimer FTM_MEDIA_SORT2("Sort 2"); +static LLFastTimer::DeclareTimer FTM_MEDIA_MISC("Misc"); + ////////////////////////////////////////////////////////////////////////////////////////// // static @@ -806,21 +816,28 @@ void LLViewerMedia::updateMedia(void *dummy_arg) impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); - for(; iter != end;) { - LLViewerMediaImpl* pimpl = *iter++; - pimpl->update(); - pimpl->calculateInterest(); + LLFastTimer t(FTM_MEDIA_UPDATE_INTEREST); + for(; iter != end;) + { + LLViewerMediaImpl* pimpl = *iter++; + pimpl->update(); + pimpl->calculateInterest(); + } } // Let the spare media source actually launch if(sSpareBrowserMediaSource) { + LLFastTimer t(FTM_MEDIA_SPARE_IDLE); sSpareBrowserMediaSource->idle(); } - // Sort the static instance list using our interest criteria - sViewerMediaImplList.sort(priorityComparitor); + { + LLFastTimer t(FTM_MEDIA_SORT); + // Sort the static instance list using our interest criteria + sViewerMediaImplList.sort(priorityComparitor); + } // Go through the list again and adjust according to priority. iter = sViewerMediaImplList.begin(); @@ -848,147 +865,150 @@ void LLViewerMedia::updateMedia(void *dummy_arg) // max_instances must be set high enough to allow the various instances used in the UI (for the help browser, search, etc.) to be loaded. // If max_normal + max_low is less than max_instances, things will tend to get unloaded instead of being set to slideshow. - for(; iter != end; iter++) { - LLViewerMediaImpl* pimpl = *iter; + LLFastTimer t(FTM_MEDIA_MISC); + for(; iter != end; iter++) + { + LLViewerMediaImpl* pimpl = *iter; - LLPluginClassMedia::EPriority new_priority = LLPluginClassMedia::PRIORITY_NORMAL; + LLPluginClassMedia::EPriority new_priority = LLPluginClassMedia::PRIORITY_NORMAL; - if(pimpl->isForcedUnloaded() || (impl_count_total >= (int)max_instances)) - { - // Never load muted or failed impls. - // Hard limit on the number of instances that will be loaded at one time - new_priority = LLPluginClassMedia::PRIORITY_UNLOADED; - } - else if(!pimpl->getVisible()) - { - new_priority = LLPluginClassMedia::PRIORITY_HIDDEN; - } - else if(pimpl->hasFocus()) - { - new_priority = LLPluginClassMedia::PRIORITY_HIGH; - impl_count_interest_normal++; // count this against the count of "normal" instances for priority purposes - } - else if(pimpl->getUsedInUI()) - { - new_priority = LLPluginClassMedia::PRIORITY_NORMAL; - impl_count_interest_normal++; - } - else if(pimpl->isParcelMedia()) - { - new_priority = LLPluginClassMedia::PRIORITY_NORMAL; - impl_count_interest_normal++; - } - else - { - // Look at interest and CPU usage for instances that aren't in any of the above states. - - // Heuristic -- if the media texture's approximate screen area is less than 1/4 of the native area of the texture, - // turn it down to low instead of normal. This may downsample for plugins that support it. - bool media_is_small = false; - F64 approximate_interest = pimpl->getApproximateTextureInterest(); - if(approximate_interest == 0.0f) + if(pimpl->isForcedUnloaded() || (impl_count_total >= (int)max_instances)) { - // this media has no current size, which probably means it's not loaded. - media_is_small = true; + // Never load muted or failed impls. + // Hard limit on the number of instances that will be loaded at one time + new_priority = LLPluginClassMedia::PRIORITY_UNLOADED; } - else if(pimpl->getInterest() < (approximate_interest / 4)) + else if(!pimpl->getVisible()) { - media_is_small = true; + new_priority = LLPluginClassMedia::PRIORITY_HIDDEN; } - - if(pimpl->getInterest() == 0.0f) + else if(pimpl->hasFocus()) { - // This media is completely invisible, due to being outside the view frustrum or out of range. - new_priority = LLPluginClassMedia::PRIORITY_HIDDEN; + new_priority = LLPluginClassMedia::PRIORITY_HIGH; + impl_count_interest_normal++; // count this against the count of "normal" instances for priority purposes } - else if(check_cpu_usage && (total_cpu > max_cpu)) + else if(pimpl->getUsedInUI()) { - // Higher priority plugins have already used up the CPU budget. Set remaining ones to slideshow priority. - new_priority = LLPluginClassMedia::PRIORITY_SLIDESHOW; + new_priority = LLPluginClassMedia::PRIORITY_NORMAL; + impl_count_interest_normal++; } - else if((impl_count_interest_normal < (int)max_normal) && !media_is_small) + else if(pimpl->isParcelMedia()) { - // Up to max_normal inworld get normal priority new_priority = LLPluginClassMedia::PRIORITY_NORMAL; impl_count_interest_normal++; } - else if (impl_count_interest_low + impl_count_interest_normal < (int)max_low + (int)max_normal) + else { - // The next max_low inworld get turned down - new_priority = LLPluginClassMedia::PRIORITY_LOW; - impl_count_interest_low++; - - // Set the low priority size for downsampling to approximately the size the texture is displayed at. + // Look at interest and CPU usage for instances that aren't in any of the above states. + + // Heuristic -- if the media texture's approximate screen area is less than 1/4 of the native area of the texture, + // turn it down to low instead of normal. This may downsample for plugins that support it. + bool media_is_small = false; + F64 approximate_interest = pimpl->getApproximateTextureInterest(); + if(approximate_interest == 0.0f) + { + // this media has no current size, which probably means it's not loaded. + media_is_small = true; + } + else if(pimpl->getInterest() < (approximate_interest / 4)) + { + media_is_small = true; + } + + if(pimpl->getInterest() == 0.0f) { - F32 approximate_interest_dimension = (F32) sqrt(pimpl->getInterest()); + // This media is completely invisible, due to being outside the view frustrum or out of range. + new_priority = LLPluginClassMedia::PRIORITY_HIDDEN; + } + else if(check_cpu_usage && (total_cpu > max_cpu)) + { + // Higher priority plugins have already used up the CPU budget. Set remaining ones to slideshow priority. + new_priority = LLPluginClassMedia::PRIORITY_SLIDESHOW; + } + else if((impl_count_interest_normal < (int)max_normal) && !media_is_small) + { + // Up to max_normal inworld get normal priority + new_priority = LLPluginClassMedia::PRIORITY_NORMAL; + impl_count_interest_normal++; + } + else if (impl_count_interest_low + impl_count_interest_normal < (int)max_low + (int)max_normal) + { + // The next max_low inworld get turned down + new_priority = LLPluginClassMedia::PRIORITY_LOW; + impl_count_interest_low++; + + // Set the low priority size for downsampling to approximately the size the texture is displayed at. + { + F32 approximate_interest_dimension = (F32) sqrt(pimpl->getInterest()); - pimpl->setLowPrioritySizeLimit(llround(approximate_interest_dimension)); + pimpl->setLowPrioritySizeLimit(llround(approximate_interest_dimension)); + } + } + else + { + // Any additional impls (up to max_instances) get very infrequent time + new_priority = LLPluginClassMedia::PRIORITY_SLIDESHOW; } } - else - { - // Any additional impls (up to max_instances) get very infrequent time - new_priority = LLPluginClassMedia::PRIORITY_SLIDESHOW; - } - } - if(!pimpl->getUsedInUI() && (new_priority != LLPluginClassMedia::PRIORITY_UNLOADED)) - { - // This is a loadable inworld impl -- the last one in the list in this class defines the lowest loadable interest. - lowest_interest_loadable = pimpl; + if(!pimpl->getUsedInUI() && (new_priority != LLPluginClassMedia::PRIORITY_UNLOADED)) + { + // This is a loadable inworld impl -- the last one in the list in this class defines the lowest loadable interest. + lowest_interest_loadable = pimpl; - impl_count_total++; - } + impl_count_total++; + } - // Overrides if the window is minimized or we lost focus (taking care - // not to accidentally "raise" the priority either) - if (!gViewerWindow->getActive() /* viewer window minimized? */ - && new_priority > LLPluginClassMedia::PRIORITY_HIDDEN) - { - new_priority = LLPluginClassMedia::PRIORITY_HIDDEN; - } - else if (!gFocusMgr.getAppHasFocus() /* viewer window lost focus? */ - && new_priority > LLPluginClassMedia::PRIORITY_LOW) - { - new_priority = LLPluginClassMedia::PRIORITY_LOW; - } + // Overrides if the window is minimized or we lost focus (taking care + // not to accidentally "raise" the priority either) + if (!gViewerWindow->getActive() /* viewer window minimized? */ + && new_priority > LLPluginClassMedia::PRIORITY_HIDDEN) + { + new_priority = LLPluginClassMedia::PRIORITY_HIDDEN; + } + else if (!gFocusMgr.getAppHasFocus() /* viewer window lost focus? */ + && new_priority > LLPluginClassMedia::PRIORITY_LOW) + { + new_priority = LLPluginClassMedia::PRIORITY_LOW; + } - if(!inworld_media_enabled) - { - // If inworld media is locked out, force all inworld media to stay unloaded. - if(!pimpl->getUsedInUI()) + if(!inworld_media_enabled) { - new_priority = LLPluginClassMedia::PRIORITY_UNLOADED; + // If inworld media is locked out, force all inworld media to stay unloaded. + if(!pimpl->getUsedInUI()) + { + new_priority = LLPluginClassMedia::PRIORITY_UNLOADED; + } } - } - // update the audio stream here as well - if( !inworld_audio_enabled) - { - if(LLViewerMedia::isParcelAudioPlaying() && gAudiop && LLViewerMedia::hasParcelAudio()) + // update the audio stream here as well + if( !inworld_audio_enabled) { - gAudiop->stopInternetStream(); + if(LLViewerMedia::isParcelAudioPlaying() && gAudiop && LLViewerMedia::hasParcelAudio()) + { + LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade(); + } } - } - pimpl->setPriority(new_priority); + pimpl->setPriority(new_priority); - if(pimpl->getUsedInUI()) - { - // Any impls used in the UI should not be in the proximity list. - pimpl->mProximity = -1; - } - else - { - proximity_order.push_back(pimpl); - } + if(pimpl->getUsedInUI()) + { + // Any impls used in the UI should not be in the proximity list. + pimpl->mProximity = -1; + } + else + { + proximity_order.push_back(pimpl); + } - total_cpu += pimpl->getCPUUsage(); + total_cpu += pimpl->getCPUUsage(); - if (!pimpl->getUsedInUI() && pimpl->hasMedia()) - { - sAnyMediaShowing = true; - } + if (!pimpl->getUsedInUI() && pimpl->hasMedia()) + { + sAnyMediaShowing = true; + } + } } // Re-calculate this every time. @@ -1014,6 +1034,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } else { + LLFastTimer t(FTM_MEDIA_SORT2); // Use a distance-based sort for proximity values. std::stable_sort(proximity_order.begin(), proximity_order.end(), proximity_comparitor); } @@ -1069,13 +1090,24 @@ void LLViewerMedia::setAllMediaEnabled(bool val) gAudiop && LLViewerMedia::hasParcelAudio()) { - gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL()); + if (LLAudioEngine::AUDIO_PAUSED == gAudiop->isInternetStreamPlaying()) + { + // 'false' means unpause + gAudiop->pauseInternetStream(false); + } + else + { + LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getParcelAudioURL()); + } } } else { // This actually unloads the impl, as opposed to "stop"ping the media LLViewerParcelMedia::stop(); - if (gAudiop) gAudiop->stopInternetStream(); + if (gAudiop) + { + LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade(); + } } } @@ -1484,6 +1516,8 @@ void LLViewerMedia::setOpenIDCookie() std::string profile_url = getProfileURL(""); LLURL raw_profile_url( profile_url.c_str() ); + LL_DEBUGS("MediaAuth") << "Requesting " << profile_url << llendl; + LL_DEBUGS("MediaAuth") << "sOpenIDCookie = [" << sOpenIDCookie << "]" << llendl; LLHTTPClient::get(profile_url, new LLViewerMediaWebProfileResponder(raw_profile_url.getAuthority()), headers); @@ -1716,7 +1750,8 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, mNavigateSuspended(false), mNavigateSuspendedDeferred(false), mIsUpdated(false), - mTrustedBrowser(false) + mTrustedBrowser(false), + mZoomFactor(1.0) { // Set up the mute list observer if it hasn't been set up already. @@ -1862,7 +1897,7 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_ if(plugin_basename.empty()) { - LL_WARNS("Media") << "Couldn't find plugin for media type " << media_type << LL_ENDL; + LL_WARNS_ONCE("Media") << "Couldn't find plugin for media type " << media_type << LL_ENDL; } else { @@ -1888,11 +1923,11 @@ LLPluginClassMedia* LLViewerMediaImpl::newSourceFromMediaType(std::string media_ llstat s; if(LLFile::stat(launcher_name, &s)) { - LL_WARNS("Media") << "Couldn't find launcher at " << launcher_name << LL_ENDL; + LL_WARNS_ONCE("Media") << "Couldn't find launcher at " << launcher_name << LL_ENDL; } else if(LLFile::stat(plugin_name, &s)) { - LL_WARNS("Media") << "Couldn't find plugin at " << plugin_name << LL_ENDL; + LL_WARNS_ONCE("Media") << "Couldn't find plugin at " << plugin_name << LL_ENDL; } else { @@ -2302,6 +2337,17 @@ void LLViewerMediaImpl::clearCache() } } + +////////////////////////////////////////////////////////////////////////////////////////// +void LLViewerMediaImpl::setPageZoomFactor( double factor ) +{ + if(mMediaSource && factor != mZoomFactor) + { + mZoomFactor = factor; + mMediaSource->set_page_zoom_factor( factor ); + } +} + ////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::mouseDown(S32 x, S32 y, MASK mask, S32 button) { @@ -2450,44 +2496,58 @@ BOOL LLViewerMediaImpl::handleMouseUp(S32 x, S32 y, MASK mask) ////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::updateJavascriptObject() { + static LLFrameTimer timer ; + if ( mMediaSource ) { // flag to expose this information to internal browser or not. bool enable = gSavedSettings.getBOOL("BrowserEnableJSObject"); + + if(!enable) + { + return ; //no need to go further. + } + + if(timer.getElapsedTimeF32() < 1.0f) + { + return ; //do not update more than once per second. + } + timer.reset() ; + mMediaSource->jsEnableObject( enable ); // these values are only menaingful after login so don't set them before bool logged_in = LLLoginInstance::getInstance()->authSuccess(); if ( logged_in ) { - // current location within a region - LLVector3 agent_pos = gAgent.getPositionAgent(); - double x = agent_pos.mV[ VX ]; - double y = agent_pos.mV[ VY ]; - double z = agent_pos.mV[ VZ ]; - mMediaSource->jsAgentLocationEvent( x, y, z ); - - // current location within the grid - LLVector3d agent_pos_global = gAgent.getLastPositionGlobal(); - double global_x = agent_pos_global.mdV[ VX ]; - double global_y = agent_pos_global.mdV[ VY ]; - double global_z = agent_pos_global.mdV[ VZ ]; - mMediaSource->jsAgentGlobalLocationEvent( global_x, global_y, global_z ); - - // current agent orientation - double rotation = atan2( gAgent.getAtAxis().mV[VX], gAgent.getAtAxis().mV[VY] ); - double angle = rotation * RAD_TO_DEG; - if ( angle < 0.0f ) angle = 360.0f + angle; // TODO: has to be a better way to get orientation! - mMediaSource->jsAgentOrientationEvent( angle ); - - // current region agent is in - std::string region_name(""); - LLViewerRegion* region = gAgent.getRegion(); - if ( region ) - { - region_name = region->getName(); - }; - mMediaSource->jsAgentRegionEvent( region_name ); + // current location within a region + LLVector3 agent_pos = gAgent.getPositionAgent(); + double x = agent_pos.mV[ VX ]; + double y = agent_pos.mV[ VY ]; + double z = agent_pos.mV[ VZ ]; + mMediaSource->jsAgentLocationEvent( x, y, z ); + + // current location within the grid + LLVector3d agent_pos_global = gAgent.getLastPositionGlobal(); + double global_x = agent_pos_global.mdV[ VX ]; + double global_y = agent_pos_global.mdV[ VY ]; + double global_z = agent_pos_global.mdV[ VZ ]; + mMediaSource->jsAgentGlobalLocationEvent( global_x, global_y, global_z ); + + // current agent orientation + double rotation = atan2( gAgent.getAtAxis().mV[VX], gAgent.getAtAxis().mV[VY] ); + double angle = rotation * RAD_TO_DEG; + if ( angle < 0.0f ) angle = 360.0f + angle; // TODO: has to be a better way to get orientation! + mMediaSource->jsAgentOrientationEvent( angle ); + + // current region agent is in + std::string region_name(""); + LLViewerRegion* region = gAgent.getRegion(); + if ( region ) + { + region_name = region->getName(); + }; + mMediaSource->jsAgentRegionEvent( region_name ); } // language code the viewer is set to @@ -2506,7 +2566,7 @@ void LLViewerMediaImpl::updateJavascriptObject() } ////////////////////////////////////////////////////////////////////////////////////////// -std::string LLViewerMediaImpl::getName() const +const std::string& LLViewerMediaImpl::getName() const { if (mMediaSource) { @@ -2768,8 +2828,14 @@ bool LLViewerMediaImpl::canNavigateBack() } ////////////////////////////////////////////////////////////////////////////////////////// +static LLFastTimer::DeclareTimer FTM_MEDIA_DO_UPDATE("Do Update"); +static LLFastTimer::DeclareTimer FTM_MEDIA_GET_DATA("Get Data"); +static LLFastTimer::DeclareTimer FTM_MEDIA_SET_SUBIMAGE("Set Subimage"); + + void LLViewerMediaImpl::update() { + LLFastTimer t(FTM_MEDIA_DO_UPDATE); if(mMediaSource == NULL) { if(mPriority == LLPluginClassMedia::PRIORITY_UNLOADED) @@ -2869,20 +2935,27 @@ void LLViewerMediaImpl::update() if(width > 0 && height > 0) { - U8* data = mMediaSource->getBitsData(); + U8* data = NULL; + { + LLFastTimer t(FTM_MEDIA_GET_DATA); + data = mMediaSource->getBitsData(); + } // Offset the pixels pointer to match x_pos and y_pos data += ( x_pos * mMediaSource->getTextureDepth() * mMediaSource->getBitsWidth() ); data += ( y_pos * mMediaSource->getTextureDepth() ); - placeholder_image->setSubImage( - data, - mMediaSource->getBitsWidth(), - mMediaSource->getBitsHeight(), - x_pos, - y_pos, - width, - height); + { + LLFastTimer t(FTM_MEDIA_SET_SUBIMAGE); + placeholder_image->setSubImage( + data, + mMediaSource->getBitsWidth(), + mMediaSource->getBitsHeight(), + x_pos, + y_pos, + width, + height); + } } @@ -3341,7 +3414,6 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla { // This close request is directed at another instance pass_through = false; - LLFloaterMediaBrowser::closeRequest(uuid); LLFloaterWebContent::closeRequest(uuid); } } @@ -3361,7 +3433,6 @@ void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginCla { // This request is directed at another instance pass_through = false; - LLFloaterMediaBrowser::geometryChanged(uuid, plugin->getGeometryX(), plugin->getGeometryY(), plugin->getGeometryWidth(), plugin->getGeometryHeight()); LLFloaterWebContent::geometryChanged(uuid, plugin->getGeometryX(), plugin->getGeometryY(), plugin->getGeometryWidth(), plugin->getGeometryHeight()); } } @@ -3455,8 +3526,11 @@ BOOL LLViewerMediaImpl::isUpdated() return mIsUpdated ; } +static LLFastTimer::DeclareTimer FTM_MEDIA_CALCULATE_INTEREST("Calculate Interest"); + void LLViewerMediaImpl::calculateInterest() { + LLFastTimer t(FTM_MEDIA_CALCULATE_INTEREST); LLViewerMediaTexture* texture = LLViewerTextureManager::findMediaTexture( mTextureId ); if(texture != NULL) |