PageRenderTime 124ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 1ms

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