Commit Graph

129 Commits

Author SHA1 Message Date
Martin Storsjö
fab8156b2f avio: Copy URLContext generic options into child URLContexts
Since all URLContexts have the same AVOptions, such AVOptions
will be applied on the outermost context only and removed from the
dict, while they probably make sense on all contexts.

This makes sure that rw_timeout gets propagated to the innermost
URLContext (to make sure it gets passed to the tcp protocol, when
opening a http connection for instance).

Alternatively, such matching options would be kept in the dict
and only removed after the ffurl_connect call.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-03-24 10:34:19 +02:00
Andrey Utkin
ccea588f83 avio: Add an option 'rw_timeout'
If set non-zero, this limits duration of the retry_transfer_wrapper()
loop, thus affecting ffurl_read*(), ffurl_write(). As soon as
one single byte is successfully received/transmitted, the timer
restarts.

This has further changes by Michael Niedermayer and Martin Storsjö.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-03-24 10:33:50 +02:00
Martin Storsjö
d44f3e4059 avio: Apply avoptions on the URLContext itself as well
Currently the list of avoptions for URLContext is empty though,
but such options will be added.

Signed-off-by: Martin Storsjö <martin@martin.st>
2016-03-24 10:33:37 +02:00
Anton Khirnov
8c0ceafb0f urlprotocol: receive a list of protocols from the caller
This way, the decisions about which protocols are available for use in
any given situations can be delegated to the caller.
2016-02-22 11:45:31 +01:00
Anton Khirnov
832a202c47 protocols: make the list of protocols static
Disallow other code to touch it directly, now it's only accessible
through a blacklisting/whitelisting function.
2016-02-22 11:35:57 +01:00
Anton Khirnov
7d61dc95d7 lavf: move urlcontext_child_class_next() to protocols.c
It needs to access the list of protocols directly, so it more properly
belongs there.
2016-02-22 11:35:52 +01:00
Anton Khirnov
0fa00d0591 lavf: move avio_enum_protocols() to protocols.c
It's a more appropriate place for it.
2016-02-22 11:35:46 +01:00
Anton Khirnov
2758cdedfb lavf: reorganize URLProtocols
Instead of a linked list constructed at av_register_all(), store them
in a constant array of pointers.

Since no registration is necessary now, this removes some global state
from lavf. This will also allow the urlprotocol layer caller to limit
the available protocols in a simple and flexible way in the following
commits.
2016-02-22 11:30:58 +01:00
Diego Biurrun
b97f427fb5 lavf: Explicitly convert types at function pointer assignment
This fixes a number of "assignment from incompatible pointer type" warnings.
2015-03-11 23:53:13 +01:00
Michael Niedermayer
02484d1a93 avio: fix sizeof argument
CC: libav-stable@libav.org
Bug-Id: CID 732284
2014-10-20 10:38:38 +01:00
Gabriel Dume
4b1f5e5090 cosmetics: Write NULL pointer inequality checks more compactly
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2014-08-15 05:34:13 -07:00
Diego Biurrun
ec4f04da1a avformat: Mark argument in av_{i|o}format_next/ffurl_protocol_next as const 2014-07-26 14:51:16 -07:00
Martin Storsjö
0c5f839693 lavf: Remove a now useless parameter to ffurl_register_protocol
This was added in 9b07a2dc02 as an ABI hack to allow older
code built with lavf 52 to register protocols even if the size
of the URLProtocol struct was increased. Later, registering
protocols from outside of lavf was removed and this workaround
isn't needed any longer since lavf 53.

This removes an unchecked malloc and a memory leak for the cases
when this workaround actually was used - which it hasn't since
lavf 53.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-10-30 09:53:48 +02:00
Derek Buitenhuis
25c7db7cc9 avio: Check for memory allocation failure of private data
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2013-10-29 11:40:15 +00:00
Luca Barbato
53151723e3 avio: K&R formatting cosmetics 2013-10-28 00:04:50 +01:00
Luca Barbato
ea71aafd68 avio: Use AVERROR_PROTOCOL_NOT_FOUND
When the protocol is missing ffurl_alloc() should return
AVERROR_PROTOCOL_NOT_FOUND instead of AVERROR(ENOENT).

