[banshee] [gst#] Support track changes, buffering messages, and tags
- From: Bertrand Lorentz <blorentz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] [gst#] Support track changes, buffering messages, and tags
- Date: Thu, 19 Aug 2010 20:50:50 +0000 (UTC)
commit 7390cc71231d5a53e5149562e74c20a1aab75501
Author: Pete Johanson <peter peterjohanson com>
Date: Sat Aug 14 22:21:34 2010 -0400
[gst#] Support track changes, buffering messages, and tags
The GStreamerSharp backend now also does the following things :
1) Publishes proper events on EOS, so that the play count is updated,
and the next track is requested and then played. No gapless yet.
2) Publishes buffering events. I haven't yet implemented the more
advanced logic hiding in libbanshee that doesn't play the stream til it
is 100% buffered, but at least banshee now shows the buffering status
when playing songs from the Internet Archive plugin, for example.
3) Publishes discovered tags.
Signed-off-by: Bertrand Lorentz <bertrand lorentz gmail com>
.../Banshee.GStreamerSharp/PlayerEngine.cs | 83 ++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs
index 882c35f..e05fe74 100644
--- a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs
+++ b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs
@@ -28,6 +28,7 @@
using System;
using System.Collections;
+using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
@@ -61,6 +62,8 @@ namespace Banshee.GStreamerSharp
playbin = new PlayBin2 ();
pipeline.Add (playbin);
+ pipeline.Bus.AddWatch (OnBusMessage);
+
Banshee.ServiceStack.Application.RunTimeout (200, delegate {
OnEventChanged (PlayerEvent.Iterate);
return true;
@@ -69,6 +72,86 @@ namespace Banshee.GStreamerSharp
OnStateChanged (PlayerState.Ready);
}
+ private bool OnBusMessage (Bus bus, Message msg)
+ {
+ switch (msg.Type) {
+ case MessageType.Eos:
+ Close (false);
+ OnEventChanged (PlayerEvent.EndOfStream);
+ OnEventChanged (PlayerEvent.RequestNextTrack);
+ break;
+ case MessageType.StateChanged:
+ State old_state, new_state, pending_state;
+ msg.ParseStateChanged (out old_state, out new_state, out pending_state);
+
+ HandleStateChange (old_state, new_state, pending_state);
+
+ break;
+ case MessageType.Buffering:
+ int buffer_percent;
+ msg.ParseBuffering (out buffer_percent);
+
+ HandleBuffering (buffer_percent);
+ break;
+ case MessageType.Tag:
+ Pad pad;
+ TagList tag_list;
+ msg.ParseTag (out pad, out tag_list);
+
+ HandleTag (pad, tag_list);
+
+ break;
+ case MessageType.Error:
+ Enum error_type;
+ string err_msg, debug;
+ msg.ParseError (out error_type, out err_msg, out debug);
+
+ // TODO: What to do with the error?
+
+ break;
+ }
+
+ return true;
+ }
+
+ private void HandleBuffering (int buffer_percent)
+ {
+ OnEventChanged (new PlayerEventBufferingArgs (buffer_percent / 100.0));
+ }
+
+ private void HandleStateChange (State old_state, State new_state, State pending_state)
+ {
+ if (CurrentState != PlayerState.Loaded && old_state == State.Ready && new_state == State.Paused && pending_state == State.Playing) {
+ OnStateChanged (PlayerState.Loaded);
+ } else if (old_state == State.Paused && new_state == State.Playing && pending_state == State.VoidPending) {
+ if (CurrentState == PlayerState.Loaded) {
+ OnEventChanged (PlayerEvent.StartOfStream);
+ }
+ OnStateChanged (PlayerState.Playing);
+ } else if (CurrentState == PlayerState.Playing && old_state == State.Playing && new_state == State.Paused) {
+ OnStateChanged (PlayerState.Paused);
+ }
+ }
+
+ private void HandleTag (Pad pad, TagList tag_list)
+ {
+ foreach (string tag in tag_list.Tags) {
+ if (String.IsNullOrEmpty (tag)) {
+ continue;
+ }
+
+ if (tag_list.GetTagSize (tag) < 1) {
+ continue;
+ }
+
+ List tags = tag_list.GetTag (tag);
+
+ foreach (object o in tags) {
+ OnTagFound (new StreamTag () { Name = tag, Value = o });
+ }
+ }
+ }
+
protected override void OpenUri (SafeUri uri)
{
Console.WriteLine ("Gst# PlayerEngine OpenUri: {0}", uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]