mirror of
https://github.com/nyanmisaka/ffmpeg-rockchip.git
synced 2025-10-25 01:41:31 +08:00
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>
This commit is contained in:
@@ -139,11 +139,15 @@ void av_format_inject_global_side_data(AVFormatContext *s)
|
||||
|
||||
int ff_copy_whitelists(AVFormatContext *dst, AVFormatContext *src)
|
||||
{
|
||||
av_assert0(!dst->codec_whitelist && !dst->format_whitelist);
|
||||
av_assert0(!dst->codec_whitelist &&
|
||||
!dst->format_whitelist &&
|
||||
!dst->protocol_whitelist);
|
||||
dst-> codec_whitelist = av_strdup(src->codec_whitelist);
|
||||
dst->format_whitelist = av_strdup(src->format_whitelist);
|
||||
dst->protocol_whitelist = av_strdup(src->protocol_whitelist);
|
||||
if ( (src-> codec_whitelist && !dst-> codec_whitelist)
|
||||
|| (src->format_whitelist && !dst->format_whitelist)) {
|
||||
|| (src-> format_whitelist && !dst-> format_whitelist)
|
||||
|| (src->protocol_whitelist && !dst->protocol_whitelist)) {
|
||||
av_log(dst, AV_LOG_ERROR, "Failed to duplicate whitelist\n");
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
@@ -352,9 +356,11 @@ static int init_input(AVFormatContext *s, const char *filename,
|
||||
(!s->iformat && (s->iformat = av_probe_input_format2(&pd, 0, &score))))
|
||||
return score;
|
||||
|
||||
if ((ret = avio_open2(&s->pb, filename, AVIO_FLAG_READ | s->avio_flags,
|
||||
&s->interrupt_callback, options)) < 0)
|
||||
if ((ret = ffio_open_whitelist(&s->pb, filename, AVIO_FLAG_READ | s->avio_flags,
|
||||
&s->interrupt_callback, options,
|
||||
s->protocol_whitelist)) < 0)
|
||||
return ret;
|
||||
|
||||
if (s->iformat)
|
||||
return 0;
|
||||
return av_probe_input_buffer2(s->pb, &s->iformat, filename,
|
||||
@@ -441,6 +447,14 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
|
||||
goto fail;
|
||||
s->probe_score = ret;
|
||||
|
||||
if (!s->protocol_whitelist && s->pb && s->pb->protocol_whitelist) {
|
||||
s->protocol_whitelist = av_strdup(s->pb->protocol_whitelist);
|
||||
if (!s->protocol_whitelist) {
|
||||
ret = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (s->format_whitelist && av_match_list(s->iformat->name, s->format_whitelist, ',') <= 0) {
|
||||
av_log(s, AV_LOG_ERROR, "Format not on whitelist \'%s\'\n", s->format_whitelist);
|
||||
ret = AVERROR(EINVAL);
|
||||
|
||||
Reference in New Issue
Block a user