EXT-5267 EXT-5268: Add Parcel Media and Parcel Audio items to nearby media panel

Review #109

This (fairly major) change adds new "items" to the media list for
Parcel Media and Parcel Audio. Since these items are special (before
the items were always MoaP impls), they had to be treated
special. Moreover, actions on all of "media" had to be centralized so
that they would have similar behavior.
master
Rick Pasetto 2010-02-12 13:38:17 -08:00
parent e47dc498e8
commit ffd962f3a3
8 changed files with 529 additions and 376 deletions

View File

@ -202,12 +202,12 @@ void LLAudioEngine::updateInternetStream()
}
// virtual
int LLAudioEngine::isInternetStreamPlaying()
LLAudioEngine::LLAudioPlayState LLAudioEngine::isInternetStreamPlaying()
{
if (mStreamingAudioImpl)
return mStreamingAudioImpl->isPlaying();
return (LLAudioEngine::LLAudioPlayState) mStreamingAudioImpl->isPlaying();
return 0; // Stopped
return LLAudioEngine::AUDIO_STOPPED; // Stopped
}

View File

@ -91,6 +91,15 @@ public:
AUDIO_TYPE_COUNT = 4 // last
};
enum LLAudioPlayState
{
// isInternetStreamPlaying() returns an *int*, with
// 0 = stopped, 1 = playing, 2 = paused.
AUDIO_STOPPED = 0,
AUDIO_PLAYING = 1,
AUDIO_PAUSED = 2
};
LLAudioEngine();
virtual ~LLAudioEngine();
@ -156,7 +165,7 @@ public:
void stopInternetStream();
void pauseInternetStream(int pause);
void updateInternetStream(); // expected to be called often
int isInternetStreamPlaying();
LLAudioPlayState isInternetStreamPlaying();
// use a value from 0.0 to 1.0, inclusive
void setInternetStreamGain(F32 vol);
std::string getInternetStreamURL();

View File

