From b8a46c81eefc3da66fc1a1c3ed9bfbf4418b535d Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Fri, 5 Feb 2010 12:06:57 -0800 Subject: Media classes + A step toward restructuring Nearby Media floater Several changes here: - Implemented support for "media classification": see http://docs.google.com/a/lindenlab.com/View?id=ddznhrqn_29vhnr2pg8 - Added settings for auto-playing of said classifications Nearby Media Floater: - On/Off buttons are now explicit...no more power buttons - Parcel Media and Parcel Audio are "lighter weight", with no more on/off - List now sorts with playing items at top, non-playing below - There is now a "Show" drop-down that filters the list by classification - Added checkboxes to the bottom to control auto-play settings More work is needed, so consider this a checkpoint --- indra/newview/llviewermedia.cpp | 148 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 142 insertions(+), 6 deletions(-) (limited to 'indra/newview/llviewermedia.cpp') diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 9ced0194a2..90fb76c715 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -50,6 +50,9 @@ #include "llcallbacklist.h" #include "llparcel.h" #include "llaudioengine.h" // for gAudiop +#include "llvoavatar.h" +#include "llvoavatarself.h" +#include "llviewerregion.h" #include "llevent.h" // LLSimpleListener #include "llnotificationsutil.h" @@ -62,6 +65,10 @@ #include /*static*/ const char* LLViewerMedia::AUTO_PLAY_MEDIA_SETTING = "ParcelMediaAutoPlayEnable"; +/*static*/ const char* LLViewerMedia::SHOW_MEDIA_ON_OTHERS_SETTING = "MediaShowOnOthers"; +/*static*/ const char* LLViewerMedia::SHOW_MEDIA_WITHIN_PARCEL_SETTING = "MediaShowWithinParcel"; +/*static*/ const char* LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING = "MediaShowOutsideParcel"; + // Move this to its own file. @@ -365,8 +372,7 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s // The current media URL is not empty. // 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. - bool auto_play = (media_impl->mMediaAutoPlay && gSavedSettings.getBOOL(AUTO_PLAY_MEDIA_SETTING)); - + bool auto_play = media_impl->isAutoPlayable(); if((was_loaded || auto_play) && !update_from_self) { needs_navigate = url_changed; @@ -390,7 +396,7 @@ viewer_media_t LLViewerMedia::updateMediaImpl(LLMediaEntry* media_entry, const s media_impl->mMediaAutoPlay = media_entry->getAutoPlay(); media_impl->mMediaEntryURL = media_entry->getCurrentURL(); - if(media_impl->mMediaAutoPlay && gSavedSettings.getBOOL(AUTO_PLAY_MEDIA_SETTING)) + if(media_impl->isAutoPlayable()) { needs_navigate = true; } @@ -818,7 +824,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg) 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? */ @@ -846,7 +852,7 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } } } - + pimpl->setPriority(new_priority); if(pimpl->getUsedInUI()) @@ -940,6 +946,7 @@ bool LLViewerMedia::firstRunCallback(const LLSD& notification, const LLSD& respo { // user has elected to automatically play media. gSavedSettings.setBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING, TRUE); + // XXX TODO: what to do about other AUTO_PLAY settings? gSavedSettings.setBOOL("AudioStreamingMusic", TRUE); gSavedSettings.setBOOL("AudioStreamingMedia", TRUE); @@ -959,6 +966,7 @@ bool LLViewerMedia::firstRunCallback(const LLSD& notification, const LLSD& respo else { gSavedSettings.setBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING, FALSE); + // XXX TODO: what to do about other AUTO_PLAY settings? gSavedSettings.setBOOL("AudioStreamingMedia", FALSE); gSavedSettings.setBOOL("AudioStreamingMusic", FALSE); } @@ -2111,6 +2119,21 @@ void LLViewerMediaImpl::scaleMouse(S32 *mouse_x, S32 *mouse_y) #endif } + + +////////////////////////////////////////////////////////////////////////////////////////// +bool LLViewerMediaImpl::isMediaTimeBased() +{ + bool result = false; + + if(mMediaSource) + { + result = mMediaSource->pluginSupportsMediaTime(); + } + + return result; +} + ////////////////////////////////////////////////////////////////////////////////////////// bool LLViewerMediaImpl::isMediaPlaying() { @@ -2172,7 +2195,7 @@ void LLViewerMediaImpl::setDisabled(bool disabled) else { // We just (re)enabled this media. Do a navigate if auto-play is in order. - if(mMediaAutoPlay && gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING)) + if(isAutoPlayable()) { navigateTo(mMediaEntryURL, "", true, true); } @@ -2199,6 +2222,12 @@ bool LLViewerMediaImpl::isForcedUnloaded() const } } + // If this media's class is not supposed to be shown, unload + if (!shouldShowBasedOnClass()) + { + return true; + } + return false; } @@ -2684,3 +2713,110 @@ void LLViewerMediaImpl::setTextureID(LLUUID id) } } +////////////////////////////////////////////////////////////////////////////////////////// +// +bool LLViewerMediaImpl::isAutoPlayable() const +{ + return (mMediaAutoPlay && gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING)); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +bool LLViewerMediaImpl::shouldShowBasedOnClass() const +{ + // If this is parcel media or in the UI, return true always + if (getUsedInUI() || isParcelMedia()) return true; + + bool attached_to_another_avatar = isAttachedToAnotherAvatar(); + bool inside_parcel = isInAgentParcel(); + + // llinfos << " hasFocus = " << hasFocus() << + // " others = " << (attached_to_another_avatar && gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_ON_OTHERS_SETTING)) << + // " within = " << (inside_parcel && gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_WITHIN_PARCEL_SETTING)) << + // " outside = " << (!inside_parcel && gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING)) << llendl; + + // If it has focus, we should show it + if (hasFocus()) + return true; + + // If it is attached to an avatar and the pref is off, we shouldn't show it + if (attached_to_another_avatar) + return gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_ON_OTHERS_SETTING); + + if (inside_parcel) + return gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_WITHIN_PARCEL_SETTING); + else + return gSavedSettings.getBOOL(LLViewerMedia::SHOW_MEDIA_OUTSIDE_PARCEL_SETTING); +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +bool LLViewerMediaImpl::isAttachedToAnotherAvatar() const +{ + bool result = false; + + std::list< LLVOVolume* >::const_iterator iter = mObjectList.begin(); + std::list< LLVOVolume* >::const_iterator end = mObjectList.end(); + for ( ; iter != end; iter++) + { + if (isObjectAttachedToAnotherAvatar(*iter)) + { + result = true; + break; + } + } + return result; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +//static +bool LLViewerMediaImpl::isObjectAttachedToAnotherAvatar(LLVOVolume *obj) +{ + bool result = false; + LLXform *xform = obj; + // Walk up parent chain + while (NULL != xform) + { + LLViewerObject *object = dynamic_cast (xform); + if (NULL != object) + { + LLVOAvatar *avatar = object->asAvatar(); + if (NULL != avatar && avatar != gAgent.getAvatarObject()) + { + result = true; + break; + } + } + xform = xform->getParent(); + } + return result; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +bool LLViewerMediaImpl::isInAgentParcel() const +{ + bool result = false; + + std::list< LLVOVolume* >::const_iterator iter = mObjectList.begin(); + std::list< LLVOVolume* >::const_iterator end = mObjectList.end(); + for ( ; iter != end; iter++) + { + LLVOVolume *object = *iter; + if (LLViewerMediaImpl::isObjectInAgentParcel(object)) + { + result = true; + break; + } + } + return result; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// +// static +bool LLViewerMediaImpl::isObjectInAgentParcel(LLVOVolume *obj) +{ + return (LLViewerParcelMgr::getInstance()->inAgentParcel(obj->getPositionGlobal())); +} -- cgit v1.3 From 3aa7e1b0c10fcb660cfc13308dd2a45223696e11 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Tue, 9 Feb 2010 13:47:13 -0800 Subject: PARTIAL EXT-5261: add new "MediaTentativeAutoPlay" setting --- indra/newview/app_settings/settings.xml | 11 +++++++++++ indra/newview/llviewermedia.cpp | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'indra/newview/llviewermedia.cpp') diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 40ac49597d..02b34df4c6 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -4611,6 +4611,17 @@ Value 1 + MediaTentativeAutoPlay + + Comment + This is a tentative flag that may be temporarily set off by the user, until she teleports + Persist + 0 + Type + Boolean + Value + 1 + MemoryLogFrequency Comment diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index e77106bb2c..3063341ade 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -2663,7 +2663,9 @@ void LLViewerMediaImpl::setTextureID(LLUUID id) // bool LLViewerMediaImpl::isAutoPlayable() const { - return (mMediaAutoPlay && gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING)); + return (mMediaAutoPlay && + gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) && + gSavedSettings.getBOOL("MediaTentativeAutoPlay")); } ////////////////////////////////////////////////////////////////////////////////////////// -- cgit v1.3 From c680368e19f5be7265e2f15a1f4b626b1600e773 Mon Sep 17 00:00:00 2001 From: Rick Pasetto Date: Wed, 10 Feb 2010 14:28:46 -0800 Subject: EXT-5261 EXT-5263 EXT-5265 EXT-5266 EXT-5271 - Reformat NMF and enable behavior of media toggle in chrome Review #100 http://10.1.19.90:8080/go?page=ReviewDisplay&reviewid=100 This encompasses the first of the behavioral and structural changes for the Nearby Media Floater and the chrome button at the top of the UI. It includes: - Removal of the Parcel Media and Parcel Audio UI. Still not in the list yet. - New More/Less button, which doesn't quite work right (see below) - Changed icon for UI chrome - Enabled "turning on" and "turning off" media from the chrome and NMF - Added gear icon to bring up prefs - XUI changes to the structure of NMF - Implementation of the "tentative" autoplay flag This is basically a checkpoint so that Richard can help with the More/Less implementation --- indra/newview/llagent.cpp | 5 +++ indra/newview/llfloateruipreview.cpp | 1 - indra/newview/llstatusbar.cpp | 16 ++++++- indra/newview/llstatusbar.h | 4 ++ indra/newview/llviewermedia.cpp | 50 +++++++++++++++++++++- indra/newview/llviewermedia.h | 5 +++ .../skins/default/xui/en/panel_status_bar.xml | 9 ++-- 7 files changed, 80 insertions(+), 10 deletions(-) (limited to 'indra/newview/llviewermedia.cpp') diff --git a/indra/newview/llagent.cpp b/indra/newview/llagent.cpp index 2354323a66..f1eb942b52 100644 --- a/indra/newview/llagent.cpp +++ b/indra/newview/llagent.cpp @@ -5981,6 +5981,11 @@ bool LLAgent::teleportCore(bool is_local) // This was breaking the case of teleporting within a single sim. Backing it out for now. // gVoiceClient->leaveChannel(); + // Clear the "tentative" autoplay flag (i.e. set it to true) + // XXX: Do we also want to re-enable all media, because we might teleport + // somewhere where that media would still exist? + gSavedSettings.setBOOL("MediaTentativeAutoPlay", true); + return true; } diff --git a/indra/newview/llfloateruipreview.cpp b/indra/newview/llfloateruipreview.cpp index 3e804bef9d..81dafea018 100644 --- a/indra/newview/llfloateruipreview.cpp +++ b/indra/newview/llfloateruipreview.cpp @@ -362,7 +362,6 @@ BOOL LLFadeEventTimer::tick() if(NULL == mParent) // no more need to tick, so suicide { - delete this; return FALSE; } diff --git a/indra/newview/llstatusbar.cpp b/indra/newview/llstatusbar.cpp index a2648e4c3a..48de23fab1 100644 --- a/indra/newview/llstatusbar.cpp +++ b/indra/newview/llstatusbar.cpp @@ -61,6 +61,7 @@ #include "llresmgr.h" #include "llworld.h" #include "llstatgraph.h" +#include "llviewermedia.h" #include "llviewermenu.h" // for gMenuBarView #include "llviewerparcelmgr.h" #include "llviewerthrottle.h" @@ -188,8 +189,9 @@ BOOL LLStatusBar::postBuild() mBtnVolume->setClickedCallback( onClickVolume, this ); mBtnVolume->setMouseEnterCallback(boost::bind(&LLStatusBar::onMouseEnterVolume, this)); - LLButton* media_toggle = getChild("media_toggle_btn"); - media_toggle->setMouseEnterCallback(boost::bind(&LLFloaterReg::showInstance, "nearby_media", LLSD(), true)); + mMediaToggle = getChild("media_toggle_btn"); + mMediaToggle->setClickedCallback( &LLStatusBar::onClickMediaToggle, this ); + mMediaToggle->setMouseEnterCallback(boost::bind(&LLFloaterReg::showInstance, "nearby_media", LLSD(), true)); gSavedSettings.getControl("MuteAudio")->getSignal()->connect(boost::bind(&LLStatusBar::onVolumeChanged, this, _2)); @@ -354,6 +356,8 @@ void LLStatusBar::refresh() // update the master volume button state bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute(); mBtnVolume->setToggleState(mute_audio); + + mMediaToggle->setValue(!LLViewerMedia::isAnyMediaShowing()); } void LLStatusBar::setVisibleForMouselook(bool visible) @@ -525,6 +529,14 @@ static void onClickVolume(void* data) LLAppViewer::instance()->setMasterSystemAudioMute(!mute_audio); } +//static +void LLStatusBar::onClickMediaToggle(void* data) +{ + LLStatusBar *status_bar = (LLStatusBar*)data; + // "Selected" means it was showing the "play" icon (so media was playing), and now it shows "pause", so turn off media + LLViewerMedia::setAllMediaEnabled(! status_bar->mMediaToggle->getValue()); +} + // sets the static variables necessary for the date void LLStatusBar::setupDate() { diff --git a/indra/newview/llstatusbar.h b/indra/newview/llstatusbar.h index 21a98dd753..9532bbbd22 100644 --- a/indra/newview/llstatusbar.h +++ b/indra/newview/llstatusbar.h @@ -87,6 +87,7 @@ public: S32 getSquareMetersCommitted() const; S32 getSquareMetersLeft() const; + private: // simple method to setup the part that holds the date void setupDate(); @@ -96,6 +97,8 @@ private: static void onMouseEnterVolume(LLUICtrl* ctrl); static void onClickStatGraph(void* data); + + static void onClickMediaToggle(void* data); private: LLTextBox *mTextHealth; @@ -105,6 +108,7 @@ private: LLStatGraph *mSGPacketLoss; LLButton *mBtnVolume; + LLButton *mMediaToggle; S32 mBalance; S32 mHealth; diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index 3063341ade..c4f2f0eed7 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -261,6 +261,7 @@ static LLTimer sMediaCreateTimer; static const F32 LLVIEWERMEDIA_CREATE_DELAY = 1.0f; static F32 sGlobalVolume = 1.0f; static F64 sLowestLoadableImplInterest = 0.0f; +static bool sAnyMediaShowing = false; ////////////////////////////////////////////////////////////////////////////////////////// static void add_media_impl(LLViewerMediaImpl* media) @@ -694,6 +695,7 @@ static bool proximity_comparitor(const LLViewerMediaImpl* i1, const LLViewerMedi // static void LLViewerMedia::updateMedia(void *dummy_arg) { + sAnyMediaShowing = false; impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); @@ -860,6 +862,25 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } total_cpu += pimpl->getCPUUsage(); + + if (!pimpl->getUsedInUI()) + { + if (! pimpl->isParcelMedia()) + { + if (pimpl->hasMedia()) + { + sAnyMediaShowing = true; + } + } + else { + // Parcel media showing? + if (!LLViewerParcelMedia::getURL().empty() && LLViewerParcelMedia::getParcelMedia().notNull()) + { + sAnyMediaShowing = true; + } + } + } + } // Re-calculate this every time. @@ -899,6 +920,33 @@ void LLViewerMedia::updateMedia(void *dummy_arg) } +////////////////////////////////////////////////////////////////////////////////////////// +// static +bool LLViewerMedia::isAnyMediaShowing() +{ + return sAnyMediaShowing; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// static +void LLViewerMedia::setAllMediaEnabled(bool val) +{ + // Set "tentative" autoplay first. We need to do this here or else + // re-enabling won't start up the media below. + gSavedSettings.setBOOL("MediaTentativeAutoPlay", val); + + // Then + impl_list::iterator iter = sViewerMediaImplList.begin(); + impl_list::iterator end = sViewerMediaImplList.end(); + + for(; iter != end; iter++) + { + LLViewerMediaImpl* pimpl = *iter; + if (!pimpl->getUsedInUI()) + pimpl->setDisabled(!val); + } +} + ////////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::initClass() @@ -913,8 +961,6 @@ void LLViewerMedia::cleanupClass() gIdleCallbacks.deleteFunction(LLViewerMedia::updateMedia, NULL); } - // XXX TODO: what to do about other AUTO_PLAY settings? - // XXX TODO: what to do about other AUTO_PLAY settings? ////////////////////////////////////////////////////////////////////////////////////////// // LLViewerMediaImpl ////////////////////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index b6aaca8cfa..c9e9017e5a 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -102,6 +102,11 @@ class LLViewerMedia static bool textureHasMedia(const LLUUID& texture_id); static void setVolume(F32 volume); + // Is any media currently "showing"? Includes Parcel Media. Does not include media in the UI. + static bool isAnyMediaShowing(); + // Set all media enabled or disabled, depending on val. Does not include media in the UI. + static void setAllMediaEnabled(bool val); + static void updateMedia(void* dummy_arg = NULL); static void initClass(); diff --git a/indra/newview/skins/default/xui/en/panel_status_bar.xml b/indra/newview/skins/default/xui/en/panel_status_bar.xml index 77eb9f2a75..96c61b69f5 100644 --- a/indra/newview/skins/default/xui/en/panel_status_bar.xml +++ b/indra/newview/skins/default/xui/en/panel_status_bar.xml @@ -94,10 +94,10 @@ - - + - - - - + + - + - Nearby Media - - - + + - Show: - - + - - - - - - + + + + + + + + + + + + + + + - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - + left="10"/> + + + + -- cgit v1.3