summaryrefslogtreecommitdiff
path: root/libavformat/hls.c
Commit message (Collapse)AuthorAge
* avformat: Avoid allocation for AVStreamInternalAndreas Rheinhardt2021-09-17
| | | | | | | | | | Do this by allocating AVStream together with the data that is currently in AVStreamInternal; or rather: Put AVStream at the beginning of a new structure called FFStream (which encompasses more than just the internal fields and is a proper context in its own right, hence the name) and remove AVStreamInternal altogether. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/avio: Move internal AVIOContext fields to avio_internal.hAndreas Rheinhardt2021-08-25
| | | | | | | | | | | | | | Currently AVIOContext's private fields are all over AVIOContext. This commit moves them into a new structure in avio_internal.h instead. Said structure contains the public AVIOContext as its first element in order to avoid having to allocate a separate AVIOContextInternal which is costly for those use cases where one just wants to access an already existing buffer via the AVIOContext-API. For these cases ffio_init_context() can't fail and always returned zero, which was typically not checked. Therefore it has been made to not return anything. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hls: Simplify cleanup after read_header failureAndreas Rheinhardt2021-07-07
| | | | | | by setting the FF_FMT_INIT_CLEANUP flag. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/hls: relay format options to segment demuxerGyan Doshi2021-05-30
| | | | | Signed-off-by: Gyan Doshi <ffmpeg@gyani.pro> Reviewed-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/hls: use av_strncasecmp()Limin Wang2021-05-07
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat: Constify all muxer/demuxersAndreas Rheinhardt2021-04-27
| | | | | | | This is possible now that the next-API is gone. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat: Constify the API wrt AV(In|Out)putFormatAndreas Rheinhardt2021-04-27
| | | | | | | Also constify AVProbeData. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/hls: check return value of new_init_section()Marton Balint2021-04-18
| | | | | | Fixes part of ticket #8931. Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/hls: use av_packet_alloc() to allocate packetsJames Almer2021-03-17
| | | | Signed-off-by: James Almer <jamrial@gmail.com>
* libavformat/hls: Reset options after open_url_keepalive() failsEd Martin2021-03-15
| | | | | | | | | | | | | | open_url_keepalive() unsets the options when it uses them, this includes the offsets for the Range: header. When using the HLS tag #EXT-X-BYTERANGE along with multiple files, the range options must be preserved after open_url_keepalive() returns EOF so that the new file can be opened. Failure to do this results in ignoring the #EXT-X-BYTERANGE tag and reading the wrong bytes of the file. To fix it, reset the options before calling io_open() following open_url_keepalive() reaching EOF Reviewed-by: Steven Liu <liuqi05@kuaishou.com>
* avformat/hls: change sequence number type to int64_tZhao Zhili2021-01-24
| | | | | | | | Fix atoi() overflow for large EXT-X-MEDIA-SEQUENCE. The spec says the type of sequence number is uint64_t. Use int64_t here since current implementation requires it to be signed integer, and hlsenc use int64_t too.
* avformat/hls: update comment of file descriptionSteven Liu2020-12-28
| | | | | | reference link to rfc8216 Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* libavformat/hls: use local var url for log to avoid crashbevis2020-10-22
| | | | | | | | | During operation, the user exits and interrupts, causing pls->segment to be released, resulting in a null pointer crash Signed-off-by: bevis <javashu2012@gmail.com> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* lavf/hls: add AC-3/EAC-3 to allowed extensions file listJun Zhao2020-09-28
| | | | | | | | | | Add AC-3/EAC-3 to allowed extensions file list. From HTTP Live Streaming 2nd Edition draft-pantos-hls-rfc8216bis-07 section 3.1.3.Packed Audio, HLS demuxer need to support MP3/AC-3/EAC-3. Reviewd-by: Steven Liu <liuqi05@kuaishou.com> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/dashdec, hls: Update correct pointer to AVDictionaryAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | | | | | | | | | | open_url() in the DASH as well in the hls demuxer share a common bug: They modify an AVDictionary (i.e. set a new entry) given to them as AVDictionary *, yet if this new entry leads to reallocation and relocation of the AVDictionary, the caller's pointer will become dangling, leading to use-after-frees. So pass an AVDictionary **. (With the current implementation of AVDictionary the above can only happen if the AVDictionary was empty initially (in which case the new AVDictionary leaks); furthermore if the I/O is ordinary (i.e. opened by avio_open2() or ffio_open_whitelist()), the dict is never empty (it contains an rw_timeout entry from save_avio_options()). So this issue could only happen if the caller sets a nondefault io_open callback, but no AVIOContext (the AVFMT_FLAG_CUSTOM_IO flag won't be set in this case). In case of the HLS demuxer, it was also necessary that setting the "seekable" entry failed. Yet one should simply not rely on internals of the AVDict API.) Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hls: Use av_init_pkt() directlyAndreas Rheinhardt2020-08-18
| | | | | | | | | and remove reset_packet(). The packet's data pointer is already zeroed, so the only thing that reset_packet() does that av_init_pkt() doesn't is redundant. Reviewed-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hls: Remove redundant resetting of AVPacketAndreas Rheinhardt2020-08-18
| | | | | | | av_read_frame() already returns blank packets on error. Reviewed-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hls: Fix memleak when url is emptyAndreas Rheinhardt2020-08-18
| | | | | | | Fixes Coverity ID 1465888. Reviewed-by: Steven Liu <lingjiujianke@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hls: support avio_seek in encryption modeSteven Liu2020-08-10
| | | | Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* lavf/hls: enable custom interrup callback in sub-demuxerJun Zhao2020-07-20
| | | | | | | Enable the custom callback in sub-demuxer Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/hls: Pass a copy of the URL for probingMichael Niedermayer2020-07-01
| | | | | | | | | | The segments / url can be modified by the io read when reloading This may be an alternative or additional fix for Ticket8673 as a further alternative the reload stuff could be disabled during probing Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
* lavf/hls: Add missed side data/dispositionvacingfang2020-06-18
| | | | | | | | | hls demuxer get the stream info from sub-stream, but missed side data/disposition part, e,g, missed the DOVI side data when the stream is Dolby Vision streams. Reviewed-by <liuqi05@kuaishou.com> Signed-off-by: vacingfang <vacingfang@tencent.com>
* avformat/hls: check segment duration value of EXTINFSteven Liu2020-06-10
| | | | | | | fix ticket: 8673 set the default EXTINF duration to 1ms if duration is smaller than 1ms Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/hls: check output string is usable of ff_make_absolute_urlSteven Liu2020-06-10
| | | | | | | fix ticket: 8688 should goto failed workflow if cannot get usable string by ff_make_absolute_url Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/id3v2: Remove unnecessary indirectionAndreas Rheinhardt2020-05-25
| | | | | | | | | ff_id3v2_parse_apic/chapters/priv/priv_dict all had a parameter extra_meta of type ID3v2ExtraMeta ** as if the functions wanted to make *extra_meta point to something else. But they don't, so just use an ID3v2ExtraMeta *. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/id3v2: Avoid allocations for ID3v2ExtraMetaAndreas Rheinhardt2020-05-25
| | | | | | | | | | | | Up until now, the ID3v2ExtraMeta structure (which is used when parsing ID3v2 tags containing attached pictures, chapters etc.) contained a pointer to separately allocated data that depended on the type of the tag. Yet the difference of the sizes of the largest and the smallest of these structures is fairly small, so that it is better to simply include a union of all the possible types of tag-dependent structures in ID3v2ExtraMeta. This commit implements this. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hls: Remove redundant resetting of pointerAndreas Rheinhardt2020-05-20
| | | | | | | | ff_id3v2_free_extra_meta() takes a ID3V2ExtraMeta ** so that it can already reset the pointer. Reviewed-by: Jun Zhao <mypopy@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hls: Don't strdup non-null-terminated stringAndreas Rheinhardt2020-03-24
| | | | | | | | | | | | | | | | If an URI indicated that the data protocol was in use, it would be copied into a temporary buffer via strncpy(dst, src, strlen(src)), thereby ensuring that the trailing \0 would not be copied, despite dst being uninitialized. dst would then be av_strdup'ed, leading to potential segfaults. The solution to this is simple: Don't copy the URI in the temporary buffer at all, instead av_strdup it directly. This fixes a -Wstringop-truncation warning emitted by GCC 9.2. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat: Remove unnecessary av_packet_unref()Andreas Rheinhardt2020-02-10
| | | | | | | | | Since bae8844e the packet will always be unreferenced when a demuxer returns an error, so that a lot of calls to av_packet_unref() in lots of demuxers are now redundant and can be removed. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com> Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/hls: support data protocol in uri for EXT-X-MAPSteven Liu2020-01-18
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/hls: propagate icy to child AVIOContextsMarvin Scholz2019-12-27
| | | | | | | | | | | When the user decides they do not want to to send the Icy-MetaData header, this should be respected for all requests, not just the first one. Fix #5578 Reviewed-by: Liu Steven <lq@chinaffmpeg.org> Signed-off-by: James Almer <jamrial@gmail.com>
* avformat/hls: Use av_packet_move_ref() for packet ownership transferAndreas Rheinhardt2019-12-23
| | | | Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/hls: correct grammatical errors of m3u8_hold_counters optionSteven Liu2019-11-27
| | | | | | Suggested-by: Gyan <ffmpeg@gyani.pro> Suggested-by: Rodney Baker <rodney.baker@iinet.net.au> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/hls: add option for the m3u8 list load max timesSteven Liu2019-11-25
| | | | | | | set max times for load m3u8 when the m3u8 list refresh do not with new segments any times. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/hls: continue to play enabled playlist when have failed playlistSteven Liu2019-11-13
| | | | | | fix ticket: 7811 Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* lavf/hls: support probesize/max_analyze_duration when open sub-demuxerJun Zhao2019-11-08
| | | | | | | Add probesize/max_analyze_duration support when open the sub-demuxer, it's will be used to minimizing the initial delay. Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: fix the log context setting in log messageJun Zhao2019-11-08
| | | | | | Fix the log context setting in log message Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/hls: Set AVFMT_TS_DISCONT flag on HLS input formatPhilip Langdale2019-10-30
| | | | | | | | | | | | | | | | | | | | | | | | | | There have been many reports over the years about problems when taking an HLS stream as input to `ffmpeg` where there are timestamp discontinuities present. This is explicitly supported in the HLS spec (EXT-X-DISCONTINUITY) and often used for ad injection. Various fixes and work-arounds have been proposed over the years, but one step that seems obvious, even if it's not a complete fix, is to mark the HLS input format as supporting discontinuities. This will prevent timestamp fixup logic in ffmpeg.c kicking in that ends up mangling the timestamps unnecessarily. I've tested this out with an example provided by Joe Koberg early last year, and it is sufficient to allow `ffmpeg` to download and mux the stream correctly. Joe had briefly suggested that other situations can still be handled incorrectly, but this seems like a strict improvement. Joe's example: https://s3.amazonaws.com/playon-test-videos/discont_test_new/discont_test.m3u8 Reviewed-by: Steven Liu <lq@onvideo.cn> Reviewed-by: Dennis Mungai <dmngaie@gmail.com>
* avformat/hls: fix missing segment offset reset on last segment when ↵vectronic2019-10-08
| | | | | | | http_multiple is enabled. Reviewed-by: Steven Liu <lq@onvideo.cn> Signed-off-by: vectronic <hello.vectronic@gmail.com>
* avformat/hls: pass http offset options to http requestvectronic2019-10-08
| | | | | | | | made with persistent connections to prevent incorrect reset of offset when demuxing HLS+FMP4 Signed-off-by: Steven Liu <lq@onvideo.cn> Signed-off-by: vectronic <hello.vectronic@gmail.com>
* lavf/hls: fix memory leak in error handling path for option tmpJun Zhao2019-09-14
| | | | | | | fix memory leak in error handling path for option tmp. Reviewed-by: Steven Liu <lq@onvideo.cn> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: remove redundancy seekable settingJun Zhao2019-09-14
| | | | | | | | ffio_init_context with NULL seek callback will setting seekable with 0, so remove the redundancy seekable setting. Reviewed-by: Steven Liu <lq@onvideo.cn> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: drop unnecessary check before ff_format_io_closeJun Zhao2019-09-14
| | | | | | | | ff_format_io_close will check the AVIOContext pointer pb, so drop the unnecessary check before ff_format_io_close. Reviewed-by: Steven Liu <lq@onvideo.cn> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: refine the log messageJun Zhao2019-09-14
| | | | | | | refine the log message, it's will help the debugging Reviewed-by: Steven Liu <lq@onvideo.cn> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: add http_seekable option for HTTP partial requestsJun Zhao2019-08-08
| | | | | | | | | | Add http_seekable option for HTTP partial requests, when The EXT-X-BYTERANGE tag indicates that a Media Segment is a sub-range of the resource identified by its URI, we can use HTTP partial requests to get the Media Segment. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: replace the same code logic with ensure_playlist()vacingfang2019-07-26
| | | | | | | | Replace the same code logic with ensure_playlist(), it's will help reusable blocks of code. Reviewed-by: Jun Zhao <barryjzhao@tencent.com> Signed-off-by: vacingfang <vacingfang@tencent.com>
* lavf/hls: remove redundancy reset_packet() after av_packet_unref()Jun Zhao2019-07-26
| | | | | | | | av_packet_unref have reseted the AVPacket, so don't need to call reset_packet after that. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* lavf/hls: More log messageJun Zhao2019-06-14
| | | | | | | More log message, it's will help the debugging Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/hls: add http 2.0 version number compare for the http_multipleSteven Liu2019-06-14
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
* avformat/hls: avformat_find_stream_info when the audio list in the variantSteven Liu2019-06-14
| | | | Signed-off-by: Steven Liu <lq@chinaffmpeg.org>