diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index bd4e85af7596ba98566ee456a04f47d5bd855fca..3a264b25db3177a7891404bd7dcb2ce5417008ac 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -99,9 +99,11 @@ set(viewer_SOURCE_FILES alpanelaopulldown.cpp alpanelmusicticker.cpp alpanelradaralert.cpp + alpanelstreaminfo.cpp alpanelquicksettings.cpp alpanelquicksettingspulldown.cpp alrenderutils.cpp + alstreaminfo.cpp altoolalign.cpp alunzip.cpp alviewermenu.cpp @@ -827,9 +829,11 @@ set(viewer_HEADER_FILES alpanelaopulldown.h alpanelmusicticker.h alpanelradaralert.h + alpanelstreaminfo.h alpanelquicksettings.h alpanelquicksettingspulldown.h alrenderutils.h + alstreaminfo.h altoolalign.h alunzip.h alviewermenu.h diff --git a/indra/newview/alpanelstreaminfo.cpp b/indra/newview/alpanelstreaminfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..3e5eac5200399be237cf2199d9eeb90c0294c2b6 --- /dev/null +++ b/indra/newview/alpanelstreaminfo.cpp @@ -0,0 +1,53 @@ +/* + * @file alpanelstreaminfo.cpp + * @brief Toast tip panel for stream info + * + * $LicenseInfo:firstyear=2015&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (c) 2015, Cinder Roxley <cinder@sdf.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + * + */ + +#include "llviewerprecompiledheaders.h" +#include "alpanelstreaminfo.h" + +#include "llnotifications.h" +#include "lltextbox.h" +#include "llviewercontrol.h" // for gSavedSettings + +ALPanelStreamInfo::ALPanelStreamInfo(const LLNotificationPtr& notification) +: LLPanelTipToast(notification) +{ + buildFromFile("panel_stream_info_toast.xml"); + + //getChild<LLUICtrl>("music_icon")->setValue(notification->getPayload()["FROM_ID"]); + getChild<LLUICtrl>("message")->setValue(notification->getMessage()); + + if (notification->getPayload().has("respond_on_mousedown") + && notification->getPayload()["respond_on_mousedown"]) + { + setMouseDownCallback(boost::bind(&LLNotification::respond, + notification, notification->getResponseTemplate())); + } + + S32 max_line_count = gSavedSettings.getS32("TipToastMessageLineCount"); + snapToMessageHeight(getChild<LLTextBox>("message"), max_line_count); +} diff --git a/indra/newview/alpanelstreaminfo.h b/indra/newview/alpanelstreaminfo.h new file mode 100644 index 0000000000000000000000000000000000000000..a03a8d8099c8985c6402440ffc5e2c65a7830321 --- /dev/null +++ b/indra/newview/alpanelstreaminfo.h @@ -0,0 +1,48 @@ +/* + * @file alpanelstreaminfo.h + * @brief Toast tip panel for stream info prototypes + * + * $LicenseInfo:firstyear=2015&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * Copyright (c) 2015, Cinder Roxley <cinder@sdf.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + * + */ + +#ifndef AL_PANELSTREAMINFO_H +#define AL_PANELSTREAMINFO_H + +#include "llpaneltiptoast.h" + +/** + * Represents audio steam info tip toast panel. + */ +class ALPanelStreamInfo final : public LLPanelTipToast +{ + // disallow instantiation of this class +private: + // grant privileges to instantiate this class to LLToastPanel + friend class LLToastPanel; + + ALPanelStreamInfo(const LLNotificationPtr& notification); + virtual ~ALPanelStreamInfo() = default; +}; + +#endif // AL_PANELSTREAMINFO_H diff --git a/indra/newview/alstreaminfo.cpp b/indra/newview/alstreaminfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..00d4ee97d904379fa0fb02a6c08c45f67c9da7fa --- /dev/null +++ b/indra/newview/alstreaminfo.cpp @@ -0,0 +1,100 @@ +/* + * @file alstreaminfo.cpp + * @brief Class enables display of audio stream metadata + * + * Copyright (c) 2014, Cinder Roxley <cinder@sdf.org> + * + * Permission is hereby granted, free of charge, to any person or organization + * obtaining a copy of the software and accompanying documentation covered by + * this license (the "Software") to use, reproduce, display, distribute, + * execute, and transmit the Software, and to prepare derivative works of the + * Software, and to permit third-parties to whom the Software is furnished to + * do so, all subject to the following: + * + * The copyright notices in the Software and this entire statement, including + * the above license grant, this restriction and the following disclaimer, + * must be included in all copies of the Software, in whole or in part, and + * all derivative works of the Software, unless such copies or derivative + * works are solely in the form of machine-executable object code generated by + * a source language processor. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#include "llviewerprecompiledheaders.h" +#include "alstreaminfo.h" + +#include "llaudioengine.h" +#include "llnotificationsutil.h" +#include "llstreamingaudio.h" +#include "lltrans.h" +#include "llurlaction.h" +#include "llviewercontrol.h" // LLCachedControl + +#include "llfloater.h" +#include "llfloaterreg.h" + +ALStreamInfo::ALStreamInfo() +{ + if (gAudiop && gAudiop->getStreamingAudioImpl() && gAudiop->getStreamingAudioImpl()->supportsMetaData()) + { + mMetadataConnection = gAudiop->getStreamingAudioImpl()->setMetadataUpdatedCallback([this](const LLSD& metadata) { handleMetadataUpdate(metadata); }); + } +} + +ALStreamInfo::~ALStreamInfo() +{ + if (mMetadataConnection.connected()) + { + mMetadataConnection.disconnect(); + } +} + +void ALStreamInfo::handleMetadataUpdate(const LLSD& metadata) +{ + static LLCachedControl<bool> show_stream_info(gSavedSettings, "ShowStreamInfo", false); + if (!show_stream_info) return; + + LLFloater* music_ticker = LLFloaterReg::findInstance("music_ticker"); + if (music_ticker) + return; + + if (metadata.size() > 0) + { + std::string station = metadata.has("TRSN") ? metadata["TRSN"].asString() : metadata.has("icy-name") ? metadata["icy-name"].asString() : LLTrans::getString("NowPlaying"); + // Some stations get a little ridiculous with the length. + if (station.length() > 64) + { + LLStringUtil::truncate(station, 64); + station.append("..."); + } + LLSD args; + LLSD payload; + args["STATION"] = station; + std::stringstream info; + if (metadata.has("TITLE")) + info << metadata["TITLE"].asString(); + if (metadata.has("TITLE") && metadata.has("ARTIST")) + info << "\n"; + if (metadata.has("ARTIST")) + info << metadata["ARTIST"].asString(); + args["INFO"] = info.str(); + if (metadata.has("URL")) + LLNotificationsUtil::add("StreamInfo", args, + LLSD().with("respond_on_mousedown", TRUE), + boost::bind(&LLUrlAction::openURL, metadata["URL"].asString())); + else if (metadata.has("icy-url")) + LLNotificationsUtil::add("StreamInfo", args, + LLSD().with("respond_on_mousedown", TRUE), + boost::bind(&LLUrlAction::openURL, metadata["icy-url"].asString())); + else + LLNotificationsUtil::add("StreamInfo", args); + } +} diff --git a/indra/newview/alstreaminfo.h b/indra/newview/alstreaminfo.h new file mode 100644 index 0000000000000000000000000000000000000000..f0b17ae636164fadfcb0393ca4206074801f6c40 --- /dev/null +++ b/indra/newview/alstreaminfo.h @@ -0,0 +1,48 @@ +/* + * @file alstreaminfo.h + * @brief Class enables display of audio stream metadata + * + * Copyright (c) 2014, Cinder Roxley <cinder@sdf.org> + * + * Permission is hereby granted, free of charge, to any person or organization + * obtaining a copy of the software and accompanying documentation covered by + * this license (the "Software") to use, reproduce, display, distribute, + * execute, and transmit the Software, and to prepare derivative works of the + * Software, and to permit third-parties to whom the Software is furnished to + * do so, all subject to the following: + * + * The copyright notices in the Software and this entire statement, including + * the above license grant, this restriction and the following disclaimer, + * must be included in all copies of the Software, in whole or in part, and + * all derivative works of the Software, unless such copies or derivative + * works are solely in the form of machine-executable object code generated by + * a source language processor. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT + * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE + * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + +#ifndef AL_STREAMINFO_H +#define AL_STREAMINFO_H + +#include "llsingleton.h" + +class ALStreamInfo : public LLSimpleton<ALStreamInfo> +{ +public: + ALStreamInfo(); + ~ALStreamInfo(); + +private: + void handleMetadataUpdate(const LLSD& metadata); + + boost::signals2::connection mMetadataConnection; +}; + +#endif // LL_STREAMINFO_H diff --git a/indra/newview/app_settings/settings_alchemy.xml b/indra/newview/app_settings/settings_alchemy.xml index bcdb665d62e977631037b27646976e46e12da0e3..93ae97d96c1736ddd8b3547fcbdd26d4a3644a7f 100644 --- a/indra/newview/app_settings/settings_alchemy.xml +++ b/indra/newview/app_settings/settings_alchemy.xml @@ -1366,6 +1366,17 @@ <key>Value</key> <integer>1</integer> </map> + <key>ShowStreamInfo</key> + <map> + <key>Comment</key> + <string>Show audio stream info in toasts</string> + <key>Persist</key> + <integer>1</integer> + <key>Type</key> + <string>Boolean</string> + <key>Value</key> + <integer>1</integer> + </map> <key>SnapshotDetection</key> <map> <key>Comment</key> diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp index 5400cb3cc1010fe6cb97d9142d6ca8dde6d8c4d7..1ca2340e245994537f598648d147e69d1dae7a9d 100644 --- a/indra/newview/llappviewer.cpp +++ b/indra/newview/llappviewer.cpp @@ -264,6 +264,8 @@ using namespace LL; #include "aldiscordmanager.h" #endif +#include "alstreaminfo.h" + // *FIX: These extern globals should be cleaned up. // The globals either represent state/config/resource-storage of either // this app, or another 'component' of the viewer. App globals should be @@ -1780,6 +1782,8 @@ bool LLAppViewer::cleanup() gAudiop = nullptr; } + ALStreamInfo::deleteSingleton(); + // Note: this is where LLFeatureManager::getInstance()-> used to be deleted. // Patch up settings for next time diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7a6a2388c9a9ca5d3b31bd1b1eda2fefaa9a0dda..412cae0d15e07595f40ec34031ea767990932cbe 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -90,6 +90,7 @@ #include "message.h" #include "v3math.h" +#include "alstreaminfo.h" #include "llagent.h" #include "llagentbenefits.h" #include "llagentcamera.h" @@ -3145,6 +3146,8 @@ void LLStartUp::multimediaInit() std::string msg = LLTrans::getString("LoginInitializingMultimedia"); set_startup_status(0.42f, msg.c_str(), gAgent.mMOTD.c_str()); display_startup(); + + ALStreamInfo::createInstance(); } void LLStartUp::fontInit() diff --git a/indra/newview/lltoastpanel.cpp b/indra/newview/lltoastpanel.cpp index b35766e4e731c545f9f19b37ec78c61d184ec661..bed3b6d6358b1c824806ed201cc2676bac174f1c 100644 --- a/indra/newview/lltoastpanel.cpp +++ b/indra/newview/lltoastpanel.cpp @@ -31,6 +31,7 @@ #include "llpanelgenerictip.h" #include "llpanelonlinestatus.h" #include "alpanelradaralert.h" +#include "alpanelstreaminfo.h" #include "llnotifications.h" #include "lltoastnotifypanel.h" #include "lltoastpanel.h" @@ -129,6 +130,10 @@ LLToastPanel* LLToastPanel::buidPanelFromNotification( { res = new ALPanelRadarAlert(notification); } + else if (notification->matchesTag("StreamInfo")) + { + res = new ALPanelStreamInfo(notification); + } // in all other case we use generic tip panel else { diff --git a/indra/newview/skins/default/textures/icons/MusicNote.png b/indra/newview/skins/default/textures/icons/MusicNote.png new file mode 100644 index 0000000000000000000000000000000000000000..3a34b14db2542814aebea9f1199219e3cdbc6c9c Binary files /dev/null and b/indra/newview/skins/default/textures/icons/MusicNote.png differ diff --git a/indra/newview/skins/default/textures/textures.xml b/indra/newview/skins/default/textures/textures.xml index 27dff8b3ee4e9cbf0485848a3974e2c6ceecc749..3e8abb1334bb8ba2d4f71bb19bbf227f551661eb 100644 --- a/indra/newview/skins/default/textures/textures.xml +++ b/indra/newview/skins/default/textures/textures.xml @@ -433,6 +433,7 @@ with the same filename but different name <texture name="Movement_TurnRight_On" file_name="bottomtray/Movement_TurnRight_On.png" preload="false" /> <texture name="Movement_Up_Off" file_name="bottomtray/Movement_Up_Off.png" preload="false" /> <texture name="Movement_Up_On" file_name="bottomtray/Movement_Up_On.png" preload="false" /> + <texture name="MusicNote" file_name="icons/MusicNote.png" preload="false" /> <texture name="NavBar_BG" file_name="navbar/NavBar_BG.png" preload="true" scale.left="1" scale.top="1" scale.right="0" scale.bottom="0" /> <texture name="NavBar_BG_NoFav_Bevel" file_name="navbar/NavBar_BG_NoFav_Bevel.png" preload="true" scale.left="1" scale.top="1" scale.right="0" scale.bottom="0" /> diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index 2c88f768a450ab34e28b477170af7302eba705c0..5f39d7ef3e75af568bb05525a02fadb5ff8254b6 100644 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -12689,6 +12689,17 @@ the region "[REGION]"? [AGENT] has left [REGION]. </notification> + <notification + icon="notifytip.tga" + name="StreamInfo" + log_to_chat="false" + type="notifytip"> + <tag>StreamInfo</tag> +[STATION] + +[INFO] + </notification> + <notification icon="notify.tga" name="AutoAcceptedInventory" diff --git a/indra/newview/skins/default/xui/en/panel_music_ticker.xml b/indra/newview/skins/default/xui/en/panel_music_ticker.xml index 033b8b1f0f380e88d0781b8f63991c6ab465fb17..75234b2c27058363dfa08efea9e1b2e399674b35 100644 --- a/indra/newview/skins/default/xui/en/panel_music_ticker.xml +++ b/indra/newview/skins/default/xui/en/panel_music_ticker.xml @@ -4,7 +4,8 @@ follows="top|right|left" width="300" height="46" - name="music_ticker"> + name="music_ticker" + class="music_ticker"> <string name="paused"> (not playing) </string> diff --git a/indra/newview/skins/default/xui/en/panel_stream_info_toast.xml b/indra/newview/skins/default/xui/en/panel_stream_info_toast.xml new file mode 100644 index 0000000000000000000000000000000000000000..b6735efb1b342a6bbd7c640c34f353b8d0fbab45 --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_stream_info_toast.xml @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="utf-8" standalone="yes" ?> +<panel + background_visible="false" + height="40" + label="stream_info_toast" + layout="topleft" + left="0" + name="stream_info" + top="0" + width="220"> + <icon + follows="top|left" + height="18" + image_name="MusicNote" + layout="topleft" + left="3" + mouse_opaque="false" + name="music_icon" + top="15" + width="18" /> + <text + font="SansSerifSmall" + follows="all" + height="13" + layout="topleft" + left_pad="5" + name="message" + text_color="White" + top="15" + use_ellipses="true" + value="" + width="189" + word_wrap="true" + max_length="350" /> +</panel> \ No newline at end of file diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 4f5f00e77dde85dca07fcdde3aadd6e9e9a0f84a..ead78f2c884f4b621290cf4e9d2ab255be9bd047 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -4427,6 +4427,7 @@ and report the problem. <string name="AvatarTyping">Typing</string> <string name="UnknownAvatar">Unknown Avatar</string> <string name="NotAvailableOnPlatform">Not availalbe on this platform</string> + <string name="NowPlaying">Now Playing</string> <string name="GridInfoTitle">GRID INFO</string> <!-- <LSL Preprocessor -->