@ -64,11 +64,8 @@
extern LLControlGroup gSavedSettings;
// Ugh, isInternetStreamPlaying() returns not a bool, but an *int*, with
// 0 = stopped, 1 = playing, 2 = paused.
static const int PARCEL_AUDIO_STOPPED = 0;
static const int PARCEL_AUDIO_PLAYING = 1;
static const int PARCEL_AUDIO_PAUSED = 2;
static const LLUUID PARCEL_MEDIA_LIST_ITEM_UUID = LLUUID("CAB5920F-E484-4233-8621-384CF373A321");
static const LLUUID PARCEL_AUDIO_LIST_ITEM_UUID = LLUUID("DF4B020D-8A24-4B95-AB5D-CA970D694822");
//
// LLPanelNearByMedia
@ -79,7 +76,9 @@ LLPanelNearByMedia::LLPanelNearByMedia()
mEnableAllCtrl(NULL),
mEnableParcelMediaCtrl(NULL),
mAllMediaDisabled(false),
mDebugInfoVisible(false)
mDebugInfoVisible(false),
mParcelMediaItem(NULL),
mParcelAudioItem(NULL)
{
mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING);
@ -116,7 +115,6 @@ BOOL LLPanelNearByMedia::postBuild()
mParcelMediaMuteCtrl = getChild<LLButton>("parcel_media_mute");
mEnableParcelMediaCtrl = getChild<LLUICtrl>("parcel_media_enable_btn");
mDisableParcelMediaCtrl = getChild<LLUICtrl>("parcel_media_disable_btn");
mParcelMediaText = getChild<LLTextBox>("parcel_media_name");
mItemCountText = getChild<LLTextBox>("media_item_count");
mParcelMediaPlayCtrl = getChild<LLButton>("parcel_media_play_btn");
mParcelMediaPauseCtrl = getChild<LLButton>("parcel_media_pause_btn");
@ -127,20 +125,13 @@ BOOL LLPanelNearByMedia::postBuild()
mShowCtrl = getChild<LLComboBox>("show_combo");
mEmptyNameString = getString("empty_item_text");
mDefaultParcelMediaName = getString("default_parcel_media_name");
mParcelMediaName = getString("parcel_media_name");
mParcelAudioName = getString("parcel_audio_name");
mPlayingString = getString("playing_suffix");
mMediaList->setDoubleClickCallback(onZoomMedia, this);
mMediaList->sortByColumnIndex(PROXIMITY_COLUMN, TRUE);
mMediaList->sortByColumnIndex(VISIBILITY_COLUMN, FALSE);
std::string url = LLViewerParcelMedia::getURL();
if (!url.empty())
{
std::string name = LLViewerParcelMedia::getName();
mParcelMediaText->setValue(name.empty()?url:name);
mParcelMediaText->setToolTip(url);
}
refreshList();
updateColumns();
@ -199,8 +190,6 @@ void LLPanelNearByMedia::draw()
{
mItemCountText->setValue(llformat(getString("media_item_count_format").c_str(), mMediaList->getItemCount()));
// refreshParcelMediaUI();
// refreshParcelAudioUI();
refreshList();
F32 alpha = mHoverTimer.getStarted()
@ -221,11 +210,11 @@ bool LLPanelNearByMedia::getParcelAudioAutoStart()
return mParcelAudioAutoStart;
}
void LLPanelNearByMedia::addMediaItem(const LLUUID &id)
LLScrollListItem* LLPanelNearByMedia::addListItem(const LLUUID &id)
{
if (NULL == mMediaList) return;
if (NULL == mMediaList) return NULL;
// Just set up the columns -- the values will be filled in by updateMediaItem().
// Just set up the columns -- the values will be filled in by updateListItem().
LLSD row;
row["id"] = id;
@ -255,22 +244,98 @@ void LLPanelNearByMedia::addMediaItem(const LLUUID &id)
}
LLScrollListItem* new_item = mMediaList->addElement(row);
LLScrollListCheck* scroll_list_check = dynamic_cast<LLScrollListCheck*>(new_item->getColumn(CHECKBOX_COLUMN));
if (scroll_list_check)
if (NULL != new_item)
{
LLCheckBoxCtrl *check = scroll_list_check->getCheckBox();
check->setCommitCallback(boost::bind(&LLPanelNearByMedia::onCheckItem, this, _1, id));
}
LLScrollListCheck* scroll_list_check = dynamic_cast<LLScrollListCheck*>(new_item->getColumn(CHECKBOX_COLUMN));
if (scroll_list_check)
{
LLCheckBoxCtrl *check = scroll_list_check->getCheckBox();
check->setCommitCallback(boost::bind(&LLPanelNearByMedia::onCheckItem, this, _1, id));
}
}
return new_item;
}
void LLPanelNearByMedia::updateMediaItem(LLScrollListItem* item, LLViewerMediaImpl* impl)
void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, LLViewerMediaImpl* impl)
{
std::string item_name;
std::string item_tooltip;
std::string debug_str;
LLPanelNearByMedia::MediaClass media_class = MEDIA_CLASS_ALL;
getNameAndUrlHelper(impl, item_name, item_tooltip, mEmptyNameString);
// Focused
if (impl->hasFocus())
{
media_class = MEDIA_CLASS_FOCUSED;
}
// Is attached to another avatar?
else if (impl->isAttachedToAnotherAvatar())
{
media_class = MEDIA_CLASS_ON_OTHERS;
}
// Outside agent parcel
else if (!impl->isInAgentParcel())
{
media_class = MEDIA_CLASS_OUTSIDE_PARCEL;
}
else {
// inside parcel
media_class = MEDIA_CLASS_WITHIN_PARCEL;
}
if(mDebugInfoVisible)
{
debug_str += llformat("%g/", (float)impl->getInterest());
// proximity distance is actually distance squared -- display it as straight distance.
debug_str += llformat("%g/", fsqrtf(impl->getProximityDistance()));
// s += llformat("%g/", (float)impl->getCPUUsage());
// s += llformat("%g/", (float)impl->getApproximateTextureInterest());
debug_str += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea());
debug_str += LLPluginClassMedia::priorityToString(impl->getPriority());
if(impl->hasMedia())
{
debug_str += '@';
}
else if(impl->isPlayable())
{
debug_str += '+';
}
else if(impl->isForcedUnloaded())
{
debug_str += '!';
}
}
updateListItem(item,
item_name,
item_tooltip,
impl->getProximity(),
impl->isMediaDisabled(),
impl->hasMedia(),
impl->isMediaTimeBased() && impl->isMediaPlaying(),
media_class,
debug_str);
}
void LLPanelNearByMedia::updateListItem(LLScrollListItem* item,
const std::string &item_name,
const std::string &item_tooltip,
S32 proximity,
bool is_disabled,
bool has_media,
bool is_time_based_and_playing,
LLPanelNearByMedia::MediaClass media_class,
const std::string &debug_str)
{
LLScrollListCell* cell = item->getColumn(PROXIMITY_COLUMN);
if(cell)
{
// since we are forced to sort by text, encode sort order as string
// proximity of -1 means "closest"
S32 proximity = impl->isParcelMedia() ? -1 : impl->getProximity();
std::string proximity_string = STRINGIZE(proximity);
std::string old_proximity_string = cell->getValue().asString();
if(proximity_string != old_proximity_string)
@ -283,86 +348,83 @@ void LLPanelNearByMedia::updateMediaItem(LLScrollListItem* item, LLViewerMediaIm
cell = item->getColumn(CHECKBOX_COLUMN);
if(cell)
{
cell->setValue(!impl->isMediaDisabled());
cell->setValue(!is_disabled);
}
cell = item->getColumn(VISIBILITY_COLUMN);
if(cell)
{
S32 old_visibility = cell->getValue();
S32 new_visibility = (impl->hasMedia()) ? 1 : ((impl->isMediaDisabled()) ? 0 : -1);
// *HACK ALERT: force ordering of Media before Audio before the rest of the list
S32 new_visibility =
item->getUUID() == PARCEL_MEDIA_LIST_ITEM_UUID ? 3
: item->getUUID() == PARCEL_AUDIO_LIST_ITEM_UUID ? 2
: (has_media) ? 1
: ((is_disabled) ? 0
: -1);
cell->setValue(STRINGIZE(new_visibility));
if (new_visibility != old_visibility)
{
mMediaList->setNeedsSort(true);
}
}
S32 media_class = -1;
cell = item->getColumn(NAME_COLUMN);
if(cell)
{
std::string name;
std::string url;
std::string name = item_name;
std::string old_name = cell->getValue().asString();
getNameAndUrlHelper(impl, name, url, mEmptyNameString);
if (impl->isParcelMedia())
if (has_media)
{
cell->setToolTip(name + " : " + url);
name = mDefaultParcelMediaName;
name += " " + mPlayingString;
}
else {
cell->setToolTip(url);
}
if (impl->hasMedia()) name += " " + mPlayingString;
if (name != old_name)
{
cell->setValue(name);
}
cell->setToolTip(item_tooltip);
// *TODO: Make these font styles/colors configurable via XUI
LLColor4 cell_color = LLColor4::white;
U8 font_style = LLFontGL::NORMAL;
LLColor4 cell_color = LLColor4::white;
// Focused
if (impl->hasFocus())
// Only colorize by class in debug
if (mDebugInfoVisible)
{
if (mDebugInfoVisible) cell_color = LLColor4::yellow;
media_class = MEDIA_CLASS_FOCUSED;
switch (media_class) {
case MEDIA_CLASS_FOCUSED:
cell_color = LLColor4::yellow;
break;
case MEDIA_CLASS_ON_OTHERS:
cell_color = LLColor4::red;
break;
case MEDIA_CLASS_OUTSIDE_PARCEL:
cell_color = LLColor4::orange;
break;
case MEDIA_CLASS_WITHIN_PARCEL:
default:
break;
}
}
// Is attached to another avatar?
else if (impl->isAttachedToAnotherAvatar())
if (is_disabled)
{
if (mDebugInfoVisible) cell_color = LLColor4::red;
media_class = MEDIA_CLASS_ON_OTHERS;
}
// Outside agent parcel
else if (!impl->isInAgentParcel())
{
if (mDebugInfoVisible) cell_color = LLColor4::orange;
media_class = MEDIA_CLASS_OUTSIDE_PARCEL;
}
else {
// inside parcel
media_class = MEDIA_CLASS_WITHIN_PARCEL;
}
if (impl->isMediaDisabled())
{
//font_style |= LLFontGL::ITALIC;
//cell_color = LLColor4::black;
// Dim it if it is disabled
cell_color.setAlpha(0.25);
if (mDebugInfoVisible)
{
font_style |= LLFontGL::ITALIC;
cell_color = LLColor4::black;
}
else {
// Dim it if it is disabled
cell_color.setAlpha(0.25);
}
}
// Dim it if it isn't "showing"
else if (!impl->hasMedia())
else if (!has_media)
{
cell_color.setAlpha(0.25);
}
// Bold it if it is time-based media and it is playing
else if (impl->isMediaTimeBased() &&
impl->isMediaPlaying())
else if (is_time_based_and_playing)
{
if (mDebugInfoVisible) font_style |= LLFontGL::BOLD;
}
@ -386,125 +448,101 @@ void LLPanelNearByMedia::updateMediaItem(LLScrollListItem* item, LLViewerMediaIm
cell = item->getColumn(DEBUG_COLUMN);
if(cell)
{
std::string s;
s += llformat("%g/", (float)impl->getInterest());
// proximity distance is actually distance squared -- display it as straight distance.
s += llformat("%g/", fsqrtf(impl->getProximityDistance()));
// s += llformat("%g/", (float)impl->getCPUUsage());
// s += llformat("%g/", (float)impl->getApproximateTextureInterest());
s += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea());
s += LLPluginClassMedia::priorityToString(impl->getPriority());
if(impl->hasMedia())
{
s += '@';
}
else if(impl->isPlayable())
{
s += '+';
}
else if(impl->isForcedUnloaded())
{
s += '!';
}
cell->setValue(s);
cell->setValue(debug_str);
}
}
}
void LLPanelNearByMedia::removeMediaItem(const LLUUID &id)
void LLPanelNearByMedia::removeListItem(const LLUUID &id)
{
if (NULL == mMediaList) return;
mMediaList->deleteSingleItem(mMediaList->getItemIndex(id));
}
void LLPanelNearByMedia::refreshParcelMediaUI()
{
std::string url = LLViewerParcelMedia::getURL();
LLStyle::Params style_params;
if (url.empty())
{
style_params.font.style = "ITALIC";
mParcelMediaText->setText(mDefaultParcelMediaName, style_params);
mEnableParcelMediaCtrl->setEnabled(false);
mDisableParcelMediaCtrl->setEnabled(false);
}
else {
std::string name = LLViewerParcelMedia::getName();
if (name.empty()) name = url;
mParcelMediaText->setText(name, style_params);
mParcelMediaText->setToolTip(url);
mEnableParcelMediaCtrl->setEnabled(true);
mDisableParcelMediaCtrl->setEnabled(true);
}
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
bool should_include = choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL;
// Set up the default play controls state
mParcelMediaPauseCtrl->setEnabled(false);
mParcelMediaPauseCtrl->setVisible(false);
mParcelMediaPlayCtrl->setEnabled(true);
mParcelMediaPlayCtrl->setVisible(true);
mParcelMediaCtrl->setEnabled(false);
if (LLViewerParcelMedia::getParcelMedia())
// First Parcel Media: add or remove it as necessary
if (should_include && LLViewerMedia::hasParcelMedia())
{
if (LLViewerParcelMedia::getParcelMedia()->getMediaPlugin() &&
LLViewerParcelMedia::getParcelMedia()->getMediaPlugin()->pluginSupportsMediaTime())
// Yes, there is parcel media.
if (NULL == mParcelMediaItem)
{
mParcelMediaCtrl->setEnabled(true);
switch(LLViewerParcelMedia::getParcelMedia()->getMediaPlugin()->getStatus())
{
case LLPluginClassMediaOwner::MEDIA_PLAYING:
mParcelMediaPlayCtrl->setEnabled(false);
mParcelMediaPlayCtrl->setVisible(false);
mParcelMediaPauseCtrl->setEnabled(true);
mParcelMediaPauseCtrl->setVisible(true);
break;
case LLPluginClassMediaOwner::MEDIA_PAUSED:
default:
// default play status is kosher
break;
}
mParcelMediaItem = addListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
mMediaList->setNeedsSort(true);
}
}
}
void LLPanelNearByMedia::refreshParcelAudioUI()
{
bool parcel_audio_enabled = !getParcelAudioURL().empty();
mParcelAudioCtrl->setToolTip(getParcelAudioURL());
else if (NULL != mParcelMediaItem) {
removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
mParcelMediaItem = NULL;
mMediaList->setNeedsSort(true);
}
if (gAudiop && parcel_audio_enabled)
// ... then update it
if (NULL != mParcelMediaItem)
{
mParcelAudioCtrl->setEnabled(true);
if (PARCEL_AUDIO_PLAYING == gAudiop->isInternetStreamPlaying())
std::string name, url, tooltip;
getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, "");
if (name.empty())
{
mParcelAudioPlayCtrl->setEnabled(false);
mParcelAudioPlayCtrl->setVisible(false);
mParcelAudioPauseCtrl->setEnabled(true);
mParcelAudioPauseCtrl->setVisible(true);
tooltip = url;
}
else {
mParcelAudioPlayCtrl->setEnabled(true);
mParcelAudioPlayCtrl->setVisible(true);
mParcelAudioPauseCtrl->setEnabled(false);
mParcelAudioPauseCtrl->setVisible(false);
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
if (should_include && LLViewerMedia::hasParcelAudio())
{
// Yes, there is parcel audio.
if (NULL == mParcelAudioItem)
{
mParcelAudioItem = addListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
mMediaList->setNeedsSort(true);
}
}
else {
mParcelAudioCtrl->setEnabled(false);
mParcelAudioPlayCtrl->setEnabled(true);
mParcelAudioPlayCtrl->setVisible(true);
mParcelAudioPauseCtrl->setEnabled(false);
mParcelAudioPauseCtrl->setVisible(false);
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();
updateListItem(mParcelAudioItem,
mParcelAudioName,
LLViewerMedia::getParcelAudioURL(),
-1, // Proximity after Parcel Media, but closer than anything else
!is_playing,
is_playing,
is_playing,
MEDIA_CLASS_ALL,
"parcel audio");
}
}
@ -531,6 +569,8 @@ void LLPanelNearByMedia::refreshList()
updateColumns();
}
refreshParcelItems();
// Get the canonical list from LLViewerMedia
LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList();
LLViewerMedia::impl_list::iterator priority_iter;
@ -548,27 +588,19 @@ void LLPanelNearByMedia::refreshList()
{
impl->setInNearbyMediaList(false);
}
if (!impl->isParcelMedia())
{
bool remove_item = false;
LLUUID media_id = impl->getMediaTextureID();
if (impl->isParcelMedia())
{
remove_item = LLViewerParcelMedia::getURL().empty();
}
else {
S32 proximity = impl->getProximity();
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);
remove_item = (proximity < 0 || !shouldShow(impl));
}
if (remove_item)
//S32 index = mMediaList->getItemIndex(media_id);
if (proximity < 0 || !shouldShow(impl))
{
// This isn't inworld media -- don't show it in the list.
if (impl->getInNearbyMediaList())
{
// There's a row for this impl -- remove it.
removeMediaItem(media_id);
removeListItem(media_id);
impl->setInNearbyMediaList(false);
}
}
@ -577,7 +609,7 @@ void LLPanelNearByMedia::refreshList()
if (!impl->getInNearbyMediaList())
{
// We don't have a row for this impl -- add one.
addMediaItem(media_id);
addListItem(media_id);
impl->setInNearbyMediaList(true);
}
}
@ -590,9 +622,15 @@ void LLPanelNearByMedia::refreshList()
enabled_count++;
}
}
}
mDisableAllCtrl->setEnabled(LLViewerMedia::isAnyMediaShowing());
mEnableAllCtrl->setEnabled(disabled_count > 0);
}
mDisableAllCtrl->setEnabled(LLViewerMedia::isAnyMediaShowing() ||
LLViewerMedia::isParcelMediaPlaying() ||
LLViewerMedia::isParcelAudioPlaying());
mEnableAllCtrl->setEnabled(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();
@ -604,17 +642,21 @@ void LLPanelNearByMedia::refreshList()
LLScrollListItem* item = (*item_it);
LLUUID row_id = item->getUUID();
LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
if(impl)
if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID &&
row_id != PARCEL_AUDIO_LIST_ITEM_UUID)
{
updateMediaItem(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.
removeMediaItem(row_id);
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);
}
}
}
@ -645,29 +687,28 @@ void LLPanelNearByMedia::updateColumns()
}
void LLPanelNearByMedia::onClickEnableAll()
{
{
LLViewerMedia::setAllMediaEnabled(true);
// Parcel Audio, too
onClickParcelAudioPlay();
}
}
void LLPanelNearByMedia::onClickDisableAll()
{
{
LLViewerMedia::setAllMediaEnabled(false);
// Parcel Audio, too
onClickParcelAudioStop();
}
}
void LLPanelNearByMedia::onClickEnableParcelMedia()
{
if ( ! LLViewerMedia::isParcelMediaPlaying() )
{
LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
}
}
void LLPanelNearByMedia::onClickDisableParcelMedia()
{
// This actually unloads the impl, as opposed to "stop"ping the media
LLViewerParcelMedia::stop();
}
// This actually unloads the impl, as opposed to "stop"ping the media
LLViewerParcelMedia::stop();
}
void LLPanelNearByMedia::onCheckItem(LLUICtrl* ctrl, const LLUUID &row_id)
{
@ -678,12 +719,26 @@ void LLPanelNearByMedia::onCheckItem(LLUICtrl* ctrl, const LLUUID &row_id)
bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled)
{
LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
if(impl)
if (row_id == PARCEL_AUDIO_LIST_ITEM_UUID)
{
impl->setDisabled(disabled);
if (disabled) onClickParcelAudioStop();
else onClickParcelAudioStart();
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);
return true;
}
}
return false;
}
@ -733,6 +788,18 @@ void LLPanelNearByMedia::onClickParcelMediaPause()
LLViewerParcelMedia::pause();
}
void LLPanelNearByMedia::onClickParcelAudioStart()
{
// User *explicitly* started the internet stream, so keep the stream
// playing and updated as they cross to other parcels etc.
mParcelAudioAutoStart = true;
if (!gAudiop)
return;
gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL());
}
void LLPanelNearByMedia::onClickParcelAudioPlay()
{
// User *explicitly* started the internet stream, so keep the stream
@ -742,13 +809,13 @@ void LLPanelNearByMedia::onClickParcelAudioPlay()
if (!gAudiop)
return;
if (PARCEL_AUDIO_PAUSED == gAudiop->isInternetStreamPlaying())
if (LLAudioEngine::AUDIO_PAUSED == gAudiop->isInternetStreamPlaying())
{
// 'false' means unpause
gAudiop->pauseInternetStream(false);
}
else {
gAudiop->startInternetStream(getParcelAudioURL());
gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL());
}
}
@ -829,7 +896,7 @@ void LLPanelNearByMedia::onMoreLess()
setShape(new_rect);
}
// static
void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName)
{
@ -855,10 +922,3 @@ void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::strin
}
}
// static
std::string LLPanelNearByMedia::getParcelAudioURL()
{
return LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL();
}

