| @@ -192,14 +192,20 @@ static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf, · 191 unmodified lines |
| 192 | return AVERROR_INVALIDDATA; | 192 | return AVERROR_INVALIDDATA; |
| 193 | } | 193 | } |
| 194 | | 194 | |
| | 195 | s->last_sr.ssrc = AV_RB32(buf + 4); |
| | 196 | s->last_sr.ntp_timestamp = AV_RB64(buf + 8); |
| | 197 | s->last_sr.rtp_timestamp = AV_RB32(buf + 16); |
| | 198 | s->last_sr.sender_nb_packets = AV_RB32(buf + 20); |
| | 199 | s->last_sr.sender_nb_bytes = AV_RB32(buf + 24); |
| | 200 | |
| | 201 | s->pending_sr = 1; |
| 195 | s->last_rtcp_reception_time = av_gettime_relative(); | 202 | s->last_rtcp_reception_time = av_gettime_relative(); |
| 196 | s->last_rtcp_ntp_time = AV_RB64(buf + 8); | 203 | |
| 197 | s->last_rtcp_timestamp = AV_RB32(buf + 16); | | |
| 198 | if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) { | 204 | if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) { |
| 199 | s->first_rtcp_ntp_time = s->last_rtcp_ntp_time; | 205 | s->first_rtcp_ntp_time = s->last_sr.ntp_timestamp; |
| 200 | if (!s->base_timestamp) | 206 | if (!s->base_timestamp) |
| 201 | s->base_timestamp = s->last_rtcp_timestamp; | 207 | s->base_timestamp = s->last_sr.rtp_timestamp; |
| 202 | s->rtcp_ts_offset = (int32_t)(s->last_rtcp_timestamp - s->base_timestamp); | 208 | s->rtcp_ts_offset = (int32_t)(s->last_sr.rtp_timestamp - s->base_timestamp); |
| 203 | } | 209 | } |
| 204 | | 210 | |
| 205 | break; | 211 | break; |
| @@ -367,11 +373,11 @@ int ff_rtp_check_and_send_back_rr(RTPDemuxContext *s, URLContext *fd, · 161 unmodified lines |
| 367 | avio_wb32(pb, extended_max); /* max sequence received */ | 373 | avio_wb32(pb, extended_max); /* max sequence received */ |
| 368 | avio_wb32(pb, stats->jitter >> 4); /* jitter */ | 374 | avio_wb32(pb, stats->jitter >> 4); /* jitter */ |
| 369 | | 375 | |
| 370 | if (s->last_rtcp_ntp_time == AV_NOPTS_VALUE) { | 376 | if (s->last_sr.ntp_timestamp == AV_NOPTS_VALUE) { |
| 371 | avio_wb32(pb, 0); /* last SR timestamp */ | 377 | avio_wb32(pb, 0); /* last SR timestamp */ |
| 372 | avio_wb32(pb, 0); /* delay since last SR */ | 378 | avio_wb32(pb, 0); /* delay since last SR */ |
| 373 | } else { | 379 | } else { |
| 374 | uint32_t middle_32_bits = s->last_rtcp_ntp_time >> 16; // this is valid, right? do we need to handle 64 bit values special? | 380 | uint32_t middle_32_bits = s->last_sr.ntp_timestamp >> 16; // this is valid, right? do we need to handle 64 bit values special? |
| 375 | uint32_t delay_since_last = av_rescale(av_gettime_relative() - s->last_rtcp_reception_time, | 381 | uint32_t delay_since_last = av_rescale(av_gettime_relative() - s->last_rtcp_reception_time, |
| 376 | 65536, AV_TIME_BASE); | 382 | 65536, AV_TIME_BASE); |
| 377 | | 383 | |
| @@ -538,7 +544,7 @@ RTPDemuxContext *ff_rtp_parse_open(AVFormatContext *s1, AVStream *st, · 160 unmodified lines |
| 538 | if (!s) | 544 | if (!s) |
| 539 | return NULL; | 545 | return NULL; |
| 540 | s->payload_type = payload_type; | 546 | s->payload_type = payload_type; |
| 541 | s->last_rtcp_ntp_time = AV_NOPTS_VALUE; | 547 | s->last_sr.ntp_timestamp = AV_NOPTS_VALUE; |
| 542 | s->first_rtcp_ntp_time = AV_NOPTS_VALUE; | 548 | s->first_rtcp_ntp_time = AV_NOPTS_VALUE; |
| 543 | s->ic = s1; | 549 | s->ic = s1; |
| 544 | s->st = st; | 550 | s->st = st; |
| @@ -596,9 +602,9 @@ static int rtp_set_prft(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestamp) { · 51 unmodified lines |
| 596 | if (!prft) | 602 | if (!prft) |
| 597 | return AVERROR(ENOMEM); | 603 | return AVERROR(ENOMEM); |
| 598 | | 604 | |
| 599 | rtcp_time = ff_parse_ntp_time(s->last_rtcp_ntp_time) - NTP_OFFSET_US; | 605 | rtcp_time = ff_parse_ntp_time(s->last_sr.ntp_timestamp) - NTP_OFFSET_US; |
| 600 | /* Cast to int32_t to handle timestamp wraparound correctly */ | 606 | /* Cast to int32_t to handle timestamp wraparound correctly */ |
| 601 | delta_timestamp = (int32_t)(timestamp - s->last_rtcp_timestamp); | 607 | delta_timestamp = (int32_t)(timestamp - s->last_sr.rtp_timestamp); |
| 602 | delta_time = av_rescale_q(delta_timestamp, s->st->time_base, AV_TIME_BASE_Q); | 608 | delta_time = av_rescale_q(delta_timestamp, s->st->time_base, AV_TIME_BASE_Q); |
| 603 | | 609 | |
| 604 | prft->wallclock = rtcp_time + delta_time; | 610 | prft->wallclock = rtcp_time + delta_time; |
| @@ -617,21 +623,21 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam · 12 unmodified lines |
| 617 | if (timestamp == RTP_NOTS_VALUE) | 623 | if (timestamp == RTP_NOTS_VALUE) |
| 618 | return; | 624 | return; |
| 619 | | 625 | |
| 620 | if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) { | 626 | if (s->last_sr.ntp_timestamp != AV_NOPTS_VALUE) { |
| 621 | if (rtp_set_prft(s, pkt, timestamp) < 0) { | 627 | if (rtp_set_prft(s, pkt, timestamp) < 0) { |
| 622 | av_log(s->ic, AV_LOG_WARNING, "rtpdec: failed to set prft"); | 628 | av_log(s->ic, AV_LOG_WARNING, "rtpdec: failed to set prft"); |
| 623 | } | 629 | } |
| 624 | } | 630 | } |
| 625 | | 631 | |
| 626 | if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE && s->ic->nb_streams > 1) { | 632 | if (s->last_sr.ntp_timestamp != AV_NOPTS_VALUE && s->ic->nb_streams > 1) { |
| 627 | int64_t addend; | 633 | int64_t addend; |
| 628 | int32_t delta_timestamp; | 634 | int32_t delta_timestamp; |
| 629 | | 635 | |
| 630 | /* compute pts from timestamp with received ntp_time */ | 636 | /* compute pts from timestamp with received ntp_time */ |
| 631 | /* Cast to int32_t to handle timestamp wraparound correctly */ | 637 | /* Cast to int32_t to handle timestamp wraparound correctly */ |
| 632 | delta_timestamp = (int32_t)(timestamp - s->last_rtcp_timestamp); | 638 | delta_timestamp = (int32_t)(timestamp - s->last_sr.rtp_timestamp); |
| 633 | /* convert to the PTS timebase */ | 639 | /* convert to the PTS timebase */ |
| 634 | addend = av_rescale(s->last_rtcp_ntp_time - s->first_rtcp_ntp_time, | 640 | addend = av_rescale(s->last_sr.ntp_timestamp - s->first_rtcp_ntp_time, |
| 635 | s->st->time_base.den, | 641 | s->st->time_base.den, |
| 636 | (uint64_t) s->st->time_base.num << 32); | 642 | (uint64_t) s->st->time_base.num << 32); |
| 637 | pkt->pts = s->range_start_offset + s->rtcp_ts_offset + addend + | 643 | pkt->pts = s->range_start_offset + s->rtcp_ts_offset + addend + |