Bug-Id: 577
CC: libav-stable@libav.org
2013-10-21 15:55:20 +02:00
Michael Niedermayer
5d876be87a avio: Handle AVERROR_EOF in the same way as the return value 0
This makes sure the ffurl_read_complete function actually
returns the number of bytes read, as the documentation of the
function says, even if the underlying protocol uses AVERROR_EOF
instead of 0.

Signed-off-by: Martin Storsjö <martin@martin.st>
2013-07-07 13:30:01 +03:00
Mans Rullgard
4521645b1a avio: fix pointer type mismatches in avio_enum_protocols()
Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-10-27 13:43:44 +01:00
Jordi Ortiz
d6b9da1178 avio: add (ff)url_get_multi_file_handle() for getting more than one fd
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-08-17 22:14:30 +03:00
Mans Rullgard
896bb0d742 Replace usleep() calls with av_usleep()
This reduces the dependency on unistd.h which is not available
on all systems.

Signed-off-by: Mans Rullgard <mans@mansr.com>
2012-06-22 17:15:36 +01:00
Samuel Pitoiset
32d545e0a4 avio: Add a function for signalling end of reading/writing
Signed-off-by: Martin Storsjö <martin@martin.st>
2012-05-22 23:16:41 +03:00
Alex Converse
7181c4edee cosmetics: Remove extra newlines at EOF 2012-01-27 17:19:09 -08:00
Anton Khirnov
374e469b8d lavf: remove disabled FF_API_OLD_INTERRUPT_CB cruft 2012-01-27 10:52:43 +01:00
Anton Khirnov
2439f2ca82 lavf: remove disabled FF_API_OLD_AVIO cruft 2012-01-27 10:52:42 +01:00
Martin Storsjö
acb074301c avio: Only do implicit network initialization for network protocols
The implicit network initialization is set to be removed in the
future, but is kept for compatibility. By not doing the implicit
initialization for non-network protocols, we avoid the warning
about avformat_network_init() not being called for these, where
it really doesn't make much sense.

