1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00
Commit Graph

224 Commits

Author SHA1 Message Date
Michael Niedermayer
f8611ae1ef avformat/avio: Check av_opt_copy() for failure
Fixes: CID1477416 Unchecked return value

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2021-05-27 17:41:36 +02:00
Anton Khirnov
9d4c018497 avio: do not export avpriv_io_{move,delete}
They are private and not used by anything outside of lavf. There is no
reason for them to be exported.
2021-05-22 15:27:55 +02:00
James Almer
0bf3a7361d avutil: remove deprecated AVClass.child_class_next
Signed-off-by: James Almer <jamrial@gmail.com>
2021-04-27 11:48:04 -03:00
Andreas Rheinhardt
ea5bf12a9a avformat/avio: Use av_strstart instead of strncmp
It makes the intent clearer and avoids calculating the length
in advance.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-28 17:14:21 +01:00
Andreas Rheinhardt
7b43646e18 avformat/avio: Remove ffurl_open
It is only used in commented-out (and nonworking) code in async.c.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-02-02 23:53:29 +01:00
Anton Khirnov
43ed2b86d6 URLContext: switch to child_class_iterate() 2020-06-10 12:36:44 +02:00
Paul B Mahol
d64cbd4fda remove CHAR_MIN/CHAR_MAX usage
It is not needed at all.
2020-03-17 22:46:36 +01:00
Marton Balint
19b9f8996e avformat/avio: fix ff_rename to respect used protocol
Also simplify it and make it always log the error.

This fixes for example the image2 muxer when used with an URL which also
contains the protocol:

ffmpeg -f lavfi -i testsrc -vframes 10 -atomic_writing 1 file:out%d.png

Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-19 22:17:04 +01:00
Marton Balint
df993269ec avformat/avio: move ff_rename implementation from internal.h to avio.c
Signed-off-by: Marton Balint <cus@passwd.hu>
2020-01-19 22:17:04 +01:00
Andreas Rheinhardt
2205fb2810 avformat/avio: Use ffurl_closep
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2019-11-29 19:58:35 +01:00
Carl Eugen Hoyos
a650e8c8e9 lavf/avio: Print https warning also for avio_find_protocol_name().
Helps to fix ticket #8197.
2019-10-01 19:52:47 +02:00
Jun Zhao
4d3e9e3135 avformat/avio: make the logic simple
remove the "ret" to make the code simple and generic.

Signed-off-by: Jun Zhao <mypopydev@gmail.com>
2018-05-06 15:07:28 +08:00
Steven Liu
be4dfbf7b7 avformat/avio: check input URLContext value NULL
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Reviewed-by: Karthick Jeyapal <kjeyapal@akamai.com>
2017-12-28 12:07:22 +08:00
Carl Eugen Hoyos
3605b312f6 lavf/avio: Print the https warning also for missing tls protocol. 2017-10-23 11:48:17 +02:00
Daniel Kucera
858db4b01f libavformat: not treat 0 as EOF
transfer_func variable passed to retry_transfer_wrapper
are h->prot->url_read and h->prot->url_write functions.
These need to return EOF or other error properly.
In case of returning >= 0, url_read/url_write is retried
until error is returned.

Signed-off-by: Daniel Kucera <daniel.kucera@gmail.com>
2017-10-19 22:07:21 +02:00
Wan-Teh Chang
2f84f40d45 avformat/avio: Remove no-op code in url_find_protocol().
In url_find_protocol(), proto_str is either "file" or a string
consisting of only the characters in URL_SCHEME_CHARS, which does not
include ','. Therefore the strchr(proto_str, ',') call always returns
NULL.

Note: The code was added in commit
6161c41817.

Signed-off-by: Wan-Teh Chang <wtc@google.com>
Signed-off-by: Muhammad Faiz <mfcc64@gmail.com>
2017-07-10 06:56:51 +07:00
Alexander Strasser
a70d5e2593 lavf/avio: Be more explicit in logging white/black list matches
The current form of the messages indicating matches in the white
or black lists seems to be a bit too much relying on context.

