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
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
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.
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))
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.
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.
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.
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.
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.
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.
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().
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.
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.
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
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.
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.
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.
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).