View File

@ -84,15 +84,23 @@ private:
};
// Add/remove an LLViewerMediaImpl to/from the list
void addMediaItem(const LLUUID &id);
void updateMediaItem(LLScrollListItem* item, LLViewerMediaImpl* impl);
void removeMediaItem(const LLUUID &id);
LLScrollListItem* addListItem(const LLUUID &id);
void updateListItem(LLScrollListItem* item, LLViewerMediaImpl* impl);
void updateListItem(LLScrollListItem* item,
const std::string &item_name,
const std::string &item_tooltip,
S32 proximity,
bool is_disabled,
bool has_media,
bool is_time_based_and_playing,
MediaClass media_class,
const std::string &debug_str);
void removeListItem(const LLUUID &id);
// Refresh the list in the UI
void refreshList();
void refreshParcelMediaUI();
void refreshParcelAudioUI();
void refreshParcelItems();
// UI Callbacks
void onClickEnableAll();
@ -106,6 +114,7 @@ private:
void onClickParcelMediaPause();
void onClickParcelAudioPlay();
void onClickParcelAudioStop();
void onClickParcelAudioStart();
void onClickParcelAudioPause();
void onCheckAutoPlay();
void onAdvancedButtonClick();
@ -117,10 +126,8 @@ private:
private:
bool setDisabled(const LLUUID &id, bool disabled);
static void getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName);
static std::string getParcelAudioURL();
static void getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName);
void updateColumns();
@ -134,7 +141,6 @@ private:
LLButton* mParcelMediaMuteCtrl;
LLUICtrl* mEnableParcelMediaCtrl;
LLUICtrl* mDisableParcelMediaCtrl;
LLTextBox* mParcelMediaText;
LLTextBox* mItemCountText;
LLUICtrl* mParcelMediaCtrl;
LLUICtrl* mParcelMediaPlayCtrl;
@ -148,12 +154,15 @@ private:
bool mDebugInfoVisible;
bool mParcelAudioAutoStart;
std::string mEmptyNameString;
std::string mDefaultParcelMediaName;
std::string mPlayingString;
std::string mParcelMediaName;
std::string mParcelAudioName;
S32 mOriginalHeight;
S32 mNearbyMediaPanelHeight;
LLFrameTimer mHoverTimer;
LLScrollListItem* mParcelMediaItem;
LLScrollListItem* mParcelAudioItem;
};