Make the messages more explicit.

Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
2017-03-14 22:58:53 +01:00
Alexander Strasser
6693d57e99 lavf/avio: Remove unnecessary escaping of ' in string literals
Signed-off-by: Alexander Strasser <eclipse7@gmx.net>
2017-03-14 22:58:53 +01:00
Joel Cunningham
8c8e5d5286 HTTP: improve performance by reducing forward seeks
This commit optimizes HTTP performance by reducing forward seeks, instead
favoring a read-ahead and discard on the current connection (referred to
as a short seek) for seeks that are within a TCP window's worth of data.
This improves performance because with TCP flow control, a window's worth
of data will be in the local socket buffer already or in-flight from the
sender once congestion control on the sender is fully utilizing the window.

Note: this approach doesn't attempt to differentiate from a newly opened
connection which may not be fully utilizing the window due to congestion
control vs one that is. The receiver can't get at this information, so we
assume worst case; that full window is in use (we did advertise it after all)
and that data could be in-flight

The previous behavior of closing the connection, then opening a new
with a new HTTP range value results in a massive amounts of discarded
and re-sent data when large TCP windows are used.  This has been observed
on MacOS/iOS which starts with an initial window of 256KB and grows up to
1MB depending on the bandwidth-product delay.

When seeking within a window's worth of data and we close the connection,
then open a new one within the same window's worth of data, we discard
from the current offset till the end of the window.  Then on the new
connection the server ends up re-sending the previous data from new
offset till the end of old window.

Example (assumes full window utilization):

TCP window size: 64KB
Position: 32KB
Forward seek position: 40KB

      *                      (Next window)
32KB |--------------| 96KB |---------------| 160KB
        *
  40KB |---------------| 104KB

Re-sent amount: 96KB - 40KB = 56KB

For a real world test example, I have MP4 file of ~25MB, which ffplay
only reads ~16MB and performs 177 seeks. With current ffmpeg, this results
in 177 HTTP GETs and ~73MB worth of TCP data communication.  With this
patch, ffmpeg issues 4 HTTP GETs and 3 seeks for a total of ~22MB of TCP data
communication.

To support this feature, the short seek logic in avio_seek() has been
extended to call a function to get the short seek threshold value.  This
callback has been plumbed to the URLProtocol structure, which now has
infrastructure in HTTP and TCP to get the underlying receiver window size
via SO_RCVBUF.  If the underlying URL and protocol don't support returning
a short seek threshold, the default s->short_seek_threshold is used

This feature has been tested on Windows 7 and MacOS/iOS.  Windows support
is slightly complicated by the fact that when TCP window auto-tuning is
enabled, SO_RCVBUF doesn't report the real window size, but it does if
SO_RCVBUF was manually set (disabling auto-tuning). So we can only use
this optimization on Windows in the later case

Signed-off-by: Joel Cunningham <joel.cunningham@me.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2017-02-14 17:00:30 +01:00
Michael Niedermayer
936751b652 avformat/avio: Fix null pointer dereference in case of memleak
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-18 00:53:21 +02:00
Yong Lei
7bacf74536 avformat/avio: fix memory leak in url_find_protocol
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-05-18 00:51:52 +02:00
Derek Buitenhuis
f8e89d8a29 Merge commit 'fab8156b2f30666adabe227b3d7712fd193873b1'
* commit 'fab8156b2f30666adabe227b3d7712fd193873b1':
  avio: Copy URLContext generic options into child URLContexts

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-21 15:55:09 +01:00
Derek Buitenhuis
299d4f9428 Merge commit 'ccea588f831906084b8c8235222920e6984beb72'
* commit 'ccea588f831906084b8c8235222920e6984beb72':
  avio: Add an option 'rw_timeout'

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-18 15:47:54 +01:00
Derek Buitenhuis
4eef36a4f6 Merge commit 'd44f3e4059506a182f59218b1e967d42b01e097c'
* commit 'd44f3e4059506a182f59218b1e967d42b01e097c':
  avio: Apply avoptions on the URLContext itself as well

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-04-18 15:35:12 +01:00
Carl Eugen Hoyos
7e1e25c2dc lavf/avio: Remove linebreak from https warning. 2016-04-10 15:39:13 +02:00
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
Michael Niedermayer
6b7ce0ea0d avformat/avio: Fix unknown protocol handling
Fixes regression since bb8cc89b29

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-03-17 02:09:39 +01:00
Derek Buitenhuis
93629735d7 avformat: Add a protocol blacklisting API
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-03-04 16:13:42 +00:00
Derek Buitenhuis
bb8cc89b29 Merge commit '832a202c47a246ed15e3edc6b05dfcfa7d82c4b2'
* commit '832a202c47a246ed15e3edc6b05dfcfa7d82c4b2':
  protocols: make the list of protocols static

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-29 18:08:15 +00:00
Derek Buitenhuis
53025fe187 Merge commit '7d61dc95d741ca134d59b1f34c4e10c4c4e36f56'
* commit '7d61dc95d741ca134d59b1f34c4e10c4c4e36f56':
  lavf: move urlcontext_child_class_next() to protocols.c

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-29 17:00:44 +00:00
Derek Buitenhuis
8fd5342463 Merge commit '0fa00d05911aa8043ecad8dead4a73cab7faadf6'
* commit '0fa00d05911aa8043ecad8dead4a73cab7faadf6':
  lavf: move avio_enum_protocols() to protocols.c

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-29 16:56:47 +00:00
Derek Buitenhuis
9c75148e6e Merge commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d'
This commit also disables the async fate test, because it
used internal APIs in a non-kosher way, which no longer
exists.

