static int sls_flags_filename_process(struct AVFormatContext *s, HLSContext *hls,

                                      VariantStream *vs, HLSSegment *en,

                                      double duration, int64_t pos, int64_t size)

{

    if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&

        strlen(vs->current_segment_final_filename_fmt)) {

        av_strlcpy(vs->avf->filename, vs->current_segment_final_filename_fmt, sizeof(vs->avf->filename));

        if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {

            char * filename = av_strdup(vs->avf->filename);  // %%s will be %s after strftime

            if (!filename) {

                av_free(en);

                return AVERROR(ENOMEM);

            }

            if (replace_int_data_in_filename(vs->avf->filename, sizeof(vs->avf->filename),

                filename, 's', pos + size) < 1) {

                av_log(hls, AV_LOG_ERROR,

                       "Invalid second level segment filename template '%s', "

                        "you can try to remove second_level_segment_size flag\n",

                       filename);

                av_free(filename);

                av_free(en);

                return AVERROR(EINVAL);

            }

            av_free(filename);

        }

        if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {

            char * filename = av_strdup(vs->avf->filename);  // %%t will be %t after strftime

            if (!filename) {

                av_free(en);

                return AVERROR(ENOMEM);

            }

            if (replace_int_data_in_filename(vs->avf->filename, sizeof(vs->avf->filename),

                filename, 't',  (int64_t)round(duration * HLS_MICROSECOND_UNIT)) < 1) {

                av_log(hls, AV_LOG_ERROR,

                       "Invalid second level segment filename template '%s', "

                        "you can try to remove second_level_segment_time flag\n",

                       filename);

                av_free(filename);

                av_free(en);

                return AVERROR(EINVAL);

            }

            av_free(filename);

        }

    }

    return 0;

}

static int sls_flags_filename_process(struct AVFormatContext *s, HLSContext *hls,

                                      VariantStream *vs, HLSSegment *en,

                                      double duration, int64_t pos, int64_t size)

