Commit graph

103 commits

Author SHA1 Message Date
Mathieu Duponchelle
da6afdec9c doc: remove xml from comments 2019-05-29 22:58:08 +02:00
Thibault Saunier
47a49f3381 docs: Build documentation with hotdoc 2019-05-13 17:00:00 -04:00
Thibault Saunier
5a2b9357c9 Mark some properties as DOC_SHOW_DEFAULT 2019-05-13 11:36:32 -04:00
Thibault Saunier
7fe3f36ac8 Minor documentation fixes 2019-05-13 11:36:27 -04:00
Alex Ashley
dbe0a8cbc3 curlhttpsrc: set BUFFER_OFFSET when creating GstBuffer
To make curlhttpsrc behave more like souphttpsrc, set the
BUFFER_OFFSET in its output buffers to match the segment
start. This means that in a HTTP RANGE request, the BUFFER_OFFSET
will match the value in the RANGE request.
2019-02-19 17:55:13 +00:00
Alex Ashley
2d806477d0 curlhttpsrc: export same HTTP error status as souphttpsrc
To make it closer to a drop-in replacement for souphttpsrc,
expose the same gst_error_message_with_details as souphttpsrc,
so that applications can received the HTTP status code and reason
when an error occurs.
2019-02-19 17:55:12 +00:00
Alex Ashley
c2fe4e58ad curlhttpsrc: fix various leaks and thread safety issues
curlhttpsrc uses a single thread running the
gst_curl_http_src_curl_multi_loop() function to handle receiving
data and messages from libcurl. Each instance of curlhttpsrc adds
an entry into a queue in GstCurlHttpSrcMultiTaskContext and waits
for the multi_loop to perform the HTTP request.

Valgrind has shown up race conditions and memory leaks:
1. gst_curl_http_src_change_state() does not wait for the multi_loop
   to complete before going to the NULL state, which means that
   an instance of GstCurlHttpSrc can be released while
   gst_curl_http_src_curl_multi_loop() still has a reference to it.
2. if multiple elements try to be removed from the queue at once,
   only the last one is deleted.
3. source->caps is leaked
4. curl multi_handle is leaked
5. leak of curl_handle if URI not set
6. leak of http_headers when reusing element
7. null pointer dereference in negotiate caps
8. double-free of the default user-agent string
9. leak of multi_task_context.task

This commit changes the logic so that each element has a connection
status, which is used by the multi_loop to decide when to remove an
element from its queue. An instance of curlhttpsrc will not enter
the NULL state until its reference has been removed from the queue.

When shutting down the curl multi loop, the memory allocated from the
call to curl_multi_init() is now released.

When gstadaptivedemux uses a URI source element, it will re-use
it for multiple requests, moving it between READY and PLAYING
between each request. curlhttpsrc was leaking the http_headers
structure in this use case.

The gst_curl_http_src_negotiate_caps() function extracts the
"response-headers" field from the http_headers, but did not check
that this field might be NULL.

If the user-agent property is set, the global user-agent string
was freed. This caused a double-free error if the user-agent is
ever set a second time during the execution of the process.

There are situations within curlhttpsrc where the code needs
both the global multi_task_context mutex and the per-element
buffer_mutex. To avoid deadlocks, it is vital that the order in
which these are requested is always the same. This commit modifies
the locking order to always be in the order:
 1. multi_task_context.task_rec_mutex
 2. buffer_mutex

Fixes #876
2019-02-19 17:55:12 +00:00
Jonathan Karlsson
d49bc71f00 curlhttpsink: free content type before assigning it
Not doing this would result in a memory leak.
2018-12-17 15:56:08 +00:00
Jonathan Karlsson
e8ec1c0143 curlbasesink: cleanup transfer immediately when done 2018-12-17 14:24:07 +00:00
Patricia Muscalu
e0adbee49a curlbasesink: Rename curl transfer thread
Some systems restrict the length of thread names to 16 bytes.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/838
2018-12-06 15:36:47 +00:00
Jonathan Karlsson
b025736899 curlhttpsink: Enable content type changes
Makes it possible to change content type without having to
reinitialize the element, typically after reset.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/merge_requests/41
2018-12-06 09:08:59 +00:00
Tim-Philipp Müller
a4cfb1fa14 meson: add 'curl-ssh2' option for curl libssh2 support
https://bugzilla.gnome.org/show_bug.cgi?id=797346
2018-10-28 11:53:42 +00:00
Xavier Claessens
8dfe0dd9ce meson: Use the 'curl' feature option
https://bugzilla.gnome.org/show_bug.cgi?id=797346
2018-10-28 11:51:34 +00:00
Wim Taymans
cb16d0b239 curlhhtpsrc: avoid invalid memory references
gst_curl_http_src_remove_queue_item() can free qelement and then
we get an invalid memory reference when we do qelement->next a
couple of lines below. Take the next pointer earlier so that we can
safely free.
2018-08-16 11:44:27 +02:00
Jonathan Karlsson
d74ceb343a curlhttpsink: Support for multipart/form-data Content-Type
Add support to set multipart/form-data as Content-Type by sending a
caps event to the curlhttpsink with a field named "boundary".

