Gst.Bus.Connect never calls its signal handler.
Thibault Saunier
tsaunier at gnome.org
Mon Jan 8 18:00:05 UTC 2018
Hello Justin,
I have the impression you are doing something wrong, I just went ahead
and tested what you said doesn't work by modiying our
PlayBackTutorial3[0] as follow:
```
diff --git a/samples/PlaybackTutorial3.cs b/samples/PlaybackTutorial3.cs
index dc725b063..f6debca55 100644
--- a/samples/PlaybackTutorial3.cs
+++ b/samples/PlaybackTutorial3.cs
@@ -93,6 +93,7 @@ namespace GstreamerSharp
// This function is called when playbin has created
the appsrc element, so we have a chance to configure it.
static void SourceSetup (object sender, GLib.SignalArgs args) {
+ Console.WriteLine ("YAY SETUP!!");
var info = new Gst.Audio.AudioInfo ();
var source = new
Gst.App.AppSrc(((Element)args.Args [0]).Handle);
Console.WriteLine ("Source has been created.
Configuring.");
@@ -107,6 +108,16 @@ namespace GstreamerSharp
source.EnoughData += StopFeed;
}
+ static void HandleStateChanged (object sender,
GLib.SignalArgs args) {
+ Gst.State oldstate, newstate, pending;
+ var msg = (Message) args.Args[0];
+
+ // Print error details on the screen
+ msg.ParseStateChanged (out oldstate, out
newstate, out pending);
+
+ Console.WriteLine("New state: {0}", newstate);
+ }
+
// This function is called when an error message is
posted on the bus
static void HandleError (object sender, GLib.SignalArgs args) {
GLib.GException err;
@@ -137,6 +148,7 @@ namespace GstreamerSharp
var bus = Pipeline.Bus;
bus.AddSignalWatch ();
bus.Connect ("message::error", HandleError);
+ bus.Connect("message::state-changed",
HandleStateChanged);
// Start playing the pipeline
Pipeline.SetState (State.Playing);
```
And this works just as expected, are you running a mainloop?
Cheers,
Thibault
[0] https://cgit.freedesktop.org/gstreamer/gstreamer-sharp/tree/samples/PlaybackTutorial3.cs
On Mon, Jan 8, 2018 at 7:06 AM, Justin J. Kim <justin.joy.9to5 at gmail.com> wrote:
> Hello,
>
> I am not sure whether this is my environment problem or gstreamer-shap's
> bug.
> Although gstreamer-sharp provides some examples how to connect signal
> handler to a Gst.Bus,
> it only works when I added the handler to 'SyncMessage'.
>
> I am using VS.Net 2017 on Windows 10.
>
> More specifically, this is the case that signal handler works.
>
>
> ```
> Element pipeline = (Pipeline) Parse.Launch ("uridecodebin name=uridecodebin
> ! fakesink");
>
> var bus = pipeline.Bus;
> bus.AddSignalWatch();
> bus.EnableSyncMessageEmission();
> bus.SyncMessage += HandleBusMessage;
>
> ```
>
> The below case is to use 'Bus.Connect', but the handler never be called.
> However, if I create "uridecodebin", it always emits "source-setup" signal
> so I can use "Connect".
>
>
> ```
> Element pipeline = (Pipeline) Parse.Launch ("uridecodebin name=uridecodebin
> ! fakesink");
>
> var bus = pipeline.Bus;
> bus.AddSignalWatch();
> // HandleStateChanged never be called.
> bus.Connect("message::state-changed", HandleStateChanged);
>
> uridecodebin = pipeline.GetByName("uridecodebin");
> // SourceSetup is always called.
> uridecodebin.Connect("source-setup", SourceSetup);
> ```
>
> Am I missing something when calling "Connect"?
>
> BR,
> Justin
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>
More information about the gstreamer-devel
mailing list