{

    if ((hls->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&

        strlen(vs->current_segment_final_filename_fmt)) {

        av_strlcpy(vs->avf->filename, vs->current_segment_final_filename_fmt, sizeof(vs->avf->filename));

        if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {

            char * filename = av_strdup(vs->avf->filename);  

            if (!filename) {

                av_free(en);

                return AVERROR(ENOMEM);

            }

            if (replace_int_data_in_filename(vs->avf->filename, sizeof(vs->avf->filename),

                filename, 's', pos + size) < 1) {

                av_log(hls, AV_LOG_ERROR,

                       "Invalid second level segment filename template '%s', "

                        "you can try to remove second_level_segment_size flag\n",

                       filename);

                av_free(filename);

                av_free(en);

                return AVERROR(EINVAL);

            }

            av_free(filename);

        }

        if (hls->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {

            char * filename = av_strdup(vs->avf->filename);  

            if (!filename) {

                av_free(en);

                return AVERROR(ENOMEM);

            }

            if (replace_int_data_in_filename(vs->avf->filename, sizeof(vs->avf->filename),

                filename, 't',  (int64_t)round(duration * HLS_MICROSECOND_UNIT)) < 1) {

                av_log(hls, AV_LOG_ERROR,

                       "Invalid second level segment filename template '%s', "

                        "you can try to remove second_level_segment_time flag\n",

                       filename);

                av_free(filename);

                av_free(en);

                return AVERROR(EINVAL);

            }

            av_free(filename);

        }

    }

    return 0;

}

static int FUNC_0(struct AVFormatContext *VAR_0, HLSContext *VAR_1,

                                      VariantStream *VAR_2, HLSSegment *VAR_3,

                                      double VAR_4, int64_t VAR_5, int64_t VAR_6)

{

    if ((VAR_1->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&

        strlen(VAR_2->current_segment_final_filename_fmt)) {

        av_strlcpy(VAR_2->avf->VAR_8, VAR_2->current_segment_final_filename_fmt, sizeof(VAR_2->avf->VAR_8));

        if (VAR_1->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) {

            char * VAR_8 = av_strdup(VAR_2->avf->VAR_8);  

            if (!VAR_8) {

                av_free(VAR_3);

                return AVERROR(ENOMEM);

            }

            if (replace_int_data_in_filename(VAR_2->avf->VAR_8, sizeof(VAR_2->avf->VAR_8),

                VAR_8, 'VAR_0', VAR_5 + VAR_6) < 1) {

                av_log(VAR_1, AV_LOG_ERROR,

                       "Invalid second level segment VAR_8 template '%VAR_0', "

                        "you can try to remove second_level_segment_size flag\n",

                       VAR_8);

                av_free(VAR_8);

                av_free(VAR_3);

                return AVERROR(EINVAL);

            }

            av_free(VAR_8);

        }

        if (VAR_1->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) {

            char * VAR_8 = av_strdup(VAR_2->avf->VAR_8);  

            if (!VAR_8) {

                av_free(VAR_3);

                return AVERROR(ENOMEM);

            }

            if (replace_int_data_in_filename(VAR_2->avf->VAR_8, sizeof(VAR_2->avf->VAR_8),

                VAR_8, 't',  (int64_t)round(VAR_4 * HLS_MICROSECOND_UNIT)) < 1) {

                av_log(VAR_1, AV_LOG_ERROR,

                       "Invalid second level segment VAR_8 template '%VAR_0', "

                        "you can try to remove second_level_segment_time flag\n",

                       VAR_8);

                av_free(VAR_8);

                av_free(VAR_3);

                return AVERROR(EINVAL);

            }

            av_free(VAR_8);

        }

    }

    return 0;

}

static int FUNC_0(struct AVFormatContext *VAR_0, HLSContext *VAR_1,
VariantStream *VAR_2, HLSSegment *VAR_3,
double VAR_4, int64_t VAR_5, int64_t VAR_6)
{ if ((VAR_1->flags & (HLS_SECOND_LEVEL_SEGMENT_SIZE | HLS_SECOND_LEVEL_SEGMENT_DURATION)) &&
strlen(VAR_2->current_segment_final_filename_fmt)) { av_strlcpy(VAR_2->avf->VAR_8, VAR_2->current_segment_final_filename_fmt, sizeof(VAR_2->avf->VAR_8)); if (VAR_1->flags & HLS_SECOND_LEVEL_SEGMENT_SIZE) { char * VAR_8 = av_strdup(VAR_2->avf->VAR_8); if (!VAR_8) { av_free(VAR_3); return AVERROR(ENOMEM); } if (replace_int_data_in_filename(VAR_2->avf->VAR_8, sizeof(VAR_2->avf->VAR_8),
VAR_8, 'VAR_0', VAR_5 + VAR_6) < 1) { av_log(VAR_1, AV_LOG_ERROR,
"Invalid second level segment VAR_8 template '%VAR_0', "
"you can try to remove second_level_segment_size flag\n",
VAR_8); av_free(VAR_8); av_free(VAR_3); return AVERROR(EINVAL); } av_free(VAR_8); } if (VAR_1->flags & HLS_SECOND_LEVEL_SEGMENT_DURATION) { char * VAR_8 = av_strdup(VAR_2->avf->VAR_8); if (!VAR_8) { av_free(VAR_3); return AVERROR(ENOMEM); } if (replace_int_data_in_filename(VAR_2->avf->VAR_8, sizeof(VAR_2->avf->VAR_8),
VAR_8, 't',  (int64_t)round(VAR_4 * HLS_MICROSECOND_UNIT)) < 1) { av_log(VAR_1, AV_LOG_ERROR,
"Invalid second level segment VAR_8 template '%VAR_0', "
"you can try to remove second_level_segment_time flag\n",
VAR_8); av_free(VAR_8); av_free(VAR_3); return AVERROR(EINVAL); } av_free(VAR_8); } } return 0; }