Commit graph

213 commits

Author SHA1 Message Date
paul.kim
129eecf012 souphttpsrc: Reset retry_count to 0 when GST_FLOW_FLUSHING
If a lot of seek method is called very quickly, sometimes data reading
and do_request occurs while seek flush event is occurring and error
occurs because retry_count
reaches to the max. Thus, reset retry_count if flush occurs after
do_request and read_buffer.

https://bugzilla.gnome.org/show_bug.cgi?id=790199
2018-01-19 11:40:07 +02:00
paul.kim
b4edfb5998 souphttpsrc: Remove range header when seek to 0
This fixes the previous range header is remained if seek to 0 is
attempted.

https://bugzilla.gnome.org/show_bug.cgi?id=779957
2017-11-10 10:22:36 +01:00
Edward Hervey
770bb07f30 souphttpsrc: Fix seeking back to 0
This is a regression introduced by "03db374 - souphttpsrc: retry
request on early termination from the server"

The problem was that when seeking back to 0, we would not end up calling
add_range_header() which in addition to adding range headers *ALSO* sets
the read_position to the requested one.

This would result in a wide variety of later failures, like reading
again and again instead of stopping properly.
2017-11-08 16:34:01 +01:00
Sebastian Dröge
d0dfbb04c0 souphttpsrc: Post an element message with the HTTP headers on the bus too
Instead of just sending a sticky event with them downstream. This allows
getting the HTTP headers easily in the application, and especially also
on errors.
2017-07-13 14:50:44 +03:00
Seungha Yang
b0f09d4ad0 souphttpsrc: Unset limit on the number of connection if soup session sharing is used
Soup allows only up to two connections per host in a session,
if we use default value. When session sharing is used, however,
more connections might be required in a session.
(e.g., multi-audio adaptive streaming case)

https://bugzilla.gnome.org/show_bug.cgi?id=784495
2017-07-04 09:13:12 +03:00
Nicolas Dufresne
52eb761acc souphttpsrc: Allow any type of proxy
Currently we only allowed HTTP proxy. Don't filter for the scheme, just check
if it looks like an URI. Soup will warn if the URI is invalid or if
proxy protocol is not supported. This enables using SOCKS 4/5 which is
directly implemented into GIO.

https://bugzilla.gnome.org/show_bug.cgi?id=783012
2017-06-29 15:24:30 -04:00
Sebastian Dröge
1f2e48852e souphttpsrc: Make session sharing thread-safe on our side
https://bugzilla.gnome.org/show_bug.cgi?id=780140
2017-05-18 15:11:01 +03:00
Nicolas Dufresne
b68d936ae0 Remove plugin specific static build option
Static and dynamic plugins now have the same interface. The standard
--enable-static/--enable-shared toggle are sufficient.
2017-05-16 14:41:19 -04:00
Sebastian Dröge
eee911bd1e souphttpsrc: Use a in-memory cookie jar by default in sessions we created
This ensures that cookies are stored and used as set by the server, and
shared with other souphttpsrc that use the same SoupSession.

https://bugzilla.gnome.org/show_bug.cgi?id=780140
2017-05-09 14:27:00 +02:00
Sebastian Dröge
7cb70e7aea souphttpsrc: Implement soup session sharing
souphttpsrc now shares its SoupSession with other elements in the
pipeline via GstContext if possible (session-wide settings are all the
defaults), or if the context was forced by the application.

This allows multiple souphttpsrcs to reuse connections, cookies, etc.

https://bugzilla.gnome.org/show_bug.cgi?id=780140
2017-05-09 14:27:00 +02:00
Edward Hervey
8586150aec souphttpsrc: Make more usage of error macro
And make sure we actually use the provided soup_msg argument in the macro
2017-04-13 08:00:30 +02:00
Tim-Philipp Müller
f26edcdf34 docs: update two references to the removed 'mad' plugin
https://bugzilla.gnome.org/show_bug.cgi?id=776140
2017-03-20 17:03:54 +00:00
Sebastian Dröge
b1ba5f10ce souphttpsrc: Include GStreamer souphttpsrc version in default User-Agent string 2017-03-16 13:53:16 +02:00
Nicolas Dufresne
ca0ed8a134 Fix plugin filenames to match plugin names
- libgstpulse.so becomes libgstpulseaudio.so
- libgstsouphttpsrc.so becomes libgstsoup.so
- libgstoss4audio.so becomes libgstoss4.so

