Commit graph

152 commits

Author SHA1 Message Date
George Kiagiadakis
bd2a1487cc splitmuxsrc: add a format-location signal that allows bypassing the location property
This signal allows a user to directly return a sorted list of
files to be joined, so that they don't have to follow the
filename pattern that the "location" property expects.

https://bugzilla.gnome.org/show_bug.cgi?id=753625
2016-05-05 10:49:07 +01:00
Xavier Claessens
0fc02f35c7 splitmuxsink: Fix deadlock case when source reaches EOS
https://bugzilla.gnome.org/show_bug.cgi?id=765072
2016-05-05 01:22:10 +10:00
Xavier Claessens
7886e8d8a0 spitmuxsink: Avoid creating small file at EOS
When EOS is reached, the current file get closed and the last
GOP in the mq was written in a new file.

https://bugzilla.gnome.org/show_bug.cgi?id=765072
2016-04-16 22:14:37 +10:00
Damian Ziobro
ae4484c2ba splitmuxsink: Add max_files_number property
https://bugzilla.gnome.org/show_bug.cgi?id=744612
2016-04-14 04:18:11 +10:00
Jan Schmidt
41d2b6f19e splitmux: Handle a hang draining out at EOS
Make sure that all data is drained out when the reference pad
goes EOS. Fixes a problem where data that arrives on other
pads after the reference pad finishes can stall forever and
never pass EOS.

https://bugzilla.gnome.org/show_bug.cgi?id=763711
2016-04-01 00:48:05 +11:00
Xavier Claessens
fb835c100a splitmuxsink: Fix occasional deadlock when ending file with subtitle
Deadlock occurs when splitting files if one stream received no buffer during
the first GOP of the next file. That can happen in that scenario for example:
 1) The first GOP of video is collected, it has a duration of 10s.
    max_in_running_time is set to 10s.
 2) Other streams catchup and we receive the first subtitle buffer at ts=0 and
    has a duration of 1min.
 3) We receive the 2nd subtitle buffer with a ts=1min. in_running_time is set to
    1min. That buffer is blocked in handle_mq_input() because
    max_in_running_time is still 10s.
 4) Since all in_running_time are now > 10s, max_out_running_time is now set to
    10s. That first GOP gets recorded into the file. The muxer pop buffers out
    of the mq, when it tries to pop a 2nd subtitle buffer it blocks because the
    GstDataQueue is empty.
 5) A 2nd GOP of video is collected and has a duration of 10s as well.
    max_in_running_time is now 20s. Since subtitle's in_running_time is already
    1min, that GOP is already complete.
 6) But let's say we overran the max file size, we thus set state to
    SPLITMUX_STATE_ENDING_FILE now. As soon as a buffer with ts > 10s (end of
    previous GOP) arrives in handle_mq_output(), EOS event is sent downstream
    instead. But since the subtitle queue is empty, that's never going to
    happen. Pipeline is now deadlocked.

To fix this situation we have to:
 - Send a dummy event through the queue to wakeup output thread.
 - Update out_running_time to at least max_out_running_time so it sends EOS.
 - Respect time order, so we set out_running_tim=max_in_running_time because
   that's bigger than previous buffer and smaller than next.

https://bugzilla.gnome.org/show_bug.cgi?id=763711
2016-04-01 00:48:05 +11:00
Thiago Santos
d738fa0787 splitmuxsink: only try to create internal sink if it doesn't exist
This allows splitmuxsink to be reused after being put to NULL.

Test included

https://bugzilla.gnome.org/show_bug.cgi?id=762893
2016-03-24 20:10:25 -03:00
Vineeth TM
1071309870 good: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763076
2016-03-24 14:32:20 +02:00
Aurélien Zanelli
84e441d268 multifilesink: close file on write error with next-file mode is set to buffer
If we have an error during fwrite call, file stays open and thus next
incoming buffer will trigger an assert when trying to opening a new
file.
This happens if we do not restart element, file is closed at stop, and
if application handles the returned GST_FLOW_ERROR to keep bin alive.

