PageRenderTime 156ms CodeModel.GetById 14ms app.highlight 128ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llpanelnearbymedia.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 1232 lines | 974 code | 140 blank | 118 comment | 217 complexity | 869b6de0762edef471d60143fa8f9280 MD5 | raw file
   1/** 
   2 * @file llpanelnearbymedia.cpp
   3 * @brief Management interface for muting and controlling nearby media
   4 *
   5 * $LicenseInfo:firstyear=2005&license=viewerlgpl$
   6 * Second Life Viewer Source Code
   7 * Copyright (C) 2010, Linden Research, Inc.
   8 * 
   9 * This library is free software; you can redistribute it and/or
  10 * modify it under the terms of the GNU Lesser General Public
  11 * License as published by the Free Software Foundation;
  12 * version 2.1 of the License only.
  13 * 
  14 * This library is distributed in the hope that it will be useful,
  15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  17 * Lesser General Public License for more details.
  18 * 
  19 * You should have received a copy of the GNU Lesser General Public
  20 * License along with this library; if not, write to the Free Software
  21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  22 * 
  23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
  24 * $/LicenseInfo$
  25 */
  26
  27#include "llviewerprecompiledheaders.h"
  28
  29#include "llpanelnearbymedia.h"
  30
  31#include "llaudioengine.h"
  32#include "llcheckboxctrl.h"
  33#include "llcombobox.h"
  34#include "llresizebar.h"
  35#include "llresizehandle.h"
  36#include "llscrolllistctrl.h"
  37#include "llscrolllistitem.h"
  38#include "llscrolllistcell.h"
  39#include "llslider.h"
  40#include "llsliderctrl.h"
  41#include "llagent.h"
  42#include "llagentui.h"
  43#include "llbutton.h"
  44#include "lltextbox.h"
  45#include "llviewermedia.h"
  46#include "llviewerparcelmedia.h"
  47#include "llviewerregion.h"
  48#include "llviewermediafocus.h"
  49#include "llviewerparcelmgr.h"
  50#include "llparcel.h"
  51#include "llpluginclassmedia.h"
  52#include "llvovolume.h"
  53#include "llstatusbar.h"
  54#include "llsdutil.h"
  55#include "llvieweraudio.h"
  56
  57#include "llfloaterreg.h"
  58#include "llfloaterpreference.h" // for the gear icon
  59#include "lltabcontainer.h"
  60
  61#include <stringize.h>
  62
  63extern LLControlGroup gSavedSettings;
  64
  65static const LLUUID PARCEL_MEDIA_LIST_ITEM_UUID = LLUUID("CAB5920F-E484-4233-8621-384CF373A321");
  66static const LLUUID PARCEL_AUDIO_LIST_ITEM_UUID = LLUUID("DF4B020D-8A24-4B95-AB5D-CA970D694822");
  67
  68//
  69// LLPanelNearByMedia
  70//
  71
  72
  73LLPanelNearByMedia::LLPanelNearByMedia()
  74:	mMediaList(NULL),
  75	  mEnableAllCtrl(NULL),
  76	  mAllMediaDisabled(false),
  77	  mDebugInfoVisible(false),
  78	  mParcelMediaItem(NULL),
  79	  mParcelAudioItem(NULL)
  80{
  81	mHoverTimer.stop();
  82
  83	mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) &&
  84							gSavedSettings.getBOOL("MediaTentativeAutoPlay");
  85
  86	gSavedSettings.getControl(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING)->getSignal()->connect(boost::bind(&LLPanelNearByMedia::handleMediaAutoPlayChanged, this, _2));
  87
  88	mCommitCallbackRegistrar.add("MediaListCtrl.EnableAll",		boost::bind(&LLPanelNearByMedia::onClickEnableAll, this));
  89	mCommitCallbackRegistrar.add("MediaListCtrl.DisableAll",		boost::bind(&LLPanelNearByMedia::onClickDisableAll, this));
  90	mCommitCallbackRegistrar.add("MediaListCtrl.GoMediaPrefs", boost::bind(&LLPanelNearByMedia::onAdvancedButtonClick, this));
  91	mCommitCallbackRegistrar.add("MediaListCtrl.MoreLess", boost::bind(&LLPanelNearByMedia::onMoreLess, this));
  92	mCommitCallbackRegistrar.add("SelectedMediaCtrl.Stop",		boost::bind(&LLPanelNearByMedia::onClickSelectedMediaStop, this));	
  93	mCommitCallbackRegistrar.add("SelectedMediaCtrl.Play",		boost::bind(&LLPanelNearByMedia::onClickSelectedMediaPlay, this));
  94	mCommitCallbackRegistrar.add("SelectedMediaCtrl.Pause",		boost::bind(&LLPanelNearByMedia::onClickSelectedMediaPause, this));
  95	mCommitCallbackRegistrar.add("SelectedMediaCtrl.Mute",		boost::bind(&LLPanelNearByMedia::onClickSelectedMediaMute, this));
  96	mCommitCallbackRegistrar.add("SelectedMediaCtrl.Volume",	boost::bind(&LLPanelNearByMedia::onCommitSelectedMediaVolume, this));
  97	mCommitCallbackRegistrar.add("SelectedMediaCtrl.Zoom",		boost::bind(&LLPanelNearByMedia::onClickSelectedMediaZoom, this));
  98	mCommitCallbackRegistrar.add("SelectedMediaCtrl.Unzoom",	boost::bind(&LLPanelNearByMedia::onClickSelectedMediaUnzoom, this));
  99	
 100	buildFromFile( "panel_nearby_media.xml");
 101}
 102
 103LLPanelNearByMedia::~LLPanelNearByMedia()
 104{
 105}
 106
 107BOOL LLPanelNearByMedia::postBuild()
 108{
 109	LLPanel::postBuild();
 110
 111	const S32 RESIZE_BAR_THICKNESS = 6;
 112	LLResizeBar::Params p;
 113	p.rect = LLRect(0, RESIZE_BAR_THICKNESS, getRect().getWidth(), 0);
 114	p.name = "resizebar_bottom";
 115	p.min_size = getRect().getHeight();
 116	p.side = LLResizeBar::BOTTOM;
 117	p.resizing_view = this;
 118	addChild( LLUICtrlFactory::create<LLResizeBar>(p) );
 119
 120	p.rect = LLRect( 0, getRect().getHeight(), RESIZE_BAR_THICKNESS, 0);
 121	p.name = "resizebar_left";
 122	p.min_size = getRect().getWidth();
 123	p.side = LLResizeBar::LEFT;
 124	addChild( LLUICtrlFactory::create<LLResizeBar>(p) );
 125	
 126	LLResizeHandle::Params resize_handle_p;
 127	resize_handle_p.rect = LLRect( 0, RESIZE_HANDLE_HEIGHT, RESIZE_HANDLE_WIDTH, 0 );
 128	resize_handle_p.mouse_opaque(false);
 129	resize_handle_p.min_width(getRect().getWidth());
 130	resize_handle_p.min_height(getRect().getHeight());
 131	resize_handle_p.corner(LLResizeHandle::LEFT_BOTTOM);
 132	addChild(LLUICtrlFactory::create<LLResizeHandle>(resize_handle_p));
 133
 134	mNearbyMediaPanel = getChild<LLUICtrl>("nearby_media_panel");
 135	mMediaList = getChild<LLScrollListCtrl>("media_list");
 136	mEnableAllCtrl = getChild<LLUICtrl>("all_nearby_media_enable_btn");
 137	mDisableAllCtrl = getChild<LLUICtrl>("all_nearby_media_disable_btn");
 138	mShowCtrl = getChild<LLComboBox>("show_combo");
 139
 140	// Dynamic (selection-dependent) controls
 141	mStopCtrl = getChild<LLUICtrl>("stop");
 142	mPlayCtrl = getChild<LLUICtrl>("play");
 143	mPauseCtrl = getChild<LLUICtrl>("pause");
 144	mMuteCtrl = getChild<LLUICtrl>("mute");
 145	mVolumeSliderCtrl = getChild<LLUICtrl>("volume_slider_ctrl");
 146	mZoomCtrl = getChild<LLUICtrl>("zoom");
 147	mUnzoomCtrl = getChild<LLUICtrl>("unzoom");
 148	mVolumeSlider = getChild<LLSlider>("volume_slider");
 149	mMuteBtn = getChild<LLButton>("mute_btn");
 150	
 151	mEmptyNameString = getString("empty_item_text");
 152	mParcelMediaName = getString("parcel_media_name");
 153	mParcelAudioName = getString("parcel_audio_name");
 154	mPlayingString = getString("playing_suffix");
 155	
 156	mMediaList->setDoubleClickCallback(onZoomMedia, this);
 157	mMediaList->sortByColumnIndex(PROXIMITY_COLUMN, TRUE);
 158	mMediaList->sortByColumnIndex(VISIBILITY_COLUMN, FALSE);
 159	
 160	refreshList();
 161	updateControls();
 162	updateColumns();
 163	
 164	LLView* minimized_controls = getChildView("minimized_controls");
 165	mMoreRect = getRect();
 166	mLessRect = getRect();
 167	mLessRect.mBottom = minimized_controls->getRect().mBottom;
 168
 169	getChild<LLUICtrl>("more_btn")->setVisible(false);
 170	onMoreLess();
 171	
 172	return TRUE;
 173}
 174
 175void LLPanelNearByMedia::handleMediaAutoPlayChanged(const LLSD& newvalue)
 176{
 177	// update mParcelAudioAutoStart if AUTO_PLAY_MEDIA_SETTING changes
 178	mParcelAudioAutoStart = gSavedSettings.getBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING) &&
 179							gSavedSettings.getBOOL("MediaTentativeAutoPlay");							
 180}
 181
 182/*virtual*/
 183void LLPanelNearByMedia::onMouseEnter(S32 x, S32 y, MASK mask)
 184{
 185	mHoverTimer.stop();
 186	LLPanel::onMouseEnter(x,y,mask);
 187}
 188
 189
 190/*virtual*/
 191void LLPanelNearByMedia::onMouseLeave(S32 x, S32 y, MASK mask)
 192{
 193	mHoverTimer.start();
 194	LLPanel::onMouseLeave(x,y,mask);
 195}
 196
 197/*virtual*/ 
 198void LLPanelNearByMedia::onTopLost()
 199{
 200	setVisible(FALSE);
 201}
 202
 203
 204/*virtual*/ 
 205void LLPanelNearByMedia::handleVisibilityChange ( BOOL new_visibility )
 206{
 207	if (new_visibility)	
 208	{
 209		mHoverTimer.start(); // timer will be stopped when mouse hovers over panel
 210	}
 211	else
 212	{
 213		mHoverTimer.stop();
 214	}
 215}
 216
 217/*virtual*/
 218void LLPanelNearByMedia::reshape(S32 width, S32 height, BOOL called_from_parent)
 219{
 220	LLPanel::reshape(width, height, called_from_parent);
 221
 222	LLButton* more_btn = findChild<LLButton>("more_btn");
 223	if (more_btn && more_btn->getValue().asBoolean())
 224	{
 225		mMoreRect = getRect();
 226	}
 227
 228}
 229
 230const F32 AUTO_CLOSE_FADE_TIME_START= 4.0f;
 231const F32 AUTO_CLOSE_FADE_TIME_END = 5.0f;
 232
 233/*virtual*/
 234void LLPanelNearByMedia::draw()
 235{
 236	// keep bottom of panel on screen
 237	LLRect screen_rect = calcScreenRect();
 238	if (screen_rect.mBottom < 0)
 239	{
 240		LLRect new_rect = getRect();
 241		new_rect.mBottom += 0 - screen_rect.mBottom;
 242		setShape(new_rect);
 243	}
 244
 245	refreshList();
 246	updateControls();
 247	
 248	F32 alpha = mHoverTimer.getStarted() 
 249		? clamp_rescale(mHoverTimer.getElapsedTimeF32(), AUTO_CLOSE_FADE_TIME_START, AUTO_CLOSE_FADE_TIME_END, 1.f, 0.f)
 250		: 1.0f;
 251	LLViewDrawContext context(alpha);
 252
 253	LLPanel::draw();
 254
 255	if (alpha == 0.f)
 256	{
 257		setVisible(false);
 258	}
 259}
 260
 261/*virtual*/
 262BOOL LLPanelNearByMedia::handleHover(S32 x, S32 y, MASK mask)
 263{
 264	LLPanel::handleHover(x, y, mask);
 265	
 266	// If we are hovering over this panel, make sure to clear any hovered media
 267	// ID.  Note that the more general solution would be to clear this ID when
 268	// the mouse leaves the in-scene view, but that proved to be problematic.
 269	// See EXT-5517
 270	LLViewerMediaFocus::getInstance()->clearHover();
 271		
 272	// Always handle
 273	return true;
 274}
 275
 276bool LLPanelNearByMedia::getParcelAudioAutoStart()
 277{
 278	return mParcelAudioAutoStart;
 279}
 280
 281LLScrollListItem* LLPanelNearByMedia::addListItem(const LLUUID &id)
 282{
 283	if (NULL == mMediaList) return NULL;
 284	
 285	// Just set up the columns -- the values will be filled in by updateListItem().
 286	
 287	LLSD row;
 288	row["id"] = id;
 289	
 290	LLSD &columns = row["columns"];
 291	
 292	columns[CHECKBOX_COLUMN]["column"] = "media_checkbox_ctrl";
 293	columns[CHECKBOX_COLUMN]["type"] = "checkbox";	
 294	//if(mDebugInfoVisible)
 295	{
 296	columns[PROXIMITY_COLUMN]["column"] = "media_proximity";
 297	columns[PROXIMITY_COLUMN]["value"] = "";
 298		columns[VISIBILITY_COLUMN]["column"] = "media_visibility";
 299		columns[VISIBILITY_COLUMN]["value"] = "";
 300		columns[CLASS_COLUMN]["column"] = "media_class";
 301		columns[CLASS_COLUMN]["type"] = "text";
 302		columns[CLASS_COLUMN]["value"] = "";
 303	}
 304	columns[NAME_COLUMN]["column"] = "media_name";
 305	columns[NAME_COLUMN]["type"] = "text";
 306	columns[NAME_COLUMN]["value"] = "";
 307	//if(mDebugInfoVisible)
 308	{
 309		columns[DEBUG_COLUMN]["column"] = "media_debug";
 310		columns[DEBUG_COLUMN]["type"] = "text";
 311		columns[DEBUG_COLUMN]["value"] = "";
 312	}
 313	
 314	LLScrollListItem* new_item = mMediaList->addElement(row);
 315	if (NULL != new_item)
 316	{
 317		LLScrollListCheck* scroll_list_check = dynamic_cast<LLScrollListCheck*>(new_item->getColumn(CHECKBOX_COLUMN));
 318		if (scroll_list_check)
 319		{
 320			LLCheckBoxCtrl *check = scroll_list_check->getCheckBox();
 321			check->setCommitCallback(boost::bind(&LLPanelNearByMedia::onCheckItem, this, _1, id));
 322		}
 323	}	
 324	return new_item;
 325}
 326
 327void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, LLViewerMediaImpl* impl)
 328{
 329	std::string item_name;
 330	std::string item_tooltip;		
 331	std::string debug_str;
 332	LLPanelNearByMedia::MediaClass media_class = MEDIA_CLASS_ALL;
 333	
 334	getNameAndUrlHelper(impl, item_name, item_tooltip, mEmptyNameString);
 335	// Focused
 336	if (impl->hasFocus())
 337	{
 338		media_class = MEDIA_CLASS_FOCUSED;
 339	}
 340	// Is attached to another avatar?
 341	else if (impl->isAttachedToAnotherAvatar())
 342	{
 343		media_class = MEDIA_CLASS_ON_OTHERS;
 344	}
 345	// Outside agent parcel
 346	else if (!impl->isInAgentParcel())
 347	{
 348		media_class = MEDIA_CLASS_OUTSIDE_PARCEL;
 349	}
 350	else {
 351		// inside parcel
 352		media_class = MEDIA_CLASS_WITHIN_PARCEL;
 353	}
 354	
 355	if(mDebugInfoVisible)
 356	{
 357		debug_str += llformat("%g/", (float)impl->getInterest());
 358		
 359		// proximity distance is actually distance squared -- display it as straight distance.
 360		debug_str += llformat("%g/", (F32) sqrt(impl->getProximityDistance()));
 361		
 362		//			s += llformat("%g/", (float)impl->getCPUUsage());
 363		//			s += llformat("%g/", (float)impl->getApproximateTextureInterest());
 364		debug_str += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea());
 365		
 366		debug_str += LLPluginClassMedia::priorityToString(impl->getPriority());
 367		
 368		if(impl->hasMedia())
 369		{
 370			debug_str += '@';
 371		}
 372		else if(impl->isPlayable())
 373		{
 374			debug_str += '+';
 375		}
 376		else if(impl->isForcedUnloaded())
 377		{
 378			debug_str += '!';
 379		}
 380	}
 381	
 382	updateListItem(item,
 383				   item_name,
 384				   item_tooltip,
 385				   impl->getProximity(),
 386				   impl->isMediaDisabled(),
 387				   impl->hasMedia(),
 388				   impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
 389				   media_class,
 390				   debug_str);
 391}
 392
 393void LLPanelNearByMedia::updateListItem(LLScrollListItem* item,
 394										  const std::string &item_name,
 395										  const std::string &item_tooltip,
 396										  S32 proximity,
 397										  bool is_disabled,
 398										  bool has_media,
 399										  bool is_time_based_and_playing,
 400										  LLPanelNearByMedia::MediaClass media_class,
 401										  const std::string &debug_str)
 402{
 403	LLScrollListCell* cell = item->getColumn(PROXIMITY_COLUMN);
 404	if(cell)
 405	{
 406		// since we are forced to sort by text, encode sort order as string
 407		std::string proximity_string = STRINGIZE(proximity);
 408		std::string old_proximity_string = cell->getValue().asString();
 409		if(proximity_string != old_proximity_string)
 410		{
 411			cell->setValue(proximity_string);
 412			mMediaList->setNeedsSort(true);
 413		}
 414	}
 415	
 416	cell = item->getColumn(CHECKBOX_COLUMN);
 417	if(cell)
 418	{
 419		cell->setValue(!is_disabled);
 420	}
 421	
 422	cell = item->getColumn(VISIBILITY_COLUMN);
 423	if(cell)
 424	{
 425		S32 old_visibility = cell->getValue();
 426		// *HACK ALERT: force ordering of Media before Audio before the rest of the list
 427		S32 new_visibility = 
 428			item->getUUID() == PARCEL_MEDIA_LIST_ITEM_UUID ? 3
 429			: item->getUUID() == PARCEL_AUDIO_LIST_ITEM_UUID ? 2
 430			: (has_media) ? 1 
 431			: ((is_disabled) ? 0
 432			: -1);
 433		cell->setValue(STRINGIZE(new_visibility));
 434		if (new_visibility != old_visibility)
 435		{			
 436			mMediaList->setNeedsSort(true);
 437		}
 438	}
 439	
 440	cell = item->getColumn(NAME_COLUMN);
 441	if(cell)
 442	{
 443		std::string name = item_name;
 444		std::string old_name = cell->getValue().asString();
 445		if (has_media) 
 446		{
 447			name += " " + mPlayingString;
 448		}
 449		if (name != old_name)
 450		{
 451			cell->setValue(name);
 452		}
 453		cell->setToolTip(item_tooltip);
 454		
 455		// *TODO: Make these font styles/colors configurable via XUI
 456		U8 font_style = LLFontGL::NORMAL;
 457		LLColor4 cell_color = LLColor4::white;
 458		
 459		// Only colorize by class in debug
 460		if (mDebugInfoVisible)
 461		{
 462			switch (media_class) {
 463				case MEDIA_CLASS_FOCUSED:
 464					cell_color = LLColor4::yellow;
 465					break;
 466				case MEDIA_CLASS_ON_OTHERS:
 467					cell_color = LLColor4::red;
 468					break;
 469				case MEDIA_CLASS_OUTSIDE_PARCEL:
 470					cell_color = LLColor4::orange;
 471					break;
 472				case MEDIA_CLASS_WITHIN_PARCEL:
 473				default:
 474					break;
 475			}
 476		}
 477		if (is_disabled)
 478		{
 479			if (mDebugInfoVisible)
 480			{
 481				font_style |= LLFontGL::ITALIC;
 482				cell_color = LLColor4::black;
 483			}
 484			else {
 485				// Dim it if it is disabled
 486				cell_color.setAlpha(0.25);
 487			}
 488		}
 489		// Dim it if it isn't "showing"
 490		else if (!has_media)
 491		{
 492			cell_color.setAlpha(0.25);
 493		}
 494		// Bold it if it is time-based media and it is playing
 495		else if (is_time_based_and_playing)
 496		{
 497			if (mDebugInfoVisible) font_style |= LLFontGL::BOLD;
 498		}
 499		cell->setColor(cell_color);
 500		LLScrollListText *text_cell = dynamic_cast<LLScrollListText*> (cell);
 501		if (text_cell)
 502		{
 503			text_cell->setFontStyle(font_style);
 504		}
 505	}
 506	
 507	cell = item->getColumn(CLASS_COLUMN);
 508	if(cell)
 509	{
 510		// TODO: clean this up!
 511		cell->setValue(STRINGIZE(media_class));
 512	}
 513	
 514	if(mDebugInfoVisible)
 515	{
 516		cell = item->getColumn(DEBUG_COLUMN);
 517		if(cell)
 518		{
 519			cell->setValue(debug_str);
 520		}
 521	}
 522}
 523						 
 524void LLPanelNearByMedia::removeListItem(const LLUUID &id)
 525{
 526	if (NULL == mMediaList) return;
 527	
 528	mMediaList->deleteSingleItem(mMediaList->getItemIndex(id));
 529}
 530
 531void LLPanelNearByMedia::refreshParcelItems()
 532{
 533	//
 534	// First add/remove the "fake" items Parcel Media and Parcel Audio.
 535	// These items will have special UUIDs 
 536	//    PARCEL_MEDIA_LIST_ITEM_UUID
 537	//    PARCEL_AUDIO_LIST_ITEM_UUID
 538	//
 539	// Get the filter choice.
 540	const LLSD &choice_llsd = mShowCtrl->getSelectedValue();
 541	MediaClass choice = (MediaClass)choice_llsd.asInteger();
 542	// Only show "special parcel items" if "All" or "Within" filter
 543	// (and if media is "enabled")
 544	bool should_include = (choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL);
 545	
 546	// First Parcel Media: add or remove it as necessary
 547	if (gSavedSettings.getBOOL("AudioStreamingMedia") &&should_include && LLViewerMedia::hasParcelMedia())
 548	{
 549		// Yes, there is parcel media.
 550		if (NULL == mParcelMediaItem)
 551		{
 552			mParcelMediaItem = addListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
 553			mMediaList->setNeedsSort(true);
 554		}
 555	}
 556	else {
 557		if (NULL != mParcelMediaItem) {
 558			removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
 559			mParcelMediaItem = NULL;
 560			mMediaList->setNeedsSort(true);	
 561		}
 562	}
 563	
 564	// ... then update it
 565	if (NULL != mParcelMediaItem)
 566	{
 567		std::string name, url, tooltip;
 568		getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, "");
 569		if (name.empty() || name == url)
 570		{
 571			tooltip = url;
 572		}
 573		else
 574		{
 575			tooltip = name + " : " + url;
 576		}
 577		LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia();
 578		updateListItem(mParcelMediaItem,
 579					   mParcelMediaName,
 580					   tooltip,
 581					   -2, // Proximity closer than anything else, before Parcel Audio
 582					   impl == NULL || impl->isMediaDisabled(),
 583					   impl != NULL && !LLViewerParcelMedia::getURL().empty(),
 584					   impl != NULL && impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
 585					   MEDIA_CLASS_ALL,
 586					   "parcel media");
 587	}
 588	
 589	// Next Parcel Audio: add or remove it as necessary (don't show if disabled in prefs)
 590	if (should_include && LLViewerMedia::hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic"))
 591	{
 592		// Yes, there is parcel audio.
 593		if (NULL == mParcelAudioItem)
 594		{
 595			mParcelAudioItem = addListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
 596			mMediaList->setNeedsSort(true);
 597		}
 598	}
 599	else {
 600		if (NULL != mParcelAudioItem) {
 601			removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
 602			mParcelAudioItem = NULL;
 603			mMediaList->setNeedsSort(true);
 604		}
 605	}
 606	
 607	// ... then update it
 608	if (NULL != mParcelAudioItem)
 609	{
 610		bool is_playing = LLViewerMedia::isParcelAudioPlaying();
 611	
 612		std::string url;
 613        url = LLViewerMedia::getParcelAudioURL();
 614
 615		updateListItem(mParcelAudioItem,
 616					   mParcelAudioName,
 617					   url,
 618					   -1, // Proximity after Parcel Media, but closer than anything else
 619					   (!is_playing),
 620					   is_playing,
 621					   is_playing,
 622					   MEDIA_CLASS_ALL,
 623					   "parcel audio");
 624	}
 625}
 626
 627void LLPanelNearByMedia::refreshList()
 628{
 629	bool all_items_deleted = false;
 630		
 631	if(!mMediaList)
 632	{
 633		// None of this makes any sense if the media list isn't there.
 634		return;
 635	}
 636	
 637	// Check whether the debug column has been shown/hidden.
 638	bool debug_info_visible = gSavedSettings.getBOOL("MediaPerformanceManagerDebug");
 639	if(debug_info_visible != mDebugInfoVisible)
 640	{
 641		mDebugInfoVisible = debug_info_visible;
 642
 643		// Clear all items so the list gets regenerated.
 644		mMediaList->deleteAllItems();
 645		mParcelAudioItem = NULL;
 646		mParcelMediaItem = NULL;
 647		all_items_deleted = true;
 648		
 649		updateColumns();
 650	}
 651	
 652	refreshParcelItems();
 653	
 654	// Get the canonical list from LLViewerMedia
 655	LLViewerMedia::impl_list impls = LLViewerMedia::getPriorityList();
 656	LLViewerMedia::impl_list::iterator priority_iter;
 657	
 658	U32 enabled_count = 0;
 659	U32 disabled_count = 0;
 660	
 661	// iterate over the impl list, creating rows as necessary.
 662	for(priority_iter = impls.begin(); priority_iter != impls.end(); priority_iter++)
 663	{
 664		LLViewerMediaImpl *impl = *priority_iter;
 665		
 666		// If we just emptied out the list, every flag needs to be reset.
 667		if(all_items_deleted)
 668		{
 669			impl->setInNearbyMediaList(false);
 670		}
 671
 672		if (!impl->isParcelMedia())
 673		{
 674			LLUUID media_id = impl->getMediaTextureID();
 675			S32 proximity = impl->getProximity();
 676			// This is expensive (i.e. a linear search) -- don't use it here.  We now use mInNearbyMediaList instead.
 677			//S32 index = mMediaList->getItemIndex(media_id);
 678			if (proximity < 0 || !shouldShow(impl))
 679			{
 680				if (impl->getInNearbyMediaList())
 681				{
 682					// There's a row for this impl -- remove it.
 683					removeListItem(media_id);
 684					impl->setInNearbyMediaList(false);
 685				}
 686			}
 687			else
 688			{
 689				if (!impl->getInNearbyMediaList())
 690				{
 691					// We don't have a row for this impl -- add one.
 692					addListItem(media_id);
 693					impl->setInNearbyMediaList(true);
 694				}
 695			}
 696			// Update counts
 697			if (impl->isMediaDisabled())
 698			{
 699				disabled_count++;
 700			}
 701			else {
 702				enabled_count++;
 703		}
 704	}
 705	}	
 706	mDisableAllCtrl->setEnabled((gSavedSettings.getBOOL("AudioStreamingMusic") || 
 707		                         gSavedSettings.getBOOL("AudioStreamingMedia")) &&
 708								(LLViewerMedia::isAnyMediaShowing() || 
 709								 LLViewerMedia::isParcelMediaPlaying() ||
 710								 LLViewerMedia::isParcelAudioPlaying()));
 711
 712	mEnableAllCtrl->setEnabled( (gSavedSettings.getBOOL("AudioStreamingMusic") ||
 713								gSavedSettings.getBOOL("AudioStreamingMedia")) &&
 714							   (disabled_count > 0 ||
 715								// parcel media (if we have it, and it isn't playing, enable "start")
 716								(LLViewerMedia::hasParcelMedia() && ! LLViewerMedia::isParcelMediaPlaying()) ||
 717								// parcel audio (if we have it, and it isn't playing, enable "start")
 718								(LLViewerMedia::hasParcelAudio() && ! LLViewerMedia::isParcelAudioPlaying())));
 719
 720	// Iterate over the rows in the control, updating ones whose impl exists, and deleting ones whose impl has gone away.
 721	std::vector<LLScrollListItem*> items = mMediaList->getAllData();
 722
 723	for (std::vector<LLScrollListItem*>::iterator item_it = items.begin();
 724		item_it != items.end();
 725		++item_it)
 726	{
 727		LLScrollListItem* item = (*item_it);
 728		LLUUID row_id = item->getUUID();
 729		
 730		if (row_id != PARCEL_MEDIA_LIST_ITEM_UUID &&
 731			row_id != PARCEL_AUDIO_LIST_ITEM_UUID)
 732		{
 733			LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
 734			if(impl)
 735			{
 736				updateListItem(item, impl);
 737			}
 738			else
 739			{
 740				// This item's impl has been deleted -- remove the row.
 741				// Removing the row won't throw off our iteration, since we have a local copy of the array.
 742				// We just need to make sure we don't access this item after the delete.
 743				removeListItem(row_id);
 744			}
 745		}
 746	}
 747	
 748	// Set the selection to whatever media impl the media focus/hover is on. 
 749	// This is an experiment, and can be removed by ifdefing out these 4 lines.
 750	LLUUID media_target = LLViewerMediaFocus::getInstance()->getControlsMediaID();
 751	if(media_target.notNull())
 752	{
 753		mMediaList->selectByID(media_target);
 754	}
 755}
 756
 757void LLPanelNearByMedia::updateColumns()
 758{
 759	if (!mDebugInfoVisible)
 760	{
 761		if (mMediaList->getColumn(CHECKBOX_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(-1);
 762		if (mMediaList->getColumn(VISIBILITY_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(-1);
 763		if (mMediaList->getColumn(PROXIMITY_COLUMN)) mMediaList->getColumn(PROXIMITY_COLUMN)->setWidth(-1);
 764		if (mMediaList->getColumn(CLASS_COLUMN)) mMediaList->getColumn(CLASS_COLUMN)->setWidth(-1);
 765		if (mMediaList->getColumn(DEBUG_COLUMN)) mMediaList->getColumn(DEBUG_COLUMN)->setWidth(-1);
 766	}
 767	else {
 768		if (mMediaList->getColumn(CHECKBOX_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(20);
 769		if (mMediaList->getColumn(VISIBILITY_COLUMN)) mMediaList->getColumn(VISIBILITY_COLUMN)->setWidth(20);
 770		if (mMediaList->getColumn(PROXIMITY_COLUMN)) mMediaList->getColumn(PROXIMITY_COLUMN)->setWidth(30);
 771		if (mMediaList->getColumn(CLASS_COLUMN)) mMediaList->getColumn(CLASS_COLUMN)->setWidth(20);
 772		if (mMediaList->getColumn(DEBUG_COLUMN)) mMediaList->getColumn(DEBUG_COLUMN)->setWidth(200);
 773	}
 774}
 775
 776void LLPanelNearByMedia::onClickEnableAll()
 777{
 778	LLViewerMedia::setAllMediaEnabled(true);
 779}
 780
 781void LLPanelNearByMedia::onClickDisableAll()
 782{
 783	LLViewerMedia::setAllMediaEnabled(false);
 784}
 785
 786void LLPanelNearByMedia::onClickEnableParcelMedia()
 787{	
 788	if ( ! LLViewerMedia::isParcelMediaPlaying() )
 789	{
 790		LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
 791	}
 792}
 793
 794void LLPanelNearByMedia::onClickDisableParcelMedia()
 795{	
 796	// This actually unloads the impl, as opposed to "stop"ping the media
 797	LLViewerParcelMedia::stop();
 798}
 799
 800void LLPanelNearByMedia::onCheckItem(LLUICtrl* ctrl, const LLUUID &row_id)
 801{	
 802	LLCheckBoxCtrl* check = static_cast<LLCheckBoxCtrl*>(ctrl);
 803
 804	setDisabled(row_id, ! check->getValue());
 805}
 806
 807bool LLPanelNearByMedia::setDisabled(const LLUUID &row_id, bool disabled)
 808{
 809	if (row_id == PARCEL_AUDIO_LIST_ITEM_UUID)
 810	{
 811		if (disabled)
 812		{
 813			onClickParcelAudioStop();
 814		}
 815		else
 816		{
 817			onClickParcelAudioPlay();
 818		}
 819		return true;
 820	}
 821	else if (row_id == PARCEL_MEDIA_LIST_ITEM_UUID)
 822	{
 823		if (disabled)
 824		{
 825			onClickDisableParcelMedia();
 826		}
 827		else
 828		{
 829			onClickEnableParcelMedia();
 830		}
 831		return true;
 832	}
 833	else {
 834		LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(row_id);
 835		if(impl)
 836		{
 837			impl->setDisabled(disabled, true);
 838			return true;
 839		}
 840	}
 841	return false;
 842}
 843								
 844//static
 845void LLPanelNearByMedia::onZoomMedia(void* user_data)
 846{
 847	LLPanelNearByMedia* panelp = (LLPanelNearByMedia*)user_data;
 848	LLUUID media_id = panelp->mMediaList->getValue().asUUID();
 849	
 850	LLViewerMediaFocus::getInstance()->focusZoomOnMedia(media_id);
 851}
 852
 853void LLPanelNearByMedia::onClickParcelMediaPlay()
 854{
 855	LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
 856}
 857
 858void LLPanelNearByMedia::onClickParcelMediaStop()
 859{	
 860	if (LLViewerParcelMedia::getParcelMedia())
 861	{
 862		// This stops the media playing, as opposed to unloading it like
 863		// LLViewerParcelMedia::stop() does
 864		LLViewerParcelMedia::getParcelMedia()->stop();
 865	}
 866}
 867
 868void LLPanelNearByMedia::onClickParcelMediaPause()
 869{
 870	LLViewerParcelMedia::pause();
 871}
 872
 873void LLPanelNearByMedia::onClickParcelAudioPlay()
 874{
 875	// User *explicitly* started the internet stream, so keep the stream
 876	// playing and updated as they cross to other parcels etc.
 877	mParcelAudioAutoStart = true;
 878	if (!gAudiop)
 879		return;
 880
 881	if (LLAudioEngine::AUDIO_PAUSED == gAudiop->isInternetStreamPlaying())
 882	{
 883		// 'false' means unpause
 884		gAudiop->pauseInternetStream(false);
 885	}
 886	else
 887	{
 888		LLViewerAudio::getInstance()->startInternetStreamWithAutoFade(LLViewerMedia::getParcelAudioURL());
 889	}
 890}
 891
 892void LLPanelNearByMedia::onClickParcelAudioStop()
 893{
 894	// User *explicitly* stopped the internet stream, so don't
 895	// re-start audio when i.e. they move to another parcel, until
 896	// they explicitly start it again.
 897	mParcelAudioAutoStart = false;
 898	if (!gAudiop)
 899		return;
 900
 901	LLViewerAudio::getInstance()->stopInternetStreamWithAutoFade();
 902}
 903
 904void LLPanelNearByMedia::onClickParcelAudioPause()
 905{
 906	if (!gAudiop)
 907		return;
 908
 909	// 'true' means pause
 910	gAudiop->pauseInternetStream(true);
 911}
 912
 913bool LLPanelNearByMedia::shouldShow(LLViewerMediaImpl* impl)
 914{	
 915	const LLSD &choice_llsd = mShowCtrl->getSelectedValue();
 916	MediaClass choice = (MediaClass)choice_llsd.asInteger();
 917
 918	switch (choice)
 919	{	
 920		case MEDIA_CLASS_ALL:
 921			return true;
 922			break;
 923		case MEDIA_CLASS_WITHIN_PARCEL:
 924			return impl->isInAgentParcel();
 925			break;
 926		case MEDIA_CLASS_OUTSIDE_PARCEL:
 927			return ! impl->isInAgentParcel();
 928			break;
 929		case MEDIA_CLASS_ON_OTHERS:
 930			return impl->isAttachedToAnotherAvatar();
 931			break;
 932		default:
 933			break;
 934	}
 935	return true;
 936}
 937
 938void LLPanelNearByMedia::onAdvancedButtonClick()
 939{	
 940	// bring up the prefs floater
 941	LLFloaterPreference* prefsfloater = dynamic_cast<LLFloaterPreference*>(LLFloaterReg::showInstance("preferences"));
 942	if (prefsfloater)
 943	{
 944		// grab the 'audio' panel from the preferences floater and
 945		// bring it the front!
 946		LLTabContainer* tabcontainer = prefsfloater->getChild<LLTabContainer>("pref core");
 947		LLPanel* audiopanel = prefsfloater->getChild<LLPanel>("audio");
 948		if (tabcontainer && audiopanel)
 949		{
 950			tabcontainer->selectTabPanel(audiopanel);
 951		}
 952	}
 953}
 954
 955void LLPanelNearByMedia::onMoreLess()
 956{
 957	bool is_more = getChild<LLButton>("more_btn")->getToggleState();
 958	mNearbyMediaPanel->setVisible(is_more);
 959
 960	// enable resizing when expanded
 961	getChildView("resizebar_bottom")->setEnabled(is_more);
 962
 963	LLRect new_rect = is_more ? mMoreRect : mLessRect;
 964	new_rect.translate(getRect().mRight - new_rect.mRight, getRect().mTop - new_rect.mTop);
 965
 966	setShape(new_rect);
 967
 968	getChild<LLUICtrl>("more_btn")->setVisible(true);
 969}
 970
 971void LLPanelNearByMedia::updateControls()
 972{
 973	LLUUID selected_media_id = mMediaList->getValue().asUUID();
 974	
 975	if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
 976	{
 977		if (!LLViewerMedia::hasParcelAudio() || !gSavedSettings.getBOOL("AudioStreamingMusic"))
 978		{
 979			// disable controls if audio streaming music is disabled from preference
 980			showDisabledControls();
 981		}
 982		else {
 983			showTimeBasedControls(LLViewerMedia::isParcelAudioPlaying(),
 984							  false, // include_zoom
 985							  false, // is_zoomed
 986							  gSavedSettings.getBOOL("MuteMusic"), 
 987							  gSavedSettings.getF32("AudioLevelMusic") );
 988		}
 989	}
 990	else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID)
 991	{
 992		if (!LLViewerMedia::hasParcelMedia() || !gSavedSettings.getBOOL("AudioStreamingMedia"))
 993		{
 994			// disable controls if audio streaming media is disabled from preference
 995			showDisabledControls();
 996		}
 997		else {
 998			LLViewerMediaImpl* impl = LLViewerParcelMedia::getParcelMedia();
 999			if (NULL == impl)
1000			{
1001				// Just means it hasn't started yet
1002				showBasicControls(false, false, false, false, 0);
1003			}
1004			else if (impl->isMediaTimeBased())
1005			{
1006				showTimeBasedControls(impl->isMediaPlaying(), 
1007									  false, // include_zoom
1008									  false, // is_zoomed
1009									  impl->getVolume() == 0.0,
1010									  impl->getVolume() );
1011			}
1012			else {
1013				// non-time-based parcel media
1014				showBasicControls(LLViewerMedia::isParcelMediaPlaying(), 
1015							      false, 
1016								  false, 
1017								  impl->getVolume() == 0.0, 
1018								  impl->getVolume());
1019			}
1020		}
1021	}
1022	else {
1023		LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
1024		
1025		if (NULL == impl || !gSavedSettings.getBOOL("AudioStreamingMedia"))
1026		{
1027			showDisabledControls();
1028		}
1029		else {
1030			if (impl->isMediaTimeBased())
1031			{
1032				showTimeBasedControls(impl->isMediaPlaying(), 
1033									  ! impl->isParcelMedia(),  // include_zoom
1034									  LLViewerMediaFocus::getInstance()->isZoomed(),
1035									  impl->getVolume() == 0.0,
1036									  impl->getVolume());
1037			}
1038			else {
1039				showBasicControls(!impl->isMediaDisabled(), 
1040								  ! impl->isParcelMedia(),  // include_zoom
1041								  LLViewerMediaFocus::getInstance()->isZoomed(),
1042								  impl->getVolume() == 0.0,
1043								  impl->getVolume());
1044			}
1045		}
1046	}
1047}
1048
1049void LLPanelNearByMedia::showBasicControls(bool playing, bool include_zoom, bool is_zoomed, bool muted, F32 volume)
1050{
1051	mStopCtrl->setVisible(playing);
1052	mPlayCtrl->setVisible(!playing);
1053	mPauseCtrl->setVisible(false);
1054	mVolumeSliderCtrl->setVisible(true);
1055	mMuteCtrl->setVisible(true);
1056	mMuteBtn->setValue(muted);
1057	mVolumeSlider->setValue(volume);
1058	mZoomCtrl->setVisible(include_zoom && !is_zoomed);
1059	mUnzoomCtrl->setVisible(include_zoom && is_zoomed);	
1060	mStopCtrl->setEnabled(true);
1061	mZoomCtrl->setEnabled(true);
1062}
1063
1064void LLPanelNearByMedia::showTimeBasedControls(bool playing, bool include_zoom, bool is_zoomed, bool muted, F32 volume)
1065{
1066	mStopCtrl->setVisible(true);
1067	mPlayCtrl->setVisible(!playing);
1068	mPauseCtrl->setVisible(playing);
1069	mMuteCtrl->setVisible(true);
1070	mVolumeSliderCtrl->setVisible(true);
1071	mZoomCtrl->setVisible(include_zoom);
1072	mZoomCtrl->setVisible(include_zoom && !is_zoomed);
1073	mUnzoomCtrl->setVisible(include_zoom && is_zoomed);	
1074	mStopCtrl->setEnabled(true);
1075	mZoomCtrl->setEnabled(true);
1076	mMuteBtn->setValue(muted);
1077	mVolumeSlider->setValue(volume);
1078}
1079
1080void LLPanelNearByMedia::showDisabledControls()
1081{
1082	mStopCtrl->setVisible(true);
1083	mPlayCtrl->setVisible(false);
1084	mPauseCtrl->setVisible(false);
1085	mMuteCtrl->setVisible(false);
1086	mVolumeSliderCtrl->setVisible(false);
1087	mZoomCtrl->setVisible(true);
1088	mUnzoomCtrl->setVisible(false);	
1089	mStopCtrl->setEnabled(false);
1090	mZoomCtrl->setEnabled(false);
1091}
1092
1093void LLPanelNearByMedia::onClickSelectedMediaStop()
1094{
1095	setDisabled(mMediaList->getValue().asUUID(), true);
1096}
1097
1098void LLPanelNearByMedia::onClickSelectedMediaPlay()
1099{
1100	LLUUID selected_media_id = mMediaList->getValue().asUUID();
1101	
1102	// First enable it
1103	setDisabled(selected_media_id, false);
1104	
1105	// Special code to make play "unpause" if time-based and playing
1106	if (selected_media_id != PARCEL_AUDIO_LIST_ITEM_UUID)
1107	{
1108		LLViewerMediaImpl *impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ?
1109			((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
1110		if (NULL != impl)
1111		{
1112			if (impl->isMediaTimeBased() && impl->isMediaPaused())
1113			{
1114				// Aha!  It's really time-based media that's paused, so unpause
1115				impl->play();
1116				return;
1117			}
1118			else if (impl->isParcelMedia())
1119			{
1120				LLViewerParcelMedia::play(LLViewerParcelMgr::getInstance()->getAgentParcel());
1121			}
1122		}
1123	}	
1124}
1125
1126void LLPanelNearByMedia::onClickSelectedMediaPause()
1127{
1128	LLUUID selected_media_id = mMediaList->getValue().asUUID();
1129	if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
1130	{
1131		onClickParcelAudioPause();
1132	}
1133	else if (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) 
1134	{
1135		onClickParcelMediaPause();
1136	}
1137	else {
1138		LLViewerMediaImpl* impl = LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
1139		if (NULL != impl && impl->isMediaTimeBased() && impl->isMediaPlaying())
1140		{
1141			impl->pause();
1142		}
1143	}
1144}
1145
1146void LLPanelNearByMedia::onClickSelectedMediaMute()
1147{
1148	LLUUID selected_media_id = mMediaList->getValue().asUUID();
1149	if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
1150	{
1151		gSavedSettings.setBOOL("MuteMusic", mMuteBtn->getValue());
1152	}
1153	else {
1154		LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ?
1155			((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
1156		if (NULL != impl)
1157		{
1158			F32 volume = impl->getVolume();
1159			if(volume > 0.0)
1160			{
1161				impl->setVolume(0.0);
1162			}
1163			else if (mVolumeSlider->getValueF32() == 0.0)
1164			{
1165				impl->setVolume(1.0);
1166				mVolumeSlider->setValue(1.0);
1167			}
1168			else 
1169			{
1170				impl->setVolume(mVolumeSlider->getValueF32());
1171			}
1172		}
1173	}
1174}
1175
1176void LLPanelNearByMedia::onCommitSelectedMediaVolume()
1177{
1178	LLUUID selected_media_id = mMediaList->getValue().asUUID();
1179	if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID)
1180	{
1181		F32 vol = mVolumeSlider->getValueF32();
1182		gSavedSettings.setF32("AudioLevelMusic", vol);
1183	}
1184	else {
1185		LLViewerMediaImpl* impl = (selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID) ?
1186			((LLViewerMediaImpl*)LLViewerParcelMedia::getParcelMedia()) : LLViewerMedia::getMediaImplFromTextureID(selected_media_id);
1187		if (NULL != impl)
1188		{
1189			impl->setVolume(mVolumeSlider->getValueF32());
1190		}
1191	}
1192}
1193
1194void LLPanelNearByMedia::onClickSelectedMediaZoom()
1195{
1196	LLUUID selected_media_id = mMediaList->getValue().asUUID();
1197	if (selected_media_id == PARCEL_AUDIO_LIST_ITEM_UUID || selected_media_id == PARCEL_MEDIA_LIST_ITEM_UUID)
1198		return;
1199	LLViewerMediaFocus::getInstance()->focusZoomOnMedia(selected_media_id);
1200}
1201
1202void LLPanelNearByMedia::onClickSelectedMediaUnzoom()
1203{
1204	LLViewerMediaFocus::getInstance()->unZoom();
1205}
1206
1207
1208// static
1209void LLPanelNearByMedia::getNameAndUrlHelper(LLViewerMediaImpl* impl, std::string& name, std::string & url, const std::string &defaultName)
1210{
1211	if (NULL == impl) return;
1212	
1213	name = impl->getName();
1214	url = impl->getCurrentMediaURL();	// This is the URL the media impl actually has loaded
1215	if (url.empty())
1216	{
1217		url = impl->getMediaEntryURL();	// This is the current URL from the media data
1218	}
1219	if (url.empty())
1220	{
1221		url = impl->getHomeURL();		// This is the home URL from the media data
1222	}
1223	if (name.empty())
1224	{
1225		name = url;
1226	}
1227	if (name.empty())
1228	{
1229		name = defaultName;
1230	}
1231}
1232