Commit graph

139 commits

Author SHA1 Message Date
Marijn Suijten
e88994a0b7 use cfg_if to refactor some #[cfg()] / #[cfg(not())] pairs 2020-11-19 16:39:31 +01:00
Marijn Suijten
aeb1b70581 Remove doc(cfg()) from expressions
warning: unused doc comment
       --> gstreamer-video/src/video_info.rs:655:37
        |
    655 |           #[cfg_attr(feature = "dox", doc(cfg(feature = "v1_12")))]
        |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
    656 | /         {
    657 | |             VideoInfoBuilder {
    658 | |                 format,
    659 | |                 width,
    ...   |
    674 | |             }
    675 | |         }
        | |_________- rustdoc does not generate documentation for expressions

Also simplify some blocks into expressions which are allowed to have
attributes as well since Rust 1.43.
2020-11-19 16:39:31 +01:00
Marijn Suijten
bd75778fcb Add doc(cfg()) on all manual files 2020-11-19 16:39:31 +01:00
François Laignel
c987bb0c7d gstreamer/message: enhance Debug impl for Message[Ref]
When "{:?}" printing a Message[Ref], the following issues lower the
experience:

- If the Message seqnum is GST_SEQNUM_INVALID (0), a panic occurs due
  to an assertion failure in MessageRef::get_seqnum.
- The src of the Message displays the GString address.

