static int rm_write_header(AVFormatContext *s)
{
    RMMuxContext *rm = s->priv_data;
    StreamInfo *stream;
    int n;
    AVCodecContext *codec;
    for(n=0;n<s->nb_streams;n++) {
        s->streams[n]->id = n;
        codec = s->streams[n]->codec;
        stream = &rm->streams[n];
        memset(stream, 0, sizeof(StreamInfo));
        stream->num = n;
        stream->bit_rate = codec->bit_rate;
        stream->enc = codec;
        switch(codec->codec_type) {
        case AVMEDIA_TYPE_AUDIO:
            rm->audio_stream = stream;
            stream->frame_rate = (float)codec->sample_rate / (float)codec->frame_size;
            /* XXX: dummy values */
            stream->packet_max_size = 1024;
            stream->nb_packets = 0;
            stream->total_frames = stream->nb_packets;
            break;
        case AVMEDIA_TYPE_VIDEO:
            rm->video_stream = stream;
            stream->frame_rate = (float)codec->time_base.den / (float)codec->time_base.num;
            /* XXX: dummy values */
            stream->packet_max_size = 4096;
            stream->nb_packets = 0;
            stream->total_frames = stream->nb_packets;
            break;
        default:
            return -1;
    if (rv10_write_header(s, 0, 0))
        return AVERROR_INVALIDDATA;
    avio_flush(s->pb);
    return 0;
static int rm_write_header(AVFormatContext *s)
{
    RMMuxContext *rm = s->priv_data;
    StreamInfo *stream;
    int n;
    AVCodecContext *codec;
    for(n=0;n<s->nb_streams;n++) {
        s->streams[n]->id = n;
        codec = s->streams[n]->codec;
        stream = &rm->streams[n];
        memset(stream, 0, sizeof(StreamInfo));
        stream->num = n;
        stream->bit_rate = codec->bit_rate;
        stream->enc = codec;
        switch(codec->codec_type) {
        case AVMEDIA_TYPE_AUDIO:
            rm->audio_stream = stream;
            stream->frame_rate = (float)codec->sample_rate / (float)codec->frame_size;
            
            stream->packet_max_size = 1024;
            stream->nb_packets = 0;
            stream->total_frames = stream->nb_packets;
            break;
        case AVMEDIA_TYPE_VIDEO:
            rm->video_stream = stream;
            stream->frame_rate = (float)codec->time_base.den / (float)codec->time_base.num;
            
            stream->packet_max_size = 4096;
            stream->nb_packets = 0;
            stream->total_frames = stream->nb_packets;
            break;
        default:
            return -1;
    if (rv10_write_header(s, 0, 0))
        return AVERROR_INVALIDDATA;
    avio_flush(s->pb);
    return 0;
static int FUNC_0(AVFormatContext *VAR_0)
{
    RMMuxContext *rm = VAR_0->priv_data;
    StreamInfo *stream;
    int VAR_1;
    AVCodecContext *codec;
    for(VAR_1=0;VAR_1<VAR_0->nb_streams;VAR_1++) {
        VAR_0->streams[VAR_1]->id = VAR_1;
        codec = VAR_0->streams[VAR_1]->codec;
        stream = &rm->streams[VAR_1];
        memset(stream, 0, sizeof(StreamInfo));
        stream->num = VAR_1;
        stream->bit_rate = codec->bit_rate;
        stream->enc = codec;
        switch(codec->codec_type) {
        case AVMEDIA_TYPE_AUDIO:
            rm->audio_stream = stream;
            stream->frame_rate = (float)codec->sample_rate / (float)codec->frame_size;
            
            stream->packet_max_size = 1024;
            stream->nb_packets = 0;
            stream->total_frames = stream->nb_packets;
            break;
        case AVMEDIA_TYPE_VIDEO:
            rm->video_stream = stream;
            stream->frame_rate = (float)codec->time_base.den / (float)codec->time_base.num;
            
            stream->packet_max_size = 4096;
            stream->nb_packets = 0;
            stream->total_frames = stream->nb_packets;
            break;
        default:
            return -1;
    if (rv10_write_header(VAR_0, 0, 0))
        return AVERROR_INVALIDDATA;
    avio_flush(VAR_0->pb);
    return 0;
static int FUNC_0(AVFormatContext *VAR_0)
{ RMMuxContext *rm = VAR_0->priv_data; StreamInfo *stream; int VAR_1; AVCodecContext *codec; for(VAR_1=0;VAR_1<VAR_0->nb_streams;VAR_1++) { VAR_0->streams[VAR_1]->id = VAR_1; codec = VAR_0->streams[VAR_1]->codec; stream = &rm->streams[VAR_1]; memset(stream, 0, sizeof(StreamInfo)); stream->num = VAR_1; stream->bit_rate = codec->bit_rate; stream->enc = codec; switch(codec->codec_type) { case AVMEDIA_TYPE_AUDIO:
rm->audio_stream = stream; stream->frame_rate = (float)codec->sample_rate / (float)codec->frame_size; stream->packet_max_size = 1024; stream->nb_packets = 0; stream->total_frames = stream->nb_packets; break; case AVMEDIA_TYPE_VIDEO:
rm->video_stream = stream; stream->frame_rate = (float)codec->time_base.den / (float)codec->time_base.num; stream->packet_max_size = 4096; stream->nb_packets = 0; stream->total_frames = stream->nb_packets; break; default:
return -1; if (rv10_write_header(VAR_0, 0, 0))
return AVERROR_INVALIDDATA; avio_flush(VAR_0->pb); return 0;