Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft: Port 'Screencast' demo to Vala #180

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

BharatAtbrat
Copy link
Contributor

The current code does not work, the GStreamer Pipeline is causing issues. There might be some problems with the implementation

Note - The Camera port also does not work because it uses Gst Pipeline.

Screengrab of the error :

2024-06-14.23-00-30.mp4

The current code does not work, Gstreamer Pipeline
is causing issues.
@BharatAtbrat
Copy link
Contributor Author

@Diego-Ivan I'd appreciate a review :). I don't think I understand how the pipeline works correctly

@Diego-Ivan
Copy link
Contributor

The current code does not work, the GStreamer Pipeline is causing issues. There might be some problems with the implementation

Note - The Camera port also does not work because it uses Gst Pipeline.

It needs to Gst.init needs to be called, passing null should be allowed (as it is done in both the JS and Python demos). Do you know if there is any workaround for this @lw64 ?

I'd appreciate a review :). I don't think I understand how the pipeline works correctly

I'm really not a GStreamer guy, but up to my understanding, this is how it works:

  1. The portal asks Pipewire for a file descriptor, which is the place where it will write the camera frames so the app can read them.
  2. The file descriptor will be given to the pipewiresrc element, which is the responsible to read the frames.
  3. When the pipewiresrc reads one, it will push it to a queue which contains the frames that need to be drawn.
  4. The glsinkbin will pop a frame from the queue and will "create the instructions" to draw it.
  5. The gtk4paintablesink will receive the instructions and will draw the frame to a Gtk.Picture

src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
@BharatAtbrat
Copy link
Contributor Author

The current code does not work, the GStreamer Pipeline is causing issues. There might be some problems with the implementation
Note - The Camera port also does not work because it uses Gst Pipeline.

It needs to Gst.init needs to be called, passing null should be allowed (as it is done in both the JS and Python demos). Do you know if there is any workaround for this @lw64 ?

I'd appreciate a review :). I don't think I understand how the pipeline works correctly

I'm really not a GStreamer guy, but up to my understanding, this is how it works:

  1. The portal asks Pipewire for a file descriptor, which is the place where it will write the camera frames so the app can read them.
  2. The file descriptor will be given to the pipewiresrc element, which is the responsible to read the frames.
  3. When the pipewiresrc reads one, it will push it to a queue which contains the frames that need to be drawn.
  4. The glsinkbin will pop a frame from the queue and will "create the instructions" to draw it.
  5. The gtk4paintablesink will receive the instructions and will draw the frame to a Gtk.Picture

I did try calling Gst.init() but it doesn't allow me to use null as a parameter, it instead requires a ref weak string[]?
Using ref args with arguments from the main method, the error goes away but the demo fails to start

Explicit variable declaration
Changed the way node_id is accessed with a more proper way to get
elements from the touple
Skip Gst.state enum
Replace enclosing whole method in try catch
Throw an error from start_screencast_session()
Declare portal and parent as global for easier access
@Diego-Ivan
Copy link
Contributor

I did try calling Gst.init() but it doesn't allow me to use null as a parameter, it instead requires a ref weak string[]?
Using ref args with arguments from the main method, the error goes away but the demo fails to start

@BharatAtbrat I use this very ugly workaround to test it:

unowned string[] workaround = null;
Gst.init (ref workaround);

But I think this is an issue with the Vala bindings, it should allow null.

@sonnyp
Copy link
Contributor

sonnyp commented Oct 9, 2024

Is this still an issue with 47?

@Diego-Ivan
Copy link
Contributor

Unfortunately yes, but I think we can use the workaround I suggested to have this merged. I don't think it would be a big deal.

Just tested the demo and it works perfectly, thank you so much @BharatAtbrat !

imagen

src/Screencast/main.vala Outdated Show resolved Hide resolved
src/Screencast/main.vala Outdated Show resolved Hide resolved
Workaround as suggested by @Diego-Ivan
Demo functions as expected
@lw64
Copy link
Contributor

lw64 commented Oct 9, 2024

But I think this is an issue with the Vala bindings, it should allow null.

I don't think this second use of the function can be expressed in the Vala bindings, you probably would need to create a second binding for the function that executed it with null values. Maybe gst.init_null (), feel free to add it :)

@BharatAtbrat
Copy link
Contributor Author

But I think this is an issue with the Vala bindings, it should allow null.

I don't think this second use of the function can be expressed in the Vala bindings, you probably would need to create a second binding for the function that executed it with null values. Maybe gst.init_null (), feel free to add it :)

Adding it directly brings up an error saying the name init_null does not exist. What am I doing wrong?

@lw64
Copy link
Contributor

lw64 commented Oct 9, 2024

What do you mean with "adding directly"? I meant changing the vapi

@BharatAtbrat
Copy link
Contributor Author

What do you mean with "adding directly"? I meant changing the vapi

Oh my bad :P, I thought this already existed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants