summaryrefslogtreecommitdiffstats
path: root/libavformat/aviobuf.c
Commit message (Collapse)AuthorAgeFilesLines
* lavf/aviobuf: add ff_get_chomp_lineJun Zhao2018-04-121-0/+8
| | | | | | | Same as ff_get_line but strip the white-space characters in the string tail. Signed-off-by: Jun Zhao <[email protected]>
* avformat/aviobuf: add ff_read_line_to_bprint and ↵Marton Balint2018-02-241-0/+46
| | | | | | | | ff_read_line_to_bprint_overwrite functions To be able to read lines longer than a static buffer size. Signed-off-by: Marton Balint <[email protected]>
* avformat/aviobuf: zero initialize the AVIOContext in ffio_init_context()James Almer2018-02-141-1/+3
| | | | | | | | This makes sure no field is ever used uninitialized. Reviewed-by: Carl Eugen Hoyos <[email protected]> Reviewed-by: wm4 <[email protected]> Signed-off-by: James Almer <[email protected]>
* libavformat/avio: Utility function to return URLContextJeyapal, Karthick2017-11-291-0/+13
|
* lavf/aviobuf: return EINVAL when reading from a write-only context.Nicolas George2017-10-291-1/+1
| | | | Signed-off-by: Nicolas George <[email protected]>
* lavf/avio: temporarily accept 0 as EOF.Nicolas George2017-10-291-9/+21
| | | | | | | | Print a warning to let applicatios fix their use. After a deprecation period, check with a low-level assert. Also make the constraint explicit in the doxygen comment. Signed-off-by: Nicolas George <[email protected]>
* avformat: Drop deprecated feof() AVIO fuctionJames Almer2017-10-211-7/+0
| | | | Deprecated in 08/2014.
* libavformat: not treat 0 as EOFDaniel Kucera2017-10-191-8/+12
| | | | | | | | | | 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 <[email protected]>
* lavf: make avio_read_partial() publicwm42017-09-011-1/+1
| | | | | | | | | Main use-case is proxying avio through a foreign I/O layer and a custom AVIO context, without losing latency and performance characteristics. Signed-off-by: Luca Barbato <[email protected]> Merged from Libav commit 173b56218f39c64.
* avio: add a destructor for AVIOContextAnton Khirnov2017-09-011-3/+14
| | | | | | | | Before this commit, AVIOContext is to be freed with a plain av_free(), which prevents us from adding any deeper structure to it. (cherry picked from commit 99684f3ae752fc8bfb44a2dd1482f8d7a3d8536d) Signed-off-by: James Almer <[email protected]>
* avformat/aviobuf: Fix signed integer overflow in avio_seek()Vitaly Buka2017-08-231-0/+2
| | | | | | | | Signed integer overflow is undefined behavior. Detected with clang and -fsanitize=signed-integer-overflow Signed-off-by: Vitaly Buka <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
* avformat/aviobuf: add support for specifying minimum packet size and marking ↵Marton Balint2017-06-241-0/+7
| | | | | | | flush points Reviewed-by: Michael Niedermayer <[email protected]> Signed-off-by: Marton Balint <[email protected]>
* avformat/aviobuf: fix flushing write buffers after seeking backward or forwardMarton Balint2017-06-241-12/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch makes aviobuf work more like traditinal file IO, which is how people think about it. For example, in the past, aviobuf only flushed buffers until the current buffer position, even if more data was written to it previously, and a backward seek was used to reposition the IO context. From now, aviobuf will keep track of the written data, so no explicit seek will be required till the end of the buffer, or till the end of file before flushing. This fixes at least one regression, fate-vsynth3-flv was broken if flush_packets option was set to false, an explicit seek was removed in 4e3cc4bdd8acedbcc703607ed0efbb64bb5c3cc4. Also from now on, if a forward seek in the write buffer were to cause a gap between the already written data and the new file position, a flush will happen. The must_flush varable is also removed, which might have caused needless flushes with multiple seeks whithin the write buffer. Since we know the amount of data written to it, we will know when to flush. Signed-off-by: Marton Balint <[email protected]>
* avformat/aviobuf: Only downscale the buffer once it has been usedMichael Niedermayer2017-05-191-1/+1
| | | | | | The code mistook the first iteration sometimes as the end Signed-off-by: Michael Niedermayer <[email protected]>
* Merge commit '3f75e5116b900f1428aa13041fc7d6301bf1988a'James Almer2017-04-131-0/+7
|\ | | | | | | | | | | | | * commit '3f75e5116b900f1428aa13041fc7d6301bf1988a': avio: Keep track of the amount of data written Merged-by: James Almer <[email protected]>
| * avio: Keep track of the amount of data writtenLuca Barbato2016-12-081-3/+10
| | | | | | | | Make avio_size() work with any write AVIOContext.
* | Merge commit '8ea35af7620e4f73f9e8c072e1c0fac9a04ec161'James Almer2017-03-211-0/+3
|\| | | | | | | | | | | | | * commit '8ea35af7620e4f73f9e8c072e1c0fac9a04ec161': avio: add a new flag for marking streams seekable by timestamp Merged-by: James Almer <[email protected]>
| * avio: add a new flag for marking streams seekable by timestampAnton Khirnov2016-09-301-0/+3
| |
* | Merge commit '83548fe894cdb455cc127f754d09905b6d23c173'James Almer2017-03-211-1/+1
|\| | | | | | | | | | | | | * commit '83548fe894cdb455cc127f754d09905b6d23c173': lavf: fix usage of AVIOContext.seekable Merged-by: James Almer <[email protected]>
| * lavf: fix usage of AVIOContext.seekableAnton Khirnov2016-09-301-1/+1
| | | | | | | | | | | | | | | | It is supposed to be a flag. The only currently defined value is AVIO_SEEKABLE_NORMAL, but other ones may be added in the future. However all the current lavf code treats this field as a bool (mainly for historical reasons). Change all those cases to properly check for AVIO_SEEKABLE_NORMAL.
* | HTTP: improve performance by reducing forward seeksJoel Cunningham2017-02-141-1/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
* | libavformat/avio: Add avio_get_dyn_buf functionsoftworkz2017-01-071-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds the avio_get_dyn_buf function which allows accessing the content of a DynBuffer without destroying it. This is required in matroskaenc for preliminary writing (correct) mkv headers. Context for this change is fixing regression bug #5977. Signed-off-by: Michael Niedermayer <[email protected]>
* | lavf/aviobuf.c: Adapt avio_accept and avio_handshake to new AVIOContext APIStephan Holljes2016-10-031-2/+4
| | | | | | | | Signed-off-by: Stephan Holljes <[email protected]>
* | avformat/avio: add a crc callback function for CRC-32 IEEE-LEJames Almer2016-08-041-0/+6
| | | | | | | | | | | | Reviewed-by: Nicolas George <[email protected]> Reviewed-by: Michael Niedermayer <[email protected]> Signed-off-by: James Almer <[email protected]>
* | cosmetics: fix some misspelled wordsJames Almer2016-07-171-1/+1
| | | | | | | | Signed-off-by: James Almer <[email protected]>
* | Merge commit 'db7968bff4851c2be79b15b2cb2ae747424d2fca'Matthieu Bouron2016-06-231-2/+50
|\| | | | | | | | | | | | | * commit 'db7968bff4851c2be79b15b2cb2ae747424d2fca': avio: Allow custom IO users to get labels for the output bytestream Merged-by: Matthieu Bouron <[email protected]>
| * avio: Allow custom IO users to get labels for the output bytestreamMartin Storsjö2016-05-181-2/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows callers with avio write callbacks to get the bytestream positions that correspond to keyframes, suitable for live streaming. In the simplest form, a caller could expect that a header is written to the bytestream during the avformat_write_header, and the data output to the avio context during e.g. av_write_frame corresponds exactly to the current packet passed in. When combined with av_interleaved_write_frame, and with muxers that do buffering (most muxers that do some sort of fragmenting or clustering), the mapping from input data to bytestream positions is nontrivial. This allows callers to get directly information about what part of the bytestream is what, without having to resort to assumptions about the muxer behaviour. One keyframe/fragment/block can still be split into multiple (if they are larger than the aviocontext buffer), which would call the callback with e.g. AVIO_DATA_MARKER_SYNC_POINT, followed by AVIO_DATA_MARKER_UNKNOWN for the second time it is called with the following data. Signed-off-by: Martin Storsjö <[email protected]>
* | Merge commit 'fab8156b2f30666adabe227b3d7712fd193873b1'Derek Buitenhuis2016-04-211-1/+1
|\| | | | | | | | | | | | | * commit 'fab8156b2f30666adabe227b3d7712fd193873b1': avio: Copy URLContext generic options into child URLContexts Merged-by: Derek Buitenhuis <[email protected]>
| * avio: Copy URLContext generic options into child URLContextsMartin Storsjö2016-03-241-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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ö <[email protected]>
| * lavf: add a protocol whitelist/blacklist for file opened internallyAnton Khirnov2016-02-221-4/+63
| | | | | | | | | | | | | | | | Should make the default behaviour safer for careless callers that open random untrusted files. Bug-Id: CVE-2016-1897 Bug-Id: CVE-2016-1898
| * urlprotocol: receive a list of protocols from the callerAnton Khirnov2016-02-221-2/+18
| | | | | | | | | | This way, the decisions about which protocols are available for use in any given situations can be delegated to the caller.
* | hls: read protocol options through the AVIOContextHendrik Leppkes2016-03-161-0/+4
| | | | | | | | | | | | | | | | | | | | This reverts commit 9f9ed79d4cb40e5d9093899f8a79086ff23da844. The hlsopts member was never set anywhere and always NULL, furthermore the HLS demuxer needs to retrieve the proper options from the underlying http protocol (cookies, user-agent, etc), so a dummy context won't help. Instead, use the AVIOContext directly to access the options.
* | avformat: Add a protocol blacklisting APIDerek Buitenhuis2016-03-041-4/+9
| | | | | | | | Signed-off-by: Derek Buitenhuis <[email protected]>
* | hls: Add and use a memebr of AVIOInternal rather than abuse opaqueDerek Buitenhuis2016-02-291-4/+0
| | | | | | | | Signed-off-by: Derek Buitenhuis <[email protected]>
* | Merge commit 'cae448cfbf31d492cba782bc64fc4eed556ed83d'Derek Buitenhuis2016-02-291-17/+68
|\| | | | | | | | | | | | | * commit 'cae448cfbf31d492cba782bc64fc4eed556ed83d': aviobuf: add a private data struct for avio_open()ed contexts Merged-by: Derek Buitenhuis <[email protected]>
| * aviobuf: add a private data struct for avio_open()ed contextsAnton Khirnov2016-02-221-16/+66
| | | | | | | | It will be useful in the following commits.
* | avformat: add protocol_whitelistMichael Niedermayer2016-02-021-4/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 <[email protected]> Signed-off-by: Michael Niedermayer <[email protected]>
* | avformat/avio: free url/avio optionsMichael Niedermayer2016-01-291-0/+1
| | | | | | | | Signed-off-by: Michael Niedermayer <[email protected]>
* | avformat/aviobuf: Fix end check in put_str16()Michael Niedermayer2016-01-131-0/+2
| | | | | | | | | | | | | | | | Fixes out of array read Fixes: 03c406ec9530e594a074ce2979f8a1f0/asan_heap-oob_7dec26_4664_37c52495b2870a2eaac65f53958e76c1.flac Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <[email protected]>
* | avio: add detail to avio_printf() size warningReynaldo H. Verdejo Pinochet2015-12-271-1/+1
| | | | | | | | | | | | | | Previous "currently size is limited" didn't give away much in terms of useful info. Signed-off-by: Reynaldo H. Verdejo Pinochet <[email protected]>
* | avformat/aviobuf: Simplify avio_read() and avio_seek()Bryan Huh2015-11-161-5/+4
| | | | | | | | Signed-off-by: Michael Niedermayer <[email protected]>
* | avformat/aviobuf: Improve readability of aviobuf (Add comments and docs)Bryan Huh2015-11-161-2/+5
| | | | | | | | Signed-off-by: Michael Niedermayer <[email protected]>
* | lavf/avio: add avio_accept and avio_handshakeStephan Holljes2015-08-011-0/+17
| | | | | | | | Signed-off-by: Stephan Holljes <[email protected]>
* | Merge commit '059a934806d61f7af9ab3fd9f74994b838ea5eba'Michael Niedermayer2015-07-271-2/+2
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * commit '059a934806d61f7af9ab3fd9f74994b838ea5eba': lavc: Consistently prefix input buffer defines Conflicts: doc/examples/decoding_encoding.c libavcodec/4xm.c libavcodec/aac_adtstoasc_bsf.c libavcodec/aacdec.c libavcodec/aacenc.c libavcodec/ac3dec.h libavcodec/asvenc.c libavcodec/avcodec.h libavcodec/avpacket.c libavcodec/dvdec.c libavcodec/ffv1enc.c libavcodec/g2meet.c libavcodec/gif.c libavcodec/h264.c libavcodec/h264_mp4toannexb_bsf.c libavcodec/huffyuvdec.c libavcodec/huffyuvenc.c libavcodec/jpeglsenc.c libavcodec/libxvid.c libavcodec/mdec.c libavcodec/motionpixels.c libavcodec/mpeg4videodec.c libavcodec/mpegvideo.c libavcodec/noise_bsf.c libavcodec/nuv.c libavcodec/nvenc.c libavcodec/options.c libavcodec/parser.c libavcodec/pngenc.c libavcodec/proresenc_kostya.c libavcodec/qsvdec.c libavcodec/svq1enc.c libavcodec/tiffenc.c libavcodec/truemotion2.c libavcodec/utils.c libavcodec/utvideoenc.c libavcodec/vc1dec.c libavcodec/wmalosslessdec.c libavformat/adxdec.c libavformat/aiffdec.c libavformat/apc.c libavformat/apetag.c libavformat/avidec.c libavformat/bink.c libavformat/cafdec.c libavformat/flvdec.c libavformat/id3v2.c libavformat/isom.c libavformat/matroskadec.c libavformat/mov.c libavformat/mpc.c libavformat/mpc8.c libavformat/mpegts.c libavformat/mvi.c libavformat/mxfdec.c libavformat/mxg.c libavformat/nutdec.c libavformat/oggdec.c libavformat/oggparsecelt.c libavformat/oggparseflac.c libavformat/oggparseopus.c libavformat/oggparsespeex.c libavformat/omadec.c libavformat/rawdec.c libavformat/riffdec.c libavformat/rl2.c libavformat/rmdec.c libavformat/rtpdec_latm.c libavformat/rtpdec_mpeg4.c libavformat/rtpdec_qdm2.c libavformat/rtpdec_svq3.c libavformat/sierravmd.c libavformat/smacker.c libavformat/smush.c libavformat/spdifenc.c libavformat/takdec.c libavformat/tta.c libavformat/utils.c libavformat/vqf.c libavformat/westwood_vqa.c libavformat/xmv.c libavformat/xwma.c libavformat/yop.c Merged-by: Michael Niedermayer <[email protected]>
| * lavc: Consistently prefix input buffer definesVittorio Giovara2015-07-271-2/+2
| | | | | | | | Signed-off-by: Vittorio Giovara <[email protected]>
| * avio: Add avio_put_str16beLuca Barbato2015-06-071-14/+20
| |
* | avio: fix potential crashes when combining ffio_ensure_seekback + crcwm42015-06-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | Calling ffio_ensure_seekback() if ffio_init_checksum() has been called on the same context can lead to out of bounds memory accesses and crashes. The reason is that ffio_ensure_seekback() does not update checksum_ptr after reallocating the buffer, resulting in a dangling pointer. This effectively fixes potential crashes when opening mp3 files. Signed-off-by: Michael Niedermayer <[email protected]>
* | avformat/avio: move short seek threshold to the contextMichael Niedermayer2015-06-111-1/+2
| | | | | | | | | | | | This allows us to adjust it internally. Signed-off-by: Michael Niedermayer <[email protected]>
* | avformat/aviobuf: Check for ffio_set_buf_size() failureMichael Niedermayer2015-06-071-1/+3
| | | | | | | | Signed-off-by: Michael Niedermayer <[email protected]>
* | Merge commit 'bff0349d9da527084e1433167466d8afc9e25c7f'Michael Niedermayer2015-06-011-0/+8
|\| | | | | | | | | | | | | * commit 'bff0349d9da527084e1433167466d8afc9e25c7f': avio: Add avio_read wrapper to simplify error checking Merged-by: Michael Niedermayer <[email protected]>