static int rtp_write_header(AVFormatContext *s1)

{

    RTPDemuxContext *s = s1->priv_data;

    int payload_type, max_packet_size, n;

    AVStream *st;



    if (s1->nb_streams != 1)

        return -1;

    st = s1->streams[0];



    payload_type = rtp_get_payload_type(st->codec);

    if (payload_type < 0)

        payload_type = RTP_PT_PRIVATE; /* private payload type */

    s->payload_type = payload_type;



    s->base_timestamp = random();

    s->timestamp = s->base_timestamp;

    s->ssrc = random();

    s->first_packet = 1;



    max_packet_size = url_fget_max_packet_size(&s1->pb);

    if (max_packet_size <= 12)

        return AVERROR_IO;

    s->max_payload_size = max_packet_size - 12;



    switch(st->codec->codec_id) {

    case CODEC_ID_MP2:

    case CODEC_ID_MP3:

        s->buf_ptr = s->buf + 4;

        s->cur_timestamp = 0;

        break;

    case CODEC_ID_MPEG1VIDEO:

        s->cur_timestamp = 0;

        break;

    case CODEC_ID_MPEG2TS:

        n = s->max_payload_size / TS_PACKET_SIZE;

        if (n < 1)

            n = 1;

        s->max_payload_size = n * TS_PACKET_SIZE;

        s->buf_ptr = s->buf;

        break;

    default:

        s->buf_ptr = s->buf;

        break;

    }



    return 0;

}

static int rtp_write_header(AVFormatContext *s1)

{

    RTPDemuxContext *s = s1->priv_data;

    int payload_type, max_packet_size, n;

    AVStream *st;



    if (s1->nb_streams != 1)

        return -1;

    st = s1->streams[0];



    payload_type = rtp_get_payload_type(st->codec);

    if (payload_type < 0)

        payload_type = RTP_PT_PRIVATE; 

    s->payload_type = payload_type;



    s->base_timestamp = random();

    s->timestamp = s->base_timestamp;

    s->ssrc = random();

    s->first_packet = 1;



    max_packet_size = url_fget_max_packet_size(&s1->pb);

    if (max_packet_size <= 12)

        return AVERROR_IO;

    s->max_payload_size = max_packet_size - 12;



    switch(st->codec->codec_id) {

    case CODEC_ID_MP2:

    case CODEC_ID_MP3:

        s->buf_ptr = s->buf + 4;

        s->cur_timestamp = 0;

        break;

    case CODEC_ID_MPEG1VIDEO:

        s->cur_timestamp = 0;

        break;

    case CODEC_ID_MPEG2TS:

        n = s->max_payload_size / TS_PACKET_SIZE;

        if (n < 1)

            n = 1;

        s->max_payload_size = n * TS_PACKET_SIZE;

        s->buf_ptr = s->buf;

        break;

    default:

        s->buf_ptr = s->buf;

        break;

    }



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)

{

    RTPDemuxContext *s = VAR_0->priv_data;

    int VAR_1, VAR_2, VAR_3;

    AVStream *st;



    if (VAR_0->nb_streams != 1)

        return -1;

    st = VAR_0->streams[0];



    VAR_1 = rtp_get_payload_type(st->codec);

    if (VAR_1 < 0)

        VAR_1 = RTP_PT_PRIVATE; 

    s->VAR_1 = VAR_1;



    s->base_timestamp = random();

    s->timestamp = s->base_timestamp;

    s->ssrc = random();

    s->first_packet = 1;



    VAR_2 = url_fget_max_packet_size(&VAR_0->pb);

    if (VAR_2 <= 12)

        return AVERROR_IO;

    s->max_payload_size = VAR_2 - 12;



    switch(st->codec->codec_id) {

    case CODEC_ID_MP2:

    case CODEC_ID_MP3:

        s->buf_ptr = s->buf + 4;

        s->cur_timestamp = 0;

        break;

    case CODEC_ID_MPEG1VIDEO:

        s->cur_timestamp = 0;

        break;

    case CODEC_ID_MPEG2TS:

        VAR_3 = s->max_payload_size / TS_PACKET_SIZE;

        if (VAR_3 < 1)

            VAR_3 = 1;

        s->max_payload_size = VAR_3 * TS_PACKET_SIZE;

        s->buf_ptr = s->buf;

        break;

    default:

        s->buf_ptr = s->buf;

        break;

    }



    return 0;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ RTPDemuxContext *s = VAR_0->priv_data; int VAR_1, VAR_2, VAR_3; AVStream *st; if (VAR_0->nb_streams != 1)
return -1; st = VAR_0->streams[0]; VAR_1 = rtp_get_payload_type(st->codec); if (VAR_1 < 0)
VAR_1 = RTP_PT_PRIVATE; s->VAR_1 = VAR_1; s->base_timestamp = random(); s->timestamp = s->base_timestamp; s->ssrc = random(); s->first_packet = 1; VAR_2 = url_fget_max_packet_size(&VAR_0->pb); if (VAR_2 <= 12)
return AVERROR_IO; s->max_payload_size = VAR_2 - 12; switch(st->codec->codec_id) { case CODEC_ID_MP2:
case CODEC_ID_MP3:
s->buf_ptr = s->buf + 4; s->cur_timestamp = 0; break; case CODEC_ID_MPEG1VIDEO:
s->cur_timestamp = 0; break; case CODEC_ID_MPEG2TS:
VAR_3 = s->max_payload_size / TS_PACKET_SIZE; if (VAR_3 < 1)
VAR_3 = 1; s->max_payload_size = VAR_3 * TS_PACKET_SIZE; s->buf_ptr = s->buf; break; default:
s->buf_ptr = s->buf; break; } return 0; }