Hi!

Here's a new version. I also added it to Jira:
http://jira.secondlife.com/browse/VWR-12655

Changes:

* Changed to use notifications. I think this is a better way to do it, and 
makes it possible to translate, unlike the hardcoded message.

* Added setting and preferences panel to make it possible to disable. The 
default setting is enabled. It adds a "Show stream's title in chat" under 
"Play Streaming Music When Available".

* Removes a debug message that didn't add anything useful.

* Fixed the patch (first version was reversed ^_^;;)

Left to do:
* Windows support. Windows appears to use QuickTime for audio streaming, so 
I poked around on Apple's website, but didn't turn up anything useful yet. 
All I found so far is a post to the quicktime mailing list asking how to do 
it, without answers.

* Translation. The only thing to translate is: "Playing: [TITLE]".

Windows support should be doable due to mentions of iTunes being able to 
get the info. 

I *think* it's probably done by handling the event in 
mcActionFilterCallBack in llmediaimplquicktime.cpp, but the list of the 
possible values for the action variable I found doesn't seem to have 
anything suitable. Help would be very appreciated. Just pointing me to the 
appropiate documentation would probably be enough.

Unless there are any problems with code, I think this could be committed, 
and would like to do so unless there are any problems with it.

diff --git a/indra/llaudio/audioengine.h b/indra/llaudio/audioengine.h
index b582f14..bb66d75 100644
--- a/indra/llaudio/audioengine.h
+++ b/indra/llaudio/audioengine.h
@@ -179,6 +179,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/indra/llmedia/llmediaimplgstreamer.cpp b/indra/llmedia/llmediaimplgstreamer.cpp
index 51614c5..d4e8fc2 100644
--- a/indra/llmedia/llmediaimplgstreamer.cpp
+++ b/indra/llmedia/llmediaimplgstreamer.cpp
@@ -73,7 +73,8 @@ LLMediaImplGStreamer () :
 	mTextureFormatType ( LL_MEDIA_UNSIGNED_INT_8_8_8_8_REV ),
 	mPump ( NULL ),
 	mPlaybin ( NULL ),
-	mVideoSink ( NULL )
+	mVideoSink ( NULL ),
+	mLastTitle ( "" )
 #ifdef LL_GST_SOUNDSINK
 	,mAudioSink ( NULL )
 #endif // LL_GST_SOUNDSINK
@@ -300,6 +301,8 @@ 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
@@ -361,6 +364,33 @@ 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 f1ffd3a..2a32765 100644
--- a/indra/llmedia/llmediaimplgstreamer.h
+++ b/indra/llmedia/llmediaimplgstreamer.h
@@ -100,6 +100,7 @@ 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 e6da4f6..97fed5f 100644
--- a/indra/llmedia/llmediaobserver.h
+++ b/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/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 27eacfb..038d199 100644
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -10371,5 +10371,16 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
+    <key>ShowStreamTitle</key>
+    <map>
+      <key>Comment</key>
+      <string>Show the title of the song playing on the parcel's stream</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>Boolean</string>
+      <key>Value</key>
+      <integer>1</integer>
+    </map>
   </map>
 </llsd>
diff --git a/indra/newview/lloverlaybar.cpp b/indra/newview/lloverlaybar.cpp
index 7b85927..2aa0851 100644
--- a/indra/newview/lloverlaybar.cpp
+++ b/indra/newview/lloverlaybar.cpp
@@ -62,6 +62,8 @@
 #include "llvoiceremotectrl.h"
 #include "llwebbrowserctrl.h"
 #include "llselectmgr.h"
+#include "llviewermedia.h"
+#include "llnotify.h"
 
 //
 // Globals
@@ -71,6 +73,52 @@ 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)
+{
+	if ( !gSavedSettings.getBOOL("ShowStreamTitle") )
+	{
+		return;
+	}
+
+
+	LLStringUtil::format_map_t args;
+	args["[TITLE]"] = event_in.getStringValue();
+	LLNotifyBox::showXml("StreamTitle", args);
+}
+
+
 //
 // Functions
 //
@@ -114,6 +162,7 @@ LLOverlayBar::LLOverlayBar()
 	factory_map["chat_bar"] = LLCallbackMap(LLOverlayBar::createChatBar, this);
 	
 	LLUICtrlFactory::getInstance()->buildPanel(this, "panel_overlaybar.xml", &factory_map);
+
 }
 
 BOOL LLOverlayBar::postBuild()
@@ -362,6 +411,7 @@ void LLOverlayBar::toggleMusicPlay(void*)
 	// 			if ( gAudiop->isInternetStreamPlaying() == 0 )
 				{
 					gAudiop->startInternetStream(parcel->getMusicURL());
+					sTitleObserver.init(parcel->getMusicURL());
 				}
 			}
 		}
diff --git a/indra/newview/skins/default/xui/en-us/notify.xml b/indra/newview/skins/default/xui/en-us/notify.xml
index 63396af..58c6b18 100644
--- a/indra/newview/skins/default/xui/en-us/notify.xml
+++ b/indra/newview/skins/default/xui/en-us/notify.xml
@@ -1065,4 +1065,9 @@ Click Accept to join the chat or Decline to decline the invitation. Click Mute t
 			The URL you clicked cannot be opened from this web browser.
 		</message>
 	</notify>
+	<notify name="StreamTitle" tip="true">
+		<message name="message">
+			Playing: [TITLE]
+		</message>
+	</notify>
 </notifications>
diff --git a/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml b/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml
index 92978ab..5bcbe53 100644
--- a/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml
+++ b/indra/newview/skins/default/xui/en-us/panel_preferences_audio.xml
@@ -9,7 +9,7 @@
 		Volume:
 	</text>
 	<text type="string" length="1" bg_visible="false" border_drop_shadow_visible="false" border_visible="false"
-	     bottom="-215" drop_shadow_visible="true" enabled="true" follows="left|top"
+	     bottom="-195" drop_shadow_visible="true" enabled="true" follows="left|top"
 	     font="SansSerifSmall" h_pad="0" halign="left" height="12" left="10"
 	     mouse_opaque="true" name="streaming_prefs_text" v_pad="0" width="128">
 		Streaming Preferences:
@@ -23,11 +23,16 @@
 	<panel border="true" bottom="-195" enabled="true" filename="panel_audio.xml"
 	     follows="left|top|right|bottom" height="180" label="Volume" left="148"
 	     mouse_opaque="true" name="Volume Panel" width="260" />
-	<check_box bottom="-220" control_name="AudioStreamingMusic" enabled="true"
+	<check_box bottom="-200" control_name="AudioStreamingMusic" enabled="true"
 	     follows="left|top" font="SansSerifSmall" height="16" initial_value="true"
 	     label="Play Streaming Music When Available (uses more bandwidth)"
 	     left="142" mouse_opaque="true" name="streaming_music" radio_style="false"
 	     width="339" />
+	<check_box bottom_delta="-20" control_name="ShowStreamTitle" enabled="true"
+	     follows="left|top" font="SansSerifSmall" height="16" initial_value="true"
+	     label="Show stream's title in chat"
+	     left="162" mouse_opaque="true" name="show_stream_title" radio_style="false"
+	     width="338" />
 	<check_box bottom_delta="-20" control_name="AudioStreamingVideo" enabled="true"
 	     follows="left|top" font="SansSerifSmall" height="16" initial_value="true"
 	     label="Play Streaming Media When Available (uses more bandwidth)"

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