Commit graph

2174 commits

Author SHA1 Message Date
Olivier Crête
6379433a70 aggregator: Protect data with the same mutex as GCond
Whenever a GCond is used, the safest paradigm is to protect
the variable which change is signalled by the GCond with the same
mutex that the GCond depends on.

https://bugzilla.gnome.org/show_bug.cgi?id=742684
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
d33e6a191e aggregator: Nitpick spacing/punctuation in debug logging 2017-12-02 15:10:26 +00:00
Olivier Crête
ec5ff5f308 aggregator: Remove pointless atomic
It is only modified from the streaming thread
2017-12-02 15:10:26 +00:00
Olivier Crête
53dd0c650f aggregator: Fix query leak 2017-12-02 15:10:26 +00:00
Sebastian Dröge
4534253145 aggregator: Print jitter from clock waiting in the debug logs 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
f4ad5f0cdf aggregator: don't use iterator when setting flush pending on pads 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
0db6fc999b aggregator: check if pads are ready more efficiently
No need to use an iterator for this which creates a temporary
structure every time and also involves taking and releasing the
object lock many times in the course of iterating. Not to mention
all that GList handling in gst_aggregator_iterate_sinkpads().
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
100d860ad2 aggregator: name vfunc arguments consistently 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
50908e60d0 aggregator: add g-i transfer and scope annotations 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
6af6dcb0f7 aggregator: register names of iterate_sinkpads functions with debug system 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
417445c065 aggregator: reduce debug messages for taking/releasing logs to TRACE level
Don't spam debug log with this stuff.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
c5e3fe807a aggregator: move property member into private structure
Our locking (or lack thereof) while accessing this also
looks generally quite dodgy.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
b813456233 aggregator: remove empty dispose function 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
71ec8e2879 aggregator: give private functions namespace prefix
Especially the GST_DEBUG_FUNCPTR ones.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
3793bb8ad9 aggregator: fix up some docs comments in header 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
7302a42ac1 aggregator: remove now-unused system clock member 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
9f417fb08e aggregator: make GstAggregatorPadForeachFunc take an GstAggregatorPad 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
601554df70 aggregator: bring start/stop vfunc semantics in line with other baseclasses
Sub-class should not have to chain up to GstAggregator's start/stop
vfuncs, same as in GstBaseSrc, GstBaseSink, GstBaseTransform etc.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
a7e2a01098 aggregator: remove pointless GST_DEBUG_FUNCPTR
Not useful for GObject vfuncs.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
760d3c5611 aggregator: remove duplicate pad parent_class variable
G_DEFINE_TYPE already provides one, just need to use it.
2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
85171e3512 aggregator: add _CAST() variants for cast macros 2017-12-02 15:10:26 +00:00
Tim-Philipp Müller
5350d8c653 aggregator: make padding larger
Esp. the class structures, can't have enough
spare space for virtual functions.
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
ced334d397 aggregator: Log to the pad instead of the element
More correct way of doing the same thing as before
2017-12-02 15:10:26 +00:00
Sebastian Dröge
8da3d1e596 aggregator: Make sure that the minimum latencies are never GST_CLOCK_TIME_NONE 2017-12-02 15:10:26 +00:00
Sebastian Dröge
4846f06b41 aggregator: Wait for the minimum latency, not the maximum
The minimum latency is the latency we have to wait at least
to guarantee that all upstreams have produced data. The maximum
latency has no meaning like that and shouldn't be used for waiting.
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
d18b6de2e6 aggregator: Clamp the min latency at the max if it's greater 2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
b49805a840 aggregator: Print the sinkpad name while logging latency queries
Very useful while debugging.
2017-12-02 15:10:26 +00:00
Nirbheek Chauhan
bbde713640 aggregator: Take the stream lock when iterating sink pads
When iterating sink pads to collect some data, we should take the stream lock so
we don't get stale data and possibly deadlock because of that. This fixes
a definitive deadlock in _wait_and_check() that manifests with high max
latencies in a live pipeline, and fixes other possible race conditions.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
9bac89113e aggregator: Don't leak flush-start events 2017-12-02 15:10:26 +00:00
Sebastian Dröge
f2814fa5e3 aggregator: Also change the default latency to 0, not just the minimum 2017-12-02 15:10:26 +00:00
Sebastian Dröge
6697f1521a aggregator: Fix docs and default value of the latency property 2017-12-02 15:10:26 +00:00
Sebastian Dröge
4c477549d2 aggregator: Also include the subclass latency in the result of the latency query 2017-12-02 15:10:26 +00:00
Sebastian Dröge
5caf89da37 aggregator: Post a latency message if the value of the latency property changes 2017-12-02 15:10:26 +00:00
Sebastian Dröge
7240852e55 aggregator: Wake up the src thread after handling a latency query
Due to changed latencies or changed live-ness we might have to
adjust if we wait on a deadline at all and how long.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
a20863a7ec aggregator: Don't count the number of times we need to wake up but instead check all conditions for waiting again
This simplifies the code and also makes sure that we don't forget to check all
conditions for waiting.

Also fix a potential deadlock caused by not checking if we're actually still
running before starting to wait.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
b1dcc7efb0 aggregator: Add function to allow subclasses to set their own latency
For audiomixer this is one blocksize, for videoaggregator this should
be the duration of one output frame.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
435a477f63 aggregator: Add a timeout parameter to ::aggregate()
When this is TRUE, we really have to produce output. This happens
in live mixing mode when we have to output something for the current
time, no matter if we have enough input or not.
2017-12-02 15:10:26 +00:00
Sebastian Dröge
bf5652f84a aggregator: Some minor cleanup 2017-12-02 15:10:26 +00:00
Matthew Waters
f4b86a6d8c aggregator: make the src pad task drive the pipeline for live pipelines
This removes the uses of GAsyncQueue and replaces it with explicit
GMutex, GCond and wakeup count which is used for the non-live case.

For live pipelines, the aggregator waits on the clock until either
data arrives on all sink pads or the expected output buffer time
arrives plus the timeout/latency at which time, the subclass
produces a buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=741146
2017-12-02 15:10:26 +00:00
Sebastian Dröge
47d0efacf2 aggregator: Unblock events/queries immediately if the pad is flushing
https://bugzilla.gnome.org/show_bug.cgi?id=740376
2017-12-02 15:10:26 +00:00
Sebastian Dröge
f3c741e74e aggregator: Drop serialized events/queries if the pad is flushing
https://bugzilla.gnome.org/show_bug.cgi?id=740376
2017-12-02 15:10:26 +00:00
Sebastian Dröge
0ad159dfb4 aggregator: Block serialized events/queries until the pad has consumed all buffers
Otherwise the caps of the pad might change while the subclass still works with
a buffer of the old caps, assuming the the current pad caps apply to that
buffer. Which then leads to crashes and other nice effects.

https://bugzilla.gnome.org/show_bug.cgi?id=740376
2017-12-02 15:10:26 +00:00
Sebastian Dröge
e3b42c8acb aggregator: Fix typo in debug output 2017-12-02 15:10:26 +00:00
Matthew Waters
4bdbb7a98f aggregator: add _get_latency() for subclass usage
API: gst_aggregator_get_latency

https://bugzilla.gnome.org/show_bug.cgi?id=739996
2017-12-02 15:10:26 +00:00
Vineeth T M
376de6cef3 audiomixer: critical error for blocksize, timeout min/max values
Audiomixer blocksize, cant be 0, hence adjusting the minimum value to 1
timeout value of aggregator is defined with MAX of MAXINT64,
but it cannot cross G_MAXLONG * GST_SECOND - 1
Hence changed the max value of the same

https://bugzilla.gnome.org/show_bug.cgi?id=738845
2017-12-02 15:10:26 +00:00
Matthew Waters
3c8198e99f aggregator: add latency query handling 2017-12-02 15:10:26 +00:00
Matthew Waters
efdcc6c8eb aggregator: add a timeout property determining buffer wait time
Determines the amount of time that a pad will wait for a buffer before
being marked unresponsive.

Network sources may fail to produce buffers for an extended period of time,
currently causing the pipeline to stall possibly indefinitely, waiting for
these buffers to appear.

Subclasses should render unresponsive pads with either silence (audio), the
last (video) frame or what makes the most sense in the given context.
2017-12-02 15:10:26 +00:00
Jan Alexander Steffens (heftig)
e8c34afd5f aggregator: Replace GMainContext with GAsyncQueue (v2)
The previous implementation kept accumulating GSources,
slowing down the iteration and leaking memory.

Instead of trying to fix the main context flushing, replace
it with a GAsyncQueue which is simple to flush and has
less overhead.

