static int write_representation(AVFormatContext *s, AVStream *stream, char *id,

                                int output_width, int output_height,

                                int output_sample_rate) {

    WebMDashMuxContext *w = s->priv_data;

    AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0);

    AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0);

    AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0);

    AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);

    AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);

    if ((w->is_live && (!filename)) ||

        (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {

        return -1;

    }

    avio_printf(s->pb, "<Representation id=\"%s\"", id);

    // FIXME: For live, This should be obtained from the input file or as an AVOption.

    avio_printf(s->pb, " bandwidth=\"%s\"",

                w->is_live ? (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);

    if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_width)

        avio_printf(s->pb, " width=\"%d\"", stream->codec->width);

    if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_height)

        avio_printf(s->pb, " height=\"%d\"", stream->codec->height);

    if (stream->codec->codec_type = AVMEDIA_TYPE_AUDIO && output_sample_rate)

        avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codec->sample_rate);

    if (w->is_live) {

        // For live streams, Codec and Mime Type always go in the Representation tag.

        avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(stream->codec->codec_id));

        avio_printf(s->pb, " mimeType=\"%s/webm\"",

                    stream->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");

        // For live streams, subsegments always start with key frames. So this

        // is always 1.

        avio_printf(s->pb, " startsWithSAP=\"1\"");

        avio_printf(s->pb, ">");

    } else {

        avio_printf(s->pb, ">\n");

        avio_printf(s->pb, "<BaseURL>%s</BaseURL>\n", filename->value);

        avio_printf(s->pb, "<SegmentBase\n");

        avio_printf(s->pb, "  indexRange=\"%s-%s\">\n", cues_start->value, cues_end->value);

        avio_printf(s->pb, "<Initialization\n");

        avio_printf(s->pb, "  range=\"0-%s\" />\n", irange->value);

        avio_printf(s->pb, "</SegmentBase>\n");

    }

    avio_printf(s->pb, "</Representation>\n");

    return 0;

}

