webrtcsink icon indicating copy to clipboard operation
webrtcsink copied to clipboard

readme: add gst-launch with meta example

Open colemickens opened this issue 3 years ago • 8 comments
trafficstars

please, and thank you. I'm new to gstreamer and can't really figure out how meta works with gst-launch, nor has Google turned up anything helpful yet.

colemickens avatar Aug 19 '22 06:08 colemickens

meta="a-structure, display-name=${dname}" is what I came up with, is that the simplest way?

colemickens avatar Aug 19 '22 06:08 colemickens

So, an example would be helpful indeed. Yesterday I was updating my application to work with the meta instead of display-name, and it follows the Gst Structure syntax. To construct it in Rust you can do as follows:

let metadata = gstreamer::Structure::new("meta", 
    &[
        (&"display-name", &"potato")
    ]
).to_string();

let pipeline_string = format!(
    " ! webrtcsink stun-server={stun_endpoint} \
      turn-server={turn_endpoint} \
      signaller::address={signalling_endpoint} \
      video-caps={capability} \
      meta={metadata:?}"
);

Hope it helps!

joaoantoniocardoso avatar Aug 19 '22 11:08 joaoantoniocardoso

Since it is a metadata, I wonder how to serialize a gstreamer::Structure from a Rust struct, it would be very helpful.

joaoantoniocardoso avatar Aug 19 '22 11:08 joaoantoniocardoso

thanks @joaoantoniocardoso :) @thiblahute care to comment on this?

MathieuDuponchelle avatar Aug 19 '22 20:08 MathieuDuponchelle

meta="a-structure, display-name=${dname}" is what I came up with, is that the simplest way?

Yes this is the right way to do it.

So, an example would be helpful indeed. Yesterday I was updating my application to work with the meta instead of display name, and it follows the Gst Structure syntax. To construct it in Rust you can do as follows:

let metadata = gstreamer::Structure::new("meta", 
   &[
      (&"display-name", &"potato")
  ]
).to_string();
let pipeline_string = format!(
   " ! webrtcsink stun-server={stun_endpoint} \
     turn-server={turn_endpoint} \
     signaller::address={signalling_endpoint} \
     video-caps={capability} \
     meta={metadata:?}"
);

This is correct but I would find it cleaner to use metadata.to_string() (instead of abusing the Debug implementation ) or retrieve the element and set the structure as a prop fwiw :-)

Since it is a metadata, I wonder how to serialize a gstreamer::Structure from a Rust struct, it would be very helpful.

We should implement that with Serde at some point I think, but it is not done. I implemented a json_to_gst_structure function in my webrtcsrc branch which is fairly simple if it can help meanwhile.

thiblahute avatar Aug 19 '22 22:08 thiblahute

@colemickens btw PR is welcome to add the example in the readme as suggested here :-)

thiblahute avatar Aug 22 '22 13:08 thiblahute

This is correct but I would find it cleaner to use metadata.to_string() (instead of abusing the Debug implementation ) or retrieve the element and set the structure as a prop fwiw :-)

metadata is already a String (you might just misread it?), and the debug :? is just there to get \" around the (String) metadata, as meta=\"{metadata}\". I agree that it is better to use \" instead of :?, especially in an example.

We should implement that with Serde at some point I think, but it is not done. I implemented a json_to_gst_structure function in my webrtcsrc branch which is fairly simple if it can help meanwhile.

Nice! That's very helpful, thanks!

joaoantoniocardoso avatar Aug 22 '22 13:08 joaoantoniocardoso

metadata is already a String (you might just misread it?), and the debug :? is just there to get " around the (String) metadata, as meta="{metadata}". I agree that it is better to use " instead of :?, especially in an example.

Indeed I read too fast. No problem in any case.

thiblahute avatar Aug 22 '22 21:08 thiblahute

Closing, @colemickens if you decide to update the README it now lives at https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs :)

MathieuDuponchelle avatar Oct 24 '22 09:10 MathieuDuponchelle