https://bugzilla.gnome.org/show_bug.cgi?id=736782
2017-12-02 15:10:26 +00:00
Mathieu Duponchelle
aaff6b50f8 aggregator: Set seqnum only when segments are received. 2017-12-02 15:10:26 +00:00
Thibault Saunier
1efd6b2edd aggregator: Add a streaming lock so to secure flush start action
Without a lock that is taken in FLUSH_START we had a rare race where we
end up aggregating a buffer that was before the whole FLUSH_START/STOP
dance. That could lead to very wrong behaviour in subclasses.
2017-12-02 15:10:25 +00:00
Thibault Saunier
d5a3056ef2 aggregator: Query seeking when a seek failed to see if it was expected
And do not worry if seeking failed on a stream that is not seekable
2017-12-02 15:10:25 +00:00
Mathieu Duponchelle
f6adb43916 aggregator: set future seqnum before propagating the seek event.
So the seqnum is properly set for the following events.
2017-12-02 15:10:25 +00:00
Thibault Saunier
eb1d322962 aggregator: Store segment when seeked in READY for later use 2017-12-02 15:10:25 +00:00
Sebastian Dröge
034e74b216 aggregator: Unref the taglist in GstAggregator::stop() 2017-12-02 15:10:25 +00:00
Thibault Saunier
cc14d18e08 aggregator: Take lock to ensure set_caps is not called concurently
Avoiding to be in an inconsistent state where we do not have
actual negotiate caps set as srccaps and leading to point where we
try to unref ->srccaps when they have already been set to NULL.

https://bugzilla.gnome.org/show_bug.cgi?id=735042
2017-12-02 15:10:25 +00:00
Matthew Waters
1a0b4f88c2 aggregator: fix up doc comment for set_src_caps
It does not occur 'later' anymore

https://bugzilla.gnome.org/show_bug.cgi?id=732662
2017-12-02 15:10:25 +00:00
Matthew Waters
42e2933133 videoaggregator: push the caps event as soon as we receive it
Along with the required mandatory dependent events.

Some elements need to perform an allocation query inside
::negotiated_caps().  Without the caps event being sent prior,
downstream elements will be unable to answer and will return
an error.

https://bugzilla.gnome.org/show_bug.cgi?id=732662
2017-12-02 15:10:25 +00:00
Mathieu Duponchelle
5ef53b8a29 aggregator: Reset flow_return *after* stopping the srcpad task.
Otherwise it might be set in an already running aggregate function.
2017-12-02 15:10:25 +00:00
Thibault Saunier
e3075ed3ef aggregator: Flush sinkpads when stopping
All values are meaningless in that case, so we should make sure that
we clean everything
2017-12-02 15:10:25 +00:00
Thibault Saunier
7e5d9daf8e aggregator: Do not forget to reset the flow return when stoping
Setting it to FLUSHING when the element is not started, and to OK
when it starts.
2017-12-02 15:10:25 +00:00
Thibault Saunier
9a88538eca aggregator: Handle event seqnum 2017-12-02 15:10:25 +00:00
Tim-Philipp Müller
3a49e1c311 aggregator: fix locking
We would unlock a mutex we never locked on SEGMENT
events.
2017-12-02 15:10:25 +00:00
Thibault Saunier
481476c439 aggregator: Avoid destroying sources we do not own
+ Unref the maincontext in a new dispose function
+ Make sure to remove all sources on dispose

https://bugzilla.gnome.org/show_bug.cgi?id=732445
2017-12-02 15:10:25 +00:00
Thiago Santos
259a73a3dc aggregator: always store or unref the buffer on the _chain function
Otherwise it leaks, and it is very common to go to flushing when the
pipeline is stopping, leaking a buffer.
2017-12-02 15:10:25 +00:00
Thiago Santos
109f7c937b aggregator: always unref the buffer on _finish function
Otherwise the user doesn't know if it was unref'd or not
2017-12-02 15:10:25 +00:00
Thiago Santos
5f1b50fce4 aggregator: add dispose/finalize functions
Add functions to be able to cleanup the mutex/cond and pending buffers
on the aggregator and on its pad
2017-12-02 15:10:25 +00:00
Matthew Waters
19c8fcfa28 aggregator: plug a memory leak of the srccaps 2017-12-02 15:10:25 +00:00
Thibault Saunier
eace37b743 libs:base: Properly declare APIs as UNSTABLE 2017-12-02 15:10:25 +00:00
Thibault Saunier
bd03141055 aggregator: Fix requested pad name 2017-12-02 15:10:25 +00:00
Thibault Saunier
ae91ee2c98 aggregator: Add new GstAggregator base class
This base class has been added to a newly created libgstbadbase library

Co-Authored by: Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>

https://bugzilla.gnome.org/show_bug.cgi?id=731917
2017-12-02 15:10:23 +00:00
Tim-Philipp Müller
db3ea93439 libs: fix indentation 2017-11-24 13:40:33 +01:00
Havard Graff
df27ec3e67 gstbasetranform: replace GST_BASE_TRANSFORM with GST_BASE_TRANSFORM_CAST
To avoid a global type-lock on chain etc.
2017-11-24 13:39:39 +01:00
Edward Hervey
40187f9247 typefindhelper: Fix overflow some more
Nothing guaranteed that off+size wouldn't exceed a 2**64 value.

Instead we reverse the operation and use a subtraction.
2017-11-04 11:48:40 +01:00
Edward Hervey
4ccdad084b typefindhelper: Fix signed integer overflow
Make sure the whole calculation is done with 64bit unsigned values

(To be ready for people want to typefind exabyte files).
2017-11-04 10:34:10 +01:00
Ashish Kumar
250d3e7284 queuearray: Fix for possible crashes due to null pointer dereferencing
https://bugzilla.gnome.org/show_bug.cgi?id=788838
2017-10-16 14:04:58 +03:00
Stefan Sauer
7eea54d6a1 collectpads: mention the query function in the docs as well 2017-10-15 15:59:11 +02:00
fengalin
6617b01af9 flowcombiner: Fix version for ref and unref functions
The functions were introduced in version 1.12.1, GstFlowCombiner was
introduced in 1.4.

https://bugzilla.gnome.org/show_bug.cgi?id=788778
2017-10-10 18:39:26 +03:00
Tim-Philipp Müller
2841b8f0b2 basesink: use new gst_buffer_list_calculate_size() utility function 2017-10-05 13:35:14 +01:00
Havard Graff
fee176d253 meson: remove vs_module_defs
The GST_EXPORT should handle it.
2017-10-05 09:35:41 +01:00
Reynaldo H. Verdejo Pinochet
402159fb88 Use proper GtkDoc notation for NULL/FALSE/TRUE 2017-10-03 13:54:25 -07:00
Tim-Philipp Müller
39e21bb6dd baseparse: fix taglist update spam
We would constantly re-post the taglist because
posted_avg_rate only gets set to avg_bitrate if
parse->priv->post_avg_bitrate is true, so if it's
false the posted rate will always differ from the
current average rate and we'd queue an update,
which leads to us spamming downstream and the
application with taglist updates.

Fix this by only queuing an update if the average
rate will actually be posted.

These taglists updates could cause expensive
operations on the application side, e.g. in Totem.

https://bugzilla.gnome.org/show_bug.cgi?id=786561
2017-08-25 17:36:33 +01:00
Tim-Philipp Müller
b37429c995 basesrc: deprecate non-functional "typefind" property
https://bugzilla.gnome.org/show_bug.cgi?id=736565
2017-07-14 17:00:48 +01:00
Jason Lin
5bd4603ed3 basesink: fix buffer leaks if preroll failed
buffer is not unreferened if preroll failed

:Detailed Notes:
- Problem : video freeze when switching from pause to 1/2-FF repeatedly
- RootCause : buffer leaks in basesink
- Solution : unref the buffer if prerolled failed

:Testing Preformed:
How to Test :
pause -> 1/2 FF -> resume -> pause -> 1/2 FF ...

https://bugzilla.gnome.org/show_bug.cgi?id=784932
2017-07-14 14:02:52 +10:00
George Kiagiadakis
bd5b1d00e6 basesrc: forward SINK_MESSAGE events downstream
https://bugzilla.gnome.org/show_bug.cgi?id=784551
2017-07-12 15:23:42 +03:00
Stefan Sauer
2ace5f4191 basesink: use GST_CLOCK_TIME macros for readability
Replace some -1 comparison with GST_CLOCK_TIME macros.
2017-07-09 21:20:03 +02:00
Stefan Sauer
7a4df51b08 collectpads: correct some comments and add more logging
Add more logging to analyze event handling (especially failure cases).
2017-07-09 21:17:43 +02:00
Stefan Sauer
c6bd520b8b docs: add a missing const in bytereader docs
This syncs the prototype with gstbytereader.h
2017-06-29 21:08:01 +02:00
Nicolas Dufresne
dd5905c31a basesrc: Removed unused private member qos_enabled 2017-06-29 10:51:33 -04:00
Nicolas Dufresne
2be51ba60c basesrc: Don't reallocate buffers when flushing
Instead of using gst_buffer_pool_set_active() when flushing, use
gst_buffer_pool_set_flushing(), this avoids uneeded reallocation of the
buffers.
2017-06-29 10:51:33 -04:00
Nicolas Dufresne
523de1a9dc basesrc: Don't hold LIVE_LOCK in create/alloc/fill
Holding this lock on live source prevents the source from changing
the caps in ::create() without risking a deadlock. This has consequences
as the LIVE_LOCK was replacing the STREAM_LOCK in many situation. As a
side effect:

- We no longer need to unlock when doing play/pause as the LIVE_LOCK
  isn't held. We then let the create() call finish, but will block if
  the state have changed meanwhile. This has the benefit that
  wait_preroll() calls in subclass is no longer needed.
- We no longer need to change the state to unlock, simplifying the
  set_flushing() interface
- We need different handling for EOS depending if we are in push or pull
  mode.

This patch also document the locking of each private class member and
the locking order.

https://bugzilla.gnome.org/show_bug.cgi?id=783301
2017-06-29 10:51:33 -04:00
Nicolas Dufresne
946622ec3f basesrc: Protect access to pool and allocator
This was only partly protected by the object lock. Always take the
object lock to access the currently configured pool and allocator.

https://bugzilla.gnome.org/show_bug.cgi?id=783301
2017-06-29 10:51:33 -04:00
Nicolas Dufresne
632952be87 baseparse: sinkcaps can be NULL in default caps negotiation
This was causing harmless assertion about the unreffed caps not being of
type caps.

https://bugzilla.gnome.org/show_bug.cgi?id=784041
2017-06-22 16:00:45 -04:00
Sebastian Dröge
35b426ff19 base: Export boxed type copy/free functions for the remaining types 2017-06-20 09:57:01 +03:00
Olivier Crête
67a496c0c2 basesrc: Hold object lock while updating latency
Otherwise in gst_base_src_query_latency(), it ended up
sometimes thinking it wasn't -1 when it was actually.
2017-05-23 00:51:49 +02:00
Sebastian Dröge
daa98fc02a gst: Don't ref_sink() GstObject subclasses in instance_init/constructor
This is something bindings can't handle and it causes leaks. Instead
move the ref_sink() to the explicit, new() constructors.

This means that abstract classes, and anything that can have subclasses,
will have to do ref_sink() in their new() function now. Specifically
this affects GstClock and GstControlSource.

https://bugzilla.gnome.org/show_bug.cgi?id=743062
2017-05-17 10:40:37 +03:00
Tim-Philipp Müller
d8f23c9786 libs: base: mark symbols explicitly for export with GST_EXPORT 2017-05-15 23:13:53 +01:00
Tim-Philipp Müller
3d8d81ecb7 g-i: no need to load registry in g-i scanner 2017-05-04 21:59:48 +01:00
Sebastian Dröge
733de3190b adapter: Check if meta transform_func is NULL before using it
https://bugzilla.gnome.org/show_bug.cgi?id=782050
2017-05-02 14:27:14 +03:00
Frédéric Dalleau
ca7fa6a661 basetransform: Check if meta transform_func is NULL before using it
An untested pointer segfaulted in webkit while playing video
on imx6 sabrelite. It turned out that the imx plugin didn't
implement the meta transform function.

The following GST_DEBUG trace was visible:
gstbasetransform.c:1779:foreach_metadata:<conv2> copy metadata
                                                GstImxVpuBufferMetaAPI

Thread 26 vqueue:src received signal SIGSEGV, Segmentation fault.

(gdb) bt
 0x00000000 in ?? ()
 0x73f8d7d8 in foreach_metadata (inbuf=0xc9b020, meta=0x474b2490,
                  user_data=<optimized out>) at gstbasetransform.c:1781
 0x73eb3ea8 in gst_buffer_foreach_meta (buffer=buffer@entry=0xc9b020,
                  func=0x73f8d705 <foreach_metadata>,
                  user_data=user_data@entry=0x474b24d4)
                  at gstbuffer.c:2234

https://bugzilla.gnome.org/show_bug.cgi?id=782050
2017-05-02 14:26:21 +03:00
Yasushi SHOJI
c423df49af basetransform: fix typo in debug log output
This unbalanced closing parenthesis is leftover from the commit
8b739d91e7. It used to wrap the caps but we don't seem to do that in
the current code.

So, just remove it. No functionality has been changed.

https://bugzilla.gnome.org/show_bug.cgi?id=781484
2017-04-19 09:21:32 +01:00
Rico Tzschichholz
72e42f0ce9 meson: A couple for GIR-generation fixes 2017-04-13 10:05:53 +01:00
Tim-Philipp Müller
519d64881f Don't use deprecated g_object_newv()
Use g_object_new() instead which nowadays has a shortcut for the
no-properties check. It still does an extra GType check in the
function guard, but there's a pending patch to remove that
and it's hardly going to be a performance issue in practice,
even less so on a system that's compiled without run-time checks.

Alternative would be to move to the new g_object_new_properties()
with a fallback define for older glib versions, but it makes the
code look more unwieldy and doesn't seem worth it.

Fixes deprecation warnings when building against newer GLib versions.

https://bugzilla.gnome.org/show_bug.cgi?id=780903
2017-04-08 09:49:59 +01:00
Sebastian Dröge
50ec7129bb queuearray: Add G_BEGIN_DECLS and G_END_DECLS to make it usable from C++ code 2017-03-24 14:21:55 +02:00
Jan Schmidt
e571002dcb baseparse: Don't forget error returns when processing more
If parsing returns a non-OK flow return in the middle
of processing an input buffer, don't overwrite that
if a later return is OK again - the subclass might
return not-linked in the middle, and then discard
subsequent data without pushing while returning OK.

A later success doesn't invalidate the earlier failure,
but we should continue processing after not-linked, so
as to keep parse state consistent.

https://bugzilla.gnome.org/show_bug.cgi?id=779831
2017-03-22 11:42:53 +11:00
Tim-Philipp Müller
834fd18dfa bytereader: fix peek value when scanning for 00 00 01 with non-0 offset
We would add the offset a second time in _scan_for_start_code()
when we found a result, but it's already been added to the data
pointer at the beginning of _masked_scan_uint32_peek(), so the
peeked value would be wrong if the initial offset was >0, and
we would potentially read memory out-of-bounds.

Add unit test for all of this.

https://bugzilla.gnome.org/show_bug.cgi?id=778365
2017-02-22 11:07:24 +00:00
Stefan Sauer
c189827619 gstbasesink: xref symbol in docs 2017-02-15 21:37:31 +01:00
Thibault Saunier
a87b4551a6 Port gtk-doc comments to their equivalent markdown syntax
Modernizing our documentation and preparing a possible move to hotdoc.
This commits also adds missing @title metadatas to all SECTIONs
2017-01-27 16:36:38 -03:00
Julien Isorce
b2c05cac8e baseparse: correctly handle non-flush seek
Otherwise when seeking/looping to the start when reaching the end,
the sink waits for the duration of the stream. So the user hears
nothing for the duration of the stream before it actually loop again.
See example attached to the bug for that.

Existing test:
gst-plugins-good/tests/icles/test-segment-seeks foo.flac
Without the patch the user hears a crack/cut at each seek.

https://bugzilla.gnome.org/show_bug.cgi?id=777780
2017-01-26 16:51:21 +00:00
Mark Nauwelaerts
9bcebaacc7 baseparse: also unset DISCONT on buffers in reverse playback fragments 2016-12-28 13:46:33 +01:00
Fabrice Bellet
de65529d52 basesink: fix a use after free case
The event may be disposed while being pushed, so we make sure the
debug infrastructure won't use it after the gst_pad_push().
2016-12-17 09:40:25 +05:30
Olivier Crête
e6febb5bc1 basesink: Document the interaction between unlock() and wait_preroll()
This was totally non-obvious, the kind of big problem is that subclasses must
be able to unblock their streaming thread and continue exactly where they left off
on unpause!

https://bugzilla.gnome.org/show_bug.cgi?id=773912
2016-11-23 11:58:43 -05:00
Sebastian Dröge
f08c8d2da3 basetransform: Ensure to set the RECONFIGURE flag again if reconfiguration failed
It might've failed just because of flushing or other things, and we
should retry again on the next possibility if something ever calls in
here again.

https://bugzilla.gnome.org/show_bug.cgi?id=774623
2016-11-18 12:04:18 +02:00
Jan Schmidt
2e579a7c1b baseparse: Fix previous commit
Check the correct segment format value.