https://bugzilla.gnome.org/show_bug.cgi?id=779344
2017-03-08 20:04:20 -05:00
Seungha Yang
804f238b3e souphttpsrc: Extract redirection uri on libsoup's restarted callback
Let libsoup handle redirection automatically.
And then, to figure out redirection uri, extract it on "restarted"
callback which will be fired before soup_session_send() is returned.

https://bugzilla.gnome.org/show_bug.cgi?id=778428
2017-02-22 16:15:22 +02:00
Arnaud Vrac
03db374144 souphttpsrc: retry request on early termination from the server
Fix a regression introduced by commit 183695c61a (refactor to use
Soup's sync API). The code previously attempted to reconnect when the
server closed the connection early, for example when the stream was put
in pause for some time.

Reintroduce this feature by checking if EOS is received before the
expected content size is downloaded. In this case, do the request
starting at the previous read position.

https://bugzilla.gnome.org/show_bug.cgi?id=776720
2017-01-26 15:59:46 +02:00
Arnaud Vrac
c08a0493ff souphttpsrc: report a useful error message when soup_session_send fails
This helps to understand cases where libsoup doesn't set the message
status code after running soup_session_send.

https://bugzilla.gnome.org/show_bug.cgi?id=777222
2017-01-23 12:54:17 +02:00
Arnaud Vrac
c4cf67cfe5 souphttpsrc: properly check that seek range was respected
This check must be done only when we are sure the request was
successfully sent. soup_session_send() might fail without setting the
status code. In this case status code is 0 so we would only catch the
error after the seek range check. In this case we would report an error
saying that the seek range was not respected, instead of reporting the
underlying error that triggered the soup_session_send() failure.

https://bugzilla.gnome.org/attachment.cgi?bugid=777222
2017-01-23 12:54:17 +02:00
Edward Hervey
41fa3fc499 souphttpsrc: Initialize return variable
In the normal use-case we would end up with ret being unitialized
causing havoc.

https://bugzilla.gnome.org/show_bug.cgi?id=777222
2017-01-19 08:38:45 +01:00
Arnaud Vrac
02317496c6 souphttpsrc: make flow return values handling clearer
The flow return values was stored in the element before because the
result had to be set from callbacks. This is not the case anymore, we
can return the flow result directly from functions, making the code
easier to understand.

https://bugzilla.gnome.org/show_bug.cgi?id=777222
2017-01-17 22:16:15 -03:00
Arnaud Vrac
9b23732559 souphttpsrc: properly track redirections
The current code configures libsoup to handle redirections
transparently, without informing the caller, thus preventing the element
to record the redirect code and location uri.

Fix this by always setting the SOUP_MESSAGE_NO_REDIRECT, preventing
libsoup from handling the redirection. When we receive a redirection
request and libsoup can safely handle it, return a custom error which
triggers a retry with the new URI.

https://bugzilla.gnome.org/show_bug.cgi?id=777222
2017-01-17 22:16:15 -03:00
Sebastian Dröge
37f991f06e souphttpsrc: Handle non-UTF8 headers and error reasons more gracefully
Especially don't put them into GstStructures in one way or another, just
ignore them or error out cleanly depending on the importance of their
content.
2016-11-28 12:00:09 +02:00
Sebastian Dröge
60d30db912 Revert "souphttpsrc: reduce reading latency by using non-blocking read"
This reverts commit 8816764112.

It causes issues with the timeouts, and causes connections to be closed
without actual reason. Needs further investigation.

https://bugzilla.gnome.org/show_bug.cgi?id=773509
2016-10-31 18:00:07 +02:00
Michael Olbrich
8666b7d871 souphttpsrc: reset read_position when reading fails
souphttpsrc maintains two variables for the position:
 * 'request_position' is where we want to be
 * 'read_position' is where we are
During Normal operations both are updated in sync when data arrives. A seek
changes 'request_position' but not 'read_position'.
When the two positions get out of sync, then a new request is send and the
'Range' header is adjusted to the current 'request_position'.

Without this patch, if reading fails, then the source is destroyed. This
triggers a new request, but the range remains unchanged. As a result, the
old range is used and old data will be read.

Changing the 'read_position' to -1 makes it explicitly different from
'request_position' and as a result the 'Range' header is updated correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=773509
2016-10-26 16:57:28 +03:00
Nirbheek Chauhan
b09f478e80 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.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-20 11:21:12 +01:00
Vincent Penquerc'h
f94c4c00c8 souphttpsrc: include http-status-code in error message details
https://bugzilla.gnome.org/show_bug.cgi?id=763038
2016-07-25 11:17:20 +01:00
Edward Hervey
1d55fbce86 souphttpsrc: Don't drop final bytes of a range request
At the end of a range request, we don't want to return GST_FLOW_EOS otherwise
the last bytes we just read will be dropped by basesrc.

Instead just return GST_FLOW_OK (which was set just before) and let basesrc
handle the fact we are at the end of the segment.
2016-07-12 07:41:59 +02:00
Sebastian Dröge
e6823e4df4 souphttpsrc: At the end of a range request, read another time to finalize the request
If we're at the end of a range request, read again to let libsoup
finalize the request. This allows to reuse the connection again later,
otherwise we would have to cancel the message and close the connection.
2016-07-12 00:42:58 +03:00
Sebastian Dröge
b1edc28695 souphttpsrc: Fix keep-alive handling
We have to get rid of the message on EOS when the complete stream is read to
remember that we successfully finished handling this specific message.
Otherwise we will cancel it later and close the connection instead of reusing
it at a later time.

It might also make sense to reuse connections if a non-200 response is
received. As long as there was no connection error, the HTTP connection should
be re-usable.
2016-07-11 19:59:22 +03:00
Thiago Santos
11c61f14bf souphttpsrc: dynamically adjust blocksize
Update the blocksize depending on how much is obtained from a read
of the input stream. This avoids doing too many reads in small chunks
when larger amounts of data are available and also prevents using
a very large memory area to read a small chunk of data.

https://bugzilla.gnome.org/show_bug.cgi?id=767833
2016-06-29 09:51:02 -03:00
Tim-Philipp Müller
33fb50b308 soup: work around frequent deadlocks in GLib type initialisation
.. by registering the types from the plugin init function. This
seems to help, but we'll see if it's enough (might need similar
things elsewhere).

https://bugzilla.gnome.org/show_bug.cgi?id=693911
https://bugzilla.gnome.org/show_bug.cgi?id=674885
2016-06-17 19:59:13 +01:00
Sebastian Dröge
4a2455b744 Revert "WIP revert soup"
This reverts commit fdac3a7a23.

Was not supposed to be pushed but a local workaround for
https://bugzilla.gnome.org/show_bug.cgi?id=693911#c13
2016-06-06 10:47:52 +03:00
Sebastian Dröge
fdac3a7a23 WIP revert soup 2016-06-03 13:25:38 +03:00
Guillaume Desmottes
6fd04b07fc souphttpsrc: fix buffer leak when flushing
When early returning in gst_soup_http_src_read_buffer() because the
element is FLUSHING, we need to unmap and unref the buffer which was just created.

https://bugzilla.gnome.org/show_bug.cgi?id=766718
2016-05-20 17:40:26 +01:00
Sebastian Dröge
e2b2185029 souphttpclientsink: Set sent_buffers and streamheader_buffers to NULL after freeing
Otherwise we might use an already freed list later and crash or worse.
2016-05-19 12:44:17 +03:00
Carlos Rafael Giani
e9a795fa8b souphttpsrc: Use audio/x-unaligned-raw instead of audio/x-raw for L16 data
Directly setting audio/x-raw caps leads to problems when the delivered
data blocks do not align properly at sample boundaries (for example, a
data block with 391 bytes). So, instead, set audio/x-unaligned-raw to
let a parser be autoplugged.

https://bugzilla.gnome.org/show_bug.cgi?id=689460
2016-05-15 13:18:02 +03:00
Thiago Santos
325741d37d souphttpsrc: check if request was cancelled when sending message
It might be that the request was aborted by the application and
we can return immediatelly
2016-05-15 06:40:01 -03:00
Thiago Santos
075a6260fd souphttpsrc: proxy resolver is on by default
Remove from the session creation parameters
2016-05-15 06:36:25 -03:00
Thiago Santos
9b52a5b9af soup: update build to warn about newer deprecated functions
We already depend on 2.48
2016-05-15 06:36:25 -03:00
Thiago Santos
8816764112 souphttpsrc: reduce reading latency by using non-blocking read
Non-blocking read will return the amount of data available without
blocking to wait for the full requested size.

The downside is that now it souphttpsrc needs to have a waiting
mechanism in case there is no data available yet to avoid busy
looping arond the inputstream.
2016-05-15 06:36:25 -03:00
Thiago Santos
183695c61a souphttpsrc: refactor to use Soup's sync API
Replace the async API with the sync API to remove all the extra mainloop
and context handling. Currently it blocks reading until 'blocksize'
bytes are available but that can be improved by using:

https://developer.gnome.org/gio/unstable/GPollableInputStream.html#g-pollable-input-stream-read-nonblocking

https://bugzilla.gnome.org/show_bug.cgi?id=693911
2016-05-14 08:40:12 -03:00
Sebastian Dröge
bc2d4c4c31 souphttpclientsink: If no proxy is set by properties, use the default libsoup proxy resolver
That is, use whatever system settings there might exist. This is the same
behaviour we use in the HTTP source.
2016-04-15 11:36:36 +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
Xavier Claessens
10044b1d0f souphttpsrc: Add GTlsInteraction property
https://bugzilla.gnome.org/show_bug.cgi?id=750709
2015-12-14 14:56:02 -05:00
Vineeth TM
bd701b8ee5 souphttpclientsink: Fix error leak and handle error
g_thread_try_new allows for possiblity of failures. In case it fails,
error is not handled and leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=758260
2015-11-18 09:31:42 +02:00
Reynaldo H. Verdejo Pinochet
c9039751f1 souphttpsrc: remove unnecessary NULL checks before g_free() 2015-11-15 01:43:08 -08:00
Sebastian Dröge
51adc9d889 souphttpsrc: EOS immediately if we have an empty seek segment
https://bugzilla.gnome.org/show_bug.cgi?id=748316
2015-10-14 16:56:26 +03:00
Stavros Vagionitis
21c6da6764 souphttpsrc: Make non-inclusive segment boundaries inclusive
The problem is that the filesrc and souphttpsrc are behaving
differently regarding the calculation of the segment boundaries. The
filesrc is using a non-inclusive boundaries, while the souphttpsrc
uses inclusive. Currently the hlsdemux calculates the boundaries as
inclusive, so for this reason there is no problem with the souphttpsrc,
but there is an issue in the filesrc.

The GstSegment is non-inclusive, so the proposed solution is to use
non-inclusive boundaries in the hlsdemux in order to be consistent.
Make the change in the hlsdemux, will break the souphttpsrc, which
will expect inclusive boundaries, but the hlsdemux will offer
non-inclusive. This change makes sure that the non-inclusive
boundaries are converted to inclusive.

https://bugzilla.gnome.org/show_bug.cgi?id=748316
2015-10-14 16:56:22 +03:00
Graham Leggett
af25e3cc93 souphttpclientsink: Add the retry and retry-delay properties
These allow a failed request to be retried after the given number of seconds
instead of failing the pipeline. Take account of the Retry-After header if
present. Add retries parameter that controls the number of times an HTTP
request will be retried before failing.

https://bugzilla.gnome.org/show_bug.cgi?id=756318
2015-10-14 15:23:00 +03:00
Vineeth TM
6eb8db8afd souphttpclientsink: Check if soup message is created
If soup message is not created then the same should not be passed
on, which is resulting in segfault. Hence throwing a warning message
and returning

https://bugzilla.gnome.org/show_bug.cgi?id=755326
2015-10-12 16:53:29 +03:00