From 96741727e0d1dbb743fe9dcfff68d52b12617136 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Mon, 15 Jun 2009 03:00:48 -0700 Subject: Applied Dale Glass' patch for VWR-12655: Add support for displaying the title of the song --- linden/indra/llaudio/audioengine.h | 2 + linden/indra/llmedia/llmediaimplgstreamer.cpp | 46 ++++++++++++++------ linden/indra/llmedia/llmediaimplgstreamer.h | 1 + linden/indra/llmedia/llmediaobserver.h | 1 + linden/indra/newview/app_settings/settings.xml | 11 +++++ linden/indra/newview/lloverlaybar.cpp | 49 ++++++++++++++++++++++ .../default/xui/en-us/panel_preferences_audio.xml | 6 ++- 7 files changed, 102 insertions(+), 14 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index d289ba5..579f58f 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h @@ -182,6 +182,8 @@ public: static void assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status); friend class LLPipeline; // For debugging + + LLMediaBase * getStreamMedia() { return mInternetStreamMedia; } public: F32 mMaxWindGain; // Hack. Public to set before fade in? diff --git a/linden/indra/llmedia/llmediaimplgstreamer.cpp b/linden/indra/llmedia/llmediaimplgstreamer.cpp index d1bab29..c0c2070 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.cpp +++ b/linden/indra/llmedia/llmediaimplgstreamer.cpp @@ -89,6 +89,7 @@ LLMediaImplGStreamer () : mPump ( NULL ), mPlaybin ( NULL ), mVideoSink ( NULL ), + mLastTitle ( "" ), mState( GST_STATE_NULL ), mPlayThread ( NULL ) { @@ -470,6 +471,8 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp case GST_STATE_PAUSED: break; case GST_STATE_PLAYING: + impl->mLastTitle = ""; + LLMediaEvent event( impl, 100 ); impl->getEventEmitter().update( &LLMediaObserver::onUpdateProgress, event ); // emit an event to say that a media source was loaded @@ -521,18 +524,35 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp } case GST_MESSAGE_TAG: { - GstTagList *tag_list; - gchar *title; - gchar *artist; - gst_message_parse_tag(message, &tag_list); - gboolean hazTitle = gst_tag_list_get_string(tag_list, - GST_TAG_TITLE, &title); - gboolean hazArtist = gst_tag_list_get_string(tag_list, - GST_TAG_ARTIST, &artist); - if(hazTitle) - LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL; - if(hazArtist) - LL_INFOS("MediaInfo") << "Artist: " << artist << LL_ENDL; + GstTagList *new_tags; + + gst_message_parse_tag( message, &new_tags ); + + gchar *title; + gchar *artist; + + if ( gst_tag_list_get_string(new_tags, GST_TAG_TITLE, &title) ) + { + LL_INFOS("MediaInfo") << "Title: " << title << LL_ENDL; + std::string newtitle(title); + + if ( newtitle != impl->mLastTitle && newtitle != "" ) + { + impl->mLastTitle = newtitle; + LLMediaEvent event( impl, impl->mLastTitle ); + impl->getEventEmitter().update( &LLMediaObserver::onMediaTitleChange, event ); + } + + g_free(title); + } + + if (gst_tag_list_get_string(new_tags, GST_TAG_ARTIST, &artist)) + { + LL_INFOS("MediaInfo") << "Artist: " << artist << LL_ENDL; + g_free(artist); + } + + gst_tag_list_free(new_tags); break; } case GST_MESSAGE_EOS: @@ -551,10 +571,10 @@ gboolean LLMediaImplGStreamer::bus_callback(GstBus *bus, GstMessage *message, gp impl->addCommand(LLMediaBase::COMMAND_STOP); } break; + } default: /* unhandled message */ break; - } } /* we want to be notified again the next time there is a message * on the bus, so return true (false means we want to stop watching diff --git a/linden/indra/llmedia/llmediaimplgstreamer.h b/linden/indra/llmedia/llmediaimplgstreamer.h index baefdaf..51a8c37 100644 --- a/linden/indra/llmedia/llmediaimplgstreamer.h +++ b/linden/indra/llmedia/llmediaimplgstreamer.h @@ -127,6 +127,7 @@ class LLMediaImplGStreamer: GMainLoop *mPump; // event pump for this media GstElement *mPlaybin; GstSLVideo *mVideoSink; + std::string mLastTitle; GstState mState; GstState getState() const { return mState; } diff --git a/linden/indra/llmedia/llmediaobserver.h b/linden/indra/llmedia/llmediaobserver.h index e6da4f6..97fed5f 100644 --- a/linden/indra/llmedia/llmediaobserver.h +++ b/linden/indra/llmedia/llmediaobserver.h @@ -102,6 +102,7 @@ class LLMediaObserver virtual void onMediaSizeChange( const EventType& event_in ) { } virtual void onMediaContentsChange( const EventType& event_in ) { } virtual void onMediaStatusTextChange( const EventType& event_in ) { } + virtual void onMediaTitleChange( const EventType &event_in ) { } virtual void onNavigateBegin( const EventType& event_in ) { } virtual void onNavigateComplete( const EventType& event_in ) { } virtual void onUpdateProgress( const EventType& event_in ) { } diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 5c76185..7ab215a 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -7337,6 +7337,17 @@ Value 0 + ShowStreamTitle + + Comment + Show the title of the song playing on the parcel's stream + Persist + 1 + Type + Boolean + Value + 1 + ShowTangentBasis Comment diff --git a/linden/indra/newview/lloverlaybar.cpp b/linden/indra/newview/lloverlaybar.cpp index 91a7375..e1aeeca 100644 --- a/linden/indra/newview/lloverlaybar.cpp +++ b/linden/indra/newview/lloverlaybar.cpp @@ -41,6 +41,7 @@ #include "llagent.h" #include "llbutton.h" #include "llchatbar.h" +#include "llfloaterchat.h" #include "llfocusmgr.h" #include "llimview.h" #include "llmediaremotectrl.h" @@ -72,6 +73,53 @@ LLOverlayBar *gOverlayBar = NULL; extern S32 MENU_BAR_HEIGHT; + +class LLTitleObserver + : public LLMediaObserver +{ +public: + void init(std::string url); + /*virtual*/ void onMediaTitleChange(const EventType& event_in); +private: + LLMediaBase* mMediaSource; +}; + +static LLTitleObserver sTitleObserver; + +static LLRegisterWidget r("media_remote"); + +void LLTitleObserver::init(std::string url) +{ + + if (!gAudiop) + { + return; + } + + mMediaSource = gAudiop->getStreamMedia(); // LLViewerMedia::getSource(); + + if ( mMediaSource ) + { + mMediaSource->addObserver(this); + } +} + +//virtual +void LLTitleObserver::onMediaTitleChange(const EventType& event_in) +{ + if ( !gSavedSettings.getBOOL("ShowStreamTitle") ) + { + return; + } + + LLChat chat; + //TODO: set this in XUI + std::string playing_msg = "Playing: " + event_in.getStringValue(); + chat.mText = playing_msg; + LLFloaterChat::addChat(chat, FALSE, FALSE); +} + + // // Functions // @@ -406,6 +454,7 @@ void LLOverlayBar::toggleMusicPlay(void*) // if ( gAudiop->isInternetStreamPlaying() == 0 ) { gAudiop->startInternetStream(parcel->getMusicURL()); + sTitleObserver.init(parcel->getMusicURL()); } } } diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml index 92978ab..c960d36 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml @@ -15,7 +15,7 @@ Streaming Preferences: Audio Preferences: @@ -28,6 +28,10 @@ label="Play Streaming Music When Available (uses more bandwidth)" left="142" mouse_opaque="true" name="streaming_music" radio_style="false" width="339" /> +