parse->segment.format is the format we're outputting in,
not the upstream format. Use parse->priv->upstream_format instead,
and make sure it's set in pull mode.
2016-11-16 00:30:26 +11:00
Jan Schmidt
d81c0aec81 baseparse: Restrict query/convert responses when demuxing
If the parser is not parsing a raw elementary stream, restrict
the position, duration and conversion query replies to
things we can sensibly answer about - especially don't do
random conversions to/from bytes.
2016-11-16 00:12:22 +11:00
Scott D Phillips
1e30725331 typefindhelper: Update prototype of helper_find_suggest()
forward declaration prototype is updated to match the change in:

 5a72c23 Change some types to match their prototypes

https://bugzilla.gnome.org/show_bug.cgi?id=774293
2016-11-15 14:29:36 +02:00
Scott D Phillips
5a72c23a54 Change some types to match their prototypes
Particularly note that the underlying integer type of the enum
GstTypeFindProbability is implementation dependent and may not match
guint.

https://bugzilla.gnome.org/show_bug.cgi?id=774293
2016-11-14 21:03:57 +02:00
Nicolas Huet
9cd2677791 adapter: fix distance when getting prev pts/dts at offset
https://bugzilla.gnome.org/show_bug.cgi?id=765662
2016-11-11 18:18:23 +00:00
Guillaume Desmottes
fcb938caae basetransform: fix pool leak when early returning in decide_allocation
https://bugzilla.gnome.org/show_bug.cgi?id=769023
2016-11-11 13:29:35 +00:00
Seungha Yang
562681a1b7 basesrc: Support PROTECTION event from application
Application may want to send PROTECTION event to the src element.

https://bugzilla.gnome.org/show_bug.cgi?id=769775
2016-11-11 13:07:51 +00:00
Nirbheek Chauhan
accd0b4129 meson: Add GstBase-1.0.gir to gst_base_dep
Without this, GIR generators can't find and use it
2016-11-11 04:41:39 +05:30
Tim-Philipp Müller
bce5d0fc55 baseparse: add since marker for new API to docs and fix win32 .def file 2016-11-10 13:49:29 +00:00
Vincent Penquerc'h
4caf66fbca baseparse: expose gst_base_parse_drain 2016-11-10 12:47:37 +00:00
Thibault Saunier
0079aea21c meson: Advertise dependency on gst_dep generating girs
And do not simply link to libgst as the gir information
location only exist in declare_dependecy

https://bugzilla.gnome.org/show_bug.cgi?id=774044
2016-11-09 17:00:49 -03:00
Nicolas Dufresne
7c8087f49a basesink: Make sure we never drop the preroll buffer
This is cosmetic as 'late' should never be set during preroll (in pause).
Though code may evolve in the future, so this is good for preventing
potential bugs.

https://bugzilla.gnome.org/show_bug.cgi?id=772468
2016-11-03 15:26:06 -04:00
Nicolas Dufresne
5ca63b7f04 basesink: Don't nest prepare/render calls
When the first buffer arrives, we endup calling:

  ->prepare()
    ->prepare()
    ->preroll()
  ->render()

This will likely confuse any element using this method. With this patch,
we ensure the preroll take place before the first render prepare() is
called. This will result in:

  ->prepare()
  ->preroll()
  ->prepare()
  ->render()

https://bugzilla.gnome.org/show_bug.cgi?id=772468
2016-11-03 13:19:46 -04:00
Luis de Bethencourt
c53b2e3740 basesink: fix typo in documentation
Small typo in the documentatin of gst_base_sink_set_drop_out_of_segment().
Fixing it.
2016-11-02 16:28:08 +00:00
Sebastian Dröge
c6a5798c74 basesink: Fix gst_base_sink_set_drop_out_of_segment() documentation
Also silences a GI warning.
2016-11-02 16:35:59 +02:00
Sebastian Dröge
9ea6af280d Revert "baseparse: fix draining with less data than min frame size available"
This reverts commit 2e278aeb71.

Some parsers, specifically audio parsers, assume to get all remaining
data on EOS and just pass them onwards. While the idea here is correct,
we will probably need a property for this on baseparse for parsers to
opt-in.

https://bugzilla.gnome.org/show_bug.cgi?id=773666
2016-11-02 09:35:05 +02:00
Jan Schmidt
bf3a7c54f7 Add new basesink API to exports and Since markers
Add Since markers to the new basesink API to drop
out-of-segment buffers, and add them to the
win32 exports
2016-11-02 11:34:47 +11:00
Jan Schmidt
812d4976f0 fakesink: Add property to not drop out-of-segment buffers
Implement handling in basesink to not unconditionally discard
out-of-segment buffers and expose it as a new property on fakesink
(not unconditionally in all basesink based sinks).

The property defaults to FALSE.

https://bugzilla.gnome.org/show_bug.cgi?id=765734
2016-11-02 11:21:37 +11:00
Tim-Philipp Müller
2e278aeb71 baseparse: fix draining with less data than min frame size available
baseparse would pass whatever is left in the adapter to the
subclass when draining, even if it's less than the minimum
frame size required. This is bogus, baseparse should just
discard that data then. The original intention of that code
seems to have been that if we have more data available than
the minimum required we should pass all of the data available
and not just the minimum required, which does make sense, so
we'll continue to do that in the case that more data is available.

Fixes assertions in rawvideoparse on EOS after not-negotiated with
fakesrc sizetype=random ! queue ! rawvideoparse format=rgb ! appsink caps=video/x-raw,format=I420

https://bugzilla.gnome.org/show_bug.cgi?id=773666
2016-11-01 20:33:56 +02:00
Nicolas Dufresne
eab0e76268 Revert "collectpads: Assume PTS is equal DTS if PTS is missing"
This reverts commit 9b0d42ceec.

https://bugzilla.gnome.org/show_bug.cgi?id=762207
2016-10-24 11:54:34 -04:00
Jesper Larsen
9ae7f465a5 adapter: Fix mix-up between DTS and PTS
https://bugzilla.gnome.org/show_bug.cgi?id=773319
2016-10-21 16:47:22 +03:00
Sebastian Dröge
dc0ed9a5eb basesink: Remove unused fields and always use the buffer timestamp difference for calculating the QoS proportion
The buffer timestamps are only hints and more often than not have
nothing to do with reality.

https://bugzilla.gnome.org/show_bug.cgi?id=771306
2016-09-15 10:56:58 +02:00
Sebastian Dröge
c1bd6677c6 basesink: Use the average durations based on timestamps for the QoS proportion when doing trickmodes
The durations of the buffers are (usually) assuming that no frames are being
dropped and are just the durations coming from the stream. However if we do
trickmodes, frames are being dropped regularly especially if only key units
are supposed to be played.

Fixes completely bogus QoS proportion values in the above case.
2016-09-08 15:19:38 +03:00
Thibault Saunier
4714ef2f8e Make use of the new GST_ELEMENT_FLOW_ERROR API all around.
https://bugzilla.gnome.org/show_bug.cgi?id=770158
2016-08-27 09:33:20 -03:00
Nirbheek Chauhan
b2f9808722 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Mathieu Duponchelle <mathieu.duponchelle@opencreed.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2016-08-19 21:26:14 +01:00
Aurélien Zanelli
ec2723d366 collectpads: add g-i transfer annotations to peek/pop/read_buffer/take_buffer functions
https://bugzilla.gnome.org/show_bug.cgi?id=768948
2016-07-20 12:34:00 +01:00
Sebastian Dröge
af0d087bbd basesrc: Fix automatic-eos=false mode if a segment.stop is given
If segment.stop was given, and the subclass provides a size that might be
smaller than segment.stop and also smaller than the actual size, we would
already stop there.

Instead try reading up to segment.stop, the goal is to ignore the (possibly
inaccurate) size the subclass gives and finish until segment.stop or when the
subclass tells us to stop.
2016-07-12 12:34:47 +03:00
Jan Alexander Steffens (heftig)
d71e03b3be baseparse: Don't add calculated bitrates until threshold
Waiting before posting calculated bitrates seems to be the
intent of the code, so avoid adding them to the tag list
pushed with the first frame.

When the threshold is reached, gst_base_parse_update_bitrates
sets tags_changed, so this posts the calculated ones right
that moment.

This prevents an insane average calculated from just the
first (key) frame from getting posted.

https://bugzilla.gnome.org/show_bug.cgi?id=768439
2016-07-05 19:42:38 +03:00
Sebastian Dröge
8e8b8a8d34 baseparse: Make sure to not create an invalid event order when generating the default CAPS event because of a GAP event
There must be a SEGMENT event before the GAP event, and SEGMENT events must
come after any CAPS event. We however did not produce any CAPS yet, so we need
to ensure to insert the CAPS event before the SEGMENT event into the pending
events list.