Origin issue for an occurrence of the first case above fixed in
https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/-/merge_requests/860
2020-10-13 11:11:38 +02:00
François Laignel
fa3f6eefc9 message: get_seqnum: return next seqnum if Message seqnum is invalid
See https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/601
2020-10-13 11:11:38 +02:00
Sebastian Dröge
a4239c3462 gstreamer: Remove API that was deprecated in 0.16 2020-08-24 17:33:35 +03:00
Sebastian Dröge
af01f1bc67 gstreamer: Simplify MiniObject bindings by removing one layer of abstraction
And instead directly implementing this via the macro on the target
types.
2020-06-30 11:06:02 +03:00
François Laignel
f421d878b6 message: add constructor on target types
... and deprecate the `Message::new_*` forms.
2020-06-25 10:48:20 +02:00
Sebastian Dröge
6e431ce060 Run everything through rustfmt again
It got some improvements for applying consistent formatting to code
blocks in macros.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/-/merge_requests/468>
2020-04-24 12:46:16 +03: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
Guillaume Gomez
a58cd4b5bc Manual code fixes 2019-11-11 11:34:09 +01:00
Sebastian Dröge
3a8d05075d Switch everything from mem::uninitialized() to MaybeUninit or mem::zeroed()
And also fix a few cases where mem::uninitialized() was simply wrong to
use.
2019-07-11 17:56:50 +03:00
Sebastian Dröge
d1e562b9f6 Explicitly add dyn keyword to trait objects
Trait objects without are deprecated with the latest nightly and this
makes it more clear that we're doing dynamic dispatch anyway.
2019-06-06 09:09:34 +03:00
Vivia Nikolaidou
05d936fcee gstreamer: Add binding for GstMessageType and gst_bus_timed_pop_filtered
Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer-rs/issues/168
2019-05-10 19:35:13 +03:00
Sebastian Dröge
b2b8bfab52 Add manual implementations for various new 1.16 functions 2019-04-23 20:45:39 +03:00
Sebastian Dröge
54705f959a message: DeviceAdded/Removed getters are transfer full 2019-04-23 20:45:39 +03:00
Sebastian Dröge
e7898c1b24 Update manual code 2019-04-15 19:19:19 +03:00
Sebastian Dröge
8c39da4e5b Update to Rust 1.31 linter-specific attributes 2019-03-04 15:16:01 +02:00
Sebastian Dröge
cc3c3876ab Implement Debug for EventView and MessageView 2019-01-22 16:55:59 +02:00
Sebastian Dröge
36bcb5630a Remove various unused use statements 2018-12-08 14:58:14 +02:00
Sebastian Dröge
fb0178a4f2 Call gst::init() in message::test_other_fields() test at the beginning 2018-11-03 20:15:27 +02:00
Sebastian Dröge
eb0a804a50 Run everything through latest rustfmt 2018-10-08 15:02:23 +03:00
Sebastian Dröge
6fd0ed4cb3 Move all minobjects to newtype wrapper types
For consistency with external crates and to help rustdoc, which gets
confused on impl blocks for type aliases.
2018-09-28 18:11:46 +03:00
Sebastian Dröge
a43c78f2c5 Run everything through rustfmt 2018-09-28 13:15:18 +03:00
Sebastian Dröge
33a6aab6d7 Run everything through latest rustfmt 2018-07-27 13:36:40 +03:00
Sebastian Dröge
694bcaa697 Fix all clippy warnings
Or silence the ones we don't care about.
2018-07-20 10:28:20 +03:00
Thibault Saunier
2962f186f7 Print pointer value when formatting debug strings 2018-05-14 09:22:25 +03:00
Sebastian Dröge
2cefd9aea6 Re-run everything through rustfmt 2018-04-25 11:13:14 +03:00
Sebastian Dröge
492c3d656c Run everything through rustfmt again 2018-04-01 11:57:58 +03:00
François Laignel
406eb119d3 message: add test_other_fields
Fixes https://github.com/sdroege/gstreamer-rs/pull/93
2018-03-19 10:32:07 +02:00
Sebastian Dröge
0112d22804 Various manual 1.14 API additions and remove deprecated functions 2018-03-19 10:32:07 +02:00
Sebastian Dröge
4117c01ff2 Run everything through latest rustfmt-nightly 2018-02-22 11:18:37 +01:00
fengalin
da924e5d4d Event & Message: factorize common attributes in generic builders
Concrete events and messages share common attributes which can be factorized in generic builder `struct`s. This reduces noise in the concrete implementations.
2018-01-29 17:33:49 +02:00
fengalin
2d1218e6d6 Event, Message & Query: allow dereferencing concrete types to access generic type methods
Implement `deref` for concrete derivatives of `Event`, `Message` and `Query`. This allows accessing generic methods such as `is_sticky` for events, `get_seqnum` for messages or `is_serialized` for queries and `get_structure` for all.
2018-01-29 17:33:49 +02:00
fengalin
86812c1a53 MessageBuilder: comment out other_fields related methods until GStreamer v1.14 is released
These methods are commented out in order to maintain consistency between messages with and without arguments. It will be restored and conditioned to feature "v1_14" when GStreamer v1.14 is released.
2018-01-29 10:07:42 +02:00
fengalin
3c65a50076 Fix building argument-less messages
Building an argument-less message such as eos yields an assertion failure due to the inner structure being null. The short term solution consists in checking that the inner `structure` is not `null` before attempting to insert `other_fields`. The consequence is that `others_fields` defined for argument-less messages will be ignored. A correction will be applied when GStreamer 1.14 is released thank to the introduction of `gst_message_writable_structure` (see https://bugzilla.gnome.org/show_bug.cgi?id=792928). Due to the dependency on GStreamer 1.14, the correction will be only available under the activation of a feature "v1_14".

Events are not affected as the build method the availability of `gst_event_writable_structure` and this function "will never return NULL". However, we can avoid a `structure` allocation for argument-less messages without `other_fields`.
2018-01-29 10:07:42 +02:00
Sebastian Dröge
9b6efb2339 Fix various clippy warnings 2017-12-20 21:46:58 +02:00
Sebastian Dröge
e0dc84c10a Run everything through rustfmt again 2017-12-20 19:30:14 +02:00
Sebastian Dröge
62058ab1c3 Use &ToSendValue for the stream-status stream_object in the builder 2017-12-16 18:39:50 +02:00
Sebastian Dröge
ccf6c1a632 Owner of structure-change and stream-status messages is mandatory 2017-12-16 18:39:33 +02:00
Sebastian Dröge
bcf6b34c1b Code/text of progress messages is mandatory 2017-12-16 18:38:53 +02:00
Sebastian Dröge
974e681a5d Move optional taglist/entry_struct fields into the Redirect builder from the constructor 2017-12-16 18:13:25 +02:00
Sebastian Dröge
7bc1fce97d Move value for PropertyNotification message into the builder instead of constructor 2017-12-16 18:10:10 +02:00
Sebastian Dröge
b9c4e4cd6e Allow no value for the PropertyNotify message
It can contain no value.

Also use &ToSendValue instead of an actual value for building the
message.
2017-12-16 15:37:06 +02:00
Sebastian Dröge
c99928d030 Change FormatValue related API to be more convenient to use
FormatValue is now renamed to GenericFormattedValue and the API slightly
changed. In addition there is now a FormattedValue trait, and a
SpecificFormattedValue trait plus types for Bytes, Buffers and the
existing ClockTime.

This allows to create functions like
  Pad::query_duration<F: SpecificFormattedValue>() -> Option<F>
and doesn't require the caller to unwrap the generic value anymore,
which is completely unneeded in these cases.

In addition, Segment became FormattedSegment<T> with API to
upcast/downcast between the specific formatted values and the generic
formatted value. This greatly simplifies usage of Segments.
2017-12-09 19:45:18 +02:00
Sebastian Dröge
f1c6c4fd06 Change various integers to FormatValue and ClockTime in events/queries/messages 2017-12-05 22:43:37 +02:00
Sebastian Dröge
55f044dd83 Add newtype wrappers and INVALID constants for event/message GroupId and Seqnum 2017-12-05 21:33:04 +02:00
Sebastian Dröge
411f54afed Run everything to rustfmt again 2017-12-01 19:02:53 +02:00
Sebastian Dröge
fccb1eca5e Implement fmt::Debug more consistently for miniobjects and various other types 2017-12-01 11:34:01 +02:00
Sebastian Dröge
c57d5523d2 Implement ToOwned for Message/Event/QueryRef 2017-12-01 11:34:01 +02:00
Sebastian Dröge
1576ff6c32 Event/Message::get_structure() can return None 2017-12-01 11:33:21 +02:00
Sebastian Dröge
2508f432f4 Remove some unneeded lifetime annotations 2017-11-27 14:03:33 +02:00
Sebastian Dröge
1dbc63dcb3 Message::get_src() can return None
The src is optional
2017-11-16 13:58:42 +02:00
Sebastian Dröge
7eb8429046 Run everything through latest rustfmt-nightly again 2017-11-15 22:33:51 +02:00
Sebastian Dröge
0629a0283e Use SendValue instead of Value for all our GValue usage
We require types that can be sent between threads.
2017-11-15 20:32:52 +02:00
Sebastian Dröge
d4bd1c2d76 Add dox feature to everything as needed 2017-11-12 13:33:02 +01:00
Sebastian Dröge
c39c0c7264 Implement ClockTime as ClockTime(Option<u64>)
And also implement a FormatValue type that holds a value together with
its format to make usage of the positions/durations/seek positions/etc
more convenient and safe.

Fixes https://github.com/sdroege/gstreamer-rs/issues/3
2017-11-11 11:57:29 +01:00
Sebastian Dröge
e1d134c4be Run everything through latest rustfmt-nightly 2017-10-17 12:06:51 +03:00
Sebastian Dröge
de10335167 Allow creating Error/Warning/Info messages only from specific kinds of glib::Error domains 2017-09-15 18:35:54 +03:00
Sebastian Dröge
499ca3eff3 Also implement Sync+Send for Event and Message 2017-09-14 15:52:40 +03:00
Sebastian Dröge
608279c6d4 Fix various clippy warnings 2017-09-13 23:54:22 +03:00
Sebastian Dröge
17cce1a3d7 Add support for setting custom fields in message/events during construction 2017-09-13 22:38:19 +03:00
Sebastian Dröge
85b335fd89 Fix/hide various clippy warnings in gstreamer 2017-09-10 15:21:26 +03:00
Sebastian Dröge
dae1a51764 Work around rustdoc bug with impls on type aliases
https://github.com/rust-lang/rust/issues/44182
2017-08-30 15:12:11 +03:00
Sebastian Dröge
f0935d7e1e Add remaining gst_init() assertions 2017-08-30 14:39:09 +03:00
Sebastian Dröge
14adb331ec Implement StaticType on the actual MiniObjects, not the GstRc wrapper 2017-08-18 16:21:49 +03:00
fengalin
04f09ebc86 Add bindings for GstToc/TocSetter
https://github.com/sdroege/gstreamer-rs/pull/22

Fixes https://github.com/sdroege/gstreamer-rs/issues/10
2017-08-09 19:38:39 +03:00
Sebastian Dröge
a0c6db70e0 Add Context support for messages/queries 2017-08-02 20:58:33 +03:00
Sebastian Dröge
d7baadee22 Fix various other compiler/clippy warnings 2017-08-02 20:09:00 +03:00
Sebastian Dröge
09db28bbf5 Fix various clippy warnings 2017-08-02 19:40:31 +03:00
Sebastian Dröge
03285a6311 Run everything through latest rustfmt-nightly 2017-07-31 12:16:42 +01:00
Sebastian Dröge
f06bc0d6ef Add event example and clean-up event/message constructor API 2017-07-30 15:49:25 +01:00
Sebastian Dröge
2c949a9a05 Add Event bindings
And make Message bindings more consistent
2017-07-30 15:06:44 +01:00
Sebastian Dröge
02a4c8c14d Add new() functions for all messages 2017-07-29 14:56:34 +01:00
Sebastian Dröge
69e1fdd529 Add Query bindings 2017-07-29 13:52:31 +01:00
Sebastian Dröge
9c357abf1a Add support for Fractions 2017-07-12 13:25:11 +03:00
Sebastian Dröge
8421cec1ee Implement message types that use tag lists / structures 2017-07-12 11:06:21 +03:00
Sebastian Dröge
71c0885575 Remove some unused "use"s 2017-07-11 00:36:38 +03:00
Sebastian Dröge
4c5aa49fa2 Run manual code through rustfmt 2017-07-11 00:33:24 +03:00
Sebastian Dröge
4964495b03 Implement some more missing API now that we have Structure 2017-07-11 00:26:27 +03:00
Sebastian Dröge
1264f2f5c0 Rename MessageImpl to MessageRef
These will show up as (possibly mutable) references later in API from
which we explicitly borrow references instead of getting a new one.
2017-07-10 17:12:24 +03:00
Sebastian Dröge
e43bf21ded Add initialization safety assertions
Ensure that GStreamer is initialized before allowing to call any
functions
2017-07-10 17:12:14 +03:00
Sebastian Dröge
992105b49f Implement basic GstStructure bindings 2017-07-10 17:10:15 +03:00
Sebastian Dröge
4808865371 Implement Builder for all Messages 2017-07-07 14:39:22 +03:00
Sebastian Dröge
9b91024221 Implement all message parsing API 2017-07-05 01:47:33 +03:00
Sebastian Dröge
cb26c0aaed Remove some useless message code 2017-07-03 18:45:59 +03:00
Sebastian Dröge
9a364c26c6 Remove EOS message constructor for now
These should probably all use the builder pattern
2017-07-03 18:11:26 +03:00
Sebastian Dröge
eeea572c96 Implement further parts of the Message machinery 2017-07-03 17:52:10 +03:00
Sebastian Dröge
aa3581cee9 Add initial Message/MiniObject bindings 2017-07-03 14:01:08 +03:00