Signed-off-by: Martin Storsjö <martin@martin.st>
2012-01-05 23:56:56 +02:00
Martin Storsjö
45f511ece7 avio: Mark the old interrupt callback mechanism as deprecated
Prepare for removing it at an upcoming major bump.
2011-11-18 11:01:16 +01:00
Martin Storsjö
1dee0aca74 avio: add avio_open2, taking an interrupt callback and options
The interrupt callback has to be passed in during opening (setting it
after opening isn't enough), since a blocking open couldn't be
interrupted otherwise.

Options are passed down to procotols and also need to be available
during open() in most cases.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2011-11-13 13:17:04 +01:00
Anton Khirnov
ddffc2fdc3 avio: add support for passing options to protocols.
Not used anywhere yet, support for passing options from avio_open() will
follow.
2011-11-13 13:14:39 +01:00
Anton Khirnov
163a31136d avio: add and use ffurl_protocol_next(). 2011-11-13 13:14:14 +01:00
Martin Storsjö
6f1b7b3944 avio: Add an AVIOInterruptCB parameter to ffurl_open/ffurl_alloc
Change all uses of these function to pass the relevant
callback on.
2011-11-13 13:12:17 +01:00
Martin Storsjö
9957cdbfd5 avformat: Use ff_check_interrupt 2011-11-13 13:08:13 +01:00
Martin Storsjö
c4a090ddb5 avio: Add an internal utility function for checking the new interrupt callback
Signed-off-by: Anton Khirnov <anton@khirnov.net>
2011-11-13 13:07:48 +01:00
Martin Storsjö
d10361b658 avio: Free URLContext private data allocated via AVOptions
Signed-off-by: Martin Storsjö <martin@martin.st>
2011-11-10 10:51:06 +02:00
Diego Biurrun
124e28847b Remove some stray unnecessary ffmpeg references. 2011-11-02 10:42:54 +01:00
Anton Khirnov
f0029cbcf6 lavf: use designated initializers for AVClasses. 2011-05-17 23:01:42 +02:00
Diego Biurrun
046f081b46 configure: Do not unconditionally add -D_POSIX_C_SOURCE to CPPFLAGS.
Adding _POSIX_C_SOURCE to CPPFLAGS globally produces all sorts of problems
since it causes certain system functions to be hidden on some (BSD) systems.
The solution is to only add the flag on systems that really require it, i.e.
glibc-based ones.

This change makes BSD systems compile out-of-the-box without the need for
adding specific flags manually.  It also allows dropping a number of flags
set manually on a file-per-file basis, but were only present to work around
breakage introduced by the presence of _POSIX_C_SOURCE.

Also add _XOPEN_SOURCE to CPPFLAGS for glibc systems.  We use XSI extensions
in several places already, so it is preferable to define it globally instead
of littering source files with individual #defines only needed for glibc.
2011-05-12 11:41:59 +02:00
Martin Storsjö
26f6b8c571 avio: Fix sanity checks in ffurl_read*
This fixes e.g. reading data over HTTP, where the underlying
socket is set to read/write.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2011-04-20 17:00:11 +02:00
Stefano Sabatini
59d96941f0 avio: remove AVIO_* access symbols in favor of new AVIO_FLAG_* symbols
Make AVIO_FLAG_ access constants work as flags, and in particular fix
the behavior of functions (such as avio_check()) which expect them to
be flags rather than modes.

This breaks API.
2011-04-19 19:47:58 +02:00
Anton Khirnov
7f804085f1 lavf: remove FF_API_URL_CLASS cruft. 2011-04-19 18:31:12 +02:00
Anton Khirnov
dcd4a7b62f lavf: remove FF_API_REGISTER_PROTOCOL cruft 2011-04-19 18:28:38 +02:00
Anton Khirnov
4bde56d1af avio: deprecate url_exist in favor of avio_check. 2011-04-13 07:38:18 +02:00
Stefano Sabatini
175389c854 avio: add avio_check()
The new function is more flexible than url_exist(), as it allows to
specify which access flags to check, and does not require an explicit
open of the checked resource.

Signed-off-by: Anton Khirnov <anton@khirnov.net>
2011-04-13 07:38:15 +02:00
Anton Khirnov
cdc6a87f19 avio: deprecate av_protocol_next(). 2011-04-08 17:48:53 +02:00
Anton Khirnov
f8270bbf8c avio: add a function for iterating though protocol names. 2011-04-08 17:48:44 +02:00
Anton Khirnov
026e175775 avio: deprecate the typedef for URLInterruptCB
There's no particular reason to pollute the namespace with a typedef for
it.
2011-04-08 07:07:58 +02:00
Anton Khirnov
8e76a19b63 avio: make av_register_protocol2 internal. 2011-04-07 18:11:24 +02:00
Anton Khirnov
80c6e238b0 avio: avio_ prefix for url_set_interrupt_cb. 2011-04-07 18:11:24 +02:00
Anton Khirnov
f87b1b373a avio: AVIO_ prefixes for URL_ open flags. 2011-04-07 18:07:16 +02:00
Anton Khirnov
1305d93c42 avio: deprecate av_url_read_seek
It's not used anywhere internally.

Salvage its documentation for ffio_read_seek.
2011-04-05 08:40:27 +02:00
Anton Khirnov
fa104e14ab avio: deprecate av_url_read_pause
It's not used anywhere internally.

Salvage its documentation for ffio_read_pause.
2011-04-05 08:39:40 +02:00