New, also help on dealing with multiple audio streams using gstreamer-rs

classic Classic list List threaded Threaded
31 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Sebastian Dröge-3
On Thu, 2020-12-17 at 13:49 +0000, Michael Johnson wrote:
All those warnings are related to not handling the None type, I didn't think that would have any bearing. 

You were ignoring Results. set_property(), emit(), etc return Results.

Wait. You're not supposed to use emit? Then why does it exist? Surely you emit a signal to then be caught by the connect.

What is the alternative to using emit then, and why does the alternative still relate to connect? 

One side is connecting to a signal, the other side is emitting signals. For normal signals, the emitter is the object itself. In this case playbin.

For action signals (get-audio-tags on playbin for example), you would emit the signal instead of playbin. Action signals "abuse" the signal machinery for having something like "dynamic function calls".

By the logic of setting the value of 2 every them then current audio should go -1,-1,2 not -1,-1,-1. It yields 2 on exit. Which was my point

You print the current value before you set it to the new one. So in the end it is 2, but you don't print it anymore.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Michael Johnson
In reply to this post by Michael Johnson
Regardless, if you want to press a button to change audio stream surely you emit when the button is pressed, which then causes the callback to run 

Without that it only emits on startup and close. And that's not helpful 

Thank you for all your help so far, it's been highly appreciated

On Thu, 17 Dec 2020, 13:50 Michael Johnson, <[hidden email]> wrote:
Oh wait I see what you mean about the first point. My eyes can't see a minus sign apparently :P



On Thu, 17 Dec 2020, 13:49 Michael Johnson, <[hidden email]> wrote:
All those warnings are related to not handling the None type, I didn't think that would have any bearing. 

Wait. You're not supposed to use emit? Then why does it exist? Surely you emit a signal to then be caught by the connect. By the logic of setting the value of 2 every them then current audio should go -1,-1,2 not -1,-1,-1. It yields 2 on exit. Which was my point

What is the alternative to using emit then, and why does the alternative still relate to connect? 

On Thu, 17 Dec 2020, 13:36 Sebastian Dröge, <[hidden email]> wrote:
On Thu, 2020-12-17 at 12:28 +0000, Michael Johnson wrote:
As requested a toy example,
Here we see that the audio-changed emit never activates the connect, maybe because it emits before the video has began playing?

I'm probably doing something very wrong 

Yeah, you're ignoring compiler warnings here that tell you that you're ignoring potential errors :)

Make sure to at least `unwrap()` `Result`s instead of ignoring them, then you immediately know if you did something wrong there.
In this case the emitting of the "audio-changed" signal fails because of the wrong number of arguments.

But that also doesn't matter here: that signal is supposed to be emitted by playbin whenever something changes, not by you.

After removing that line what I get is

current audio track is -1
number of audio tracks is 1
current audio track is -1
number of audio tracks is 2
current audio track is -1
number of audio tracks is 3

That looks as expected. Every signal emission you're setting the current audio track to 2, but only the last time there actually is a 3rd (0, 1, 2) audio track available.
So in the end it should use the 3rd audio track.

If you change it for example to set it to 1 then you'll see that during the last signal emission the current audio track is 1.


For getting state into the signal handler closure, take a look at the overlay-composition.rs example and what it does with the DrawingContext inside the Arc<Mutex<_>> there.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Michael Johnson
Ahhh I think I see, so then how do you go about emitting that signal without using it from playbin for these action signals

On Thu, 17 Dec 2020, 14:04 Michael Johnson, <[hidden email]> wrote:
Regardless, if you want to press a button to change audio stream surely you emit when the button is pressed, which then causes the callback to run 

Without that it only emits on startup and close. And that's not helpful 

Thank you for all your help so far, it's been highly appreciated

On Thu, 17 Dec 2020, 13:50 Michael Johnson, <[hidden email]> wrote:
Oh wait I see what you mean about the first point. My eyes can't see a minus sign apparently :P



On Thu, 17 Dec 2020, 13:49 Michael Johnson, <[hidden email]> wrote:
All those warnings are related to not handling the None type, I didn't think that would have any bearing. 

Wait. You're not supposed to use emit? Then why does it exist? Surely you emit a signal to then be caught by the connect. By the logic of setting the value of 2 every them then current audio should go -1,-1,2 not -1,-1,-1. It yields 2 on exit. Which was my point

What is the alternative to using emit then, and why does the alternative still relate to connect? 

On Thu, 17 Dec 2020, 13:36 Sebastian Dröge, <[hidden email]> wrote:
On Thu, 2020-12-17 at 12:28 +0000, Michael Johnson wrote:
As requested a toy example,
Here we see that the audio-changed emit never activates the connect, maybe because it emits before the video has began playing?

I'm probably doing something very wrong 

Yeah, you're ignoring compiler warnings here that tell you that you're ignoring potential errors :)

Make sure to at least `unwrap()` `Result`s instead of ignoring them, then you immediately know if you did something wrong there.
In this case the emitting of the "audio-changed" signal fails because of the wrong number of arguments.

