static int hls_write_header(AVFormatContext *s)

{

    HLSContext *hls = s->priv_data;

    int ret, i;

    char *p;

    const char *pattern = "%d.ts";

    int basename_size = strlen(s->filename) + strlen(pattern);



    hls->number      = 0;



    hls->recording_time = hls->time * 1000000;

    hls->start_pts      = AV_NOPTS_VALUE;



    for (i = 0; i < s->nb_streams; i++)

        hls->has_video +=

            s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO;



    if (hls->has_video > 1)

        av_log(s, AV_LOG_WARNING,

               "More than a single video stream present, "

               "expect issues decoding it.\n");



    hls->oformat = av_guess_format("mpegts", NULL, NULL);



    if (!hls->oformat) {

        ret = AVERROR_MUXER_NOT_FOUND;

        goto fail;

    }



    hls->basename = av_malloc(basename_size);



    if (!hls->basename) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    strcpy(hls->basename, s->filename);



    p = strrchr(hls->basename, '.');



    if (p)

        *p = '\0';



    av_strlcat(hls->basename, "%d.ts", basename_size);



    if ((ret = hls_mux_init(s)) < 0)

        goto fail;



    if ((ret = hls_start(s)) < 0)

        goto fail;



    if ((ret = avformat_write_header(hls->avf, NULL)) < 0)

        return ret;





fail:

    if (ret) {

        av_free(hls->basename);

        if (hls->avf)

            avformat_free_context(hls->avf);

    }

    return ret;

}

static int hls_write_header(AVFormatContext *s)

{

    HLSContext *hls = s->priv_data;

    int ret, i;

    char *p;

    const char *pattern = "%d.ts";

    int basename_size = strlen(s->filename) + strlen(pattern);



    hls->number      = 0;



    hls->recording_time = hls->time * 1000000;

    hls->start_pts      = AV_NOPTS_VALUE;



    for (i = 0; i < s->nb_streams; i++)

        hls->has_video +=

            s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO;



    if (hls->has_video > 1)

        av_log(s, AV_LOG_WARNING,

               "More than a single video stream present, "

               "expect issues decoding it.\n");



    hls->oformat = av_guess_format("mpegts", NULL, NULL);



    if (!hls->oformat) {

        ret = AVERROR_MUXER_NOT_FOUND;

        goto fail;

    }



    hls->basename = av_malloc(basename_size);



    if (!hls->basename) {

        ret = AVERROR(ENOMEM);

        goto fail;

    }



    strcpy(hls->basename, s->filename);



    p = strrchr(hls->basename, '.');



    if (p)

        *p = '\0';



    av_strlcat(hls->basename, "%d.ts", basename_size);



    if ((ret = hls_mux_init(s)) < 0)

        goto fail;



    if ((ret = hls_start(s)) < 0)

        goto fail;



    if ((ret = avformat_write_header(hls->avf, NULL)) < 0)

        return ret;





fail:

    if (ret) {

        av_free(hls->basename);

        if (hls->avf)

            avformat_free_context(hls->avf);

    }

    return ret;

}

    int basename_size = strlen(s->filename) + strlen(pattern);
static int FUNC_0(AVFormatContext *VAR_0)

{

    HLSContext *hls = VAR_0->priv_data;

    int VAR_1, VAR_2;

    char *VAR_3;

    const char *VAR_4 = "%d.ts";

    int VAR_5 = strlen(VAR_0->filename) + strlen(VAR_4);



    hls->number      = 0;



    hls->recording_time = hls->time * 1000000;

    hls->start_pts      = AV_NOPTS_VALUE;



    for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++)

        hls->has_video +=

            VAR_0->streams[VAR_2]->codec->codec_type == AVMEDIA_TYPE_VIDEO;



    if (hls->has_video > 1)

        av_log(VAR_0, AV_LOG_WARNING,

               "More than a single video stream present, "

               "expect issues decoding it.\n");



    hls->oformat = av_guess_format("mpegts", NULL, NULL);



    if (!hls->oformat) {

        VAR_1 = AVERROR_MUXER_NOT_FOUND;

        goto fail;

    }



    hls->basename = av_malloc(VAR_5);



    if (!hls->basename) {

        VAR_1 = AVERROR(ENOMEM);

        goto fail;

    }



    strcpy(hls->basename, VAR_0->filename);



    VAR_3 = strrchr(hls->basename, '.');



    if (VAR_3)

        *VAR_3 = '\0';



    av_strlcat(hls->basename, "%d.ts", VAR_5);



    if ((VAR_1 = hls_mux_init(VAR_0)) < 0)

        goto fail;



    if ((VAR_1 = hls_start(VAR_0)) < 0)

        goto fail;



    if ((VAR_1 = avformat_write_header(hls->avf, NULL)) < 0)

        return VAR_1;





fail:

    if (VAR_1) {

        av_free(hls->basename);

        if (hls->avf)

            avformat_free_context(hls->avf);

    }

    return VAR_1;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ HLSContext *hls = VAR_0->priv_data; int VAR_1, VAR_2; char *VAR_3; const char *VAR_4 = "%d.ts"; int VAR_5 = strlen(VAR_0->filename) + strlen(VAR_4); hls->number      = 0; hls->recording_time = hls->time * 1000000; hls->start_pts      = AV_NOPTS_VALUE; for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) hls->has_video +=
VAR_0->streams[VAR_2]->codec->codec_type == AVMEDIA_TYPE_VIDEO; if (hls->has_video > 1)
av_log(VAR_0, AV_LOG_WARNING,
"More than a single video stream present, "
"expect issues decoding it.\n"); hls->oformat = av_guess_format("mpegts", NULL, NULL); if (!hls->oformat) { VAR_1 = AVERROR_MUXER_NOT_FOUND; goto fail; } hls->basename = av_malloc(VAR_5); if (!hls->basename) { VAR_1 = AVERROR(ENOMEM); goto fail; } strcpy(hls->basename, VAR_0->filename); VAR_3 = strrchr(hls->basename, '.'); if (VAR_3)
*VAR_3 = '\0'; av_strlcat(hls->basename, "%d.ts", VAR_5); if ((VAR_1 = hls_mux_init(VAR_0)) < 0)
goto fail; if ((VAR_1 = hls_start(VAR_0)) < 0)
goto fail; if ((VAR_1 = avformat_write_header(hls->avf, NULL)) < 0)
return VAR_1; fail:
if (VAR_1) { av_free(hls->basename); if (hls->avf)
avformat_free_context(hls->avf); } return VAR_1; }