summaryrefslogtreecommitdiff
path: root/libavformat/dashdec.c
Commit message (Collapse)AuthorAge
* avformat/hls, dashdec: Don't use AV_OPT flags in av_dict_set()Andreas Rheinhardt2022-05-16
| | | | | | | | | | | | | | | | | av_dict_set() expects a different set of flags, namely the AV_DICT_* flags. Using AV_OPT_FLAG_DECODING_PARAM (or any AV_OPT_FLAG_*) ic av_dict_set() is therefore completely wrong and given that av_dict_set() just doesn't care about whether the string it receives has anything to do with a decoding parameter or not, it should just be removed without replacement. (The numerical value of AV_OPT_FLAG_DECODING_PARAM currently coincides with AV_DICT_IGNORE_SUFFIX. Given that the dictionaries we are dealing with here are always empty (i.e. NULL) before the calls to av_dict_set(), this flag changes nothing. It would be different if it were equal to one of the AV_DICT_DONT_STRDUP_* values.) Reviewed-by: Jan Ekström <jeebjp@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dashdec: accept and relay CENC decryption keyGyan Doshi2022-05-14
| | | | | Allows to process CENC-encrypted media segments. Option arg syntax is same as that for option decryption_key in MOV demuxer
* avformat/demux: Add new demux.h headerAndreas Rheinhardt2022-05-10
| | | | | | And move those stuff already in demuxer-only files to it. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dashdec: avoid calling strlen multiple timesLimin Wang2022-01-30
| | | | | Reviewed-by: Steven Liu <liuqi05@kuaishou.com> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
* avformat/dashdec: do not use filesize when reading XML fileMarton Balint2022-01-09
| | | | Signed-off-by: Marton Balint <cus@passwd.hu>
* avformat/aviobuf: ffio_copy_url_optionsPierre-Anthony Lemieux2021-12-19
| | | | | Signed-off-by: Pierre-Anthony Lemieux <pal@palemieux.com> Signed-off-by: Zane van Iperen <zane@zanevaniperen.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/internal: Move ff_read_line_to_bprint_overwrite to avio_internal.hAndreas Rheinhardt2021-07-29
| | | | | | | | | | | | | It only uses an AVIOContext and an AVBPrint. When doing so, it turned out that several non-users of ff_read_line_to_bprint_overwrite() and ff_bprint_to_codecpar_extradata() relied on libavformat/internal.h to include bprint.h or avstring.h for them. In order to avoid a repeat of this and in order to reduce unnecessary dependencies, a forward declaration of struct AVBPrint is used instead of including bprint.h. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
* avformat/dashdec: 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: 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/dashdec: Also fetch final partial segmentMatt Robinson2021-04-14
| | | | | | | | | | Currently, the DASH demuxer omits the final segment for a non-live stream (using SegmentTemplate) if it is shorter than the other segments. Correct calc_max_seg_no to round up when calulating the number of segments instead of rounding down to resolve this issue. Signed-off-by: Matt Robinson <git@nerdoftheherd.com>
* avformat/dashdec: Don't needlessly strdup metadataAndreas Rheinhardt2021-03-08
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove limit on length of idAndreas Rheinhardt2021-03-08
| | | | | Reviewed-by: James Almer <jamrial@gmail.com> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Increase size of id bufferAndreas Rheinhardt2021-03-02
| | | | | | | | The current size is not enough, see e.g. http://ftp.itec.aau.at/datasets/DASHDataset2014/TearsOfSteel/1sec/TearsOfSteel_1s_simple_2014_05_09.mpd Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Ensure strings are zero-terminatedAndreas Rheinhardt2021-03-02
| | | | | | | | | | | | | | | | | strncpy only ensures that one does not write beyond the end of the destination buffer; in case of truncation it does not zero-terminate the destination buffer. This makes using it the way it is now in the DASH demuxer dangerous. So use av_strlcpy instead. Also don't write anything if there is no id: The buffer has already been zeroed initially. The DASH testset from the Universität Klagenfurt contains samples with ids that are too long. E.g. http://ftp.itec.aau.at/datasets/DASHDataset2014/TearsOfSteel/1sec/TearsOfSteel_1s_simple_2014_05_09.mpd Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Avoid segfault when URL template is unexpectedly missingsfan52021-02-04
| | | | | | This isn't supposed to happen, but unfinished support for non-templated manifests and lack of e.g. presentationTimeOffset handling can provoke such a situation even with well-formed input.
* avformat/dashdec: Fix missing NULL checksfan52021-02-04
|
* avformat/dashdec: rename variable name for more readableSteven Liu2021-02-04
| | | | | | | | Rename is_init_section_common_audio to is_init_section_common_subtitle for is_common_init_section_exist(c->subtitles, c->n_subtitles). Because it is checked to subtitles, not audio. Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/dashdec: check init_section before use it.Steven Liu2021-02-04
| | | | | | | | | | | | | | because there have no Initialization in SegmentTemplate, so it will have no init_section for init segment file. but in the is_common_init_section_exist function it will be used for check to url, url_offset and size, so check init_section before use init_section. And fix code style in is_common_init_section_exist, make the code block short when it too long. fix ticket: 9062 Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/dashdec: check the root url lengthSteven Liu2020-10-20
| | | | | | | if the length of the root url is 0, unnecessary process the root_url Signed-off-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: liuqi05 <liuqi05@kuaishou.com>
* avformat/dashdec: Reset pointer to NULL after freeing itAndreas Rheinhardt2020-10-08
| | | | | | | | | | This is currently safe here, because the effective lifetime of adaptionset_lang is parse_manifest_adaptationset() (i.e. the pointer gets overwritten each time on entry to the function and gets freed before exiting the function), but it is nevertheless safer to reset the pointer. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* libavformat/dashdec: Fix issue with dash on WindowsChristopher Degawa2020-10-08
| | | | | | | | | | | | | | | | | | Use xmlFree instead of av_freep snip from libxml2: * xmlGetProp: ... * Returns the attribute value or NULL if not found. * It's up to the caller to free the memory with xmlFree(). According to libxml2, you are supposed to use xmlFree instead of free on the pointer returned by it, and also using av_freep on Windows will call _aligned_free instead of normal free, causing _aligned_free to raise SIGTRAP and crashing ffmpeg and ffplay. Signed-off-by: Christopher Degawa <ccom@randomderp.com>
* avformat/dashdec: Avoid duplicating stringAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix memleak on allocation error, avoid allocationAndreas Rheinhardt2020-09-21
| | | | | | | | | | get_content_url() allocates two buffers for temporary strings and when one of them couldn't be allocated, it simply returns, although one of the two allocations could have succeeded and would leak in this scenario. This can be fixed by avoiding one of the temporary buffers. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: CosmeticsAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | 1. Perform the necessary reindentations after the last few commits. 2. Adapt switches to the ordinary indentation style. 3. Now that the effective lifetimes of the variables containing the freshly allocated strings used when parsing the representation are disjoint, the variables can be replaced by a single variable. Doing so has the advantage of making it more clear that these are throwaway variables, hence it has been done. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove redundant casts to constAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Return early for unsupported representationsAndreas Rheinhardt2020-09-21
| | | | | | | | | This allows to reduce the level of indentation for parsing the supported representations (audio, video and subtitles). It also allows to avoid some allocations and frees for unsupported representations. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove redundant checksAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | This commit removes two always-true checks as well as a dead default case of a switch. The check when parsing manifests is always true, because we now jump to the cleaning code in case the format of the representation is unknown. The default case of the switch is dead, because the type of the representation is already checked at the beginning of parse_manifest_representation(). The check when reading the header is dead, because we error out if an error happened before. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix memleaks on error to add representation to dynarrayAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | | Up until now, the DASH demuxer used av_dynarray_add() to add audio/video/subtitles representations to arrays. Yet av_dynarray_add() frees the array upon failure, leading to leaks of its elements; furthermore, the element to be added leaks, too. This has been fixed by using av_dynarray_add_nofree() instead and by freeing the elements that could not be added to the list. Furthermore, errors from this are now checked and returned. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix leak of representation languagesAndreas Rheinhardt2020-09-21
| | | | | | | | | | These languages are normally freed after having been added as metadata to their respective AVStreams. Yet if one never reaches said point, they leak. This can happen as a result of an error when reading the header or as a result of refreshing the manifests. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix leak of string on error when parsing representationAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | | | | | The DASH demuxer currently extracts several strings at once from an xml document before processing them one by one; these strings are allocated, stored in local variables and need to be freed by the demuxer itself. So if an error happens when processing one of them, all strings need to be freed before returning. This has simply not been done, leading to leaks. A simple fix would be to add the necessary code for freeing; yet there is a better solution: Avoid having several strings at the same time by extracting a string, processing it and immediately freeing it. That way one only has to free at most one string on error. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix leak of representation on errorAndreas Rheinhardt2020-09-21
| | | | | | | | | | | If parsing a representation fails, it is not added to the list of representations and is therefore not freed in dash_close(); it therefore leaked in most error paths in parse_manifest_representation() (some error paths had (incomplete) code for freeing). This commit fixes freeing the representation in this case. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove unused index of representationAndreas Rheinhardt2020-09-21
| | | | | | | It is always zero. Also remove other unused elements. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Fix memleaks upon read_header failureAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Check allocation of AVProgramAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.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/dashdec: Fix leak of AVDictionary on errorAndreas Rheinhardt2020-09-21
| | | | | | | | Just postpone the allocation of the dict until it is really needed (after the checks that can fail). Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Free subtitle representations on exitAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Free strings as soon as they aren't needed anymoreAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Don't overwrite and leak old initialization fragmentsAndreas Rheinhardt2020-09-21
| | | | | Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Don't leave representation in inconsistent state on errorAndreas Rheinhardt2020-09-21
| | | | | | | | | This currently doesn't cause any trouble, because the only caller did not clean up the representation upon error at all; but fixing this is a prerequisite for doing so. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Remove dead codeAndreas Rheinhardt2020-09-21
| | | | | | | | | | | | | The code in question seems to have been copied from about 70 lines above; yet the code here is only executed if some of the variables (namely representation_segmenttemplate_node and fragment_template_node) are NULL, so it makes no sense to check them for a child element. Also remove a redundant resetting of a pointer to an AVFormatContext after avformat_close_input() (which already sets the pointer to NULL). Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: Avoid double free on errorAndreas Rheinhardt2020-09-21
| | | | | | | | | When using one of the AV_DICT_DONT_STRDUP_KEY/VAL flags, av_dict_set() already frees the key/value on error, so that freeing it again would lead to a double free. Reviewed-by: Steven Liu <lq@chinaffmpeg.org> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
* avformat/dashdec: drop arbitrary DASH manifest size limitJan Ekström2020-09-05
| | | | | | | | | | | | | | | | | | | Currently the utilized AVBPrint API is internally limited to unsigned integers, so if we limit the file size as well as the amount to read to UINT_MAX - 1, we do not require additional limiting to be performed on the values. This change is based on the fact that initially the 8*1024 value added in 96d70694aea64616c68db8be306c159c73fb3980 was only for the case where the file size was not known. It was not a maximum file size limit. In 29121188983932f79aef8501652630d322a9974c this was reworked to be a maximum manifest file size limit, while its commit message appears to only note that it added support for larger manifest file sizes. This should enable various unfortunately large MPEG-DASH manifests, such as Youtube's multi-megabyte live stream archives to load up as well as bring back the original intent of the logic.
* lavf/dashdec: 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>
* lavf/dashdec: Add missed side data/dispositionJun Zhao2020-06-18
| | | | | | | | dash 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 Signed-off-by: Jun Zhao <barryjzhao@tencent.com>
* avformat/dashdec: compute the segment size use current pos minus offset plus oneSteven Liu2020-05-07
| | | | | | | | because the offset should use one byte Reviewed-by: Zhao Jun <barryjzhao@tencent.com> Reported-by: Zhao Jun <barryjzhao@tencent.com> Signed-off-by: Steven Liu <liuqi05@kuaishou.com>
* lavf/dashdec: support larger manifestsrcombs2020-05-06
|
* avformat/dashdec: add attribute lang for audio and subtitle streamsSteven Liu2020-04-15
| | | | | | There should have language in the metadata of streams which show to user Signed-off-by: Steven Liu <lq@chinaffmpeg.org>