https://bugzilla.gnome.org/show_bug.cgi?id=766970
2016-07-04 10:35:41 +02:00
Sebastian Dröge
b9a4a2a952 basesink: Update start time when losing state only if we were in PLAYING
If we were in PAUSED, the current clock time and base time don't have much to
do with the running time anymore as the clock might have advanced while we
were PAUSED. The system clock does that for example, audio clocks often don't.

Updating the start time in PAUSED will cause a) the wrong position to be
reported, b) step events to step not just the requested amount but the amount
of time we spent in PAUSED. The start time should only ever be updated when
going from PLAYING to PAUSED to remember the current running time (to be able
to compensate later when going to PLAYING for the clock time advancing while
PAUSED), not when we are already in PAUSED.

Based on a patch by Kishore Arepalli <kishore.arepalli@gmail.com>

The updating of the start time when the state is lost was added in commit
ba943a82c0 to fix the position reporting when
the state is lost. This still works correctly after this change.

https://bugzilla.gnome.org/show_bug.cgi?id=739289
2016-06-13 20:20:44 +02:00
Sebastian Dröge
8c7da1d426 adapter: Rename functions and implement new functions, update test
We don't do calculations with different units (buffer offsets and bytes)
anymore but have functions for:
1) getting the number of bytes since the last discont
2) getting the offset (and pts/dts) at the last discont

and the previously added function to get the last offset and its distance from
the current adapter position.

https://bugzilla.gnome.org/show_bug.cgi?id=766647
2016-06-10 09:49:33 +03:00
Edward Hervey
67ae0ad225 adapter: Add methods to query current offset
API: gst_buffer_prev_offset
API: gst_buffer_get_offset_from_discont

The gst_buffer_get_offset_from_discont() method allows retrieving the current
offset based on the GST_BUFFER_OFFSET of the buffers that were pushed in.

The offset will be set initially by the GST_BUFFER_OFFSET of
DISCONT buffers, and then incremented by the sizes of the following
buffers.

The gst_buffer_prev_offset() method allows retrievent the previous
GST_BUFFER_OFFSET regardless of flags. It works in the same way as
the other gst_buffer_prev_*() methods.

https://bugzilla.gnome.org/show_bug.cgi?id=766647
2016-06-10 09:49:33 +03:00
Edward Hervey
ea395c2498 baseparse: Make sure DISCONT flags are properly propagated
If we drop a frame that contained a discontinuity, we must remember
that for the next frame that *will* be pushed downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=766795
2016-06-07 09:42:39 +02:00
Tim-Philipp Müller
0274650e42 g-i: pass compiler env to g-ir-scanner
It's what introspection.mak does as well. Should
fix spurious build failures on gnome-continuous.
2016-05-24 00:40:27 +01:00
Sebastian Dröge
d184e7a9a0 basesink/src: Post an error message if ::start() fails
The subclass should do that already, but just in case do it ourselves too as a
fallback. Without this, e.g. playbin will just wait forever if this fails
because it is triggered as part of an ASYNC state change.
2016-05-15 11:04:25 +03:00
Tim-Philipp Müller
246b285783 flowcombiner: add debug category
Not that it logs much.
2016-05-05 18:50:05 +01:00
Tim-Philipp Müller
5ebfe26a51 flowcombiner: fix docs for gst_flow_combiner_reset() 2016-05-05 18:02:21 +01:00
Sebastian Dröge
5294065985 baseparse: Remember if we interpolated DTS from PTS and refresh it whenever we update the PTS
Otherwise PTS and DTS will come out of sync if upstream continues to provide
PTS and not DTS, and we have to skip some data from the stream or PTS are not
exactly increasing with the duration of each packet.

https://bugzilla.gnome.org/show_bug.cgi?id=765260
2016-04-20 11:49:24 +03:00
Sebastian Dröge
c434b6486d typefindhelper: Fix gobject-introspection warning about invalid transfer annotation
gsttypefindhelper.c:485: Warning: GstBase: invalid "transfer" annotation for gsize: only valid for array, struct, union, boxed, object and interface types
2016-04-20 11:45:28 +03:00
Sebastian Dröge
895332e056 baseparse: When initializing DTS from PTS, remember that we did so
If we don't store the value in prev_dts, we would over and over again
initialize the DTS from the last known upstream PTS. If upstream only provides
PTS every now and then, then this causes DTS to be rather static.

For example in adaptive streaming scenarios this means that all buffers in a
fragment will have exactly the same DTS while the PTS is properly updated. As
our queues are now preferring to do buffer fill level calculations on DTS,
this is causing huge problems there.

See https://bugzilla.gnome.org/show_bug.cgi?id=691481#c27 where this part of
the code was introduced.

https://bugzilla.gnome.org/show_bug.cgi?id=765096
2016-04-15 16:02:29 +03:00
Sebastian Dröge
00e4499b15 Revert "basesink: Take PREROLL_LOCK in wait_event()"
This reverts commit 828a4627db.

The lock was already taken elsewhere, in gst_base_sink_event().
2016-04-12 15:17:36 +03:00
Sebastian Dröge
828a4627db basesink: Take PREROLL_LOCK in wait_event()
It is calling do_sync(), which requires the STREAM_LOCK and PREROLL_LOCK to be
taken. The STREAM_LOCK is already taken in all callers, the PREROLL_LOCK not.

https://bugzilla.gnome.org/show_bug.cgi?id=764939
2016-04-12 15:11:30 +03:00
Vineeth TM
8cc3e908c3 gstreamer: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763020
2016-03-24 14:43:41 +02:00
Nicolas Dufresne
9b0d42ceec collectpads: Assume PTS is equal DTS if PTS is missing
This is the best guess we can make if such a buffer reached the collect
pad. This is uncommon, we do expect parsers to have tried and fixed that
if possible (or needed).

https://bugzilla.gnome.org/show_bug.cgi?id=762207
2016-03-24 14:29:47 +02:00
Sebastian Dröge
87c0513569 baseparse: Recheck after pre_push_frame() if there are tags pending
Many parsers are storing tags only in pre_push_frame(), if we wouldn't check
afterwards we would push buffers before those tags and a lot of code assumes that
tags are available before preroll.

https://bugzilla.gnome.org/show_bug.cgi?id=763553
2016-03-14 12:23:29 +02:00
Evan Nemerson
d11e657412 docs: annotate C examples as such
https://bugzilla.gnome.org/show_bug.cgi?id=731292
2016-02-15 17:45:15 +00:00
Martin Kelly
86a46ee43b pushsrc: fix minor typos in header
https://bugzilla.gnome.org/show_bug.cgi?id=761970
2016-02-12 20:50:57 +00:00
Tim-Philipp Müller
78a832ebd5 baseparse: fix stray discont flag set on outgoing buffers in push mode
We have no guarantees about what flags are set on buffers we take
out of the GstAdapter. If we push out multiple buffers from the
first input buffer (which will have discont set), only the first
buffer we push out should be flagged as discont, not all of the
buffers produced from that first initial input buffer.

Fixes issue where the first few mp3 frames/seconds of data in push
mode were skipped or garbled in some cases, and the discont flags
would also trip up decoders which were getting drained/flushed for
every buffer. This was a regression introduced in 1.6 apparently.
2016-02-04 19:04:41 +00:00
HoonHee Lee
f90fd86d5f baseparse: Try to generate caps on the srcpad before forwarding GAP event
To configure downstream elements and complete initial pre-rolling,
ensure we have default output caps before forwarding GAP event.

https://bugzilla.gnome.org/show_bug.cgi?id=753899
2016-01-29 10:49:24 +01:00
Carlos Rafael Giani
91496281eb basesrc: Only set duration/position query values in case of query success
Currently, the query values are being set even if the query itself was
determined to have failed. Fix this to ensure the values are only set in
case of a query success.

https://bugzilla.gnome.org/show_bug.cgi?id=760479
2016-01-11 21:42:10 +01:00
Xavier Claessens
46f83f5fcd core: Add g_autoptr() support to all types
https://bugzilla.gnome.org/show_bug.cgi?id=754464
2015-12-14 12:06:55 -05:00
Athanasios Oikonomou
d10c488d63 baseparse: post tag list when avg bitrate changes at least 2%
Watching videos with variant bitrate is common to have delta
more than 10 kbps, resulting in tag list spam.

Instead of relying on fixed 10 kpbs delta, it is better to
calculale the difference in percentage and update tag list
only when bitrate changes more than 2%.