But that also doesn't matter here: that signal is supposed to be emitted by playbin whenever something changes, not by you.

After removing that line what I get is

current audio track is -1
number of audio tracks is 1
current audio track is -1
number of audio tracks is 2
current audio track is -1
number of audio tracks is 3

That looks as expected. Every signal emission you're setting the current audio track to 2, but only the last time there actually is a 3rd (0, 1, 2) audio track available.
So in the end it should use the 3rd audio track.

If you change it for example to set it to 1 then you'll see that during the last signal emission the current audio track is 1.


For getting state into the signal handler closure, take a look at the overlay-composition.rs example and what it does with the DrawingContext inside the Arc<Mutex<_>> there.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Sebastian Dröge-3
In reply to this post by Michael Johnson
On Thu, 2020-12-17 at 14:04 +0000, Michael Johnson wrote:
Regardless, if you want to press a button to change audio stream surely you emit when the button is pressed, which then causes the callback to run 

You would then set the property from the button pressed signal handler.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Michael Johnson
But I'm not using the gstreamer library for handling buttons being pressed. Surely there's a way to do this another way

On Thu, 17 Dec 2020, 14:06 Sebastian Dröge, <[hidden email]> wrote:
On Thu, 2020-12-17 at 14:04 +0000, Michael Johnson wrote:
Regardless, if you want to press a button to change audio stream surely you emit when the button is pressed, which then causes the callback to run 

You would then set the property from the button pressed signal handler.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Sebastian Dröge-3
On Thu, 2020-12-17 at 14:09 +0000, Michael Johnson wrote:
But I'm not using the gstreamer library for handling buttons being pressed. Surely there's a way to do this another way

You can call set_property() on the playbin from wherever you want, it just has to be after the playbin is started or it will ignore that.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Michael Johnson
This then brings back to the original point. As commented in the test case, setting the property of current audio is doing absolutely nothing, even with removing the set in the callback



On Thu, 17 Dec 2020, 14:15 Sebastian Dröge, <[hidden email]> wrote:
On Thu, 2020-12-17 at 14:09 +0000, Michael Johnson wrote:
But I'm not using the gstreamer library for handling buttons being pressed. Surely there's a way to do this another way

You can call set_property() on the playbin from wherever you want, it just has to be after the playbin is started or it will ignore that.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Sebastian Dröge-3
On Thu, 2020-12-17 at 14:18 +0000, Michael Johnson wrote:
This then brings back to the original point. As commented in the test case, setting the property of current audio is doing absolutely nothing, even with removing the set in the callback

That works fine for me with your code. 0, 1, and 2 all have different audio.

You just have to make sure to set the track after playbin is started and knows the number of tracks. Which it notifies you about with the "audio-changed" signal.
But you can set that property from anywhere, it doesn't have to be from the signal handler.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Michael Johnson
Can you send back the test case where the switch is working. I still have it a line above the fixed aspect ratio, and that may still be too soon for it?

On Thu, 17 Dec 2020, 14:27 Sebastian Dröge, <[hidden email]> wrote:
On Thu, 2020-12-17 at 14:18 +0000, Michael Johnson wrote:
This then brings back to the original point. As commented in the test case, setting the property of current audio is doing absolutely nothing, even with removing the set in the callback

That works fine for me with your code. 0, 1, and 2 all have different audio.

You just have to make sure to set the track after playbin is started and knows the number of tracks. Which it notifies you about with the "audio-changed" signal.
But you can set that property from anywhere, it doesn't have to be from the signal handler.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Michael Johnson
Yeah that was it, if I sleep the main thread it can then be switched

Thank you so much for all your help. It's been very informative

On Thu, 17 Dec 2020, 14:28 Michael Johnson, <[hidden email]> wrote:
Can you send back the test case where the switch is working. I still have it a line above the fixed aspect ratio, and that may still be too soon for it?

On Thu, 17 Dec 2020, 14:27 Sebastian Dröge, <[hidden email]> wrote:
On Thu, 2020-12-17 at 14:18 +0000, Michael Johnson wrote:
This then brings back to the original point. As commented in the test case, setting the property of current audio is doing absolutely nothing, even with removing the set in the callback

That works fine for me with your code. 0, 1, and 2 all have different audio.

You just have to make sure to set the track after playbin is started and knows the number of tracks. Which it notifies you about with the "audio-changed" signal.
But you can set that property from anywhere, it doesn't have to be from the signal handler.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: New, also help on dealing with multiple audio streams using gstreamer-rs

Sebastian Dröge-3
In reply to this post by Michael Johnson
On Thu, 2020-12-17 at 14:28 +0000, Michael Johnson wrote:
Can you send back the test case where the switch is working. I still have it a line above the fixed aspect ratio, and that may still be too soon for it?

Yes that's too early. That's long before playbin even knows how many audio tracks there are.

You either have to wait until the Paused/Playing state is reached or use the "audio-changed" signal as an indication when playbin knows about the audio tracks.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

main.rs (2K) Download Attachment
12