https://bugzilla.gnome.org/show_bug.cgi?id=762434
2016-02-23 11:34:31 +02:00
George Kiagiadakis
eafa9f08f7 splitmuxsrc: print potentially negative offset with a sign 2016-01-25 15:36:29 +01:00
Jan Schmidt
675a4088e5 splitmuxsink: Only update running time when it increases.
Don't increment running time from every buffer. The correct
logic to only increment when running time advances is a
little further down, so delete this left-over line.
2015-12-19 03:49:28 +11:00
Graham Leggett
1a55fd42af multifilesink: fix spelling of variable
https://bugzilla.gnome.org/show_bug.cgi?id=758390
2015-11-23 11:36:20 +00:00
Vineeth TM
b0114bacdb splitmuxpartreader: Fix GCond leak
inactive_cond is not being cleared resulting in memory leak.

https://bugzilla.gnome.org/show_bug.cgi?id=757924
2015-11-11 15:38:05 +01:00
George Kiagiadakis
4a78048cc5 splitmuxsink: do not destroy the multiqueue & muxer when going to NULL
Instead, delay it until all request pads have been released. This is
because the release_pad() vfunc requires the multiqueue and muxer to
be there in order to release their request pads as well. If those
elements are destroyed earlier, release_pad() does not work, no
pads are released and some resources are leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=753622
2015-10-28 22:39:44 +11:00
George Kiagiadakis
5e4caca709 splitmuxsink: post messages when fragments are being opened and closed
This can be useful for applications that need to track the created fragments
(to log them in a recording database, for example)

https://bugzilla.gnome.org/show_bug.cgi?id=750108
2015-10-03 00:52:23 +10:00
Ramiro Polla
f0a47d0b60 splitmuxsink: allow non-video streams to serve as reference
In the absence of a video stream, the first stream will be used as
reference.

https://bugzilla.gnome.org/show_bug.cgi?id=753617
2015-10-03 00:44:58 +10:00
George Kiagiadakis
20754db26f splitmuxsink: initialize mux_start_time properly
mux_start_time refers to the running_time of the buffer
that goes first in the output file. Normally this time is
0, so this variable is initialized to 0 during the state
change to PAUSED.

However, when dealing with dynamic pipelines and starting
a recording while the pipeline has already run for a while,
the running_time of the first buffer is > 0 and this causes
a problem with detecting the end of the first file(s) when
splitting by duration, because the code will later compare
the threshold_time with (last buffer running_time - mux_start_time)
and will get it wrong until mux_start_time advances enough
to make this difference < threshold_time, creating empty files
in the meantime.

https://bugzilla.gnome.org/show_bug.cgi?id=753624
2015-10-03 00:44:01 +10:00
Tim-Philipp Müller
29afa75858 multifilesrc: fix regression with starting from index set via index property
When we haven't started yet, set the start_index when we set the index property,
so that we start at the right index position after the initial seek. The index
property was never really meant to be for writing, but it used to work, so let's
support it for backwards compatibility.

https://bugzilla.gnome.org/show_bug.cgi?id=739472
2015-08-18 13:17:34 +01:00
Thiago Santos
72212198c7 splitmuxsink: remove extra \n at debug message 2015-08-03 13:46:16 -03:00
Thiago Santos
a930a1364a splitmuxsink: prevent deadlock when states change too fast
If the GOP is completed, pads have to start gathering for the
next one but it is possible that the the state might go to
COLLECTING_GOP_START and back to WAITING_GOP_COMPLETE before the
thread has a chance to wake up and proceed, leaving it trapped in
the check_completed_gop loop and deadlocking the other threads
waiting for it to advance.

To solve it, this patch also checks that tha input running time
hasn't changed to prevent this scenario.
2015-08-03 13:46:16 -03:00
Jan Schmidt
a0182dd943 splitmuxsink: Support mpegtsmux as a muxer.
As a fallback, look for a pad template sink_%d on
the muxer when requesting pads, to support mpegtsmux