https://bugzilla.gnome.org/show_bug.cgi?id=796618
2018-07-17 16:57:06 +03:00
Xavier Claessens
83d0623293 Meson: Generate pc file for all plugins in bad
https://bugzilla.gnome.org/show_bug.cgi?id=794568
2018-04-25 11:08:09 +01:00
Jun Xie
cb1b143b5b curlhttpsrc: deadlock in multi-instance scenario
Fixed queue iterator issue and set context state to
GSTCURL_MULTI_LOOP_STATE_RUNNING in case other
instance are in running state.

https://bugzilla.gnome.org/show_bug.cgi?id=793863
2018-04-24 14:18:20 -04:00
Tim-Philipp Müller
cfe030ad1b meosn: curl: also check for and use libssh2 if available 2018-01-22 18:55:06 +00:00
Edward Hervey
8d99867c13 curlhttpsrc: Don't leak structure
CID #1415716
2017-11-22 16:58:11 +01:00
Tim-Philipp Müller
16294a147e curl: fix meson build
Include libsdir so our i18n header there is found.
2017-11-21 20:56:38 +01:00
Edward Hervey
d4afba794a curlhttpsrc: Post an error message if no URI was set
Like for other sources
2017-11-21 16:30:35 +01:00
Edward Hervey
69d794b004 curl: Add i18n 2017-11-21 16:30:17 +01:00
Edward Hervey
26108d829b curlhttpsrc: Fix return value
The function returns a gchar * (and not a boolean)
2017-11-21 15:33:08 +01:00
Edward Hervey
b8cb08c319 curlhttpsrc: Don't switch to PAUSED if not URI was specified
Like for other sources
2017-11-21 15:31:05 +01:00
Alex Ashley
048d703577 curlhttpsrc: set http-version default if curl does not have HTTP2 feature present
If the version of the curl library is recent enough to allow support
for HTTP2 (i.e. CURL_VERSION_HTTP2 is defined) but does not actually
have that feature enabled, the call to
g_object_class_install_property() uses an incorrect default value for
the "http-version" property. The default should be 1.1 if HTTP2 is
not supported by libcurl or if not enabled by libcurl.

https://bugzilla.gnome.org/show_bug.cgi?id=786049
2017-08-09 17:59:31 +03:00
Sam Hurst
6baa66a889 curlhttpsrc: Does version set fail because of HTTP2
Check to see if setting CURL_HTTP_VERSION_2_0 failed due to lack of HTTP/2
support or some bigger underlying libcurl failure

https://bugzilla.gnome.org/show_bug.cgi?id=785878
2017-08-08 09:06:49 +01:00
Philippe Normand
5bf092bd64 curlhttpsrc: set http-version class property as enum
This matches better with the preferred_http_version which was already declared
as enum.

https://bugzilla.gnome.org/show_bug.cgi?id=785878
2017-08-08 09:06:49 +01:00
Reynaldo H. Verdejo Pinochet
aa1b530f66 curl: curlqueue: add symbol name to avoid confusing gtkdoc 2017-07-26 17:22:31 -07:00
Reynaldo H. Verdejo Pinochet
d82ae7a45f curlhttpsrc: do not check for NULL before g_free()
g_free() is NULL-safe.
2017-07-26 16:51:50 -07:00
Sam Hurst
85eb69d717 curlhttpsrc: Fix flagged Coverity errors
Fixes CIDs 1415707 - 1415717
2017-07-26 23:16:10 +03:00
Sam Hurst
b922edce7b curl: Reorganise header files to fix macOS builds
https://bugzilla.gnome.org/show_bug.cgi?id=744261
2017-07-26 18:57:38 +01:00
Edward Hervey
07afe5da0c curlhttpsrc: Fix compilation without debugging system enabled 2017-07-26 09:19:42 +02:00
Sam Hurst
e74b3a02dd curl: Add curlhttpsrc element
Merged from https://github.com/bbc/gst-curlhttpsrc commit
  f8aabcfc5c50a44f3362de831377d6e86dcd2d49

https://bugzilla.gnome.org/show_bug.cgi?id=744261
2017-07-26 09:52:20 +03:00
Nicolas Dufresne
4261692187 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:05:52 -04:00
Thibault Saunier
78022a6e0c docs: Port all docstring to gtk-doc markdown 2017-04-12 12:57:57 -03:00
Imre Eörs
2c3aa2f09c curl: transfer hangs in case connection was cut between client and server
https://bugzilla.gnome.org/show_bug.cgi?id=774485
2016-11-16 09:19:45 +00:00
Nirbheek Chauhan
42af2d66d8 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Matej Knopp <matej.knopp@gmail.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:35:54 +01:00
Sebastian Rasmussen
c7e4217121 curlsmtpsink: Lock and don't send final boundary upon error
Previously GstCurlSmtpSink could cause the pipeline thread to end up
waiting for a stopped thread to perform work.