https://bugzilla.gnome.org/show_bug.cgi?id=759055
2015-12-08 11:34:13 +02:00
Reynaldo H. Verdejo Pinochet
63a9130f56 Drop usage of deprecated g-ir-scanner --strip-prefix flag 2015-12-02 15:02:25 -08:00
Thiago Santos
b93369c78a Revert "baseparse: do not overwrite header buffer timestamps"
This reverts commit 2c475a0355.

This causes issues with h264parse. It breaks timestamps as
there are headers in the middle of the stream and this patch
makes the timestamps for those differ from the ones that
are adjusted, creating a discontinuity and leading to sync
issues.
2015-11-19 00:57:17 -03:00
Thiago Santos
5feba38a4e Revert "baseparse: simplify code a bit"
This reverts commit 3984f7159a.
2015-11-19 00:57:08 -03:00
Thiago Santos
3984f7159a baseparse: simplify code a bit
Avoid repeated checks for testing if a buffer is a header
2015-11-16 08:22:14 -03:00
Thiago Santos
42d45a0f40 collectpads: handle buffer with dts-only when mapping to running time
Otherwise the buffer was left with the original values and later would
be compared with other buffers that were converted to runninn time,
leading to bad interleaving of multiple streams.

https://bugzilla.gnome.org/show_bug.cgi?id=757961
2015-11-14 10:50:35 -03:00
Thiago Santos
971ac61c36 baseparse: do not overwrite header buffer timestamps
baseparse tries to preserve timestamps from upstream if
it is running on a time segment and write that to
output buffers. It assumes the first DTS is going to be
segment.start and sets that to the first buffers. In case
the buffer is a header buffer, it had no timestamps and
will have only the DTS set due to this mechanism.

This patch prevents this by skipping this behavior for
header buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=757961
2015-11-14 10:50:35 -03:00
Tim-Philipp Müller
220dbfc13c docs: remove dummy function declarations with G_INLINE_FUNCTION for gtk-doc
gtk-doc can handle static inline functions just fine these days,
there's no need for this stuff any more.
2015-11-09 17:59:16 +00:00
Edward Hervey
16458daddb collectpads: Use GST_BUFFER_DTS_OR_PTS
Simplifies code a bit
2015-10-27 08:33:41 +01:00
Guillaume Desmottes
66b6d355e4 basesink: rename argument of PREROLL_{COND,LOCK} macros
They take a GstBaseSink instance as argument at not a GstPad. Rename the
argument to 'obj' which is not miss leading and in line with
GST_BASE_SINK_PAD(obj).

https://bugzilla.gnome.org/show_bug.cgi?id=756954
2015-10-22 13:49:06 +01:00
Sebastian Dröge
1efb451154 Use new GST_ENABLE_EXTRA_CHECKS #define
https://bugzilla.gnome.org/show_bug.cgi?id=756870
2015-10-21 14:31:56 +03:00
Edward Hervey
55f6582159 baseparse: Update internal position even if not linked
Our current position has nothing to do with being linked or not.

Avoids having stray segment updates fired every 2s
2015-10-12 17:30:38 +02:00
Stefan Sauer
05dbad27c5 index: mark two structs that don't have abi padding 2015-09-28 16:23:41 +02:00
Vivia Nikolaidou
44ba1565d9 segment: Replaced gst_segment_to_position with gst_segment_position_from_running_time
gst_segment_to_position might cause confusion, especially with the addition of
gst_segment_position_from_stream_time . Deprecated gst_segment_to_position
now, and replaced it with gst_segment_position_from_running_time.

Also added unit tests.
2015-09-26 00:00:08 +02:00
Sebastian Dröge
73263271bb basetransform: Print buffer PTS when submitting an input buffer 2015-09-23 20:31:48 +02:00
Nicolas Dufresne
2534e39e55 basetransform: Reconfigure before propose_allocation
There exist cases where a reconfigure event was propagated from
downstream, but caps didn't change. In this case, we would
reconfigure only when the next buffer arrives. The problem is that
due to the allocation query being cached, the return query parameters
endup outdated.

In this patch we refactor the reconfigurating code into a function, and
along with reconfiguring when a new buffer comes in, we also reconfigure
when a query allocation arrives.

https://bugzilla.gnome.org/show_bug.cgi?id=753850
2015-08-21 15:14:34 -07:00
Tim-Philipp Müller
a887d81bfa baseparse: avoid tag list spam if upstream provides bitrate tags already
Explicitly keep track again whether upstream tags or parser tags
already contain bitrate information, and only force a tag update
for a bitrate if we are actually going to add the bitrate to the
taglist later. This fixes constant re-sending of the same taglist,
because upstream provided a bitrate already and we didn't add it,
so we didn't save the 'posted' bitrate, which would then in turn
again trigger the 'bitrate has changed too much, update tags'
code path. Fixes tag spam with m4a files for example.

https://bugzilla.gnome.org/show_bug.cgi?id=679768
2015-08-18 15:51:53 +01:00
Tim-Philipp Müller
4ec358773a baseparse: fix tag handling
In 0.10 there were no sticky events, and all tag events
sent would just be merged with the previously-received
tags. In 1.x we have sticky events, and the tags in the
tag event(s) should at all times carry the complete tags,
so we can't just push some tags and then just push tags
with just bitrates to update the bitrates, etc.

Instead we need to keep track of the upstream stream tags
received, of the tags set by the video decoder subclass,
and send an updated tag event with the combined tags
including our own bitrate tags (if applicable) whenever
the upstream tags, the subclass tags or any of our bitrates
change.

https://bugzilla.gnome.org/show_bug.cgi?id=679768
2015-08-16 14:32:24 +01:00
Tim-Philipp Müller
41b85d91eb baseparse: add API for subclass to set tags
This is needed so that we can do proper tag handling
all around, and combine the upstream tags with the
tags set by the subclass and any extra tags the
base class may want to add.

API: gst_base_parse_merge_tags()

https://bugzilla.gnome.org/show_bug.cgi?id=679768
2015-08-16 14:32:23 +01:00
Tim-Philipp Müller
d60c249f51 baseparse: save upstream stream tags
We'll need those later.

https://bugzilla.gnome.org/show_bug.cgi?id=679768
2015-08-16 12:29:10 +01:00
Tim-Philipp Müller
bc1fb2d8b0 baseparse: minor code simplification
Use gst_pad_peer_query_duration() and remove a few
unnecessary levels of indentation. Rest of code might
looks a bit questionable, but leave it as is for now.
2015-08-15 18:41:31 +01:00
Thiago Santos
e0cc0e0888 basetransform: rework accept-caps
According to the design docs:
The ACCEPT_CAPS query is not required to work recursively, it can simply
return TRUE if a subsequent CAPS event with those caps would return
success.

So make it a shallow check instead of recursivelly check downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=748635
2015-08-13 14:07:35 -03:00
Thiago Santos
42acf05b22 basetransform: remove some dead code
Doesn't seem like it is going to get back to life anytime soon

Also removes a {} block that was likely used to keep the dead
code around.
2015-08-13 12:45:35 -03:00
Thiago Santos
7ec54c2217 basetransform: respect accept-caps intersect flag
GstPad has a flag for suggesting if the accept-caps
query should use intersect instead of the default
subset caps operation to verify if the caps would be
acceptable.

basetransform currently always uses the subset check and
this patch makes it honor the flag for using intersect
if it is set.

https://bugzilla.gnome.org/show_bug.cgi?id=748635
2015-08-13 06:01:36 -03:00
Vineeth TM
039ac81ee3 basetransform: remove unreachable return statement
https://bugzilla.gnome.org/show_bug.cgi?id=753538
2015-08-12 10:34:59 +01:00
Nicolas Dufresne
e24e902d2f basesink: Only drop buffer if their PTS is out of segment
As of now, even for stream completly inside segment, there is no
guarantied that the DTS will be inside the segment. Specifically
for H.264 with B-Frames, the first few frames often have DTS that
are before the segment.

Instead of using the sync timestamp to clip out of segment buffer,
take the duration from the start/stop provided by the sub-class, and
check if the pts and pts_end is out of segment.

https://bugzilla.gnome.org/show_bug.cgi?id=752791
2015-08-05 15:51:27 -04:00
Olivier Crête
5e5a14028a basetransform: Return FLOW_FLUSHING if negotiation fails during shutdown
https://bugzilla.gnome.org/show_bug.cgi?id=752800
2015-07-27 13:53:26 -04:00
Nicolas Dufresne
f9aa306747 basetransform: Avoid increasing query reference
gst_query_find_allocation_meta() requires the query to be
writable to work. This patch ensure avoids taking a reference
on the query, so we can now check if a certain allocation meta
is present.

