Commit graph

752 commits

Author SHA1 Message Date
Sebastian Dröge 8b3049d098 impl Clone for BufferPoolConfig and PlayerConfig 2020-01-30 23:10:26 +02:00
Sebastian Dröge 5102bfd324 Update CHANGELOG.md for 0.15.2 2020-01-30 00:40:56 +02:00
Sebastian Dröge fe4f074e90 bus: Don't use the bus sync handler in the bus Stream to notify about messages being available
This is racy and can cause the consumer of the messages to never be
woken up anymore:

1. Waker is stored because no message on the bus
2. Sync handler is called, waker is woken up
3. Bus is polled again and no message is on it (yet),
   new waker is registered
4. Bus stores the message from 2. in its queue (after
   the sync handler has returned BusSyncReply::Pass)
5. No new message ever appears on the bus because all
   this happened for the very last message

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/235
2020-01-28 23:39:36 +02:00
Sebastian Dröge 63a8afafa5 gstreamer: Use more accurate types for Seqnum, GroupId and MetaSeqnum
For the latter introduce an actual opaque type that allows using them
for comparison purposes but is not just a plain u64.

For the former represent them as opaque type around an NonZeroU32. 0 is
the invalid case and does not happen in the majority of functions. Where
it can happen, represent this case by using an Option<_> instead.

This makes it harder to mis-use these types.

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/209
2020-01-25 00:07:36 +02:00
Sebastian Dröge 0bd2903896 Update CHANGELOG.md for 0.15.1 2020-01-23 08:28:19 +02:00
Sebastian Dröge 7230aee069 Switch everything from lazy_static to once_cell::Lazy
Fewer macros, faster compile-time and the Lazy type will likely end up
in the standard library in a similar form to this.
2020-01-22 19:57:41 +02:00
Sebastian Dröge 2b5f16391d gstreamer/childproxy: Fix unused variable compiler warnings 2020-01-22 19:57:41 +02:00
Sebastian Dröge 196a9891cb Regenerate with latest gir
This switches the RTP constant strings over to once_cell::Lazy
2020-01-22 19:57:41 +02:00
Sebastian Dröge d3c77f400d Don't derive Debug impls for generic types where the type parameters don't have to impl Debug themselves
This allows to use MappedBuffer and similar types to be properly
debug-printed.

Also change VideoFrame/VideoFrameRef/RTPBuffer from a tuple struct to a
struct with proper field names to make the code easier to understand.
2020-01-22 19:10:04 +02:00
Sebastian Dröge 280fe38fe4 gstreamer/childproxy: Don't require implementing child_added/removed() signal vfuncs
Most implementers will not care about default handlers for these signals
so requiring to implement them is only unnecessarily verbose.
2020-01-22 17:14:38 +02:00
Sebastian Dröge b17f04e866 bus: Make bus Stream private and add functions on the bus directly for it
Also add a helper function that allows filtering the stream directly.
2020-01-22 10:05:36 +02:00
Sebastian Dröge 217bbc3e94 bus: Take the mutex before popping messages for the bus stream
Otherwise a message might arrive between popping, getting None and
locking the mutex for storing the waker. In that case we would never
be woken up.
2020-01-22 09:21:10 +02:00
Sebastian Dröge aa29567171 gstreamer/element: Add call_async_future() that returns a future
The future would resolve into the return value of the closure that is
called asynchronously on the thread pool, and allows asynchronous
awaiting for it to finish.

  let res = element.call_async(|element| {
      element.set_state(gst::State::Playing)
  }).await;

  assert_eq!(res, Ok(gst::StateChangeSuccess::Success))
