Commit Graph

91 Commits

Author SHA1 Message Date
James Almer 02aea61d69 avformat: remove deprecated FF_API_AVIO_WRITE_NONCONST
Signed-off-by: James Almer <jamrial@gmail.com>
2024-03-07 08:53:30 -03:00
Andreas Rheinhardt 57e20dd6b6 avformat/avio: Avoid function pointer casts
It is undefined behaviour to use a different type for a call
than the actual type of the function.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 12:08:18 +01:00
Andreas Rheinhardt f0abb44fbf avformat/aviobuf: Move code specific to URLContexts to avio.c
This separates the URL-layer adjacent parts of the code
from the parts that are also usable with custom IO.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2024-03-05 12:08:18 +01:00
Andreas Rheinhardt 2a68d945cd avformat/avio: Constify data pointees of write callbacks
They are currently non-const for reasons unknown, although
avio_write() accepts a const buffer.

Reviewed-by: Anton Khirnov <anton@khirnov.net>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-10 22:55:42 +02:00
Andreas Rheinhardt e8704a8f60 avformat/aviobuf: Don't use incompatible function pointer type for call
It is undefined behaviour even in cases where it works
(it works because both are pointers). Instead change
the functions involved to use the type expected by the AVIO-API
and add inline wrappers for our internal callers.

Reviewed-by: Tomas Härdin <git@haerdin.se>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2023-09-10 22:55:42 +02:00
Andreas Rheinhardt 155cd6baa4 Remove obsolete version.h inclusions
Forgotten in e7bd47e657.

Reviewed-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-02-24 12:56:49 +01: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
Marton Balint fb4da90fec avformat/url: add ff_make_absolulte_url2 to be able to test windows path cases
Signed-off-by: Marton Balint <cus@passwd.hu>
2021-04-07 22:14:56 +02: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
Andreas Rheinhardt e1cba568f2 avformat/url: Reorder elements of URLProtocol to make it smaller
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
2021-01-27 11:53:22 +01:00
Nicolas George 1201687da2 lavf/url: rewrite ff_make_absolute_url() using ff_url_decompose().
Also add and update some tests.

Change the semantic a little, because for filesytem paths
symlinks complicate things.
See the comments in the code for detail.

Fix trac tickets #8813 and 8814.
2020-08-12 16:45:21 +02:00
Nicolas George d853293679 lavf/url: add ff_url_decompose(). 2020-08-12 16:33:09 +02:00
Anton Khirnov 43ed2b86d6 URLContext: switch to child_class_iterate() 2020-06-10 12:36:44 +02:00
Marton Balint 09891c5391 avformat/aviobuf: add support for specifying minimum packet size and marking flush points
Reviewed-by: Michael Niedermayer <michael@niedermayer.cc>
Signed-off-by: Marton Balint <cus@passwd.hu>
2017-06-24 18:51:29 +02: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
Clément Bœsch 8ef57a0d61 Merge commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb'
* commit '41ed7ab45fc693f7d7fc35664c0233f4c32d69bb':
  cosmetics: Fix spelling mistakes

Merged-by: Clément Bœsch <u@pkh.me>
2016-06-21 21:55:34 +02:00
Vittorio Giovara 41ed7ab45f cosmetics: Fix spelling mistakes
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2016-05-04 18:16:21 +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
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
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 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
Derek Buitenhuis 1a12eb4a73 Merge commit '29c2d06d67724e994980045afa055c6c34611b30'
* commit '29c2d06d67724e994980045afa055c6c34611b30':
  cosmetics: Drop empty comment lines

Merged-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
2016-02-24 17:31:44 +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 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 29c2d06d67 cosmetics: Drop empty comment lines 2016-02-18 15:35:30 +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
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
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
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 83a897656a Merge commit 'fb238f8230c1b0314985482207add548c68f83cf'
* commit 'fb238f8230c1b0314985482207add548c68f83cf':
  urlprotocol: remove unused url_interrupt_cb declaration

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-10-18 12:16:04 +02:00
Anton Khirnov fb238f8230 urlprotocol: remove unused url_interrupt_cb declaration
It is a remnant of the old interrupt callback API.
2014-10-18 05:01:20 +02:00
Michael Niedermayer 6542e5575f Merge commit 'ec4f04da1a3462dac429b9d15dee5f027309da15'
* commit 'ec4f04da1a3462dac429b9d15dee5f027309da15':
  avformat: Mark argument in av_{i|o}format_next/ffurl_protocol_next as const

