Katharine Berry's stream title/artist display in chat.

meow-7.2.2
Tonya Souther 2011-02-17 21:13:04 -06:00
parent 284c0e0895
commit 2a37265dab
9 changed files with 211 additions and 9 deletions

View File

@ -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)
Temp_Uploads LGPL (from Dolphin Viewer 2.4)
StreamTitles BSD

View File

@ -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

View File

@ -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;
}

View File

@ -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;

View File

@ -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
)

View File

@ -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()

View File

@ -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

View File

@ -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);
}
}
}

View File

@ -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