From 2a37265dab0681e4a971768eb6cf600bb4486d31 Mon Sep 17 00:00:00 2001 From: Tonya Souther Date: Thu, 17 Feb 2011 21:13:04 -0600 Subject: [PATCH] Katharine Berry's stream title/artist display in chat. --- FIRESTORM-FEATURETABLE.txt | 3 +- indra/llaudio/llstreamingaudio.h | 5 ++ indra/llaudio/llstreamingaudio_fmod.cpp | 68 +++++++++++++++++ indra/llaudio/llstreamingaudio_fmod.h | 3 + indra/newview/CMakeLists.txt | 12 +-- indra/newview/llstartup.cpp | 4 + .../skins/default/xui/en/floater_about.xml | 6 +- indra/newview/streamtitledisplay.cpp | 74 +++++++++++++++++++ indra/newview/streamtitledisplay.h | 45 +++++++++++ 9 files changed, 211 insertions(+), 9 deletions(-) create mode 100644 indra/newview/streamtitledisplay.cpp create mode 100644 indra/newview/streamtitledisplay.h diff --git a/FIRESTORM-FEATURETABLE.txt b/FIRESTORM-FEATURETABLE.txt index fbbb9bd43d..3ffc4aebed 100644 --- a/FIRESTORM-FEATURETABLE.txt +++ b/FIRESTORM-FEATURETABLE.txt @@ -50,4 +50,5 @@ UpdatedLibCURL Curl (MIT/X11) UpdatedWebKit LGPL Progress_screens LGPL Prim_align_tool third party viewers (imprudence, Kirsten's, etc, etc, etc) please feel free to include this code into yours. -Temp_Uploads LGPL (from Dolphin Viewer 2.4) \ No newline at end of file +Temp_Uploads LGPL (from Dolphin Viewer 2.4) +StreamTitles BSD diff --git a/indra/llaudio/llstreamingaudio.h b/indra/llaudio/llstreamingaudio.h index 20104af744..eeb83e34b5 100644 --- a/indra/llaudio/llstreamingaudio.h +++ b/indra/llaudio/llstreamingaudio.h @@ -45,6 +45,11 @@ class LLStreamingAudioInterface virtual void setGain(F32 vol) = 0; virtual F32 getGain() = 0; virtual std::string getURL() = 0; + + // These three are Firestorm additions and thus optional. + virtual bool hasNewMetadata() { return false; } + virtual std::string getCurrentArtist() { return NULL; } + virtual std::string getCurrentTitle() { return NULL; } }; #endif // LL_STREAMINGAUDIO_H diff --git a/indra/llaudio/llstreamingaudio_fmod.cpp b/indra/llaudio/llstreamingaudio_fmod.cpp index bcdea771a7..2c3742567a 100644 --- a/indra/llaudio/llstreamingaudio_fmod.cpp +++ b/indra/llaudio/llstreamingaudio_fmod.cpp @@ -41,15 +41,22 @@ public: int startStream(); bool stopStream(); // Returns true if the stream was successfully stopped. bool ready(); + bool hasNewMetadata(); + std::string getCurrentArtist(); + std::string getCurrentTitle(); const std::string& getURL() { return mInternetStreamURL; } int getOpenState(); protected: + static signed char F_CALLBACKAPI metadataCallback(char *name, char *value, void *userdata); FSOUND_STREAM* mInternetStream; bool mReady; std::string mInternetStreamURL; + std::string mArtist; + std::string mTitle; + bool mHaveNewMetadata; }; @@ -271,6 +278,29 @@ void LLStreamingAudio_FMOD::setGain(F32 vol) } } +bool LLStreamingAudio_FMOD::hasNewMetadata() +{ + if(mCurrentInternetStreamp) + return mCurrentInternetStreamp->hasNewMetadata(); + + return false; +} + +std::string LLStreamingAudio_FMOD::getCurrentTitle() +{ + if(mCurrentInternetStreamp) + return mCurrentInternetStreamp->getCurrentTitle(); + + return ""; +} + +std::string LLStreamingAudio_FMOD::getCurrentArtist() +{ + if(mCurrentInternetStreamp) + return mCurrentInternetStreamp->getCurrentArtist(); + + return ""; +} /////////////////////////////////////////////////////// // manager of possibly-multiple internet audio streams @@ -304,6 +334,7 @@ int LLAudioStreamManagerFMOD::startStream() // Make sure the stream is set to 2D mode. FSOUND_Stream_SetMode(mInternetStream, FSOUND_2D); + FSOUND_Stream_Net_SetMetadataCallback(mInternetStream, metadataCallback, this); return FSOUND_Stream_PlayEx(FSOUND_FREE, mInternetStream, NULL, true); } @@ -354,3 +385,40 @@ int LLAudioStreamManagerFMOD::getOpenState() int open_state = FSOUND_Stream_GetOpenState(mInternetStream); return open_state; } + +bool LLAudioStreamManagerFMOD::hasNewMetadata() +{ + bool ret = mHaveNewMetadata; + mHaveNewMetadata = false; + return ret; +} + +std::string LLAudioStreamManagerFMOD::getCurrentArtist() +{ + return mArtist; +} + +std::string LLAudioStreamManagerFMOD::getCurrentTitle() +{ + return mTitle; +} + +signed char F_CALLBACKAPI LLAudioStreamManagerFMOD::metadataCallback(char *name, char *value, void *userdata) +{ + LLAudioStreamManagerFMOD* self = (LLAudioStreamManagerFMOD*)userdata; + if(!strcmp("ARTIST", name)) + { + self->mArtist = std::string(value); + self->mHaveNewMetadata = true; + return true; + } + + if (!strcmp("TITLE", name)) + { + self->mTitle = std::string(value); + self->mHaveNewMetadata = true; + return true; + } + return true; +} + diff --git a/indra/llaudio/llstreamingaudio_fmod.h b/indra/llaudio/llstreamingaudio_fmod.h index 9970f0d03b..a991343c30 100644 --- a/indra/llaudio/llstreamingaudio_fmod.h +++ b/indra/llaudio/llstreamingaudio_fmod.h @@ -48,6 +48,9 @@ class LLStreamingAudio_FMOD : public LLStreamingAudioInterface /*virtual*/ void setGain(F32 vol); /*virtual*/ F32 getGain(); /*virtual*/ std::string getURL(); + /*virtual*/ bool hasNewMetadata(); + /*virtual*/ std::string getCurrentArtist(); + /*virtual*/ std::string getCurrentTitle(); private: LLAudioStreamManagerFMOD *mCurrentInternetStreamp; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index c707e4b0a3..0edcd542b3 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -70,7 +70,7 @@ include_directories( set(viewer_SOURCE_FILES chatbar_as_cmdline.cpp kcwlinterface.cpp - fscontactsfloater.cpp + fscontactsfloater.cpp llagent.cpp llagentaccess.cpp llagentcamera.cpp @@ -582,7 +582,7 @@ set(viewer_SOURCE_FILES llxmlrpctransaction.cpp noise.cpp pipeline.cpp - qtoolalign.cpp + qtoolalign.cpp rlvhandler.cpp rlvhelper.cpp rlvcommon.cpp @@ -591,6 +591,7 @@ set(viewer_SOURCE_FILES rlvextensions.cpp rlvfloaters.cpp rlvui.cpp + streamtitledisplay.cpp ) set(VIEWER_BINARY_NAME "firestorm-bin" CACHE STRING @@ -613,9 +614,9 @@ endif (LINUX) set(viewer_HEADER_FILES CMakeLists.txt ViewerInstall.cmake - chatbar_as_cmdline.h + chatbar_as_cmdline.h kcwlinterface.h - fscontactsfloater.h + fscontactsfloater.h llagent.h llagentaccess.h llagentcamera.h @@ -1126,7 +1127,7 @@ set(viewer_HEADER_FILES macmain.h noise.h pipeline.h - qtoolalign.h + qtoolalign.h rlvdefines.h rlvhandler.h rlvhelper.h @@ -1136,6 +1137,7 @@ set(viewer_HEADER_FILES rlvextensions.h rlvfloaters.h rlvui.h + streamtitledisplay.h VertexCache.h VorbisFramework.h ) diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 4ea218ae8a..9c876e87ba 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -200,6 +200,7 @@ #include "llnotificationmanager.h" +#include "streamtitledisplay.h" // // exported globals @@ -2701,6 +2702,9 @@ void LLStartUp::multimediaInit() // LLViewerMedia::initClass(); LLViewerParcelMedia::initClass(); + + // Also initialise the stream titles. + new StreamTitleDisplay(); } void LLStartUp::fontInit() diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml index fec5c5d8ed..29f58b872b 100644 --- a/indra/newview/skins/default/xui/en/floater_about.xml +++ b/indra/newview/skins/default/xui/en/floater_about.xml @@ -128,9 +128,9 @@ Starlight UI by Hitomi Tiponi and: Alexandrea Fride, psi Merlin, Hugh Helendale, Digital Scribe, Naomah Beaumont, Nadin, KirstenLee Cinquetti Additional code contributed by: -Satomi Ahn, Lance Corrimal, Nicki Dasmijn, Ansariel Hiller, Zwagoth Klaar, -Shyotl Kuhr, Thickbrick Sleaford, Hitomi Tiponi, Armin WeatherHax, Chalice -Yao, and others. +Satomi Ahn, Katharine Berry, Lance Corrimal, Nicki Dasmijn, Ansariel Hiller, +Zwagoth Klaar, Shyotl Kuhr, Thickbrick Sleaford, Hitomi Tiponi, Armin +WeatherHax, Chalice Yao, and others. Additional Artists: New icons by Joseph Wain / glyphish.com diff --git a/indra/newview/streamtitledisplay.cpp b/indra/newview/streamtitledisplay.cpp new file mode 100644 index 0000000000..14fa387437 --- /dev/null +++ b/indra/newview/streamtitledisplay.cpp @@ -0,0 +1,74 @@ +/* Copyright (c) 2010 Katharine Berry All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * 3. Neither the name Katharine Berry nor the names of any contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY KATHARINE BERRY AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KATHARINE BERRY OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "llviewerprecompiledheaders.h" +#include "llchat.h" +//#include "llfloaterchat.h" +#include "llnotificationmanager.h" +#include "llaudioengine.h" +#include "llstreamingaudio.h" +#include "llviewercontrol.h" + +#include "streamtitledisplay.h" + +StreamTitleDisplay::StreamTitleDisplay() : LLEventTimer(2) { }; + +BOOL StreamTitleDisplay::tick() +{ + checkMetadata(); + return false; +} + +void StreamTitleDisplay::checkMetadata() +{ + if(!gAudiop) + return; + if(gAudiop->getStreamingAudioImpl()->hasNewMetadata() ) // && gSavedSettings.getBOOL("PhoenixShowStreamMetadata")) + { + LLChat chat; + std::string title = gAudiop->getStreamingAudioImpl()->getCurrentTitle(); + std::string artist = gAudiop->getStreamingAudioImpl()->getCurrentArtist(); + // Sometimes we get blanks... + if(title.length() > 0) + { + if(artist.length() > 0) + { + chat.mText = "Now playing: " + artist + " - " + title; + } + else + { + chat.mText = "Now playing: " + title; + } + chat.mSourceType = CHAT_SOURCE_SYSTEM; + LLSD args; + args["type"] = LLNotificationsUI::NT_NEARBYCHAT; + LLNotificationsUI::LLNotificationManager::instance().onChat(chat, args); + } + } +} diff --git a/indra/newview/streamtitledisplay.h b/indra/newview/streamtitledisplay.h new file mode 100644 index 0000000000..ac14d14231 --- /dev/null +++ b/indra/newview/streamtitledisplay.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2010 Katharine Berry All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, are permitted provided that the following + * conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided + * with the distribution. + * 3. Neither the name Katharine Berry nor the names of any contributors + * may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY KATHARINE BERRY AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KATHARINE BERRY OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef STREAMTITLEDISPLAY_H +#define STREAMTITLEDISPLAY_H + +#include "lleventtimer.h" + +class StreamTitleDisplay : LLEventTimer +{ +public: + StreamTitleDisplay(); + ~StreamTitleDisplay() { } +private: + BOOL tick(); + void checkMetadata(); +}; + +#endif // STREAMTITLEDISPLAY_H