Commit graph

119 commits

Author SHA1 Message Date
Piotr Brzeziński
eec3f18936 examples/tutorials: Use NSApp terminate() instead of sending an event
Has the same effect while being much more concise.
Unfortunately the cocoa crate doesn't (yet?) have bindings for this
function, so objc::msg_send! had to be used directly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1163>
2022-12-12 13:23:46 +02:00
Sebastian Dröge
a1165a7456 gstreamer: Add bin/pipeline builders
And also implement the Default trait for them.
2022-10-22 17:36:36 +03:00
Sebastian Dröge
2a4e1069a1 app: Add an AppSrc/AppSink builder
These allows to construct these elements explicitly together with all the
properties instead of going via gst::ElementFactory::make().
2022-10-22 10:19:49 +03:00
Sebastian Dröge
7423b1dea6 elementfactory: Change make() / create() to builders and keep the old variants as create_with_name() / make_with_name()
As a side-effect, this also now includes the element factory name in the
error messages instead of giving the same error string for every
factory.

Partially fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/318

Also let them all go through the same, single object construction code.
2022-10-19 17:48:39 +03:00
Sebastian Dröge
f9690817ad Fix nullability handling in some functions in manual code 2022-10-18 18:15:01 +03:00
Sebastian Dröge
b89a285178 Use correct gobject-sys::GObject type in the examples/tutorials 2022-10-12 14:30:19 +03:00
François Laignel
08551bb1bc format/specific: don't expose inner as pub
... users would be able to bypass the range checks and build a
defined Rust value which would be interpreted as `None` in C code.

Added format module examples for formatted values constructions.
2022-10-10 19:23:35 +02:00
Sebastian Dröge
3cd902513d Update for glib::Object::new() API changes 2022-10-07 21:45:01 +03:00
François Laignel
57d8d46ab6 gst/format: fix some ops and add others
Some operations were implemented on types that wouldn't result in
the expected physical unit. E.g.:

- `ClockTime / ClockTime` results in a unit-less factor.
- `u64 / ClockTime` would result in a `1 / ClockTime`. Since we don't
  use any `Frequency` type, this operation is removed. Users should
  use the `ClockTime` accessors to compute the expected value.

This commit also adds:

