* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
- payload_type = ff_rtp_get_payload_type(st->codec);
- if (payload_type < 0)
- payload_type = RTP_PT_PRIVATE + (st->codec->codec_type == CODEC_TYPE_AUDIO);
- s->payload_type = payload_type;
+ s->payload_type = ff_rtp_get_payload_type(st->codec);
+ if (s->payload_type < 0)
+ s->payload_type = RTP_PT_PRIVATE + (st->codec->codec_type == AVMEDIA_TYPE_AUDIO);
-// following 2 FIXMEs could be set based on the current time, there is normally no info leak, as RTP will likely be transmitted immediately
- s->base_timestamp = 0; /* FIXME: was random(), what should this be? */
+ s->base_timestamp = av_get_random_seed();
- s->first_rtcp_ntp_time = AV_NOPTS_VALUE;
+ s->first_rtcp_ntp_time = ff_ntp_time();
+ if (s1->start_time_realtime)
+ /* Round the NTP time to whole milliseconds. */
+ s->first_rtcp_ntp_time = (s1->start_time_realtime / 1000) * 1000 +
+ NTP_OFFSET_US;
if (st->codec->frame_size == 0) {
av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n");
} else {
s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size, AV_ROUND_DOWN);
}
}
if (st->codec->frame_size == 0) {
av_log(s1, AV_LOG_ERROR, "Cannot respect max delay: frame size = 0\n");
} else {
s->max_frames_per_packet = av_rescale_rnd(s1->max_delay, st->codec->sample_rate, AV_TIME_BASE * st->codec->frame_size, AV_ROUND_DOWN);
}
}
/* FIXME: We should round down here... */
s->max_frames_per_packet = av_rescale_q(s1->max_delay, (AVRational){1, 1000000}, st->codec->time_base);
}
/* FIXME: We should round down here... */
s->max_frames_per_packet = av_rescale_q(s1->max_delay, (AVRational){1, 1000000}, st->codec->time_base);
}
av_set_pts_info(st, 32, 1, st->codec->sample_rate);
}
s->buf_ptr = s->buf;
av_set_pts_info(st, 32, 1, st->codec->sample_rate);
}
s->buf_ptr = s->buf;
dprintf(s1, "RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp);
dprintf(s1, "RTCP: %02x %"PRIx64" %x\n", s->payload_type, ntp_time, s->timestamp);
s->last_rtcp_ntp_time = ntp_time;
rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1000000},
s1->streams[0]->time_base) + s->base_timestamp;
s->last_rtcp_ntp_time = ntp_time;
rtp_ts = av_rescale_q(ntp_time - s->first_rtcp_ntp_time, (AVRational){1, 1000000},
s1->streams[0]->time_base) + s->base_timestamp;
static void rtp_send_mpegaudio(AVFormatContext *s1,
const uint8_t *buf1, int size)
{
static void rtp_send_mpegaudio(AVFormatContext *s1,
const uint8_t *buf1, int size)
{
static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
{
RTPMuxContext *s = s1->priv_data;
AVStream *st = s1->streams[0];
int rtcp_bytes;
int size= pkt->size;
static int rtp_write_packet(AVFormatContext *s1, AVPacket *pkt)
{
RTPMuxContext *s = s1->priv_data;
AVStream *st = s1->streams[0];
int rtcp_bytes;
int size= pkt->size;
dprintf(s1, "%d: write len=%d\n", pkt->stream_index, size);
rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
RTCP_TX_RATIO_DEN;
if (s->first_packet || ((rtcp_bytes >= RTCP_SR_SIZE) &&
dprintf(s1, "%d: write len=%d\n", pkt->stream_index, size);
rtcp_bytes = ((s->octet_count - s->last_octet_count) * RTCP_TX_RATIO_NUM) /
RTCP_TX_RATIO_DEN;
if (s->first_packet || ((rtcp_bytes >= RTCP_SR_SIZE) &&
- (ntp_time() - s->last_rtcp_ntp_time > 5000000))) {
- rtcp_send_sr(s1, ntp_time());
+ (ff_ntp_time() - s->last_rtcp_ntp_time > 5000000))) {
+ rtcp_send_sr(s1, ff_ntp_time());
- rtp_send_samples(s1, buf1, size, 1 * st->codec->channels);
+ rtp_send_samples(s1, pkt->data, size, 1 * st->codec->channels);
- rtp_send_samples(s1, buf1, size, 2 * st->codec->channels);
+ rtp_send_samples(s1, pkt->data, size, 2 * st->codec->channels);