Fmod metadata parsing. Innitial.
This commit is contained in:
@@ -36,6 +36,8 @@
|
|||||||
|
|
||||||
#include "stdtypes.h" // from llcommon
|
#include "stdtypes.h" // from llcommon
|
||||||
|
|
||||||
|
class LLSD;
|
||||||
|
|
||||||
// Entirely abstract. Based exactly on the historic API.
|
// Entirely abstract. Based exactly on the historic API.
|
||||||
class LLStreamingAudioInterface
|
class LLStreamingAudioInterface
|
||||||
{
|
{
|
||||||
@@ -51,6 +53,7 @@ class LLStreamingAudioInterface
|
|||||||
virtual void setGain(F32 vol) = 0;
|
virtual void setGain(F32 vol) = 0;
|
||||||
virtual F32 getGain() = 0;
|
virtual F32 getGain() = 0;
|
||||||
virtual std::string getURL() = 0;
|
virtual std::string getURL() = 0;
|
||||||
|
virtual const LLSD *getMetaData() = 0; //return NULL if not supported.
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // LL_STREAMINGAUDIO_H
|
#endif // LL_STREAMINGAUDIO_H
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public:
|
|||||||
const std::string& getURL() { return mInternetStreamURL; }
|
const std::string& getURL() { return mInternetStreamURL; }
|
||||||
|
|
||||||
int getOpenState();
|
int getOpenState();
|
||||||
|
|
||||||
|
FSOUND_STREAM* getStream() { return mInternetStream; }
|
||||||
protected:
|
protected:
|
||||||
FSOUND_STREAM* mInternetStream;
|
FSOUND_STREAM* mInternetStream;
|
||||||
bool mReady;
|
bool mReady;
|
||||||
@@ -66,7 +68,8 @@ protected:
|
|||||||
LLStreamingAudio_FMOD::LLStreamingAudio_FMOD() :
|
LLStreamingAudio_FMOD::LLStreamingAudio_FMOD() :
|
||||||
mCurrentInternetStreamp(NULL),
|
mCurrentInternetStreamp(NULL),
|
||||||
mFMODInternetStreamChannel(-1),
|
mFMODInternetStreamChannel(-1),
|
||||||
mGain(1.0f)
|
mGain(1.0f),
|
||||||
|
mMetaData(NULL)
|
||||||
{
|
{
|
||||||
// Number of milliseconds of audio to buffer for the audio card.
|
// Number of milliseconds of audio to buffer for the audio card.
|
||||||
// Must be larger than the usual Second Life frame stutter time.
|
// Must be larger than the usual Second Life frame stutter time.
|
||||||
@@ -87,6 +90,17 @@ LLStreamingAudio_FMOD::~LLStreamingAudio_FMOD()
|
|||||||
// nothing interesting/safe to do.
|
// nothing interesting/safe to do.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signed char F_CALLBACKAPI MetaDataCallback(char *name, char *value, void *userdata)
|
||||||
|
{
|
||||||
|
std::string szName(name);
|
||||||
|
if(szName == "TITLE" || szName=="TIT2" || szName=="Title")
|
||||||
|
(*(LLSD*)userdata)["TITLE"] = value;
|
||||||
|
if(szName == "ARTIST" || szName=="TPE1" || szName =="WM/AlbumTitle")
|
||||||
|
(*(LLSD*)userdata)["ARTIST"] = value;
|
||||||
|
else
|
||||||
|
(*(LLSD*)userdata)[std::string(name)] = value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void LLStreamingAudio_FMOD::start(const std::string& url)
|
void LLStreamingAudio_FMOD::start(const std::string& url)
|
||||||
{
|
{
|
||||||
@@ -104,6 +118,10 @@ void LLStreamingAudio_FMOD::start(const std::string& url)
|
|||||||
llinfos << "Starting internet stream: " << url << llendl;
|
llinfos << "Starting internet stream: " << url << llendl;
|
||||||
mCurrentInternetStreamp = new LLAudioStreamManagerFMOD(url);
|
mCurrentInternetStreamp = new LLAudioStreamManagerFMOD(url);
|
||||||
mURL = url;
|
mURL = url;
|
||||||
|
if(mCurrentInternetStreamp->getStream())
|
||||||
|
{
|
||||||
|
mMetaData = new LLSD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -154,6 +172,10 @@ void LLStreamingAudio_FMOD::update()
|
|||||||
// Reset volume to previously set volume
|
// Reset volume to previously set volume
|
||||||
setGain(getGain());
|
setGain(getGain());
|
||||||
FSOUND_SetPaused(mFMODInternetStreamChannel, false);
|
FSOUND_SetPaused(mFMODInternetStreamChannel, false);
|
||||||
|
if(mCurrentInternetStreamp->getStream() && mMetaData)
|
||||||
|
{
|
||||||
|
FSOUND_Stream_Net_SetMetadataCallback(mCurrentInternetStreamp->getStream(),&MetaDataCallback, mMetaData);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -184,11 +206,17 @@ void LLStreamingAudio_FMOD::update()
|
|||||||
// buffering
|
// buffering
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLStreamingAudio_FMOD::stop()
|
void LLStreamingAudio_FMOD::stop()
|
||||||
{
|
{
|
||||||
|
if(mMetaData)
|
||||||
|
{
|
||||||
|
if(mCurrentInternetStreamp && mCurrentInternetStreamp->getStream())
|
||||||
|
FSOUND_Stream_Net_SetMetadataCallback(mCurrentInternetStreamp->getStream(),NULL,NULL);
|
||||||
|
delete mMetaData;
|
||||||
|
mMetaData = NULL;
|
||||||
|
}
|
||||||
if (mFMODInternetStreamChannel != -1)
|
if (mFMODInternetStreamChannel != -1)
|
||||||
{
|
{
|
||||||
FSOUND_SetPaused(mFMODInternetStreamChannel, true);
|
FSOUND_SetPaused(mFMODInternetStreamChannel, true);
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ class LLStreamingAudio_FMOD : public LLStreamingAudioInterface
|
|||||||
/*virtual*/ void setGain(F32 vol);
|
/*virtual*/ void setGain(F32 vol);
|
||||||
/*virtual*/ F32 getGain();
|
/*virtual*/ F32 getGain();
|
||||||
/*virtual*/ std::string getURL();
|
/*virtual*/ std::string getURL();
|
||||||
|
/*virtual*/ const LLSD *getMetaData(){return mMetaData;} //return NULL if not supported.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LLAudioStreamManagerFMOD *mCurrentInternetStreamp;
|
LLAudioStreamManagerFMOD *mCurrentInternetStreamp;
|
||||||
@@ -62,6 +63,8 @@ private:
|
|||||||
|
|
||||||
std::string mURL;
|
std::string mURL;
|
||||||
F32 mGain;
|
F32 mGain;
|
||||||
|
|
||||||
|
LLSD *mMetaData;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include "llparcel.h"
|
#include "llparcel.h"
|
||||||
#include "llviewercontrol.h"
|
#include "llviewercontrol.h"
|
||||||
#include "llbutton.h"
|
#include "llbutton.h"
|
||||||
|
#include "llstreamingaudio.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
@@ -89,6 +90,10 @@ BOOL LLMediaRemoteCtrl::postBuild()
|
|||||||
childSetAction("music_pause",LLOverlayBar::toggleMusicPlay,this);
|
childSetAction("music_pause",LLOverlayBar::toggleMusicPlay,this);
|
||||||
|
|
||||||
childSetAction("expand", onClickExpandBtn, this);
|
childSetAction("expand", onClickExpandBtn, this);
|
||||||
|
|
||||||
|
LLButton *pause = getChild<LLButton>("music_pause");
|
||||||
|
mCachedPauseTip = pause->getToolTip();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,6 +240,28 @@ void LLMediaRemoteCtrl::enableMediaButtons()
|
|||||||
music_pause_btn->setEnabled(music_show_pause);
|
music_pause_btn->setEnabled(music_show_pause);
|
||||||
music_pause_btn->setVisible(music_show_pause);
|
music_pause_btn->setVisible(music_show_pause);
|
||||||
music_play_btn->setVisible(! music_show_pause);
|
music_play_btn->setVisible(! music_show_pause);
|
||||||
|
|
||||||
|
if(music_show_pause)
|
||||||
|
{
|
||||||
|
LLStreamingAudioInterface *stream = gAudiop ? gAudiop->getStreamingAudioImpl() : NULL;
|
||||||
|
if(stream && stream->getMetaData())
|
||||||
|
{
|
||||||
|
std::string info_text = "Loading...";
|
||||||
|
const LLSD& metadata = *(stream->getMetaData());
|
||||||
|
LLSD artist = metadata.get("ARTIST");
|
||||||
|
LLSD title = metadata.get("TITLE");
|
||||||
|
if(artist.isDefined() && title.isDefined())
|
||||||
|
info_text = artist.asString() + " -- " + title.asString();
|
||||||
|
else if(title.isDefined())
|
||||||
|
info_text = std::string("Title: ") + title.asString();
|
||||||
|
else if(artist.isDefined())
|
||||||
|
info_text = std::string("Artist: ") + artist.asString();
|
||||||
|
music_pause_btn->setToolTip(info_text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
music_pause_btn->setToolTip(mCachedPauseTip);
|
||||||
|
}
|
||||||
|
|
||||||
childSetColor("music_icon", music_icon_color);
|
childSetColor("music_icon", music_icon_color);
|
||||||
if(!media_icon_name.empty())
|
if(!media_icon_name.empty())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,8 @@
|
|||||||
|
|
||||||
#include "llpanel.h"
|
#include "llpanel.h"
|
||||||
|
|
||||||
|
class LLButton;
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
class LLMediaRemoteCtrl : public LLPanel
|
class LLMediaRemoteCtrl : public LLPanel
|
||||||
@@ -57,6 +59,8 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void build();
|
void build();
|
||||||
|
|
||||||
|
std::string mCachedPauseTip;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class LLStreamingAudio_MediaPlugins : public LLStreamingAudioInterface
|
|||||||
/*virtual*/ void setGain(F32 vol);
|
/*virtual*/ void setGain(F32 vol);
|
||||||
/*virtual*/ F32 getGain();
|
/*virtual*/ F32 getGain();
|
||||||
/*virtual*/ std::string getURL();
|
/*virtual*/ std::string getURL();
|
||||||
|
/*virtual*/ LLSD *getMetaData(){return NULL;} //return NULL if not supported.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LLPluginClassMedia* initializeMedia(const std::string& media_type);
|
LLPluginClassMedia* initializeMedia(const std::string& media_type);
|
||||||
|
|||||||
Reference in New Issue
Block a user