- multiplications with integers as the left hand side operands.
- `Partial{Eq,Ord} for `Signed<T>` with `T` as left hand side operand.
- `opt_add` / `opt_sub` for `Signed<T>` with `T` as left or right hand
   side operands.
- missing tests for `Partial{Eq,Ord}` and `OptionOrd`.

This implementation can interfere with unrelated code and was removed:

- `Signed<usize>.` `PartialOrd` makes existing code computing the len
  of slices needing type annotation because the len is later used in
  a comparison for which the compiler is unable to determine if
  the len is `Signed<usize>` or `usize`.
2022-10-01 13:15:11 +02:00
François Laignel
a787197254 Use CompatibleFormattedValue where applicable
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/1059
2022-07-11 19:45:52 +02:00
Piotrek Brzeziński
1d78ac9323 examples: Update playback-tutorial-6 with new getters 2021-11-28 21:00:05 +01:00
Piotrek Brzeziński
31b78f483e examples/tutorials: Add missing playback tutorials 2021-11-25 00:13:19 +01:00
Sebastian Dröge
27613a8901 examples/tutorials: The get-XXX-tags signals on playbin can return a None taglist 2021-11-21 18:38:39 +02:00
Bilal Elmoussaoui
1ffcea4da7 manual changes post ObjectExt::emit_by_name update 2021-11-21 09:40:27 +01:00
Bilal Elmoussaoui
e3a65a3a88 gst object: add a panicking variant of set_property_from_str
Similar to what was added to ObjectExt
2021-11-08 14:42:59 +01:00
Bilal Elmoussaoui
213020165a manual changes post ObjectExt improvements 2021-11-08 14:42:59 +01:00
Sebastian Dröge
92f9f3be39 Remove various unnecessary & from property/structure field related code 2021-10-24 20:52:23 +03:00
François Laignel
f83b385487 tutorial: take advantage of Div impl on Percent 2021-10-18 14:30:59 +02:00
François Laignel
986a136492 clock_time & format: basic opt-ops impl
The option-operations crate provides traits to improve usability
when dealing with `Option`s, which is often the case with
`ClockTime` & most formats.
2021-10-18 14:30:59 +02:00
Sebastian Dröge
37c3d2d8e0 Update for glib::source_remove() removal 2021-10-12 09:30:10 +03:00
Sebastian Dröge
bdccaeee0d gstreamer: Manually implement Object::set_property_from_str() to be able to catch deserialization errors 2021-08-17 09:12:38 +03:00
Sebastian Dröge
a091ea201c examples/tutorials: Use cocoa crate to initialize the shared NSApplication instance
This is required for OpenGL to work nowadays on macOS. Simply running an
CFRunLoop on the main thread is not sufficient.

Thanks to Philippe Normand for testing this on macOS and making sure it
actually compiles and works.
2021-07-13 07:42:46 +00:00
Marijn Suijten
bea15b8ebd tutorials/13: Use nested or patterns, available since Rust 1.53 2021-07-05 06:36:57 +00:00
François Laignel
e31ce9d07b Manual ClockTime updates 2021-06-04 22:09:38 +02:00
François Laignel
90bb458e64 Rework ClockTime & FormattedValues 2021-06-04 22:09:38 +02:00
Sebastian Dröge
04e6c1b547 app: Remove signals bindings from appsrc/appsink for the signals that also have callbacks
The callbacks are more flexible and performant.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/issues/338
2021-05-30 23:00:44 +03:00
Sebastian Dröge
b1088a6d11 tutorials/basic-tutorial-13: Make sure that acquiring the main context actually succeeds 2021-05-18 12:16:59 +03:00
Sebastian Dröge
6b8bfd2701 tutorials/basic-tutorial-13: Store the main context acquire guard in a variable
Otherwise it will be immediately released again.
2021-05-18 11:43:37 +03:00
François Laignel
49583597ed manual code: fix-getters-def doc aliases 2021-05-03 20:46:57 +02:00
Marijn Suijten
f89e840d27 Remove redundant prelude imports
When importing the prelude of a crate like `gst` the `glib` prelude is
provided too.  Shedding these imports saves quite a few lines and
adheres to keeping it simple; we're not reexporting base/parent preludes
for no reason :)
2021-04-29 12:05:13 +02:00
yatinmaan
ffe6821813 tutorials: Add playback-tutorial-1 2021-04-28 02:28:38 +05:30
Sebastian Dröge
eda1d3d4a7 Update for Value trait refactoring 2021-04-25 14:45:08 +03:00
François Laignel
1395d773c3 manual fixes remove get prefix round 2 2021-04-20 18:18:02 +02:00
François Laignel
6ab9164dca fix-getters-calls 0.3.0 pass 2021-04-20 18:18:02 +02:00
François Laignel
e80a29372a fix-getters-def 0.3.0 pass 2021-04-20 18:18:02 +02:00
François Laignel
99616ec0b4 post fix-getters manual updates 2021-04-13 17:54:40 +02:00
François Laignel
53be8e5f58 fix-getters-{def,calls} pass 2021-04-13 17:54:40 +02:00
Sebastian Dröge
8b71f5331a examples/tutorials: Update for new Bus::connect_message() API that takes signal details 2021-02-28 19:08:50 +02:00
Sebastian Dröge
efb249f7b9 tutorials: Change from set_property_with_value() to set_property_from_value() 2021-02-23 12:11:48 +02:00
Sebastian Dröge
b5d5838d96 examples/tutorials: Change from emit() to emit_by_name()
And set_property_generic() to set_property_with_value()
2021-02-22 17:28:05 +02:00
Guillaume Gomez
a3f6f710a9 tutorials/basic-tutorial-13: Add "\r" at each println to fix the raw terminal display 2021-01-09 16:08:06 +01:00
Guillaume Gomez
2fcaaa53ce Add basic tutorial 13 from C gstreamer examples 2021-01-08 15:49:30 +01:00
Sebastian Dröge
d84336dc12 tutorials/basic-tutorial-5: Don't unnecessarily cast float literals to f64
error: casting float literal to `f64` is unnecessary
   --> tutorials/src/bin/basic-tutorial-5.rs:141:13
    |
141 |             1.0 as f64,
    |             ^^^^^^^^^^ help: try: `1.0_f64`
    |
2020-12-29 16:56:13 +02:00
Fernando Jiménez Moreno
dfa3812ccc Playback tutorial 4: Progressive streaming 2020-12-16 11:10:51 +00:00
Marijn Suijten
5afca49a7b gstreamer: Propagate nullability changes into manual code 2020-12-04 19:37:07 +01:00
Sebastian Dröge
a6c8fe0c8a Use repr(transparent) where it is more correct and get rid of some unneeded repr(C) 2020-10-24 17:09:10 +00:00
Sebastian Dröge
ad1d78b599 examples: Move to Rust 2018 edition 2020-10-10 11:00:48 +03:00
Sebastian Dröge
096ce958a4 tutorials: Move from failure to anyhow 2020-10-10 10:52:15 +03:00
Sebastian Dröge
fb779b42a8 Use glib::timeout_add_local() instead of removed gtk::timeout_add() 2020-08-27 09:49:27 +03:00
Guillaume Gomez
6752ef8a69 tutorials: Add resample element to the pipeline in tutorials 3 2020-07-10 11:12:38 +02:00