* commit '2758cdedfb7ac61f8b5e4861f99218b6fd43491d':
  lavf: reorganize URLProtocols

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-29 16:51:10 +00: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
Michael Niedermayer
1dba8371d9 avformat: add protocol_whitelist
Note to maintainers: update tools

Note to maintainers: set a default whitelist for your protocol
If that makes no sense then consider to set "none" and thus require the user to specify a white-list
for sub-protocols to be opened

Note, testing and checking for missing changes is needed

Reviewed-by: Andreas Cadhalpun <andreas.cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-02-02 03:39:34 +01:00
Michael Niedermayer
8fac0d6403 avformat/avio: free url/avio options
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-29 19:23:02 +01:00
Michael Niedermayer
984d58a344 avformat/avio: Limit url option parsing to the documented cases
This feature is not know much or used much AFAIK, and it might be helpfull in
exploits.
No specific case is known where it can be used in an exploit though
subsequent commits depend on this commit though

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
2016-01-20 21:21:31 +01:00
Stephan Holljes
5125e4b53f lavf/avio: add ffurl_accept and ffurl_handshake
Signed-off-by: Stephan Holljes <klaxa1337@googlemail.com>
2015-08-01 00:58:31 +02:00
Michael Niedermayer
da8b228977 avformat/avio: Move avio_delete() avio_move() to avpriv_ namespace
This was suggested in the discussion about these functions

With this change the functions are available internally but are not
part of the public API

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-29 16:30:43 +02:00
Mariusz Szczepańczyk
346624be4a lavf: set is_connected flag so url can be properly closed
Reviewed-by: Lukasz Marek <lukasz.m.luki2 at gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-24 15:40:03 +02:00
Mariusz Szczepańczyk
80e18bb486 lavf/avio: Extend API with avio_move() and avio_delete()
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-22 12:46:08 +02:00
wm4
f6c3f1ed60 avformat: clarify what package needs to be compiled with SSL support
Try to reduce user confusion.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-06-18 22:26:36 +02:00
Rodger Combs
f24d92bada lavf/tls: Support Secure Transport
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-05-29 21:52:27 +02:00
Lukasz Marek
184084c699 lavf: add directory listing API
API allows protocol implementations to provide API that
allows to list directory content.
API is similar to POSIX opendir/readdir/closedir.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-27 18:29:46 +01:00
Michael Niedermayer
22af79a9c8 Merge commit 'b97f427fb56bdbf7de8e2d4b72d01114aa6eceda'
* commit 'b97f427fb56bdbf7de8e2d4b72d01114aa6eceda':
  lavf: Explicitly convert types at function pointer assignment

Conflicts:
	libavformat/avio.c
	libavformat/aviobuf.c
	libavformat/swfenc.c

See: a76a2ffe9d and others
Merged-by: Michael Niedermayer <michaelni@gmx.at>
2015-03-12 12:38:20 +01:00