| OLD | NEW |
| 1 /* | 1 /* |
| 2 * RTP output format | 2 * RTP output format |
| 3 * Copyright (c) 2002 Fabrice Bellard | 3 * Copyright (c) 2002 Fabrice Bellard |
| 4 * | 4 * |
| 5 * This file is part of FFmpeg. | 5 * This file is part of FFmpeg. |
| 6 * | 6 * |
| 7 * FFmpeg is free software; you can redistribute it and/or | 7 * FFmpeg is free software; you can redistribute it and/or |
| 8 * modify it under the terms of the GNU Lesser General Public | 8 * modify it under the terms of the GNU Lesser General Public |
| 9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
| 10 * version 2.1 of the License, or (at your option) any later version. | 10 * version 2.1 of the License, or (at your option) any later version. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 s->payload_type = ff_rtp_get_payload_type(st->codec); | 84 s->payload_type = ff_rtp_get_payload_type(st->codec); |
| 85 if (s->payload_type < 0) | 85 if (s->payload_type < 0) |
| 86 s->payload_type = RTP_PT_PRIVATE + (st->codec->codec_type == CODEC_TYPE_
AUDIO); | 86 s->payload_type = RTP_PT_PRIVATE + (st->codec->codec_type == CODEC_TYPE_
AUDIO); |
| 87 | 87 |
| 88 // following 2 FIXMEs could be set based on the current time, there is normally
no info leak, as RTP will likely be transmitted immediately | 88 // following 2 FIXMEs could be set based on the current time, there is normally
no info leak, as RTP will likely be transmitted immediately |
| 89 s->base_timestamp = 0; /* FIXME: was random(), what should this be? */ | 89 s->base_timestamp = 0; /* FIXME: was random(), what should this be? */ |
| 90 s->timestamp = s->base_timestamp; | 90 s->timestamp = s->base_timestamp; |
| 91 s->cur_timestamp = 0; | 91 s->cur_timestamp = 0; |
| 92 s->ssrc = 0; /* FIXME: was random(), what should this be? */ | 92 s->ssrc = 0; /* FIXME: was random(), what should this be? */ |
| 93 s->first_packet = 1; | 93 s->first_packet = 1; |
| 94 s->first_rtcp_ntp_time = AV_NOPTS_VALUE; | 94 s->first_rtcp_ntp_time = ntp_time(); |
| 95 | 95 |
| 96 max_packet_size = url_fget_max_packet_size(s1->pb); | 96 max_packet_size = url_fget_max_packet_size(s1->pb); |
| 97 if (max_packet_size <= 12) | 97 if (max_packet_size <= 12) |
| 98 return AVERROR(EIO); | 98 return AVERROR(EIO); |
| 99 s->buf = av_malloc(max_packet_size); | 99 s->buf = av_malloc(max_packet_size); |
| 100 if (s->buf == NULL) { | 100 if (s->buf == NULL) { |
| 101 return AVERROR(ENOMEM); | 101 return AVERROR(ENOMEM); |
| 102 } | 102 } |
| 103 s->max_payload_size = max_packet_size - 12; | 103 s->max_payload_size = max_packet_size - 12; |
| 104 | 104 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 } | 164 } |
| 165 | 165 |
| 166 /* send an rtcp sender report packet */ | 166 /* send an rtcp sender report packet */ |
| 167 static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) | 167 static void rtcp_send_sr(AVFormatContext *s1, int64_t ntp_time) |
| 168 { | 168 { |
| 169 RTPMuxContext *s = s1->priv_data; | 169 RTPMuxContext *s = s1->priv_data; |
| 170 uint32_t rtp_ts; | 170 uint32_t rtp_ts; |
| 171 | 171 |
| 172 dprintf(s1, "RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->times
tamp); | 172 dprintf(s1, "RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->times
tamp); |
| 173 | 173 |
| 174 if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) s->first_rtcp_ntp_time = ntp_t
ime; | |
| 175 s->last_rtcp_ntp_time = ntp_time; | 174 s->last_rtcp_ntp_time = ntp_time; |
| 176 rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 100
0000}, | 175 rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 100
0000}, |
| 177 s1->streams[0]->time_base) + s->base_timestamp; | 176 s1->streams[0]->time_base) + s->base_timestamp; |
| 178 put_byte(s1->pb, (RTP_VERSION << 6)); | 177 put_byte(s1->pb, (RTP_VERSION << 6)); |
| 179 put_byte(s1->pb, 200); | 178 put_byte(s1->pb, 200); |
| 180 put_be16(s1->pb, 6); /* length in words - 1 */ | 179 put_be16(s1->pb, 6); /* length in words - 1 */ |
| 181 put_be32(s1->pb, s->ssrc); | 180 put_be32(s1->pb, s->ssrc); |
| 182 put_be32(s1->pb, ntp_time / 1000000); | 181 put_be32(s1->pb, ntp_time / 1000000); |
| 183 put_be32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000); | 182 put_be32(s1->pb, ((ntp_time % 1000000) << 32) / 1000000); |
| 184 put_be32(s1->pb, rtp_ts); | 183 put_be32(s1->pb, rtp_ts); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 NULL_IF_CONFIG_SMALL("RTP output format"), | 413 NULL_IF_CONFIG_SMALL("RTP output format"), |
| 415 NULL, | 414 NULL, |
| 416 NULL, | 415 NULL, |
| 417 sizeof(RTPMuxContext), | 416 sizeof(RTPMuxContext), |
| 418 CODEC_ID_PCM_MULAW, | 417 CODEC_ID_PCM_MULAW, |
| 419 CODEC_ID_NONE, | 418 CODEC_ID_NONE, |
| 420 rtp_write_header, | 419 rtp_write_header, |
| 421 rtp_write_packet, | 420 rtp_write_packet, |
| 422 rtp_write_trailer, | 421 rtp_write_trailer, |
| 423 }; | 422 }; |
| OLD | NEW |