The scenario was that the sink could be rendering a buffer and waiting
for the curl transfer thread to have sent the data. As soon as the
transfer thread has copied all data to curl's data buffer in
gst_curl_base_sink_transfer_read_cb() then the render call would stop
waiting and return GST_FLOW_OK. While this takes place the transfer
thread may suffer from an error e.g. due gst_poll_wait() timing out.
This causes the transfer thread to record the error, claim (it is not
really true since there was an error) that the data has been sent and
that a response has been received by trying to signal the pipeline
thread (but this has already stopped waiting). Finally the transfer
thread stops itself. A short while later the pipeline thread may attempt
to push an EOS event into GstCurlSmtpSink. Since there is no check in
gst_curl_smtp_sink_event() to check if the sink has suffered from any
error it may attempt to add a final boundary and ask the, now deceased,
transfer thread to transfer the new data. Next the sink element would
have waited for the transfer to complete (using a different mechanism
than normal transfers through GstCurlBaseSink). In this case there was
an error check to avoid waiting if an error had already been seen.
Finally GstCurlSmtpSink would chain up to GstCurlBaseSink which would
then block waiting for a response (normally this would be prevented by
the transfer thread suffering the error claiming that it had been
received, but GstCurlSmtpSink clobbered this flag after the fact).

Now GstCurlSmtpSink avoids this by locking over the entire event handing
(preventing simultaneous changes to flags by the two threads) and also
by avoiding to initiate transfer of final boundary if an error has
already been seen.

Also add GST_FIXME() for remaining similar issue where the pipeline
thread may block indefinitely waiting for transfer thread to transfer
data but the transfer thread errors out and fails to notify the pipeline
thread that the transfer failed.

https://bugzilla.gnome.org/show_bug.cgi?id=767501
2016-06-11 11:25:13 +01:00
Patricia Muscalu
0fbbbd042a curlsink: catch an unknown error
In this case the socket callback has not been called
by libcurl and the curlsink has not been notified about any
connection problems by libcurl.
This indicates that it's a bug in libcurl so catch it as
an unknown error.

https://bugzilla.gnome.org/show_bug.cgi?id=754432
2016-04-04 17:48:55 +01:00
Vineeth TM
8cdfb13658 bad: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763081
2016-03-24 14:56:51 +02:00
David Fernandez
55ba6f1ee8 curlbasesink: don't send empty buffers
Fixes problem in curlhttpsink when qtmux uses faststart.

https://bugzilla.gnome.org/show_bug.cgi?id=762013
2016-02-17 11:10:22 +00:00
Vineeth TM
7c42ba97d7 plugins-bad: Fix example pipelines
rename gst-launch --> gst-launch-1.0
replace old elements with new elements(ffmpegcolorspace -> videoconvert, ffenc_** -> avenc_**)
fix caps in examples

https://bugzilla.gnome.org/show_bug.cgi?id=759432
2015-12-15 10:30:49 +00:00
Tim-Philipp Müller
734d5a79c5 Fix code indentation 2015-11-06 19:29:49 +00:00
Luis de Bethencourt
9fb7add179 curlsshsink: remove redundant else statement
Else statement is redundant when the if block finishes with an return.
2015-07-06 15:25:16 +01:00
Patricia Muscalu
c1bad1be5d curlsink: handle socket callback for active FTP connections as well
Since version 7.28.0, libcurl allows application to set
socket options for active FTP connections.

Bump libcurl requirement to version tested.

https://bugzilla.gnome.org/show_bug.cgi?id=749815
2015-05-25 19:37:53 +01:00
Branko Subasic
f00d21aec5 curlsmtpsink: add final boundary to all multipart emails
Corrected the final boundary mechanism so that a final boundary is
added to each mail with multipart content that is sent,
not just to the last one.

https://bugzilla.gnome.org/show_bug.cgi?id=741553
2014-12-19 13:16:43 +00:00
L. Sorin
09f0b03762 curlsshsink: use the locally defined types
Just a matter of coding style, makes the code a bit tidier...

https://bugzilla.gnome.org/show_bug.cgi?id=731581
2014-10-26 21:04:02 +00:00
Stefan Sauer
24fd4cd74c curlbasesink: strip newlines from curl debug messages
The messages we receive in the custom log handler might end with a newline and
are not \0 terminated. Copy the messages, trim and terminate them.
2014-10-16 14:12:19 +02:00
Stefan Sauer
9b459b52f6 curlbasesink: small code cleanup
Use a local var and save a local var.
2014-10-16 14:12:19 +02:00
Vivia Nikolaidou
778b1814a8 curlsmtpsink: Set CURLOPT_UPLOAD to 1 to not use VRFY and other unneeded commands
Fixes the sink with SMTP servers that disable VRFY for spam protection.

http://sourceforge.net/p/curl/bugs/1389/
2014-10-06 21:28:45 +03:00