2020-01-20 12:03:59 +02:00
Guillaume Desmottes 01c4d08501 gstreamer: use thiserror crate
Make code simpler and fix deprecated warning when building on nightly as
Error::description is being deprecated.
2020-01-10 18:54:50 +05:30
Guillaume Desmottes e151ee75f8 gstreamer: error: add tests 2020-01-10 18:54:50 +05:30
Guillaume Desmottes 1f79bf3e02 gstreamer: caps: Builder: prevent re-adding features
Rework the API to statically prevent users re-adding features or
adding features if any_features() has been previously called.
2020-01-10 15:09:06 +05:30
Guillaume Desmottes fe5ebd82cc gstreamer: caps: BuilderFull: prevent adding features if using any
Rework the API to statically prevent users adding extra features if the
builder has been created with builder_full_with_any_features(). It
doesn't make sense to add extra features if all are already included.
2020-01-10 14:21:23 +05:30
Guillaume Desmottes a9adac85aa gstreamer: pad: fix build on Windows
GstPadProbeInfo.id is a gulong which are 32 bits on Windows.
2020-01-09 10:14:21 +00:00
Guillaume Desmottes 38db96859b gstreamer: add Caps::builder_full()
API to create a caps containing multiple structures.
Fix #231
2020-01-09 15:01:18 +05:30
Sebastian Dröge 775c5bfe27 gstreamer: Add getters/setters for BinFlags and fix flags API for PadFlags
The BinFlags API was accidentally used for PadFlags, allowing to set
BinFlags on pads which is not very useful.
2020-01-06 17:23:39 +02:00
Sebastian Dröge 8aac047af5 Use NonZeroU64/U32 for PadProbeId, NotifyId and DeviceMonitorFilterId
This allows for some further optimizations.
2020-01-05 11:09:46 +02:00
Guillaume Desmottes c298577139 gstreamer: add MemoryRef::dump() 2019-12-24 09:15:34 +05:30
Sebastian Dröge 69be1ce2fc Fix various new clippy warnings from 1.40 2019-12-22 12:10:27 +02:00
Sebastian Dröge d26ffc2c21 Update version to 0.16.0 2019-12-19 00:48:08 +02:00
Sebastian Dröge bb321f7fa8 Update CHANGELOG.md for 0.15.0 2019-12-18 19:15:21 +02:00
Sebastian Dröge 2ba5105b80 Implement Sync/Send for more types and don't implement Send for TypeFind
They can actually be shared with multiple threads at the same time
safely as all functions requiring an immutable reference are
thread-safe.

OTOH TypeFind can't be shared safely between different threads as not
all implementations of the TypeFind struct are thread-safe.
2019-12-18 18:37:44 +02:00
Sebastian Dröge be3c378f28 Use Results instead of Options where they signal an error instead of just a missing value
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/216
2019-12-17 22:21:28 +02:00
Sebastian Dröge eaafbd14f7 Regenerate 2019-12-15 12:19:33 +02:00
Sebastian Dröge f417d68820 Remove usage of glib_floating_reference_guard!()
It's not needed anymore.
2019-12-07 23:05:14 +02:00
Sebastian Dröge 2375c9da59 gstreamer/element: Don't steal floating references passed into release_pad()
They are apparently not part of this element so we can directly return
here instead of stealing the reference.
2019-12-07 22:58:26 +02:00
Sebastian Dröge 802fa4fcb4 gstreamer/bin: Take a strong reference of the element passed into remove_element()
It might be gone once we called into the parent class' implementation so
we need to keep a strong reference around here. Also we need to ensure
that we don't accidentally steal a floating reference from the caller
here: if the element is still floating it is apparently not part of this
bin and we can directly return FALSE.
2019-12-07 22:56:11 +02:00
Sebastian Dröge bef1143df3 gstreamer/device: Preserve floating reference flag from create_element() parent class' implementation 2019-12-07 22:51:57 +02:00
Sebastian Dröge 84ac2ef073 bin: Use from_glib_none() in Bin::add() for subclasses
This way we take ownership of any floating references passed in here, as
required by the GstBin API, instead of just borrowing the reference and
having someone else sink it or not.
2019-12-04 18:49:12 +02:00
François Laignel fd6bbf5929 Fully qualify glib_bool_error! in gst_loggable_error! 2019-11-21 19:18:01 +01:00
Sebastian Dröge 175863668d Regenerate everything with latest gir 2019-11-21 09:52:51 +02:00
François Laignel dc7937a8d4 Don't leak missing Safety doc clippy warnings
With rustc 1.40.0, clippy checks that the `unsafe` functions come with
a `Safety` section. When running clippy on a downstream crate, the
macros such as `gst_plugin_define!` leak the clippy warnings for the
unsafe functions.