https://bugzilla.gnome.org/show_bug.cgi?id=752661
2015-07-22 13:29:35 -04:00
Nicolas Dufresne
5b5cebf540 baseparse: Don't override gst_segment_do_seek()
This line has no purpose, clearly gst_segment_do_seek() is doing
the right job, also, having the start time (a timestamp) be that
same as time (the stream time) is quite odd.

https://bugzilla.gnome.org/show_bug.cgi?id=750783
2015-07-17 17:44:52 -04:00
Nicolas Dufresne
8b6e8701d5 baseparse: Fix extrapolation of seeksegment.stop
The stop shall be relative to start if extrapolated from the
duration.

https://bugzilla.gnome.org/show_bug.cgi?id=750783
2015-07-17 17:44:44 -04:00
Vineeth TM
6d78d32d51 baseparse: estimate duration on EOS
For files which are smaller than 1.5 seconds, the duration
estimation does not happen. So the duration will always be
displayed as 0. Updating the duration on EOS when the estimation
has not happened already

https://bugzilla.gnome.org/show_bug.cgi?id=750131
2015-07-10 15:23:43 -04:00
Hyunjun Ko
427400be1d adapter: change log message properly
https://bugzilla.gnome.org/show_bug.cgi?id=752116
2015-07-10 10:46:38 +03:00
Hyunjun Ko
af62e2874f adapter: fix to get valid (buffer_)list
get_list/get_buffer_list should be done with buffers in adapter remaining
while take_list/take_buffer_list flushes each buffer one by one.

https://bugzilla.gnome.org/show_bug.cgi?id=752116
2015-07-08 18:59:31 +03:00
Arnaud Vrac
ea8cabe084 baseparse: put buffer in a correct state after gst_adapter_get_buffer call
We must make the buffer writable to write its PTS and DTS, and also
reset its duration.

The behaviour is now the same as before commit c3bcbadd, except metas
might still be attached to the buffer extracted from the adapter.

https://bugzilla.gnome.org/show_bug.cgi?id=752092
2015-07-08 13:33:37 +03:00
Vineeth TM
274f4b784a baseparse: reverse playback in pull mode
right now reverse playback is disabled in pull mode.
enabling the code for the same and changing a bit of logic
to make reverse playback work.

https://bugzilla.gnome.org/show_bug.cgi?id=750783
2015-07-06 09:56:27 -04:00
Song Bing
8e2c72f125 basesink: Shouldn't drop buffer when sync=false
Shouldn't drop buffer when sync=false

https://bugzilla.gnome.org/show_bug.cgi?id=751819
2015-07-06 11:38:48 +03:00
Tim-Philipp Müller
d0f85838ab queuearray: allow storing of structs in addition to pointers
This way we don't have to allocate/free temporary structs
for storing things in the queue array.

API: gst_queue_array_new_for_struct()
API: gst_queue_array_push_tail_struct()
API: gst_queue_array_peek_head_struct()
API: gst_queue_array_pop_head_struct()
API: gst_queue_array_drop_struct()

https://bugzilla.gnome.org/show_bug.cgi?id=750149
2015-07-04 11:03:51 +01:00
Sebastian Dröge
231e77338c transform: Also copy POOL metas and make sure to copy over metas when creating subbuffers
POOL meta just means that this specific instance of the meta is related to a
pool, a copy should be made when reasonable and the flag should just not be
set in the copy.
2015-07-01 10:50:19 +02:00
Sebastian Dröge
fefd4622a3 adapter: Also copy POOL metas and make sure to copy over metas when creating subbuffers
POOL meta just means that this specific instance of the meta is related to a
pool, a copy should be made when reasonable and the flag should just not be
set in the copy.
2015-07-01 10:45:01 +02:00
Sebastian Dröge
c3bcbadd54 baseparse: Use new gst_adapter_get_buffer() API instead of gst_adapter_map()
This preserves GstMeta properly unless the subclass does special things. It's
enough to make h264parse's stream-format/alignment conversion pass through
metas as needed.

https://bugzilla.gnome.org/show_bug.cgi?id=742385
2015-06-30 18:40:28 +02:00
Sebastian Dröge
866f9ace5c adapter: Add get variants of the buffer based take functions
Main difference to gst_adapter_map() for all practical purposes is that
GstMeta of the buffers will be preserved.

https://bugzilla.gnome.org/show_bug.cgi?id=742385
2015-06-30 18:40:28 +02:00
Sebastian Dröge
e6757269db adapter: Copy over GstMeta from the input buffers to the output
All functions that return a GstBuffer or a list of them will now copy
all GstMeta from the input buffers except for meta with GST_META_FLAG_POOLED
flag or "memory" tag.

This is similar to the existing behaviour that the caller can't assume
anything about the buffer flags, timestamps or other metadata. And it's
also the same that gst_adapter_take_buffer_fast() did before, and what
gst_adapter_take_buffer() did if part of the first buffer or the complete
first buffer was requested.

https://bugzilla.gnome.org/show_bug.cgi?id=742385
2015-06-30 18:40:28 +02:00
Sebastian Dröge
c659446371 basetransform: Fix up documentation of transform_meta vfunc
By default we copy all metas that have no tags.
2015-06-29 13:58:04 +02:00
Hyunjun Ko
85aad81647 basesink: need to deep-copy last buffer list in drain
https://bugzilla.gnome.org/show_bug.cgi?id=751420
2015-06-24 10:52:56 +02:00
Sebastian Dröge
37a6e8d6df basesink: Unset the last buffer list if we only got a buffer
Also remember any preroll buffer list.
2015-06-22 14:04:45 +02:00
Hyunjun
7c34b4ed0f basesink: enable to get last sample including buffer list if needed
In case of a buffer list rendering, last-sample is not updated.
It needs to be updated and enable to get buffer list from last-sample.

