Hi!

I made a small patch to display the title of the currently playing song in 
the chat log. I only use SL on Linux, so only a gstreamer implementation is 
included so far.

Pretty much all that's needed is to add the required code to 
llmediaimplquicktime.cpp, and then call:

LLMediaEvent event(self, song_title);
self->getEventEmitter().update( &LLMediaObserver::onMediaTitleChange, 
event);

Criticism of the idea and the implementation would be appreciated. 
Currently I stuck the title announcing code into lloverlaybar.cpp, but 
that's probably not the best place for it.


diff --git a/indra/llaudio/audioengine.h b/indra/llaudio/audioengine.h
index bb66d75..b582f14 100644
--- a/indra/llaudio/audioengine.h
+++ b/indra/llaudio/audioengine.h
@@ -179,8 +179,6 @@ 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/indra/llmedia/llmediaimplgstreamer.cpp b/indra/llmedia/llmediaimplgstreamer.cpp
index d4e8fc2..51614c5 100644
--- a/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/indra/llmedia/llmediaimplgstreamer.cpp
@@ -73,8 +73,7 @@ LLMediaImplGStreamer () :
 	mTextureFormatType ( LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV ),
 	mPump ( NULL ),
 	mPlaybin ( NULL ),
-	mVideoSink ( NULL ),
-	mLastTitle ( "" )
+	mVideoSink ( NULL )
 #ifdef LL_GST_SOUNDSINK
 	,mAudioSink ( NULL )
 #endif // LL_GST_SOUNDSINK
@@ -301,8 +300,6 @@ LLMediaImplGStreamer::bus_callback (GstBus     *bus,
 		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
@@ -364,33 +361,6 @@ LLMediaImplGStreamer::bus_callback (GstBus     *bus,
 			impl->addCommand(LLMediaBase::COMMAND_STOP);
 		}
 		break;
-	case GST_MESSAGE_TAG:
-	{
-		DEBUGMSG("GST message tag");
-		GstTagList *new_tags = NULL;
-
-		gst_message_parse_tag( message, &new_tags );
-
-		if ( new_tags )
-		{
-			gchar *title = NULL;
-			if ( gst_tag_list_get_string(new_tags, GST_TAG_TITLE, &title) )
-			{
-				gst_tag_list_free(new_tags);
-				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);
-			}
-		}
-	}
-		break;
 	default:
 		/* unhandled message */
 		break;
diff --git a/indra/llmedia/llmediaimplgstreamer.h b/indra/llmedia/llmediaimplgstreamer.h
index 2a32765..f1ffd3a 100644
--- a/indra/llmedia/llmediaimplgstreamer.h
+++ b/indra/llmedia/llmediaimplgstreamer.h
@@ -100,7 +100,6 @@ class LLMediaImplGStreamer:
         	GMainLoop *mPump; // event pump for this media
 	        GstElement *mPlaybin;
 		GstSLVideo *mVideoSink;
-		std::string mLastTitle;
 #ifdef LL_GST_SOUNDSINK
 		GstSLSound *mAudioSink;
 #endif // LL_GST_SOUNDSINK
diff --git a/indra/llmedia/llmediaobserver.h b/indra/llmedia/llmediaobserver.h
index 97fed5f..e6da4f6 100644
--- a/indra/llmedia/llmediaobserver.h
+++ b/indra/llmedia/llmediaobserver.h
@@ -102,7 +102,6 @@ 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/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp
index ad401d9..7b85927 100644
--- a/indra/newview/lloverlaybar.cpp
+++ b/indra/newview/lloverlaybar.cpp
@@ -63,10 +63,6 @@
 #include "llwebbrowserctrl.h"
 #include "llselectmgr.h"
 
-#include "llchat.h"
-#include "llfloaterchat.h"
-#include "llviewermedia.h"
-
 //
 // Globals
 //
@@ -75,47 +71,6 @@ 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<LLMediaRemoteCtrl> 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)
-{
-	LLChat chat("Playing: " + event_in.getStringValue());
-	chat.mFromName = "Media";
-	llinfos << "Media changed, adding to chat: " << chat.mText << llendl;
-	LLFloaterChat::addChat(chat);
-}
-
-
 //
 // Functions
 //
@@ -159,7 +114,6 @@ LLOverlayBar::LLOverlayBar()
 	factory_map["chat_bar"] = LLCallbackMap(LLOverlayBar::createChatBar, this);
 	
 	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_overlaybar.xml", &factory_map);
-
 }
 
 BOOL LLOverlayBar::postBuild()
@@ -408,7 +362,6 @@ void LLOverlayBar::toggleMusicPlay(void*)
 	// 			if ( gAudiop->isInternetStreamPlaying() == 0 )
 				{
 					gAudiop->startInternetStream(parcel->getMusicURL());
-					sTitleObserver.init(parcel->getMusicURL());
 				}
 			}
 		}

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Policies and (un)subscribe information available here:
http://wiki.secondlife.com/wiki/SLDev
Please read the policies before posting to keep unmoderated posting privileges

Reply via email to