static int write_representation(AVFormatContext *s, AVStream *stream, char *id,

                                int output_width, int output_height,

                                int output_sample_rate) {

    WebMDashMuxContext *w = s->priv_data;

    AVDictionaryEntry *irange = av_dict_get(stream->metadata, INITIALIZATION_RANGE, NULL, 0);

    AVDictionaryEntry *cues_start = av_dict_get(stream->metadata, CUES_START, NULL, 0);

    AVDictionaryEntry *cues_end = av_dict_get(stream->metadata, CUES_END, NULL, 0);

    AVDictionaryEntry *filename = av_dict_get(stream->metadata, FILENAME, NULL, 0);

    AVDictionaryEntry *bandwidth = av_dict_get(stream->metadata, BANDWIDTH, NULL, 0);

    if ((w->is_live && (!filename)) ||

        (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {

        return -1;

    }

    avio_printf(s->pb, "<Representation id=\"%s\"", id);

    

    avio_printf(s->pb, " bandwidth=\"%s\"",

                w->is_live ? (stream->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);

    if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_width)

        avio_printf(s->pb, " width=\"%d\"", stream->codec->width);

    if (stream->codec->codec_type == AVMEDIA_TYPE_VIDEO && output_height)

        avio_printf(s->pb, " height=\"%d\"", stream->codec->height);

    if (stream->codec->codec_type = AVMEDIA_TYPE_AUDIO && output_sample_rate)

        avio_printf(s->pb, " audioSamplingRate=\"%d\"", stream->codec->sample_rate);

    if (w->is_live) {

        

        avio_printf(s->pb, " codecs=\"%s\"", get_codec_name(stream->codec->codec_id));

        avio_printf(s->pb, " mimeType=\"%s/webm\"",

                    stream->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");

        

        

        avio_printf(s->pb, " startsWithSAP=\"1\"");

        avio_printf(s->pb, ">");

    } else {

        avio_printf(s->pb, ">\n");

        avio_printf(s->pb, "<BaseURL>%s</BaseURL>\n", filename->value);

        avio_printf(s->pb, "<SegmentBase\n");

        avio_printf(s->pb, "  indexRange=\"%s-%s\">\n", cues_start->value, cues_end->value);

        avio_printf(s->pb, "<Initialization\n");

        avio_printf(s->pb, "  range=\"0-%s\" />\n", irange->value);

        avio_printf(s->pb, "</SegmentBase>\n");

    }

    avio_printf(s->pb, "</Representation>\n");

    return 0;

}

        return -1;     WebMDashMuxContext *w = s->priv_data;
static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, char *VAR_2,

                                int VAR_3, int VAR_4,

                                int VAR_5) {

    WebMDashMuxContext *w = VAR_0->priv_data;

    AVDictionaryEntry *irange = av_dict_get(VAR_1->metadata, INITIALIZATION_RANGE, NULL, 0);

    AVDictionaryEntry *cues_start = av_dict_get(VAR_1->metadata, CUES_START, NULL, 0);

    AVDictionaryEntry *cues_end = av_dict_get(VAR_1->metadata, CUES_END, NULL, 0);

    AVDictionaryEntry *filename = av_dict_get(VAR_1->metadata, FILENAME, NULL, 0);

    AVDictionaryEntry *bandwidth = av_dict_get(VAR_1->metadata, BANDWIDTH, NULL, 0);

    if ((w->is_live && (!filename)) ||

        (!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) {

        return -1;

    }

    avio_printf(VAR_0->pb, "<Representation VAR_2=\"%VAR_0\"", VAR_2);

    

    avio_printf(VAR_0->pb, " bandwidth=\"%VAR_0\"",

                w->is_live ? (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value);

    if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_3)

        avio_printf(VAR_0->pb, " width=\"%d\"", VAR_1->codec->width);

    if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_4)

        avio_printf(VAR_0->pb, " height=\"%d\"", VAR_1->codec->height);

    if (VAR_1->codec->codec_type = AVMEDIA_TYPE_AUDIO && VAR_5)

        avio_printf(VAR_0->pb, " audioSamplingRate=\"%d\"", VAR_1->codec->sample_rate);

    if (w->is_live) {

        

        avio_printf(VAR_0->pb, " codecs=\"%VAR_0\"", get_codec_name(VAR_1->codec->codec_id));

        avio_printf(VAR_0->pb, " mimeType=\"%VAR_0/webm\"",

                    VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio");

        

        

        avio_printf(VAR_0->pb, " startsWithSAP=\"1\"");

        avio_printf(VAR_0->pb, ">");

    } else {

        avio_printf(VAR_0->pb, ">\n");

        avio_printf(VAR_0->pb, "<BaseURL>%VAR_0</BaseURL>\n", filename->value);

        avio_printf(VAR_0->pb, "<SegmentBase\n");

        avio_printf(VAR_0->pb, "  indexRange=\"%VAR_0-%VAR_0\">\n", cues_start->value, cues_end->value);

        avio_printf(VAR_0->pb, "<Initialization\n");

        avio_printf(VAR_0->pb, "  range=\"0-%VAR_0\" />\n", irange->value);

        avio_printf(VAR_0->pb, "</SegmentBase>\n");

    }

    avio_printf(VAR_0->pb, "</Representation>\n");

    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0, AVStream *VAR_1, char *VAR_2,
int VAR_3, int VAR_4,
int VAR_5) { WebMDashMuxContext *w = VAR_0->priv_data; AVDictionaryEntry *irange = av_dict_get(VAR_1->metadata, INITIALIZATION_RANGE, NULL, 0); AVDictionaryEntry *cues_start = av_dict_get(VAR_1->metadata, CUES_START, NULL, 0); AVDictionaryEntry *cues_end = av_dict_get(VAR_1->metadata, CUES_END, NULL, 0); AVDictionaryEntry *filename = av_dict_get(VAR_1->metadata, FILENAME, NULL, 0); AVDictionaryEntry *bandwidth = av_dict_get(VAR_1->metadata, BANDWIDTH, NULL, 0); if ((w->is_live && (!filename)) ||
(!w->is_live && (!irange || !cues_start || !cues_end || !filename || !bandwidth))) { return -1; } avio_printf(VAR_0->pb, "<Representation VAR_2=\"%VAR_0\"", VAR_2); avio_printf(VAR_0->pb, " bandwidth=\"%VAR_0\"",
w->is_live ? (VAR_1->codec->codec_type == AVMEDIA_TYPE_AUDIO ? "128000" : "1000000") : bandwidth->value); if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_3)
avio_printf(VAR_0->pb, " width=\"%d\"", VAR_1->codec->width); if (VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO && VAR_4)
avio_printf(VAR_0->pb, " height=\"%d\"", VAR_1->codec->height); if (VAR_1->codec->codec_type = AVMEDIA_TYPE_AUDIO && VAR_5)
avio_printf(VAR_0->pb, " audioSamplingRate=\"%d\"", VAR_1->codec->sample_rate); if (w->is_live) { avio_printf(VAR_0->pb, " codecs=\"%VAR_0\"", get_codec_name(VAR_1->codec->codec_id)); avio_printf(VAR_0->pb, " mimeType=\"%VAR_0/webm\"",
VAR_1->codec->codec_type == AVMEDIA_TYPE_VIDEO ? "video" : "audio"); avio_printf(VAR_0->pb, " startsWithSAP=\"1\""); avio_printf(VAR_0->pb, ">"); } else { avio_printf(VAR_0->pb, ">\n"); avio_printf(VAR_0->pb, "<BaseURL>%VAR_0</BaseURL>\n", filename->value); avio_printf(VAR_0->pb, "<SegmentBase\n"); avio_printf(VAR_0->pb, "  indexRange=\"%VAR_0-%VAR_0\">\n", cues_start->value, cues_end->value); avio_printf(VAR_0->pb, "<Initialization\n"); avio_printf(VAR_0->pb, "  range=\"0-%VAR_0\" />\n", irange->value); avio_printf(VAR_0->pb, "</SegmentBase>\n"); } avio_printf(VAR_0->pb, "</Representation>\n"); return 0; }