https://bugzilla.gnome.org/show_bug.cgi?id=751026
2015-06-22 13:28:54 +02:00
Nicolas Dufresne
ddedc412f5 doc: Unify Since mark for attribute and enum
As this show up as prose in the doc, simply make it consistent
and "arguable" nicer to read.
2015-06-18 11:51:48 -04:00
Nicolas Dufresne
632431aecb gi: Use INTROSPECTION_INIT for --add-init-section
This new define was added to common. The new init section fixed
compilation warning found in the init line that was spread across
all files.
2015-06-16 18:08:24 -04:00
Nicolas Dufresne
66574a6238 doc: Document GstPushSrcClass 2015-06-14 10:59:51 -04:00
Nicolas Dufresne
e6ec142084 doc: Better document new GstCollectData.ABI.abi.dts
The doc generator get confused with the inline structure. So
workaround by wrapping the inner of the structure with
public/private mark, and document that GST_COLLECT_PADS_DTS macro
shall be used to access this.
2015-06-14 10:58:18 -04:00
Nicolas Dufresne
0e0a0c1b11 doc: Various doc fixes for libgstreamer-base
* Fix function name in sections.txt
* Add few missing or fix miss-named
* Workaround gtk-doc being confused with non typedef
  types (loose track of public/private
2015-06-14 10:56:28 -04:00
Nicolas Dufresne
bd9ea8d18f doc: Fix Since: marks
There was few Since: mark missing their column. Also unify the way
we set the Since mark on enum value and structure members. These
sadly don't show up in the index.
2015-06-13 20:19:59 -04:00
Nicolas Dufresne
4320337af6 doc: Remove gstindex from doc comment
Moving that to normal comment to silence the generator. GstIndex
is not in GStreamer library at the moment (removed from 0.10).
2015-06-13 13:55:27 -04:00
Nicolas Dufresne
32900408c1 gi: Set collectpads function param scope 2015-06-13 13:48:03 -04:00
Nicolas Dufresne
2f1c87094e gi: Skip allocator of non-boxed structure
These are not usable as they are, and can easily lead to crash
or leaks. This also silence warning from the scanner. If we manage to
make this usable, we can then remove that mark, it will require
to make this type boxed.
2015-06-13 13:42:58 -04:00
Tim-Philipp Müller
1164f91f1f libs: more doc scanner fixes
gstbasetransform.h:196: Warning: GstBase: "@submit_input_buffer" parameter unexpected at this location:
 * @submit_input_buffer: Function which accepts a new input buffer and pre-processes it.

gstnetcontrolmessagemeta.c:103: Warning: GstNet: gst_buffer_add_net_control_message_meta: unknown parameter 'message' in documentation comment, should be 'addr'
2015-06-13 15:06:11 +01:00
Nicolas Dufresne
51549bf6ba collectpads: Don't initially send an invalid DTS
Sending a possibly invalid DTS may confuse the muxers, which will
then think the DTS is going backward.

https://bugzilla.gnome.org/show_bug.cgi?id=740575
2015-06-12 17:20:16 -04:00
Nicolas Dufresne
b5e4f7bd9d collectpads: Add negative DTS support
Make gst_collect_pads_clip_running_time() function also store the
signed DTS in the CollectData. This signed DTS value can be used by
muxers to properly handle streams where DTS can be negative initially.

https://bugzilla.gnome.org/show_bug.cgi?id=740575
2015-06-12 17:20:16 -04:00
Jan Schmidt
0d96487879 basetransform: Add Since markers for new vfuncs
Add Since: 1.6 markers for the new submit_input_buffer() and
generate_output() vfuncs
2015-06-08 19:33:23 +10:00
Jan Schmidt
a198803bd6 basetransform: Split input buffer processing from output generation
Allow for sub-classes which want to collate incoming buffers or
split them into multiple output buffers by separating the input
buffer submission from output buffer generation and allowing
for looping of one of the phases depending on pull or push mode
operation.

https://bugzilla.gnome.org/show_bug.cgi?id=750033
2015-06-08 19:17:57 +10:00
Tim-Philipp Müller
828ceacc68 queuearray: remove duplicate assignment
We've already done this earlier in the function,
and nothing has changed since we first read it.
2015-05-30 12:40:44 +01:00
Matthew Waters
8bc0a6c562 basesink: use the slightly more correct take_sample for last-sample
gst_value_take_buffer() and gst_value_take_sample() both resolve to
g_value_take_boxed().  Use the method with the correct name if we
ever change that.
2015-05-25 21:05:56 +10:00
Jian
4f79c5e8da basesink: Fix QoS/lateness checking if subclass implements prepare/prepare_list vfuncs
In basesink functions gst_base_sink_chain_unlocked(), below code is used to
checking if buffer is late before doing prepare call to save some effort:
    if (syncable && do_sync)
      late =
          gst_base_sink_is_too_late (basesink, obj, rstart, rstop,
          GST_CLOCK_EARLY, 0, FALSE);

    if (G_UNLIKELY (late))
      goto dropped;

But this code has problem, it should calculate jitter based on current media
clock, rather than just passing 0. I found it will drop all the frames when
rewind in slow speed, such as -2X.

https://bugzilla.gnome.org/show_bug.cgi?id=749258
2015-05-14 11:18:12 +03:00
Ilya Konstantinov
b58245ac0a baseparse: fix GST_BASE_PARSE_FLAG_LOST_SYNC
Since frame->priv->discont was cleared earlier,
GST_BASE_PARSE_FLAG_LOST_SYNC was never being set.

Take the chance to refactor the frame creation a bit to
organize the flags setting and reset.

https://bugzilla.gnome.org/show_bug.cgi?id=738237
2015-04-28 12:57:35 -03:00
Thiago Santos
8641997630 baseparse: respect DISCONT flag on buffers
Drain the parser when a DISCONT buffer is received and then mark
the next buffer to be pushed as a DISCONT one

https://bugzilla.gnome.org/show_bug.cgi?id=745927
2015-04-28 12:54:08 -03:00
Tim-Philipp Müller
8e6561be91 Remove obsolete Android build cruft
This is not needed any longer.
2015-04-26 17:49:44 +01:00
Changbok Chea
60706692b3 basesrc: Remove unused assignment in perform_seek()
https://bugzilla.gnome.org/show_bug.cgi?id=748345
2015-04-23 14:03:23 +01:00
Vincent Penquerc'h
6240b03085 Revert "basesrc: fix pool leak on allocation query error path"
This reverts commit 84fdf50b2f.

It seems the bug was fixed independently, and the merge was
automagic, yielding two extra free calls.
2015-04-15 11:40:51 +01:00
Sebastian Dröge
7d3d4503a1 basesrc: Only set DTS to segment.start on the first buffer if subclass did not provide PTS
Otherwise we're going to set a rather arbitrary DTS of segment.start (usually
0) for live sources, which confuses synchronization if the source started
capturing at a later time. And it's especially wrong for raw media, for which
we should not set any DTS at all.

https://bugzilla.gnome.org/show_bug.cgi?id=747731
2015-04-13 09:23:02 +02:00
Vincent Penquerc'h
84fdf50b2f basesrc: fix pool leak on allocation query error path
It could be triggered by:

gst-launch-1.0 videotestsrc num-buffers=20 ! videcrop bottom=214748364 ! videoconvert ! autovideosink

Spotted while testing:

https://bugzilla.gnome.org/show_bug.cgi?id=743910
2015-04-07 11:41:40 +01:00
Sebastian Dröge
370076edd5 baseparse: Forward SEGMENT_DONE events immediately
There might be no more data coming afterwards, and we just drained everything
that was left to be pushed anyway.
2015-04-06 18:46:06 -07:00
Ilya Konstantinov
f35ec14d33 basesrc: do not leak buffer pool in error case
https://bugzilla.gnome.org/show_bug.cgi?id=747321
2015-04-04 11:14:12 +01:00
Sebastian Dröge
7742f0a0d3 basesrc: Fix documentation, buffer pools are unreffed and not freed 2015-04-03 13:19:33 -07:00
Nicolas Dufresne
43f2f925a9 basetransform: Add Since mark for new method
https://bugzilla.gnome.org/show_bug.cgi?id=734424
2015-04-02 17:32:42 -04:00
Thibault Saunier
506afa54df basetransform: Add a method to let subclasses cleanly update srcpad caps
API:
    gst_base_transform_update_src

https://bugzilla.gnome.org/show_bug.cgi?id=734424
2015-04-02 17:16:23 -04:00
Edward Hervey
e4d07e161d introspection: Don't use g-ir-scanner cache at compile time
It pollutes user directories and we don't need to cache it

https://bugzilla.gnome.org/show_bug.cgi?id=747095
2015-03-31 11:16:09 +02:00
Nicolas Dufresne
208696a774 basesrc: Flush-stop starts live task in paused
The flush-stop event should not restart the task for live sources unless
the element is playing. This was breaking seeks in pause with the rtpsrc.

https://bugzilla.gnome.org/show_bug.cgi?id=635701
2015-03-27 19:03:30 -04:00
Thiago Santos
a041d8862d baseparse: only post 'no valid frames' error if buffers were received
Otherwise baseparse will consider empty streams to be an error while
an empty stream is a valid scenario. With this patch, errors would
only be emitted if the parser received data but wasn't able to
produce any output from it.

This change is only for push-mode operation as in pull mode an
empty file can be considered an error for the one driving the
pipeline

Includes a unit test for it

https://bugzilla.gnome.org/show_bug.cgi?id=733171
2015-03-26 12:25:57 -03:00
Olivier Crête
187570aded baseparse: remove duplicate code
These are already freed by gst_base_parse_clear_queues()

https://bugzilla.gnome.org/show_bug.cgi?id=679768
2015-03-17 19:35:08 +00:00
Vincent Penquerc'h
780f71c4d5 baseparse: reset skip on segments and discontinuities
Large scale skip is an optimization, and thus it is safer to
stop skipping than to continue. Clear skip on segments and
discontinuities, as these are points where it is possible that
the original idea of "bytes to skip" changes.
2015-03-16 12:53:50 +00:00
Tim-Philipp Müller
01e44969df basesink: handle empty buffer list more gracefully
Don't abort, just ignore it. It's like a buffer
without memories.
2015-03-14 21:09:50 +00:00
Tim-Philipp Müller
2b4d066355 adapter: minor optimisation for gst_adapter_take_buffer_list()
Try to allocate buffer list with a suitable size from the
beginning to avoid having to re-alloc the buffer list array.
2015-03-14 21:09:45 +00:00
Tim-Philipp Müller
e6a0f52e3c adapter: add gst_adapter_take_buffer_list()
API: gst_adapter_take_buffer_list()
2015-03-14 17:22:22 +00:00
Tim-Philipp Müller
68012b4d23 collectpads: avoid multiple calls to gst_buffer_get_size() in macro 2015-03-14 16:02:03 +00:00
Tim-Philipp Müller
4a1cee3c44 adapter: avoid multiple calls to gst_buffer_get_size() in macro 2015-03-14 16:02:03 +00:00
Thiago Santos
5e15d4aa60 basesink: drain on allocation query
Allows buffers to be reclaimed when caps is to be renegotiated so
that bufferpools can be stopped. As the allocation query is
serialized all buffers have been already drained from the pipeline,
except this last_sample one.

https://bugzilla.gnome.org/show_bug.cgi?id=682770
2015-03-13 19:03:01 +00:00
Thiago Santos
901fea5985 basesink: when draining, deep copy the last buffer to unref old memory
Use gst_buffer_copy_deep() to force the copy of the underlying
memory instead of possibly doing a shallow copy of the buffer
and just referencing the memory

https://bugzilla.gnome.org/show_bug.cgi?id=745287
2015-03-13 18:37:04 +00:00