Silence the warnings for now.
2019-11-18 10:25:06 +01:00
Sebastian Dröge 9f121b1f12 gstreamer/sample: Silence clippy warning
warning: methods called `new` usually return `Self`
   --> gstreamer/src/sample.rs:107:5
    |
107 | /     pub fn new<'a>() -> SampleBuilder<'a> {
    | |_____^
2019-11-14 12:11:10 +00:00
Sebastian Dröge 0c944cb26e gstreamer: Add documentation to gst::deinit() about when it's safe to be called 2019-11-14 12:11:10 +00:00
Sebastian Dröge 8b687ab4a7 Remove header from the README.md about the move from github to gitlab
At this point everybody should've noticed.
2019-11-14 10:21:02 +00:00
Guillaume Desmottes 1206dc5b15 gstreamer: typefind: add binding for gst_type_find_get_length() 2019-11-14 09:33:29 +00:00
Sebastian Dröge 043af60126 iterator: Fix leak of the closure in Iterator::filter() 2019-11-13 12:18:21 +01:00
Sebastian Dröge 3d1b3211bf promise: Add unit test for change func handling 2019-11-13 12:13:14 +01:00
Sebastian Dröge d69e8e237f promise: Remove unneeded feature gates 2019-11-13 12:05:25 +01:00
Sebastian Dröge cd55f02e20 promise: Change change_func to get the actual reply of the promise passed 2019-11-13 11:40:41 +01:00
Sebastian Dröge 77c6741ae0 Update to futures 0.3 and require Rust 1.39
Also use async/await in the futures examples.
2019-11-11 12:18:49 +01:00
Guillaume Gomez 9e30687d8e Fix glib reexports 2019-11-11 11:34:09 +01:00
Guillaume Gomez a58cd4b5bc Manual code fixes 2019-11-11 11:34:09 +01:00
Guillaume Gomez 457ac9118b Regenerate with latest gir 2019-11-11 11:34:09 +01:00
Sebastian Dröge 8dcf3fec20 gstreamer: Change Sample constructor to the builder pattern
Simplifies construction of Samples considerably.
2019-10-23 09:55:56 +03:00
Sebastian Dröge 2d2459ed52 Export traits from the crate level and ensure that all traits are in the preludes 2019-10-17 13:30:35 +03:00
Sebastian Dröge 132eb891ed Fix dox feature and docs.rs Cargo.toml metadata 2019-10-05 00:13:29 +03:00
Sebastian Dröge 991f2e1576 Update and regenerate everything with latest gir 2019-10-05 00:03:57 +03:00
Fernando Jimenez Moreno 591468f53b gstreamer/log: Use non-panicking UTF8 conversion in log handler
Make sure that `log_handler` and `DebugMessage::get` do not panic while
processing non-UTF8 characters by using lossy instead of strict UTF8
string conversion.
2019-10-04 09:03:28 +00:00
Sebastian Dröge 06cfcd57fc Move to_string() methods into the Display trait or rename to to_str(), move from_string() into the FromStr trait
Fixes clippy warnings, prevents confusing errors and is more consistent.

The Display trait provides a to_string() method by itself and FromStr
provides from_str().
2019-10-04 11:01:55 +03:00
Sebastian Dröge 861f5c1e1a Re-run cargo fmt
Minor changes in the latest version.
2019-10-04 08:19:24 +03:00
Sebastian Dröge 19b3427909 clock: Move wake_id() from ClockId to ClockImpl
This shouldn't really be called on anything outside a Clock
implementation.
2019-09-26 11:25:52 +03:00
Sebastian Dröge 6abb0d3506 gstreamer: Add support for subclassing gst::SystemClock 2019-09-25 17:22:15 +03:00
Sebastian Dröge bacf4998ce clock: Add some more ClockId API for being able to implement clock subclasses 2019-09-25 17:22:15 +03:00
Sebastian Dröge 4e60a0aea4 clock: Add support for setting/getting/unsetting clock flags 2019-09-25 17:22:15 +03:00
Sebastian Dröge 1faf41986b gstreamer: Add bindings for ClockEntryType and ClockFlags 2019-09-25 17:22:15 +03:00
Sebastian Dröge 1c8b2c671b gstreamer: Add support for subclassing gst::Clock 2019-09-25 17:22:15 +03:00
Sebastian Dröge 74b05f0272 gstreamer: Add support for implementing gst::TagSetter interface 2019-09-25 17:22:11 +03:00
Sebastian Dröge eda3539330 gstreamer: Add support for implementing gst::Preset interface 2019-09-25 16:11:54 +03:00
Jan Alexander Steffens (heftig) 29710d9970 gstreamer: Assert that FromValueOptional works as expected
Fails without the preceding patch.
2019-09-24 10:34:44 +00:00
Jan Alexander Steffens (heftig) dca2cc1c5d gstreamer: Remove bad asserts in two impl FromValueOptional
These prevented actually getting a None out of a Value which contains a
NULL.
2019-09-24 10:34:44 +00:00
Jan Alexander Steffens (heftig) eaacee49de
iterator: Simplify StdIterator a bit 2019-09-24 11:31:28 +02:00
Sebastian Dröge 79d3888c3d Update CHANGELOG.md for 0.14.5 2019-09-17 15:41:12 +03:00
Fernando Jimenez Moreno de7a9dee1e Fix Windows build 2019-09-13 09:55:32 +02:00
Sebastian Dröge 7868018abb gstreamer/element: Add support for ElementClass::add_metadata() 2019-09-12 10:18:23 +03:00
Sebastian Dröge 6dcd255815 gstreamer/deviceprovider: Add support for subclassing gst::DeviceProvider 2019-09-12 10:18:23 +03:00
Sebastian Dröge 9df56faf48 gstreamer/device: Add support for creating gst::Device subclasses 2019-09-11 22:46:15 +03:00
Sebastian Dröge 8208ee0891 gstreamer/device: Device::create_element() is transfer floating, not transfer full
See https://gitlab.freedesktop.org/gstreamer/gstreamer/issues/444
2019-09-11 22:41:59 +03:00
Sebastian Dröge 52509b4b95 Remove subclassing feature and make it the default 2019-09-09 11:51:07 +03:00
Sebastian Dröge ea367bac14 Fix or ignore various clippy warnings
And ignore some common warnings we don't care about in general, while
also making clippy errors fail the build.
2019-09-07 19:39:19 +03:00
Jan Alexander Steffens (heftig) 105412b5a0
Iterator: Test that Iterator can be used in a for loop
`for x in foo` depends on foo implementing IntoIterator.
2019-09-05 11:01:16 +02:00
Jan Alexander Steffens (heftig) 7a12c4d5e1
Iterator: Replace ad-hoc fn iter with impl IntoIterator
std has a trait for converting things into Iterators. Make use of it.
2019-09-05 10:33:54 +02:00
Jan Alexander Steffens (heftig) a30935ad1f
Iterator: Add a wrapper implementing std's Iterator
Transposing the item type lets us be a std-compatible Iterator.

The iterator is automatically resynced when resuming iteration after
yielding Resync. This lets some combinators like `collect` and `find`
work properly.
2019-09-04 14:34:05 +02:00
Jan Alexander Steffens (heftig) db61ec4a6b
Iterator: Manually implement Debug
The derived implementation is restricted to `where T: Debug`, but the
iterator doesn't actually contain a value of type T.
2019-09-04 14:34:04 +02:00
Jan Alexander Steffens (heftig) 8db9926107
log_handler test: Ignore unknown categories
Tests run parallel in multiple threads. This makes the log_handler test
flaky because it may see log messages triggered by other threads. Make
the handler ignore all messages not in the category we care about.
2019-09-04 14:02:55 +02:00
Vivia Nikolaidou 6488c42890 element: Added num_pads, num_src_pads, num_sink_pads
Exposing the corresponding struct element in GstElement
2019-09-03 17:14:47 +03:00
François Laignel 8af1da1a4e Fully qualify inner macros for exported macros...
... otherwise they can't be resolved in dependent crates compiled
for edition 2018.
2019-09-02 09:06:29 +00:00
Mathieu Duponchelle d3d503cea6 subclass/element: expose set_clock and provide_clock vmethods 2019-08-31 02:05:21 +02:00
François Laignel 1367becfaf DateTime: manual impl for PartialOrd, PartialEq and Debug
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/217
2019-08-21 12:34:15 +02:00
François Laignel ced522ed08 Implement ser / de for Date Values, Structure fields and Tags 2019-08-19 15:51:42 +02:00
François Laignel c74eef374a Fix serde for Values with optional Types
Attention: these changes induce breaking changes for the serde
representation of some types.

Serialization of `Value`s used to rely on the `get` function
followed by an `unwrap`. This means that optional types couldn't
be serialized when they were `None`.

This commit distinguishes between the optional `Value` `Types` and
the ones that always return some value.

The `Value`s, `Structure` fields and `Tag`s with following types are
now represented as `Option`s:

- `Buffer`
- `DateTime`
- `Sample` (note: this type is used for `Tag` images)
- `String` (except for `Tag`s - see the comment in `tags_serde.rs`).

The representations for these `Type`s remain unchanged when they are
used in-place (not as part of a `Value`).

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/215
2019-08-19 15:34:24 +02:00
François Laignel 26423a069c structure::tests: use error constructors 2019-08-16 15:04:01 +02:00
Sebastian Dröge f050750b5e Update CHANGELOG.md for 0.14.4 2019-08-14 22:48:16 +03:00
Sebastian Dröge e00781309b gstreamer/element: Use from_glib_none() for the release_pad() trampoline
The reference to the pad we get passed is not guaranteed to be valid for
the whole scope of release_pad(). It might be the last reference as
owned by GstElement, and gst_element_remove_pad() would destroy it then.
2019-08-14 11:58:05 +03:00
Sebastian Dröge 2829c7ee2f gstreamer: Add StructureRef::get_optional()
This only returns Err on type mismatches. If the field does not exist or
None it returns None, otherwise the value.

StructureRef::get() returns Err also if the field does not exist.
2019-08-13 18:30:40 +03:00
Sebastian Dröge 1b860825ee Update feature flags of all dependencies to include the same version as for the crate itself
This improves build times as it allows cargo to reuse more previous
build results when building crates separately.

Also remove the serde-pickle dependency. It was only used in a single
test and caused pulling in of quite a few dependencies.
2019-08-13 16:46:08 +03:00
François Laignel 514a05accd Manual update for new Value::get signature 2019-08-13 10:57:32 +02:00
François Laignel 5d012945df Regen 2019-08-11 10:43:30 +02:00
François Laignel 26fda95a54 Fix functions unit tests for v < 1_12 2019-08-08 19:38:42 +02:00
Josh Matthews 0e36ac5205 Add high level bindings for adding new log handlers and removing the default handler. 2019-07-22 16:06:41 +00:00
Sebastian Dröge fcc361f920 gstreamer: Add bindings for gst::calculate_linear_regression() 2019-07-17 00:24:13 +03:00
Sebastian Dröge eb59456ae3 Update CHANGELOG.md for 0.14.3 2019-07-16 12:47:15 +03:00
Sebastian Dröge 007f80ca32 buffer: Allow setting/unsetting buffer flags
As there are extension flags types, we need separate setter/unsetter
functions for the flags, or otherwise we would always clear the
extension flags types (e.g. GstVideoBufferFlags).
2019-07-16 11:51:23 +03:00
Sebastian Dröge 36b0cafc5e Update CHANGELOG.md for 0.14.2 2019-07-15 20:03:48 +03:00
Sebastian Dröge ae58a469d1 meta: Add support for ReferenceTimestampMeta 2019-07-14 22:32:10 +03:00
Sebastian Dröge d8325212f4 Fix various clippy warnings 2019-07-11 22:02:01 +03:00