Conflicts:
	libavformat/format.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2014-07-27 02:09:41 +02: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
Michael Niedermayer 7f019129e1 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  lavf: Remove a now useless parameter to ffurl_register_protocol

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-30 17:48:47 +01: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
Michael Niedermayer d5ec8ba7f2 Do not leave positive values undefined when negative are defined as error
Define positive return values as non errors and leave further meaning undefined
This allows future extensions to use these values

Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2013-10-19 16:42:57 +02:00
Michael Niedermayer 1f87cbe834 Merge commit 'df9f22d42b0905385629a9d368bb5a1eef2b45ef'
* commit 'df9f22d42b0905385629a9d368bb5a1eef2b45ef':
  avf: move url utility functions in a separate file

Conflicts:
	libavformat/internal.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2013-06-17 00:09:31 +02:00
Luca Barbato df9f22d42b avf: move url utility functions in a separate file 2013-06-16 15:01:39 +02:00
Andrey Utkin 7870722592 Add 'rw_timeout' into URLContext
If set non-zero, limits duration of retry_transfer_wrapper() loop, thus
affects ffurl_read*(), ffurl_write()
Measured in microseconds.

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-29 00:05:03 +02:00
Michael Niedermayer 6c180b35c4 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  mpegvideo_enc: don't use deprecated avcodec_encode_video().
  cmdutils: refactor -codecs option.
  avconv: make -shortest a per-output file option.
  lavc: add avcodec_descriptor_get_by_name().
  lavc: add const to AVCodec* function parameters.
  swf(dec): replace CODEC_ID with AV_CODEC_ID
  dvenc: don't use deprecated AVCODEC_MAX_AUDIO_FRAME_SIZE
  rtmpdh: Do not generate the same private key every time when using libnettle
  rtp: remove ff_rtp_get_rtcp_file_handle().
  rtsp.c: use ffurl_get_multi_file_handle() instead of ff_rtp_get_rtcp_file_handle()
  avio: add (ff)url_get_multi_file_handle() for getting more than one fd
  h264: vdpau: fix crash with unsupported colorspace
  amrwbdec: Decode the fr_quality bit properly

Conflicts:
	Changelog
	cmdutils.c
	cmdutils_common_opts.h
	doc/ffmpeg.texi
	ffmpeg.c
	ffmpeg.h
	ffmpeg_opt.c
	libavcodec/h264.c
	libavcodec/options.c
	libavcodec/utils.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-08-18 15:20:32 +02: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
Michael Niedermayer edf96d631c url: add ffurl_closep() which also sets the context pointer to NULL
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
2012-06-01 14:47:30 +02:00
Michael Niedermayer d0ad91c258 Merge remote-tracking branch 'qatar/master'
* qatar/master:
  os_support: Define SHUT_RD, SHUT_WR and SHUT_RDWR on OS/2
  http: Add support for reading http POST reply headers
  http: Add http_shutdown() for ending writing of posts
  tcp: Allow signalling end of reading/writing
  avio: Add a function for signalling end of reading/writing
  lavfi: fix comment, audio is supported now.
  lavfi: fix incorrect comment.
  lavfi: remove avfilter_null_* from public API on next bump.
  lavfi: remove avfilter_default_* from public API on next bump.
  lavfi: deprecate default config_props() callback and refactor avfilter_config_links()
  avfiltergraph: smarter sample format selection.
  avconv: rename transcode_audio/video to decode_audio/video.
  asyncts: reset delta to 0 when it's not used.
  x86: lavc: use %if HAVE_AVX guards around AVX functions in yasm code.
  dwt: return errors from ff_slice_buffer_init()

Conflicts:
	ffmpeg.c
	libavfilter/avfilter.c
	libavfilter/avfilter.h
	libavfilter/formats.c
	libavfilter/version.h
	libavfilter/vf_blackframe.c
	libavfilter/vf_drawtext.c
	libavfilter/vf_fade.c
	libavfilter/vf_format.c
	libavfilter/vf_showinfo.c
	libavfilter/video.c
	libavfilter/video.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
2012-05-23 21:48:31 +02: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