static int ffserver_save_avoption(const char *opt, const char *arg, int type, FFServerConfig *config)

{

    static int hinted = 0;

    int ret = 0;

    AVDictionaryEntry *e;

    const AVOption *o = NULL;

    const char *option = NULL;

    const char *codec_name = NULL;

    char buff[1024];

    AVCodecContext *ctx;

    AVDictionary **dict;

    enum AVCodecID guessed_codec_id;



    switch (type) {

    case AV_OPT_FLAG_VIDEO_PARAM:

        ctx = config->dummy_vctx;

        dict = &config->video_opts;

        guessed_codec_id = config->guessed_video_codec_id != AV_CODEC_ID_NONE ?

                           config->guessed_video_codec_id : AV_CODEC_ID_H264;

        break;

    case AV_OPT_FLAG_AUDIO_PARAM:

        ctx = config->dummy_actx;

        dict = &config->audio_opts;

        guessed_codec_id = config->guessed_audio_codec_id != AV_CODEC_ID_NONE ?

                           config->guessed_audio_codec_id : AV_CODEC_ID_AAC;

        break;

    default:

        av_assert0(0);

    }



    if (strchr(opt, ':')) {

        //explicit private option

        snprintf(buff, sizeof(buff), "%s", opt);

        codec_name = buff;

        option = strchr(buff, ':');

        buff[option - buff] = '\0';

        option++;

        if ((ret = ffserver_set_codec(ctx, codec_name, config)) < 0)

            return ret;

        if (!ctx->codec || !ctx->priv_data)

            return -1;

    } else {

        option = opt;

    }



    o = av_opt_find(ctx, option, NULL, type | AV_OPT_FLAG_ENCODING_PARAM, AV_OPT_SEARCH_CHILDREN);

    if (!o && (!strcmp(option, "time_base")  || !strcmp(option, "pixel_format") ||

               !strcmp(option, "video_size") || !strcmp(option, "codec_tag")))

        o = av_opt_find(ctx, option, NULL, 0, 0);

    if (!o) {

        report_config_error(config->filename, config->line_num, AV_LOG_ERROR,

                            &config->errors, "Option not found: %s\n", opt);

        if (!hinted && ctx->codec_id == AV_CODEC_ID_NONE) {

            hinted = 1;

            report_config_error(config->filename, config->line_num, AV_LOG_ERROR, NULL,

                                "If '%s' is a codec private option, then prefix it with codec name, "

                                "for example '%s:%s %s' or define codec earlier.\n",

                                opt, avcodec_get_name(guessed_codec_id) ,opt, arg);

        }

    } else if ((ret = av_opt_set(ctx, option, arg, AV_OPT_SEARCH_CHILDREN)) < 0) {

        report_config_error(config->filename, config->line_num, AV_LOG_ERROR,

                &config->errors, "Invalid value for option %s (%s): %s\n", opt,

                arg, av_err2str(ret));

    } else if ((e = av_dict_get(*dict, option, NULL, 0))) {

        if ((o->type == AV_OPT_TYPE_FLAGS) && arg && (arg[0] == '+' || arg[0] == '-'))

            return av_dict_set(dict, option, arg, AV_DICT_APPEND);

        report_config_error(config->filename, config->line_num, AV_LOG_ERROR,

                &config->errors,

                "Redeclaring value of the option %s, previous value: %s\n",

                opt, e->value);

    } else if (av_dict_set(dict, option, arg, 0) < 0) {

        return AVERROR(ENOMEM);

    }

    return 0;

}

static int ffserver_save_avoption(const char *opt, const char *arg, int type, FFServerConfig *config)

