Revert "cmdutils: make use of new iteration APIs"
This reverts commit cdc78058c78dfa4966758a342acd2c1f3b282c46. It introduced several issues in the command line tools, and it's implementing a new API that may still see some changes. Revert for the time being until the state of the API is defined. Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
parent
ddd851f7cb
commit
cb97400f93
@ -1250,11 +1250,19 @@ int show_license(void *optctx, const char *opt, const char *arg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int is_device(const AVClass *avclass)
|
||||||
|
{
|
||||||
|
if (!avclass)
|
||||||
|
return 0;
|
||||||
|
return AV_IS_INPUT_DEVICE(avclass->category) || AV_IS_OUTPUT_DEVICE(avclass->category);
|
||||||
|
}
|
||||||
|
|
||||||
static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
|
static int show_formats_devices(void *optctx, const char *opt, const char *arg, int device_only, int muxdemuxers)
|
||||||
{
|
{
|
||||||
const AVInputFormat *ifmt = NULL;
|
AVInputFormat *ifmt = NULL;
|
||||||
const AVOutputFormat *ofmt = NULL;
|
AVOutputFormat *ofmt = NULL;
|
||||||
const char *last_name;
|
const char *last_name;
|
||||||
|
int is_dev;
|
||||||
|
|
||||||
printf("%s\n"
|
printf("%s\n"
|
||||||
" D. = Demuxing supported\n"
|
" D. = Demuxing supported\n"
|
||||||
@ -1267,24 +1275,34 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
|
|||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
const char *long_name = NULL;
|
const char *long_name = NULL;
|
||||||
|
|
||||||
#define x(func, type, condition) do { \
|
if (muxdemuxers !=SHOW_DEMUXERS) {
|
||||||
void *i = 0; \
|
while ((ofmt = av_oformat_next(ofmt))) {
|
||||||
if (condition) { \
|
is_dev = is_device(ofmt->priv_class);
|
||||||
while ((type = func(&i))) { \
|
if (!is_dev && device_only)
|
||||||
if ((!name || strcmp(type->name, name) < 0) && \
|
continue;
|
||||||
strcmp(type->name, last_name) > 0) { \
|
if ((!name || strcmp(ofmt->name, name) < 0) &&
|
||||||
name = type->name; \
|
strcmp(ofmt->name, last_name) > 0) {
|
||||||
long_name = type->long_name; \
|
name = ofmt->name;
|
||||||
encode = 1; \
|
long_name = ofmt->long_name;
|
||||||
} \
|
encode = 1;
|
||||||
} \
|
}
|
||||||
} } while(0)
|
}
|
||||||
|
}
|
||||||
x(av_muxer_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS && !device_only);
|
if (muxdemuxers != SHOW_MUXERS) {
|
||||||
x(av_outdev_iterate, ofmt, muxdemuxers != SHOW_DEMUXERS);
|
while ((ifmt = av_iformat_next(ifmt))) {
|
||||||
x(av_demuxer_iterate, ifmt, muxdemuxers != SHOW_MUXERS && !device_only);
|
is_dev = is_device(ifmt->priv_class);
|
||||||
x(av_indev_iterate, ifmt, muxdemuxers != SHOW_MUXERS);
|
if (!is_dev && device_only)
|
||||||
#undef x
|
continue;
|
||||||
|
if ((!name || strcmp(ifmt->name, name) < 0) &&
|
||||||
|
strcmp(ifmt->name, last_name) > 0) {
|
||||||
|
name = ifmt->name;
|
||||||
|
long_name = ifmt->long_name;
|
||||||
|
encode = 0;
|
||||||
|
}
|
||||||
|
if (name && strcmp(ifmt->name, name) == 0)
|
||||||
|
decode = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!name)
|
if (!name)
|
||||||
break;
|
break;
|
||||||
last_name = name;
|
last_name = name;
|
||||||
@ -1424,8 +1442,7 @@ static char get_media_type_char(enum AVMediaType type)
|
|||||||
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
|
static const AVCodec *next_codec_for_id(enum AVCodecID id, const AVCodec *prev,
|
||||||
int encoder)
|
int encoder)
|
||||||
{
|
{
|
||||||
void *i = 0;
|
while ((prev = av_codec_next(prev))) {
|
||||||
while ((prev = av_codec_iterate(&i))) {
|
|
||||||
if (prev->id == id &&
|
if (prev->id == id &&
|
||||||
(encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
|
(encoder ? av_codec_is_encoder(prev) : av_codec_is_decoder(prev)))
|
||||||
return prev;
|
return prev;
|
||||||
@ -2099,7 +2116,7 @@ double get_rotation(AVStream *st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_AVDEVICE
|
#if CONFIG_AVDEVICE
|
||||||
static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts)
|
static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
|
||||||
{
|
{
|
||||||
int ret, i;
|
int ret, i;
|
||||||
AVDeviceInfoList *device_list = NULL;
|
AVDeviceInfoList *device_list = NULL;
|
||||||
@ -2114,7 +2131,7 @@ static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = avdevice_list_input_sources((AVInputFormat*)fmt, NULL, opts, &device_list)) < 0) {
|
if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) {
|
||||||
printf("Cannot list sources.\n");
|
printf("Cannot list sources.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -2129,7 +2146,7 @@ static int print_device_sources(const AVInputFormat *fmt, AVDictionary *opts)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int print_device_sinks(const AVOutputFormat *fmt, AVDictionary *opts)
|
static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
|
||||||
{
|
{
|
||||||
int ret, i;
|
int ret, i;
|
||||||
AVDeviceInfoList *device_list = NULL;
|
AVDeviceInfoList *device_list = NULL;
|
||||||
@ -2144,7 +2161,7 @@ static int print_device_sinks(const AVOutputFormat *fmt, AVDictionary *opts)
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((ret = avdevice_list_output_sinks((AVOutputFormat*)fmt, NULL, opts, &device_list)) < 0) {
|
if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) {
|
||||||
printf("Cannot list sinks.\n");
|
printf("Cannot list sinks.\n");
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@ -2183,8 +2200,7 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar
|
|||||||
|
|
||||||
int show_sources(void *optctx, const char *opt, const char *arg)
|
int show_sources(void *optctx, const char *opt, const char *arg)
|
||||||
{
|
{
|
||||||
const AVInputFormat *fmt = NULL;
|
AVInputFormat *fmt = NULL;
|
||||||
void *i = 0;
|
|
||||||
char *dev = NULL;
|
char *dev = NULL;
|
||||||
AVDictionary *opts = NULL;
|
AVDictionary *opts = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -2195,14 +2211,24 @@ int show_sources(void *optctx, const char *opt, const char *arg)
|
|||||||
if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
|
if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
while ((fmt = av_indev_iterate(&i))) {
|
do {
|
||||||
|
fmt = av_input_audio_device_next(fmt);
|
||||||
|
if (fmt) {
|
||||||
if (!strcmp(fmt->name, "lavfi"))
|
if (!strcmp(fmt->name, "lavfi"))
|
||||||
continue; //it's pointless to probe lavfi
|
continue; //it's pointless to probe lavfi
|
||||||
if (dev && !av_match_name(dev, fmt->name))
|
if (dev && !av_match_name(dev, fmt->name))
|
||||||
continue;
|
continue;
|
||||||
print_device_sources(fmt, opts);
|
print_device_sources(fmt, opts);
|
||||||
}
|
}
|
||||||
|
} while (fmt);
|
||||||
|
do {
|
||||||
|
fmt = av_input_video_device_next(fmt);
|
||||||
|
if (fmt) {
|
||||||
|
if (dev && !av_match_name(dev, fmt->name))
|
||||||
|
continue;
|
||||||
|
print_device_sources(fmt, opts);
|
||||||
|
}
|
||||||
|
} while (fmt);
|
||||||
fail:
|
fail:
|
||||||
av_dict_free(&opts);
|
av_dict_free(&opts);
|
||||||
av_free(dev);
|
av_free(dev);
|
||||||
@ -2212,8 +2238,7 @@ int show_sources(void *optctx, const char *opt, const char *arg)
|
|||||||
|
|
||||||
int show_sinks(void *optctx, const char *opt, const char *arg)
|
int show_sinks(void *optctx, const char *opt, const char *arg)
|
||||||
{
|
{
|
||||||
const AVOutputFormat *fmt = NULL;
|
AVOutputFormat *fmt = NULL;
|
||||||
void *i = 0;
|
|
||||||
char *dev = NULL;
|
char *dev = NULL;
|
||||||
AVDictionary *opts = NULL;
|
AVDictionary *opts = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
@ -2224,11 +2249,22 @@ int show_sinks(void *optctx, const char *opt, const char *arg)
|
|||||||
if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
|
if ((ret = show_sinks_sources_parse_arg(arg, &dev, &opts)) < 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
while ((fmt = av_outdev_iterate(&i))) {
|
do {
|
||||||
|
fmt = av_output_audio_device_next(fmt);
|
||||||
|
if (fmt) {
|
||||||
if (dev && !av_match_name(dev, fmt->name))
|
if (dev && !av_match_name(dev, fmt->name))
|
||||||
continue;
|
continue;
|
||||||
print_device_sinks(fmt, opts);
|
print_device_sinks(fmt, opts);
|
||||||
}
|
}
|
||||||
|
} while (fmt);
|
||||||
|
do {
|
||||||
|
fmt = av_output_video_device_next(fmt);
|
||||||
|
if (fmt) {
|
||||||
|
if (dev && !av_match_name(dev, fmt->name))
|
||||||
|
continue;
|
||||||
|
print_device_sinks(fmt, opts);
|
||||||
|
}
|
||||||
|
} while (fmt);
|
||||||
fail:
|
fail:
|
||||||
av_dict_free(&opts);
|
av_dict_free(&opts);
|
||||||
av_free(dev);
|
av_free(dev);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user