void LLPanelNearByMedia::onClickSelectedMediaMute() { LLUUID selected_media_id = mMediaList->getValue().asUUID(); if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) { gSavedSettings.setBOOL("MuteMusic", mMuteBtn->getValue()); } else { LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ? ((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id); if (NULL != impl) { F32 volume = impl->getVolume(); if(volume > 0.0) { impl->setVolume(0.0); } else if (mVolumeSlider->getValueF32() == 0.0) { impl->setVolume(1.0); mVolumeSlider->setValue(1.0); } else { impl->setVolume(mVolumeSlider->getValueF32()); } } } }
void LLPanelNearByMedia::onClickSelectedMediaPlay() { LLUUID selected_media_id = mMediaList->getValue().asUUID(); // First enable it setDisabled(selected_media_id, false); // Special code to make play "unpause" if time-based and playing if (selected_media_id != PARCEL_AUDIO_LIST_ITEM_UUID) { LLViewerMediaImpl *impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ? ((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id); if (NULL != impl) { if (impl->isMediaTimeBased() && impl->isMediaPaused()) { // Aha! It's really time-based media that's paused, so unpause impl->play(); return; } else if (impl->isParcelMedia()) { LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel()); } } } }
void LLViewerMediaFocus::focusZoomOnMedia(LLUUID media_id) { LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(media_id); if(impl) { // Get the first object from the media impl's object list. This is completely arbitrary, but should suffice. LLVOVolume *obj = impl->getSomeObject(); if(obj) { // This media is attached to at least one object. Figure out which face it's on. S32 face = obj->getFaceIndexWithMediaImpl(impl, -1); // We don't have a proper pick normal here, and finding a face's real normal is... complicated. LLVector3 normal = obj->getApproximateFaceNormal(face); if(normal.isNull()) { // If that didn't work, use the inverse of the camera "look at" axis, which should keep the camera pointed in the same direction. // llinfos << "approximate face normal invalid, using camera direction." << llendl; normal = LLViewerCamera::getInstance()->getAtAxis(); normal *= (F32)-1.0f; } // Attempt to focus/zoom on that face. setFocusFace(obj, face, impl, normal); if(mMediaControls.get()) { mMediaControls.get()->resetZoomLevel(); mMediaControls.get()->nextZoomLevel(); } } } }
void LLPanelPrimMediaControls::onClickOpen() { LLViewerMediaImpl* impl = getTargetMediaImpl(); if(impl) { LLWeb::loadURL(impl->getCurrentMediaURL()); } }
LLPluginClassMedia* LLPanelPrimMediaControls::getTargetMediaPlugin() { LLViewerMediaImpl* impl = getTargetMediaImpl(); if(impl && impl->hasMedia()) { return impl->getMediaPlugin(); } return NULL; }
void LLPanelPrimMediaControls::onClickSkipForward() { focusOnTarget(); LLViewerMediaImpl* impl = getTargetMediaImpl(); if (impl) { impl->skipForward(mSkipStep); } }
////////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::setVolume(F32 volume) { impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); for(; iter != end; iter++) { LLViewerMediaImpl* pimpl = *iter; pimpl->setVolume(volume); } }
///////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::clearAllCaches() { // Clear all plugins' caches impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); for (; iter != end; iter++) { LLViewerMediaImpl* pimpl = *iter; pimpl->clearCache(); } }
void LLPanelPrimMediaControls::onClickHome() { focusOnTarget(); LLViewerMediaImpl* impl = getTargetMediaImpl(); if(impl) { impl->navigateHome(); } }
void LLPanelPrimMediaControls::onClickMediaStop() { focusOnTarget(); LLViewerMediaImpl* impl = getTargetMediaImpl(); if(impl) { impl->stop(); } }
////////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::updateMedia() { impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); for(; iter != end; iter++) { LLViewerMediaImpl* pimpl = *iter; pimpl->update(); } }
void LLPanelPrimMediaControls::onScrollDown(void* user_data) { LLPanelPrimMediaControls* this_panel = static_cast<LLPanelPrimMediaControls*> (user_data); this_panel->focusOnTarget(); LLViewerMediaImpl* impl = this_panel->getTargetMediaImpl(); if(impl) { impl->scrollWheel(0, 1, MASK_NONE); } }
void LLPanelPrimMediaControls::onScrollLeft(void* user_data) { LLPanelPrimMediaControls* this_panel = static_cast<LLPanelPrimMediaControls*> (user_data); this_panel->focusOnTarget(); LLViewerMediaImpl* impl = this_panel->getTargetMediaImpl(); if(impl) { impl->scrollWheel(1, 0, MASK_NONE); // impl->handleKeyHere(KEY_LEFT, MASK_NONE); } }
////////////////////////////////////////////////////////////////////////////////////////// // static bool LLViewerMedia::textureHasMedia(const LLUUID& texture_id) { impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); for(; iter != end; iter++) { LLViewerMediaImpl* pimpl = *iter; if(pimpl->getMediaTextureID() == texture_id) { return true; } } return false; }
void LLPanelNearByMedia::onCommitSelectedMediaVolume() { LLUUID selected_media_id = mMediaList->getValue().asUUID(); if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) { F32 vol = mVolumeSlider->getValueF32(); gSavedSettings.setF32("AudioLevelMusic", vol); } else { LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ? ((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id); if (NULL != impl) { impl->setVolume(mVolumeSlider->getValueF32()); } } }
////////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::updateMedia() { sUpdatedCookies = getCookieStore()->getChangedCookies(); if(!sUpdatedCookies.empty()) { lldebugs << "updated cookies will be sent to all loaded plugins: " << llendl; lldebugs << sUpdatedCookies << llendl; } impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); for(; iter != end; iter++) { LLViewerMediaImpl* pimpl = *iter; pimpl->update(); } }
// static void LLViewerMedia::play(const std::string& media_url, const std::string& mime_type, const LLUUID& placeholder_texture_id, S32 media_width, S32 media_height, U8 media_auto_scale, U8 media_loop) { sViewerMediaImpl.play(media_url, mime_type, placeholder_texture_id, media_width, media_height, media_auto_scale, media_loop); }
bool LLBrowserNotification::processNotification(const LLNotificationPtr& notification) { LLUUID media_id = notification->getPayload()["media_id"].asUUID(); LLMediaCtrl* media_instance = LLMediaCtrl::getInstance(media_id); if (media_instance) { media_instance->showNotification(notification); } else if (LLViewerMediaFocus::instance().getControlsMediaID() == media_id) { LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(media_id); if (impl) { impl->showNotification(notification); } } return false; }
////////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::updateBrowserUserAgent() { std::string user_agent = getCurrentUserAgent(); impl_list::iterator iter = sViewerMediaImplList.begin(); impl_list::iterator end = sViewerMediaImplList.end(); for(; iter != end; iter++) { LLViewerMediaImpl* pimpl = *iter; LLPluginClassMedia* plugin = pimpl->getMediaPlugin(); if(plugin && plugin->pluginSupportsMediaBrowser()) { plugin->setBrowserUserAgent(user_agent); } } }
void LLPanelNearByMedia::onClickSelectedMediaPause() { LLUUID selected_media_id = mMediaList->getValue().asUUID(); if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) { onClickParcelAudioPause(); } else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) { onClickParcelMediaPause(); } else { LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id); if (NULL != impl && impl->isMediaTimeBased() && impl->isMediaPlaying()) { impl->pause(); } } }
bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled) { if (row_id == PARCEL_AUDIO_LIST_ITEM_UUID) { if (disabled) { onClickParcelAudioStop(); } else { onClickParcelAudioPlay(); } return true; } else if (row_id == PARCEL_MEDIA_LIST_ITEM_UUID) { if (disabled) { onClickDisableParcelMedia(); } else { onClickEnableParcelMedia(); } return true; } else { LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); if(impl) { impl->setDisabled(disabled, true); return true; } } return false; }
void LLPanelNearByMedia::refreshParcelItems() { // // First add/remove the "fake" items Parcel Media and Parcel Audio. // These items will have special UUIDs // PARCEL_MEDIA_LIST_ITEM_UUID // PARCEL_AUDIO_LIST_ITEM_UUID // // Get the filter choice. const LLSD &choice_llsd = mShowCtrl->getSelectedValue(); MediaClass choice = (MediaClass)choice_llsd.asInteger(); // Only show "special parcel items" if "All" or "Within" filter // (and if media is "enabled") bool should_include = (choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL); // First Parcel Media: add or remove it as necessary if (gSavedSettings.getBOOL("AudioStreamingMedia") &&should_include && LLViewerMedia::hasParcelMedia()) { // Yes, there is parcel media. if (NULL == mParcelMediaItem) { mParcelMediaItem = addListItem(PARCEL_MEDIA_LIST_ITEM_UUID); mMediaList->setNeedsSort(true); } } else { if (NULL != mParcelMediaItem) { removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID); mParcelMediaItem = NULL; mMediaList->setNeedsSort(true); } } // ... then update it if (NULL != mParcelMediaItem) { std::string name, url, tooltip; getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, ""); if (name.empty() || name == url) { tooltip = url; } else { tooltip = name + " : " + url; } LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia(); updateListItem(mParcelMediaItem, mParcelMediaName, tooltip, -2, // Proximity closer than anything else, before Parcel Audio impl == NULL || impl->isMediaDisabled(), impl != NULL && !LLViewerParcelMedia::getURL().empty(), impl != NULL && impl->isMediaTimeBased() && impl->isMediaPlaying(), MEDIA_CLASS_ALL, "parcel media"); } // Next Parcel Audio: add or remove it as necessary (don't show if disabled in prefs) if (should_include && LLViewerMedia::hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic")) { // Yes, there is parcel audio. if (NULL == mParcelAudioItem) { mParcelAudioItem = addListItem(PARCEL_AUDIO_LIST_ITEM_UUID); mMediaList->setNeedsSort(true); } } else { if (NULL != mParcelAudioItem) { removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID); mParcelAudioItem = NULL; mMediaList->setNeedsSort(true); } } // ... then update it if (NULL != mParcelAudioItem) { bool is_playing = LLViewerMedia::isParcelAudioPlaying(); std::string url; url = LLViewerMedia::getParcelAudioURL(); updateListItem(mParcelAudioItem, mParcelAudioName, url, -1, // Proximity after Parcel Media, but closer than anything else (!is_playing), is_playing, is_playing, MEDIA_CLASS_ALL, "parcel audio"); } }
// static LLMediaBase::EStatus LLViewerMedia::getStatus() { return sViewerMediaImpl.getStatus(); }
////////////////////////////////////////////////////////////////////////////////////////// // static LLUUID LLViewerMedia::getMediaTextureID() { return sViewerMediaImpl.getMediaTextureID(); }
////////////////////////////////////////////////////////////////////////////////////////// // static void LLViewerMedia::updateImagesMediaStreams() { sViewerMediaImpl.updateImagesMediaStreams(); }
////////////////////////////////////////////////////////////////////////////////////////// // static bool LLViewerMedia::isMediaPlaying() { LLMediaBase::EStatus status = sViewerMediaImpl.getStatus(); return (status == LLMediaBase::STATUS_STARTED ); }
////////////////////////////////////////////////////////////////////////////////////////// // static bool LLViewerMedia::isMediaPaused() { LLMediaBase::EStatus status = sViewerMediaImpl.getStatus(); return (status == LLMediaBase::STATUS_PAUSED); }
/*virtual*/ void LLPanelPrimMediaControls::draw() { LLViewerMediaImpl* impl = getTargetMediaImpl(); if (impl) { LLNotificationPtr notification = impl->getCurrentNotification(); if (notification != mActiveNotification) { mActiveNotification = notification; if (notification) { showNotification(notification); } else { hideNotification(); } } } F32 alpha = getDrawContext().mAlpha; if(mHideImmediately) { //hide this panel clearFaceOnFade(); mHideImmediately = false; } else if(mFadeTimer.getStarted()) { F32 time = mFadeTimer.getElapsedTimeF32(); alpha *= llmax(lerp(1.0, 0.0, time / mControlFadeTime), 0.0f); if(time >= mControlFadeTime) { //hide this panel clearFaceOnFade(); } } // Build rect for icon area in coord system of this panel // Assumes layout_stack is a direct child of this panel mMediaControlsStack->updateLayout(); // adjust for layout stack spacing S32 space = mMediaControlsStack->getPanelSpacing() + 2; LLRect controls_bg_area = mMediaControlsStack->getRect(); controls_bg_area.mTop += space + 2; // adjust to ignore space from volume slider controls_bg_area.mBottom += mVolumeSliderCtrl->getRect().getHeight(); // adjust to ignore space from left bookend padding controls_bg_area.mLeft += mLeftBookend->getRect().getWidth() - space; // ignore space from right bookend padding controls_bg_area.mRight -= mRightBookend->getRect().getWidth() - space - 2; // draw control background UI image mBackgroundImage->draw( controls_bg_area, UI_VERTEX_COLOR % alpha); // draw volume slider background UI image if (mVolumeSliderCtrl->getVisible()) { LLRect volume_slider_rect; screenRectToLocal(mVolumeSliderCtrl->calcScreenRect(), &volume_slider_rect); mVolumeSliderBackgroundImage->draw(volume_slider_rect, UI_VERTEX_COLOR % alpha); } { LLViewDrawContext context(alpha); LLPanel::draw(); } }
void LLPanelNearByMedia::updateControls() { LLUUID selected_media_id = mMediaList->getValue().asUUID(); if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID) { if (!LLViewerMedia::hasParcelAudio() || !gSavedSettings.getBOOL("AudioStreamingMusic")) { // disable controls if audio streaming music is disabled from preference showDisabledControls(); } else { showTimeBasedControls(LLViewerMedia::isParcelAudioPlaying(), false, // include_zoom false, // is_zoomed gSavedSettings.getBOOL("MuteMusic"), gSavedSettings.getF32("AudioLevelMusic") ); } } else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) { if (!LLViewerMedia::hasParcelMedia() || !gSavedSettings.getBOOL("AudioStreamingMedia")) { // disable controls if audio streaming media is disabled from preference showDisabledControls(); } else { LLViewerMediaImpl* impl = LLViewerParcelMedia::getParcelMedia(); if (NULL == impl) { // Just means it hasn't started yet showBasicControls(false, false, false, false, 0); } else if (impl->isMediaTimeBased()) { showTimeBasedControls(impl->isMediaPlaying(), false, // include_zoom false, // is_zoomed impl->getVolume() == 0.0, impl->getVolume() ); } else { // non-time-based parcel media showBasicControls(LLViewerMedia::isParcelMediaPlaying(), false, false, impl->getVolume() == 0.0, impl->getVolume()); } } } else { LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id); if (NULL == impl || !gSavedSettings.getBOOL("AudioStreamingMedia")) { showDisabledControls(); } else { if (impl->isMediaTimeBased()) { showTimeBasedControls(impl->isMediaPlaying(), ! impl->isParcelMedia(), // include_zoom LLViewerMediaFocus::getInstance()->isZoomed(), impl->getVolume() == 0.0, impl->getVolume()); } else { showBasicControls(!impl->isMediaDisabled(), ! impl->isParcelMedia(), // include_zoom LLViewerMediaFocus::getInstance()->isZoomed(), impl->getVolume() == 0.0, impl->getVolume()); } } } }
void LLPanelNearByMedia::refreshList() { bool all_items_deleted = false; if(!mMediaList) { // None of this makes any sense if the media list isn't there. return; } // Check whether the debug column has been shown/hidden. bool debug_info_visible = gSavedSettings.getBOOL("MediaPerformanceManagerDebug"); if(debug_info_visible != mDebugInfoVisible) { mDebugInfoVisible = debug_info_visible; // Clear all items so the list gets regenerated. mMediaList->deleteAllItems(); mParcelAudioItem = NULL; mParcelMediaItem = NULL; all_items_deleted = true; updateColumns(); } refreshParcelItems(); // Get the canonical list from LLViewerMedia LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList(); LLViewerMedia::impl_list::iterator priority_iter; U32 enabled_count = 0; U32 disabled_count = 0; // iterate over the impl list, creating rows as necessary. for(priority_iter = impls.begin(); priority_iter != impls.end(); priority_iter++) { LLViewerMediaImpl *impl = *priority_iter; // If we just emptied out the list, every flag needs to be reset. if(all_items_deleted) { impl->setInNearbyMediaList(false); } if (!impl->isParcelMedia()) { LLUUID media_id = impl->getMediaTextureID(); S32 proximity = impl->getProximity(); // This is expensive (i.e. a linear search) -- don't use it here. We now use mInNearbyMediaList instead. //S32 index = mMediaList->getItemIndex(media_id); if (proximity < 0 || !shouldShow(impl)) { if (impl->getInNearbyMediaList()) { // There's a row for this impl -- remove it. removeListItem(media_id); impl->setInNearbyMediaList(false); } } else { if (!impl->getInNearbyMediaList()) { // We don't have a row for this impl -- add one. addListItem(media_id); impl->setInNearbyMediaList(true); } } // Update counts if (impl->isMediaDisabled()) { disabled_count++; } else { enabled_count++; } } } mDisableAllCtrl->setEnabled((gSavedSettings.getBOOL("AudioStreamingMusic") || gSavedSettings.getBOOL("AudioStreamingMedia")) && (LLViewerMedia::isAnyMediaShowing() || LLViewerMedia::isParcelMediaPlaying() || LLViewerMedia::isParcelAudioPlaying())); mEnableAllCtrl->setEnabled( (gSavedSettings.getBOOL("AudioStreamingMusic") || gSavedSettings.getBOOL("AudioStreamingMedia")) && (disabled_count > 0 || // parcel media (if we have it, and it isn't playing, enable "start") (LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) || // parcel audio (if we have it, and it isn't playing, enable "start") (LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying()))); // Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away. std::vector<LLScrollListItem*> items = mMediaList->getAllData(); for (std::vector<LLScrollListItem*>::iterator item_it = items.begin(); item_it != items.end(); ++item_it) { LLScrollListItem* item = (*item_it); LLUUID row_id = item->getUUID(); if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID && row_id != PARCEL_AUDIO_LIST_ITEM_UUID) { LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id); if(impl) { updateListItem(item, impl); } else { // This item's impl has been deleted -- remove the row. // Removing the row won't throw off our iteration, since we have a local copy of the array. // We just need to make sure we don't access this item after the delete. removeListItem(row_id); } } } // Set the selection to whatever media impl the media focus/hover is on. // This is an experiment, and can be removed by ifdefing out these 4 lines. LLUUID media_target = LLViewerMediaFocus::getInstance()->getControlsMediaID(); if(media_target.notNull()) { mMediaList->selectByID(media_target); } }