{

    static int hinted = 0;

    int ret = 0;

    AVDictionaryEntry *e;

    const AVOption *o = NULL;

    const char *option = NULL;

    const char *codec_name = NULL;

    char buff[1024];

    AVCodecContext *ctx;

    AVDictionary **dict;

    enum AVCodecID guessed_codec_id;



    switch (type) {

    case AV_OPT_FLAG_VIDEO_PARAM:

        ctx = config->dummy_vctx;

        dict = &config->video_opts;

        guessed_codec_id = config->guessed_video_codec_id != AV_CODEC_ID_NONE ?

                           config->guessed_video_codec_id : AV_CODEC_ID_H264;

        break;

    case AV_OPT_FLAG_AUDIO_PARAM:

        ctx = config->dummy_actx;

        dict = &config->audio_opts;

        guessed_codec_id = config->guessed_audio_codec_id != AV_CODEC_ID_NONE ?

                           config->guessed_audio_codec_id : AV_CODEC_ID_AAC;

        break;

    default:

        av_assert0(0);

    }



    if (strchr(opt, ':')) {

        

        snprintf(buff, sizeof(buff), "%s", opt);

        codec_name = buff;

        option = strchr(buff, ':');

        buff[option - buff] = '\0';

        option++;

        if ((ret = ffserver_set_codec(ctx, codec_name, config)) < 0)

            return ret;

        if (!ctx->codec || !ctx->priv_data)

            return -1;

    } else {

        option = opt;

    }



    o = av_opt_find(ctx, option, NULL, type | AV_OPT_FLAG_ENCODING_PARAM, AV_OPT_SEARCH_CHILDREN);

    if (!o && (!strcmp(option, "time_base")  || !strcmp(option, "pixel_format") ||

               !strcmp(option, "video_size") || !strcmp(option, "codec_tag")))

        o = av_opt_find(ctx, option, NULL, 0, 0);

    if (!o) {

        report_config_error(config->filename, config->line_num, AV_LOG_ERROR,

                            &config->errors, "Option not found: %s\n", opt);

        if (!hinted && ctx->codec_id == AV_CODEC_ID_NONE) {

            hinted = 1;

            report_config_error(config->filename, config->line_num, AV_LOG_ERROR, NULL,

                                "If '%s' is a codec private option, then prefix it with codec name, "

                                "for example '%s:%s %s' or define codec earlier.\n",

                                opt, avcodec_get_name(guessed_codec_id) ,opt, arg);

        }

    } else if ((ret = av_opt_set(ctx, option, arg, AV_OPT_SEARCH_CHILDREN)) < 0) {

        report_config_error(config->filename, config->line_num, AV_LOG_ERROR,

                &config->errors, "Invalid value for option %s (%s): %s\n", opt,

                arg, av_err2str(ret));

    } else if ((e = av_dict_get(*dict, option, NULL, 0))) {

        if ((o->type == AV_OPT_TYPE_FLAGS) && arg && (arg[0] == '+' || arg[0] == '-'))

            return av_dict_set(dict, option, arg, AV_DICT_APPEND);

        report_config_error(config->filename, config->line_num, AV_LOG_ERROR,

                &config->errors,

                "Redeclaring value of the option %s, previous value: %s\n",

                opt, e->value);

    } else if (av_dict_set(dict, option, arg, 0) < 0) {

        return AVERROR(ENOMEM);

    }

    return 0;

}

static int FUNC_0(const char *VAR_0, const char *VAR_1, int VAR_2, FFServerConfig *VAR_3)

{

    static int VAR_4 = 0;

    int VAR_5 = 0;

    AVDictionaryEntry *e;

    const AVOption *VAR_6 = NULL;

    const char *VAR_7 = NULL;

    const char *VAR_8 = NULL;

    char VAR_9[1024];

    AVCodecContext *ctx;

    AVDictionary **dict;

    enum AVCodecID VAR_10;



    switch (VAR_2) {

    case AV_OPT_FLAG_VIDEO_PARAM:

        ctx = VAR_3->dummy_vctx;

        dict = &VAR_3->video_opts;

        VAR_10 = VAR_3->guessed_video_codec_id != AV_CODEC_ID_NONE ?

                           VAR_3->guessed_video_codec_id : AV_CODEC_ID_H264;

        break;

    case AV_OPT_FLAG_AUDIO_PARAM:

        ctx = VAR_3->dummy_actx;

        dict = &VAR_3->audio_opts;

        VAR_10 = VAR_3->guessed_audio_codec_id != AV_CODEC_ID_NONE ?

                           VAR_3->guessed_audio_codec_id : AV_CODEC_ID_AAC;

        break;

    default:

        av_assert0(0);

    }



    if (strchr(VAR_0, ':')) {

        

        snprintf(VAR_9, sizeof(VAR_9), "%s", VAR_0);

        VAR_8 = VAR_9;

        VAR_7 = strchr(VAR_9, ':');

        VAR_9[VAR_7 - VAR_9] = '\0';

        VAR_7++;

        if ((VAR_5 = ffserver_set_codec(ctx, VAR_8, VAR_3)) < 0)

            return VAR_5;

        if (!ctx->codec || !ctx->priv_data)

            return -1;

    } else {

        VAR_7 = VAR_0;

    }



    VAR_6 = av_opt_find(ctx, VAR_7, NULL, VAR_2 | AV_OPT_FLAG_ENCODING_PARAM, AV_OPT_SEARCH_CHILDREN);

    if (!VAR_6 && (!strcmp(VAR_7, "time_base")  || !strcmp(VAR_7, "pixel_format") ||

               !strcmp(VAR_7, "video_size") || !strcmp(VAR_7, "codec_tag")))

        VAR_6 = av_opt_find(ctx, VAR_7, NULL, 0, 0);

    if (!VAR_6) {

        report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR,

                            &VAR_3->errors, "Option not found: %s\n", VAR_0);

        if (!VAR_4 && ctx->codec_id == AV_CODEC_ID_NONE) {

            VAR_4 = 1;

            report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR, NULL,

                                "If '%s' is a codec private VAR_7, then prefix it with codec name, "

                                "for example '%s:%s %s' or define codec earlier.\n",

                                VAR_0, avcodec_get_name(VAR_10) ,VAR_0, VAR_1);

        }

    } else if ((VAR_5 = av_opt_set(ctx, VAR_7, VAR_1, AV_OPT_SEARCH_CHILDREN)) < 0) {

        report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR,

                &VAR_3->errors, "Invalid value for VAR_7 %s (%s): %s\n", VAR_0,

                VAR_1, av_err2str(VAR_5));

    } else if ((e = av_dict_get(*dict, VAR_7, NULL, 0))) {

        if ((VAR_6->VAR_2 == AV_OPT_TYPE_FLAGS) && VAR_1 && (VAR_1[0] == '+' || VAR_1[0] == '-'))

            return av_dict_set(dict, VAR_7, VAR_1, AV_DICT_APPEND);

        report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR,

                &VAR_3->errors,

                "Redeclaring value of the VAR_7 %s, previous value: %s\n",

                VAR_0, e->value);

    } else if (av_dict_set(dict, VAR_7, VAR_1, 0) < 0) {

        return AVERROR(ENOMEM);

    }

    return 0;

}