https://bugzilla.gnome.org/show_bug.cgi?id=752999
2015-07-29 23:03:30 +10:00
Jan Schmidt
e7ec32801a splitmuxsrc: Use a separate lock to delay typefind.
Don't hold the main splitmux part lock over
the parent state change function, as it prevents
posting error messages that happen. Since the purpose
is to prevent typefinding from proceeding, use a
separate mutex just for that.
2015-07-29 23:03:18 +10:00
George Kiagiadakis
bbfa46363c splitmuxsink: add a "format-location" signal that allows better control over filenames
In certain applications, splitting into files named after a base
location template and an incremental sequence number is not enough.

This signal gives more fine-grained control to the application to
decide how to name the files.

https://bugzilla.gnome.org/show_bug.cgi?id=750106
2015-07-14 18:45:49 +02:00
Thiago Santos
121fcbf7da splitmuxsrc: sticky events are sent automatically from the pad
No need to send them explicitly from the element

https://bugzilla.gnome.org/show_bug.cgi?id=751240
2015-06-25 17:13:43 -03:00
Thiago Santos
af6a09ae4c splitmuxsrc: make sure to push sticky events before adding pad
It allows the caps to be set on the pad before being added for
dynamic autoplugging to work.

https://bugzilla.gnome.org/show_bug.cgi?id=751240
2015-06-25 17:13:43 -03:00
Jan Schmidt
b26bbae695 Revert "splitmuxsink: Mask async-start/done while switching files."
This reverts commit d61e5393f1.

Causes failures muxing larger GOP sizes for some reason. Reverting
while I figure it out
2015-06-23 17:33:03 +10:00
Jan Schmidt
600bab0056 splitmuxsrc: Fix startup and shutdown races.
Fix 2 startup races when things happen too quickly, and 1
at shutdown by holding a ref to the pads in use until the
loop functions exit.

Handle errors activating file parts and publish them on
the bus.

https://bugzilla.gnome.org/show_bug.cgi?id=750747
2015-06-23 12:03:14 +10:00
Jan Schmidt
d61e5393f1 splitmuxsink: Mask async-start/done while switching files.
Sometimes, extra async-start/done from the internal sink
while the element is still starting up can cause splitmuxsink
to stall in PAUSED state when it has been set to PLAYING
by the app. Drop the child's async-start/done messages while
switching, so they don't cause state changes at the
splitmuxsink level.

https://bugzilla.gnome.org/show_bug.cgi?id=750747
2015-06-23 12:03:14 +10:00
Jan Schmidt
3f39d06338 splitmuxsink: Take released-but-not-yet-output bytes into account
When deciding whether it's time to switch to a new file, take into
account data that's been released for pushing, but hasn't yet
been pushed - because downstream is slow or the threads haven't been
scheduled.

Fixes a race in the unit test and probably in practice - sometimes
failing to switch when it should for an extra GOP or two.

Also fix a problem in splitmuxsrc where playback sometimes
stalls at startup if types are found too quickly.

https://bugzilla.gnome.org/show_bug.cgi?id=750747
2015-06-12 01:57:36 +10:00
Jan Schmidt
d78502deb1 splitmuxsink: Don't accumulate more than 2 GOPs
Don't allow large amounts of data to queue up - we only need
the GOP we're writing, and the GOP we're accumulating.
2015-06-08 18:58:43 +10:00
Jan Schmidt
94e113c6c6 splitmuxsrc: Protect total_duration state variable with the object lock.
Prevent deadlocks from downstream querying duration from the streaming thread.
2015-06-08 14:16:36 +10:00
Jimmy Ohn
d3997773fc splitfilesrc: Implement binary search in find_part_for_offset
Implement binary search using gst_util_array_binary_search

https://bugzilla.gnome.org/show_bug.cgi?id=749690
2015-05-25 14:23:32 +10:00
Edward Hervey
27c91bc881 multifilesink: Add a new max-duration file switching mode
This new mode ensures that files will never exceed a certain duration
based on incoming buffer PTS (and duration if present)

Note:
* You need timestamped buffers (duh). If some of the incoming buffers don't
  have PTS, then it will just accept them in the current file
2015-05-20 15:50:07 +02:00
Edward Hervey
f1ceaab02f multifilesink: streamline the file-switch code a bit
Use the same functions regardless of the mode we are using
2015-05-20 15:50:07 +02:00
Edward Hervey
db0abbd531 multifilesink: add "aggregate-gops" property to process GOPs as a whole
This property can be used in combination with next-file=max-size
(and perhaps a future next-file=max-duration) to make sure that
each file part starts cleanly with a key frame and the appropriate headers.