View File

@ -376,7 +376,12 @@ void LLStatusBar::refresh()
bool mute_audio = LLAppViewer::instance()->getMasterSystemAudioMute();
mBtnVolume->setToggleState(mute_audio);
mMediaToggle->setValue(!LLViewerMedia::isAnyMediaShowing());
// Don't show media toggle if there's no media, parcel media, and no parcel audio
mMediaToggle->setVisible(LLViewerMedia::hasInWorldMedia() || LLViewerMedia::hasParcelMedia() || LLViewerMedia::hasParcelAudio());
// Note the "sense" of the toggle is opposite whether media is playing or not
mMediaToggle->setValue(! (LLViewerMedia::isAnyMediaShowing() ||
LLViewerMedia::isParcelMediaPlaying() ||
LLViewerMedia::isParcelAudioPlaying()));
}
void LLStatusBar::setVisibleForMouselook(bool visible)
@ -406,8 +411,8 @@ void LLStatusBar::setBalance(S32 balance)
LLButton* btn_buy_currency = getChild<LLButton>("buycurrency");
LLStringUtil::format_map_t string_args;
string_args["[AMT]"] = llformat("%s", money_str.c_str());
std::string labe_str = getString("buycurrencylabel", string_args);
btn_buy_currency->setLabel(labe_str);
std::string label_str = getString("buycurrencylabel", string_args);
btn_buy_currency->setLabel(label_str);
// Resize the balance button so that the label fits it, and the button expands to the left.
// *TODO: LLButton should have an option where to expand.
@ -559,7 +564,8 @@ 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());
bool enable = ! status_bar->mMediaToggle->getValue();
LLViewerMedia::setAllMediaEnabled(enable);
}
// sets the static variables necessary for the date