static int FUNC_0(const char *VAR_0, const char *VAR_1, int VAR_2, FFServerConfig *VAR_3)
{ static int VAR_4 = 0; int VAR_5 = 0; AVDictionaryEntry *e; const AVOption *VAR_6 = NULL; const char *VAR_7 = NULL; const char *VAR_8 = NULL; char VAR_9[1024]; AVCodecContext *ctx; AVDictionary **dict; enum AVCodecID VAR_10; switch (VAR_2) { case AV_OPT_FLAG_VIDEO_PARAM:
ctx = VAR_3->dummy_vctx; dict = &VAR_3->video_opts; VAR_10 = VAR_3->guessed_video_codec_id != AV_CODEC_ID_NONE ?
VAR_3->guessed_video_codec_id : AV_CODEC_ID_H264; break; case AV_OPT_FLAG_AUDIO_PARAM:
ctx = VAR_3->dummy_actx; dict = &VAR_3->audio_opts; VAR_10 = VAR_3->guessed_audio_codec_id != AV_CODEC_ID_NONE ?
VAR_3->guessed_audio_codec_id : AV_CODEC_ID_AAC; break; default:
av_assert0(0); } if (strchr(VAR_0, ':')) { snprintf(VAR_9, sizeof(VAR_9), "%s", VAR_0); VAR_8 = VAR_9; VAR_7 = strchr(VAR_9, ':'); VAR_9[VAR_7 - VAR_9] = '\0'; VAR_7++; if ((VAR_5 = ffserver_set_codec(ctx, VAR_8, VAR_3)) < 0)
return VAR_5; if (!ctx->codec || !ctx->priv_data)
return -1; } else { VAR_7 = VAR_0; } VAR_6 = av_opt_find(ctx, VAR_7, NULL, VAR_2 | AV_OPT_FLAG_ENCODING_PARAM, AV_OPT_SEARCH_CHILDREN); if (!VAR_6 && (!strcmp(VAR_7, "time_base")  || !strcmp(VAR_7, "pixel_format") ||
!strcmp(VAR_7, "video_size") || !strcmp(VAR_7, "codec_tag")))
VAR_6 = av_opt_find(ctx, VAR_7, NULL, 0, 0); if (!VAR_6) { report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR,
&VAR_3->errors, "Option not found: %s\n", VAR_0); if (!VAR_4 && ctx->codec_id == AV_CODEC_ID_NONE) { VAR_4 = 1; report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR, NULL,
"If '%s' is a codec private VAR_7, then prefix it with codec name, "
"for example '%s:%s %s' or define codec earlier.\n",
VAR_0, avcodec_get_name(VAR_10) ,VAR_0, VAR_1); } } else if ((VAR_5 = av_opt_set(ctx, VAR_7, VAR_1, AV_OPT_SEARCH_CHILDREN)) < 0) { report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR,
&VAR_3->errors, "Invalid value for VAR_7 %s (%s): %s\n", VAR_0,
VAR_1, av_err2str(VAR_5)); } else if ((e = av_dict_get(*dict, VAR_7, NULL, 0))) { if ((VAR_6->VAR_2 == AV_OPT_TYPE_FLAGS) && VAR_1 && (VAR_1[0] == '+' || VAR_1[0] == '-'))
return av_dict_set(dict, VAR_7, VAR_1, AV_DICT_APPEND); report_config_error(VAR_3->filename, VAR_3->line_num, AV_LOG_ERROR,
&VAR_3->errors,
"Redeclaring value of the VAR_7 %s, previous value: %s\n",
VAR_0, e->value); } else if (av_dict_set(dict, VAR_7, VAR_1, 0) < 0) { return AVERROR(ENOMEM); } return 0; }