In order for this property to work correctly, upstream elements should make
sure than any headers that need to be written in a standalone file are:
1) in the streamheader caps field
2) and/or in the stream as one or more buffers marked with GST_BUFFER_FLAG_HEADER
   that are just before the keyframe buffer

This is useful for MPEG-TS/MPEG-PS file segmenting in
combination with mpegtsmux or mpegpsmux.

Original patch by: Tim-Philipp Müller <tim@centricular.com>
2015-05-20 15:49:57 +02:00
Stefan Sauer
168881a186 Revert "doc: Workaround gtkdoc issue"
This reverts commit 1797c8f8b1.

This is fixed by the gtk-doc 1.23 release.
<para> cannot contain <refsect2>:
http://www.docbook.org/tdg/en/html/para.html
http://www.docbook.org/tdg/en/html/refsect2.html
2015-05-18 20:13:01 +02:00
Nicolas Dufresne
1797c8f8b1 doc: Workaround gtkdoc issue
With gtkdoc 1.22, the XML generator fails when a itemizedlist is
followed by a refsect2. Workaround the issue by wrapping the
refsect2 into para.
2015-05-16 23:37:06 -04:00
Tim-Philipp Müller
3755409409 splitmuxsrc: minor error message clean-up
Don't put filename in error message shown to user.
2015-05-10 10:53:13 +01:00
Luis de Bethencourt
9391622579 Rename property enums from ARG_ to PROP_
Property enum items should be named PROP_ for consistency and readability.
2015-04-27 11:22:11 +01:00
Tim-Philipp Müller
d753a3eeb1 Remove obsolete Android build cruft
This is not needed any longer.
2015-04-26 17:55:07 +01:00
Luis de Bethencourt
671b4d25cd remove unused enum items PROP_LAST
This were probably added to the enums due to cargo cult programming and are
unused. Removing them.
2015-04-24 17:01:12 +01:00
George Kiagiadakis
97c03449a4 splitmuxsink: do not access property variable without the object lock, use the local stack copy instead 2015-04-15 13:30:19 +02:00
George Kiagiadakis
1954726328 splitmuxsink: add probe on the multiqueue's sink pad instead of the ghost pad
because _release_pad tries to release it from ctx->sinkpad, which is
multiqueue's sink pad, and currently fails because the probe is not
installed there
2015-04-15 13:30:19 +02:00
Tim-Philipp Müller
b745cb8a47 multifilesink: minor docs improvement 2015-04-13 14:31:17 +01:00
Vincent Penquerc'h
a862db33b6 splitmuxsink: fix mutex leak 2015-04-09 13:01:23 +01:00
Thiago Santos
cf7d9f676d multifilesink: close files before posting message
Makes sure the files were properly flushed and closed before
the message reaches the application
2015-04-04 11:55:00 -03:00
Thiago Santos
e00f0de4f3 multifilesink: post file message on EOS
When multifilesink is operating in any mode other than one file
per buffer, the last file created won't have a file message posted
as multifilesink doesn't handle the EOS event.

This patch fixes it by using the last position to post a file
message when EOS is received. This should ensure at least the
time related data and the filename are posted to the application
or other elements

https://bugzilla.gnome.org/show_bug.cgi?id=747000
2015-04-04 07:58:44 -03:00
Jan Schmidt
d441140cd6 splitmux: Shut down element before downward state change
Make sure the state change won't hang trying to shut down pads
by making sure the streaming has stopped before chaining up.
2015-03-10 15:49:33 +11:00
Jan Schmidt
b0ce43cde3 splitmuxsink: Protect property variables with the object lock.
Use the object lock instead of the splitmux lock to protect
internal property variables, so they're not locked when
switching to a new file.

https://bugzilla.gnome.org/show_bug.cgi?id=744420
2015-03-07 00:55:47 +11:00
Tim-Philipp Müller
f5b511b42b multifile: attempt to fix docs build issue on build bot 2015-02-26 19:48:33 +00:00