From 4a020b2a1ab85ebfa078ab12457402d1f805f811 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Thu, 12 Nov 2009 18:25:42 -0800 Subject: Couple LLMimeDiscoveryResponder more tightly with LLViewerMediaImpl. This should fix DEV-41596, as well as other potential problems. --- indra/newview/llviewermedia.cpp | 95 ++++++++++++++++++++++++++++++++++++----- 1 file changed, 85 insertions(+), 10 deletions(-) (limited to 'indra/newview/llviewermedia.cpp') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 493457704b..69d4da373e 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -135,9 +135,19 @@ public: LLMimeDiscoveryResponder( viewer_media_t media_impl) : mMediaImpl(media_impl), mInitialized(false) - {} - + { + if(mMediaImpl->mMimeTypeProbe != NULL) + { + llerrs << "impl already has an outstanding responder" << llendl; + } + + mMediaImpl->mMimeTypeProbe = this; + } + ~LLMimeDiscoveryResponder() + { + disconnectOwner(); + } virtual void completedHeader(U32 status, const std::string& reason, const LLSD& content) { @@ -149,23 +159,54 @@ public: virtual void error( U32 status, const std::string& reason ) { + llwarns << "responder failed with status " << status << ", reason " << reason << llendl; + if(mMediaImpl) + { + mMediaImpl->mMediaSourceFailed = true; + } // completeAny(status, "none/none"); } void completeAny(U32 status, const std::string& mime_type) { - if(!mInitialized && ! mime_type.empty()) + // the call to initializeMedia may disconnect the responder, which will clear mMediaImpl. + // Make a local copy so we can call loadURI() afterwards. + LLViewerMediaImpl *impl = mMediaImpl; + + if(impl && !mInitialized && ! mime_type.empty()) { - if(mMediaImpl->initializeMedia(mime_type)) + if(impl->initializeMedia(mime_type)) { mInitialized = true; - mMediaImpl->loadURI(); + impl->loadURI(); + disconnectOwner(); } } } + + void cancelRequest() + { + disconnectOwner(); + } + +private: + void disconnectOwner() + { + if(mMediaImpl) + { + if(mMediaImpl->mMimeTypeProbe != this) + { + llerrs << "internal error: mMediaImpl->mMimeTypeProbe != this" << llendl; + } - public: - viewer_media_t mMediaImpl; + mMediaImpl->mMimeTypeProbe = NULL; + } + mMediaImpl = NULL; + } + + +public: + LLViewerMediaImpl *mMediaImpl; bool mInitialized; }; static LLViewerMedia::impl_list sViewerMediaImplList; @@ -708,6 +749,7 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, mIsDisabled(false), mIsParcelMedia(false), mProximity(-1), + mMimeTypeProbe(NULL), mIsUpdated(false) { @@ -811,7 +853,9 @@ void LLViewerMediaImpl::destroyMediaSource() { oldImage->setPlaying(FALSE) ; } - + + cancelMimeTypeProbe(); + if(mMediaSource) { delete mMediaSource; @@ -1316,6 +1360,8 @@ void LLViewerMediaImpl::unload() ////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::navigateTo(const std::string& url, const std::string& mime_type, bool rediscover_type, bool server_request) { + cancelMimeTypeProbe(); + if(mMediaURL != url) { // Don't carry media play state across distinct URLs. @@ -1358,6 +1404,12 @@ void LLViewerMediaImpl::navigateInternal() // Helpful to have media urls in log file. Shouldn't be spammy. llinfos << "media id= " << mTextureId << " url=" << mMediaURL << " mime_type=" << mMimeType << llendl; + if(mMimeTypeProbe != NULL) + { + llwarns << "MIME type probe already in progress -- bailing out." << llendl; + return; + } + if(mNavigateServerRequest) { setNavState(MEDIANAVSTATE_SERVER_SENT); @@ -1390,7 +1442,7 @@ void LLViewerMediaImpl::navigateInternal() if(scheme.empty() || "http" == scheme || "https" == scheme) { - LLHTTPClient::getHeaderOnly( mMediaURL, new LLMimeDiscoveryResponder(this)); + LLHTTPClient::getHeaderOnly( mMediaURL, new LLMimeDiscoveryResponder(this), 10.0f); } else if("data" == scheme || "file" == scheme || "about" == scheme) { @@ -1521,7 +1573,15 @@ void LLViewerMediaImpl::update() { if(mMediaSource == NULL) { - if(mPriority != LLPluginClassMedia::PRIORITY_UNLOADED) + if(mPriority == LLPluginClassMedia::PRIORITY_UNLOADED) + { + // This media source should not be loaded. + } + else if(mMimeTypeProbe != NULL) + { + // this media source is doing a MIME type probe -- don't try loading it again. + } + else { // This media may need to be loaded. if(sMediaCreateTimer.hasExpired()) @@ -2120,6 +2180,21 @@ void LLViewerMediaImpl::setNavState(EMediaNavState state) } } +void LLViewerMediaImpl::cancelMimeTypeProbe() +{ + if(mMimeTypeProbe != NULL) + { + // There doesn't seem to be a way to actually cancel an outstanding request. + // Simulate it by telling the LLMimeDiscoveryResponder not to write back any results. + mMimeTypeProbe->cancelRequest(); + + // The above should already have set mMimeTypeProbe to NULL. + if(mMimeTypeProbe != NULL) + { + llerrs << "internal error: mMimeTypeProbe is not NULL after cancelling request." << llendl; + } + } +} void LLViewerMediaImpl::addObject(LLVOVolume* obj) { -- cgit v1.2.3 From 2e70e4e2d7adbca52884186975623e26ab7fb9fb Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 13 Nov 2009 12:59:17 -0800 Subject: Add functionality to nearby media floater: parcel media & autoplay This change implements the enabling/disabling of parcel media, as well as setting the user's autoplay preference. I still am quite confused by this UI, so we'll need to play with it a bit to ensure it is what we want to present to users. This adds a few helpers to llviewerparcelmedia to get the name and URL of media. --- indra/newview/llviewermedia.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'indra/newview/llviewermedia.cpp') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 69d4da373e..36fef07989 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -54,6 +54,8 @@ #include // for SkinFolder listener #include +/*static*/ const char* LLViewerMedia::AUTO_PLAY_MEDIA_SETTING = "AutoPlayMedia"; + // Move this to its own file. LLViewerMediaEventEmitter::~LLViewerMediaEventEmitter() @@ -313,7 +315,7 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s // If (the media was already loaded OR the media was set to autoplay) AND this update didn't come from this agent, // do a navigate. - if((was_loaded || (media_entry->getAutoPlay() && gSavedSettings.getBOOL("AutoPlayMedia"))) && !update_from_self) + if((was_loaded || (media_entry->getAutoPlay() && gSavedSettings.getBOOL(AUTO_PLAY_MEDIA_SETTING))) && !update_from_self) { needs_navigate = (media_entry->getCurrentURL() != previous_url); } @@ -330,7 +332,7 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s media_impl->setHomeURL(media_entry->getHomeURL()); - if(media_entry->getAutoPlay() && gSavedSettings.getBOOL("AutoPlayMedia")) + if(media_entry->getAutoPlay() && gSavedSettings.getBOOL(AUTO_PLAY_MEDIA_SETTING)) { needs_navigate = true; } -- cgit v1.2.3 From 39c53fcf0eb718b0a3d1f43a3c9ee1a38ffef49f Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Fri, 13 Nov 2009 13:05:56 -0800 Subject: Clear the media texture to black instead of almost-black. --- indra/newview/llviewermedia.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'indra/newview/llviewermedia.cpp') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 69d4da373e..513fae41eb 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -1704,7 +1704,7 @@ LLViewerMediaTexture* LLViewerMediaImpl::updatePlaceholderImage() // MEDIAOPT: seems insane that we actually have to make an imageraw then // immediately discard it LLPointer raw = new LLImageRaw(texture_width, texture_height, texture_depth); - raw->clear(0x0f, 0x0f, 0x0f, 0xff); + raw->clear(0x00, 0x00, 0x00, 0xff); int discard_level = 0; // ask media source for correct GL image format constants -- cgit v1.2.3 From d191143cbc3aef7cd68cad98e480fb656c9e8c01 Mon Sep 17 00:00:00 2001 From: Monroe Linden Date: Fri, 13 Nov 2009 13:47:18 -0800 Subject: Special-case a "401" status ("auth required") in LLMimeDiscoveryResponder::error() to be treated as a mime type of "text/html" instead of a failure. --- indra/newview/llviewermedia.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'indra/newview/llviewermedia.cpp') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 513fae41eb..b4164a94e8 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -159,12 +159,21 @@ public: virtual void error( U32 status, const std::string& reason ) { - llwarns << "responder failed with status " << status << ", reason " << reason << llendl; - if(mMediaImpl) + if(status == 401) + { + // This is the "you need to authenticate" status. + // Treat this like an html page. + completeAny(status, "text/html"); + } + else { - mMediaImpl->mMediaSourceFailed = true; + llwarns << "responder failed with status " << status << ", reason " << reason << llendl; + + if(mMediaImpl) + { + mMediaImpl->mMediaSourceFailed = true; + } } - // completeAny(status, "none/none"); } void completeAny(U32 status, const std::string& mime_type) -- cgit v1.2.3