Commit graph

164 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
Thiago Santos
cb852cd128 souphttpsrc: remove unnecessary if, g_free is null safe 2015-08-14 06:43:13 -03:00
Alex Ashley
9dcc7d9cac souphttpsrc: add property to set HTTP method
To allow souphttpsrc to be use HTTP methods other than GET
(e.g. HEAD), add a "method" property that is a string. If this
property is not set, GET is used.

https://bugzilla.gnome.org/show_bug.cgi?id=752413
2015-08-14 06:37:55 -03:00
Tim-Philipp Müller
e1143041ed soup: fix typo in translated string
https://bugzilla.gnome.org/show_bug.cgi?id=753240
2015-08-04 16:28:17 +01:00
Eunhae Choi
8b6a261703 souphttpsrc: handle empty http proxy string
1) If the system http_proxy environment variable is not set
or set to an empty string, we must not set proxy to avoid
http connection error.

2) In case of proxy property setting, if user want to clear
the proxy setting, they should be able to set it to NULL or
an empty string again, so this is fixed too.

3) Check if the proxy string was parsed correctly.

https://bugzilla.gnome.org/show_bug.cgi?id=752866
2015-07-31 10:54:02 +01:00
Xavier Claessens
64e4df3fe2 souphttpsrc: Add tls-database property
https://bugzilla.gnome.org/show_bug.cgi?id=750298
2015-06-10 14:10:39 -04:00
Xavier Claessens
5ada1a6cf8 souphttpsrc: fix getter of "ssl-use-system-ca-file"
https://bugzilla.gnome.org/show_bug.cgi?id=750298
2015-06-10 12:02:16 +01:00
Sebastian Dröge
bbcfc3b9e6 souphttpsrc: Don't return a buffer when returning not GST_FLOW_OK
basesrc assumes that we don't return a buffer if
something else than OK is returned. It will just
leak any buffer we might accidentially provide
here.

This can potentially happen during flushing.

Maybe fixes https://bugzilla.gnome.org/show_bug.cgi?id=741993
2014-12-30 16:28:09 +01:00
Branislav Katreniak
1e03ffb820 souphttpsrc: log connection events at info level
https://bugzilla.gnome.org/show_bug.cgi?id=739305
2014-11-22 15:14:58 +00:00
Sebastian Dröge
53b5a44a06 souphttpsrc: If the server reports "Accept-Ranges: none" don't try range requests 2014-09-11 12:53:29 +03:00
Sebastian Dröge
4b697df494 souphttpsrc: Include redirection target in error messages
Just giving the original URI can give the false impression that e.g.
that one failed host name resolution, while actually the redirection target
did.
2014-09-04 12:14:11 +03:00
Sebastian Dröge
edc7d9027e souphttpsrc: Add custom sticky event to contain the HTTP request and response headers
This can be useful to e.g. get cookie information downstream.

https://bugzilla.gnome.org/show_bug.cgi?id=729707
2014-05-28 09:20:21 +02:00
Sebastian Dröge
2a7abc98db souphttpsrc: Clean up all pending operations from libsoup before unreffing our context
When we cancel connection attempts and similar things, there are still
some operations pending on our main context from the GCancellables. We
should let them all run before unreffing our context, otherwise we leak
file descriptors.

Unfortunately this requires libsoup 2.47.0 or newer as earlier versions
steal our main context from us and we can't use it for cleanup later
without assertions and funny crashes.

Based on a patch by Dmitry Shatrov <shatrov@gmail.com>.

https://bugzilla.gnome.org/show_bug.cgi?id=663944
2014-05-08 10:18:38 +02:00
Sebastian Dröge
3b6c17c2b6 souphttpsrc: Remember if a redirect is permanent or not and store it in the query 2014-04-28 10:04:03 +02:00
Sebastian Dröge
37609c0a82 souphttpsrc: Only keep-alive the connection in stop() if we have finished all previous messages
After cancelling a request we need to create a new connection.
2014-04-11 13:30:53 +02:00
Sebastian Dröge
847ba2a30d souphttpsrc: Also retry on unexpected network failures 2014-04-10 16:47:21 +02:00
Sebastian Dröge
037dfb6723 souphttpsrc: New property to specify the maximum number of retries before we give up 2014-04-10 16:47:07 +02:00
Alexander Zallesov
b089524b21 souphttpsrc: Change default timeout to 15 seconds
If nothing happens after 15 seconds, chances are good that
our connection will never will work. Stop after 15 seconds
instead of waiting until the system's default timeout, which
can be > 1 minute.
2014-04-10 11:11:35 +02:00
Sebastian Dröge
d918212e12 souphttpsrc: Use GST_FLOW_FLUSHING when flushing, not GST_FLOW_EOS
... and reset it properly after flushing is done. Fixes playback
in many cases when buffering is used.

https://bugzilla.gnome.org/show_bug.cgi?id=727821
2014-04-09 10:56:29 +02:00
Sebastian Dröge
5d06735dbd souphttpsrc: Add properties for selecting SSL/TLS certificate checking
And by default properly check certificates against the system's CA
certificates. Everything else is not a good default at all.
2014-03-12 15:32:55 +01:00