View File

@ -864,26 +864,9 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
total_cpu += pimpl->getCPUUsage();
// Only set sAnyMediaShowing if it isn't used in the UI. If it isn't
// parcel media, do the normal "hasMedia()" check. If it is parcel media,
// hasMedia() seems to always be true, so we do some other checks to see
// if there actually is parcel media showing
if (!pimpl->getUsedInUI())
if (!pimpl->getUsedInUI() && pimpl->hasMedia())
{
if (! pimpl->isParcelMedia())
{
if (pimpl->hasMedia())
{
sAnyMediaShowing = true;
}
}
else {
// Parcel media showing?
if (!LLViewerParcelMedia::getURL().empty() && LLViewerParcelMedia::getParcelMedia().notNull())
{
sAnyMediaShowing = true;
}
}
sAnyMediaShowing = true;
}
}
@ -947,9 +930,84 @@ void LLViewerMedia::setAllMediaEnabled(bool val)
for(; iter != end; iter++)
{
LLViewerMediaImpl* pimpl = *iter;
if (!pimpl->getUsedInUI())
if (!pimpl->getUsedInUI())
{
pimpl->setDisabled(!val);
}
}
// Also do Parcel Media and Parcel Audio
if (val)
{
if (!LLViewerMedia::isParcelMediaPlaying())
{
LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
}
if (!LLViewerMedia::isParcelAudioPlaying() && gAudiop)
{
gAudiop->startInternetStream(LLViewerMedia::getParcelAudioURL());
}
}
else {
// This actually unloads the impl, as opposed to "stop"ping the media
LLViewerParcelMedia::stop();
if (gAudiop) gAudiop->stopInternetStream();
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// static
bool LLViewerMedia::isParcelMediaPlaying()
{
return (LLViewerMedia::hasParcelMedia() && LLViewerParcelMedia::getParcelMedia() && LLViewerParcelMedia::getParcelMedia()->hasMedia());
}
/////////////////////////////////////////////////////////////////////////////////////////
// static
bool LLViewerMedia::isParcelAudioPlaying()
{
return (LLViewerMedia::hasParcelAudio() && gAudiop && LLAudioEngine::AUDIO_PLAYING == gAudiop->isInternetStreamPlaying());
}
bool LLViewerMedia::hasInWorldMedia()
{
if (! gSavedSettings.getBOOL("AudioStreamingMedia")) return false;
if (sInWorldMediaDisabled) return false;
impl_list::iterator iter = sViewerMediaImplList.begin();
impl_list::iterator end = sViewerMediaImplList.end();
// This should be quick, because there should be very few non-in-world-media impls
for (; iter != end; iter++)
{
LLViewerMediaImpl* pimpl = *iter;
if (!pimpl->getUsedInUI() && !pimpl->isParcelMedia())
{
// Found an in-world media impl
return true;
}
}
return false;
}
//////////////////////////////////////////////////////////////////////////////////////////
// static
bool LLViewerMedia::hasParcelMedia()
{
return !LLViewerParcelMedia::getURL().empty();
}
//////////////////////////////////////////////////////////////////////////////////////////
// static
bool LLViewerMedia::hasParcelAudio()
{
return !LLViewerMedia::getParcelAudioURL().empty();
}
//////////////////////////////////////////////////////////////////////////////////////////
// static
std::string LLViewerMedia::getParcelAudioURL()
{
return LLViewerParcelMgr::getInstance()->getAgentParcel()->getMusicURL();
}
//////////////////////////////////////////////////////////////////////////////////////////

View File

@ -73,60 +73,68 @@ class LLViewerMediaImpl;
class LLViewerMedia
{
LOG_CLASS(LLViewerMedia);
public:
// String to get/set media autoplay in gSavedSettings
static const char* AUTO_PLAY_MEDIA_SETTING;
static const char* SHOW_MEDIA_ON_OTHERS_SETTING;
static const char* SHOW_MEDIA_WITHIN_PARCEL_SETTING;
static const char* SHOW_MEDIA_OUTSIDE_PARCEL_SETTING;
public:
typedef std::vector<LLViewerMediaImpl*> impl_list;
typedef std::map<LLUUID, LLViewerMediaImpl*> impl_id_map;
// Special case early init for just web browser component
// so we can show login screen. See .cpp file for details. JC
static viewer_media_t newMediaImpl(const LLUUID& texture_id,
S32 media_width = 0,
S32 media_height = 0,
U8 media_auto_scale = false,
U8 media_loop = false);
static viewer_media_t updateMediaImpl(LLMediaEntry* media_entry, const std::string& previous_url, bool update_from_self);
static LLViewerMediaImpl* getMediaImplFromTextureID(const LLUUID& texture_id);
static std::string getCurrentUserAgent();
static void updateBrowserUserAgent();
static bool handleSkinCurrentChanged(const LLSD& /*newvalue*/);
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);
// String to get/set media autoplay in gSavedSettings
static const char* AUTO_PLAY_MEDIA_SETTING;
static const char* SHOW_MEDIA_ON_OTHERS_SETTING;
static const char* SHOW_MEDIA_WITHIN_PARCEL_SETTING;
static const char* SHOW_MEDIA_OUTSIDE_PARCEL_SETTING;
static void updateMedia(void* dummy_arg = NULL);
static void initClass();
static void cleanupClass();
static F32 getVolume();
static void muteListChanged();
static void setInWorldMediaDisabled(bool disabled);
static bool getInWorldMediaDisabled();
static bool isInterestingEnough(const LLVOVolume* object, const F64 &object_interest);
typedef std::vector<LLViewerMediaImpl*> impl_list;
// Returns the priority-sorted list of all media impls.
static impl_list &getPriorityList();
// This is the comparitor used to sort the list.
static bool priorityComparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2);
typedef std::map<LLUUID, LLViewerMediaImpl*> impl_id_map;
private:
static void onTeleportFinished();
// Special case early init for just web browser component
// so we can show login screen. See .cpp file for details. JC
static viewer_media_t newMediaImpl(const LLUUID& texture_id,
S32 media_width = 0,
S32 media_height = 0,
U8 media_auto_scale = false,
U8 media_loop = false);
static viewer_media_t updateMediaImpl(LLMediaEntry* media_entry, const std::string& previous_url, bool update_from_self);
static LLViewerMediaImpl* getMediaImplFromTextureID(const LLUUID& texture_id);
static std::string getCurrentUserAgent();
static void updateBrowserUserAgent();
static bool handleSkinCurrentChanged(const LLSD& /*newvalue*/);
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();
static void cleanupClass();
static F32 getVolume();
static void muteListChanged();
static void setInWorldMediaDisabled(bool disabled);
static bool getInWorldMediaDisabled();
static bool isInterestingEnough(const LLVOVolume* object, const F64 &object_interest);
// Returns the priority-sorted list of all media impls.
static impl_list &getPriorityList();
// This is the comparitor used to sort the list.
static bool priorityComparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2);
// These are just helper functions for the convenience of others working with media
static bool hasInWorldMedia();
static std::string getParcelAudioURL();
static bool hasParcelMedia();
static bool hasParcelAudio();
static bool isParcelMediaPlaying();
static bool isParcelAudioPlaying();
private:
static void onTeleportFinished();
};
// Implementation functions not exported into header file

View File

@ -6,12 +6,13 @@
background_visible="true"
layout="topleft"
width="270"
height="310"
height="290"
name="nearby_media"
help_topic="nearby_media">
<string name="media_item_count_format">(%ld media items)</string>
<string name="empty_item_text">&lt;empty&gt;</string>
<string name="default_parcel_media_name">Parcel Media</string>
<string name="parcel_media_name">Parcel Streaming Media</string>
<string name="parcel_audio_name">Parcel Streaming Audio</string>
<string name="playing_suffix">(playing)</string>
<panel
bevel_style="in"
@ -63,7 +64,7 @@
<button
name="more_less_btn"
follows="right"
tool_tip="Turn all nearby media on"
tool_tip="Advanced Controls"
top_delta="0"
right="-10"
width="60"
@ -183,67 +184,69 @@
label="Debug"
name="media_debug" />
</scroll_list>
<panel
bevel_style="in"
background_visible="true"
bg_alpha_color="0.0 0.0 0.0 1.0"
bg_opaque_color="0 0 0 0.3"
follows="left|right|bottom"
top_pad="5"
height="110"
left="10"
right="-10">
<check_box
name="media_enabled_btn"
control_name="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Check this to enable all media"
label="All Media Enabled"
top="10"
left="10"/>
<check_box
name="media_auto_play_btn"
control_name="ParcelMediaAutoPlayEnable"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Check this to let media auto-play if it wants"
label="Allow Media to auto-play"
<panel
bevel_style="in"
background_visible="true"
bg_alpha_color="0.0 0.0 0.0 1.0"
bg_opaque_color="0 0 0 0.3"
follows="left|right|bottom"
top_pad="5"
left="10"/>
<check_box
name="media_show_within_parcel_btn"
control_name="MediaShowWithinParcel"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Uncheck this to hide media within the parcel you are standing in"
label="Show media within current parcel"
left="10"/>
<check_box
name="media_show_outside_parcel_btn"
control_name="MediaShowOutsideParcel"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Uncheck this to hide media outside the parcel you are standing in"
label="Show media outside current parcel"
left="10"/>
<check_box
name="media_show_on_others_btn"
control_name="MediaShowOnOthers"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Uncheck this to hide media attached to other avatars nearby"
label="Show media attached to other avatars"
left="10"/>
height="90"
left="10"
right="-10">
<check_box
name="media_enabled_btn"
control_name="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Check this to enable all media"
label="All Media Enabled"
top="10"
left="10"/>
<check_box
name="media_auto_play_btn"
control_name="ParcelMediaAutoPlayEnable"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Check this to let media auto-play if it wants"
label="Allow Media to auto-play"
top_pad="5"
left="10"/>
<!--
<check_box
name="media_show_within_parcel_btn"
control_name="MediaShowWithinParcel"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Uncheck this to hide media within the parcel you are standing in"
label="Show media within current parcel"
left="10"/>
-->
<check_box
name="media_show_outside_parcel_btn"
control_name="MediaShowOutsideParcel"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Uncheck this to hide media outside the parcel you are standing in"
label="Show media outside current parcel"
left="10"/>
<check_box
name="media_show_on_others_btn"
control_name="MediaShowOnOthers"
enabled_control="AudioStreamingMedia"
value="true"
follows="left|bottom|right"
height="15"
tool_tip="Uncheck this to hide media attached to other avatars nearby"
label="Show media attached to other avatars"
left="10"/>
</panel>
</panel>
</panel>
</panel>