Give the timestamp info after the first RTP packet to RTCP
Previously the information was given too early which meant that RTCP used incorrect information when calculating the RTP timestamps for RTCP Sender Reports
This commit is contained in:
parent
52fccc96fa
commit
a946ffcb2a
|
@ -152,6 +152,8 @@ void kvz_rtp::connection::fill_rtp_header(uint8_t *buffer, uint32_t timestamp)
|
|||
if (wc_start_ == 0) {
|
||||
rtp_timestamp_ = generate_rand_32();
|
||||
wc_start_ = tv_to_ntp();
|
||||
|
||||
rtcp_->set_sender_ts_info(wc_start_, clock_rate_, rtp_timestamp_);
|
||||
}
|
||||
|
||||
buffer[0] = 2 << 6; // RTP version
|
||||
|
@ -164,7 +166,7 @@ void kvz_rtp::connection::fill_rtp_header(uint8_t *buffer, uint32_t timestamp)
|
|||
|
||||
rtp_error_t kvz_rtp::connection::create_rtcp(std::string dst_addr, int dst_port, int src_port)
|
||||
{
|
||||
if ((rtcp_ = new kvz_rtp::rtcp(rtp_ssrc_, wc_start_, clock_rate_, rtp_timestamp_, reader_)) == nullptr) {
|
||||
if ((rtcp_ = new kvz_rtp::rtcp(rtp_ssrc_, reader_)) == nullptr) {
|
||||
LOG_ERROR("Failed to allocate RTCP instance!");
|
||||
return RTP_MEMORY_ERROR;
|
||||
}
|
||||
|
|
15
src/rtcp.cc
15
src/rtcp.cc
|
@ -18,7 +18,7 @@
|
|||
#define UDP_HEADER_SIZE 8
|
||||
#define IP_HEADER_SIZE 20
|
||||
|
||||
kvz_rtp::rtcp::rtcp(uint32_t ssrc, uint64_t clock_start, uint32_t clock_rate, uint32_t rtp_ts_start, bool receiver):
|
||||
kvz_rtp::rtcp::rtcp(uint32_t ssrc, bool receiver):
|
||||
receiver_(receiver),
|
||||
tp_(0), tc_(0), tn_(0), pmembers_(0),
|
||||
members_(0), senders_(0), rtcp_bandwidth_(0),
|
||||
|
@ -28,9 +28,9 @@ kvz_rtp::rtcp::rtcp(uint32_t ssrc, uint64_t clock_start, uint32_t clock_rate, ui
|
|||
ssrc_ = ssrc;
|
||||
cname_ = kvz_rtp::rtcp::generate_cname();
|
||||
|
||||
clock_start_ = clock_start;
|
||||
clock_rate_ = clock_rate;
|
||||
rtp_ts_start_ = rtp_ts_start_;
|
||||
clock_start_ = 0;
|
||||
clock_rate_ = 0;
|
||||
rtp_ts_start_ = 0;
|
||||
|
||||
memset(&sender_stats, 0, sizeof(sender_stats));
|
||||
}
|
||||
|
@ -201,6 +201,13 @@ std::string kvz_rtp::rtcp::generate_cname()
|
|||
return host + "@" + user;
|
||||
}
|
||||
|
||||
void kvz_rtp::rtcp::set_sender_ts_info(uint64_t clock_start, uint32_t clock_rate, uint32_t rtp_ts_start)
|
||||
{
|
||||
clock_start_ = clock_start;
|
||||
clock_rate_ = clock_rate;
|
||||
rtp_ts_start_ = rtp_ts_start;
|
||||
}
|
||||
|
||||
void kvz_rtp::rtcp::sender_update_stats(kvz_rtp::frame::rtp_frame *frame)
|
||||
{
|
||||
if (!frame)
|
||||
|
|
|
@ -22,7 +22,7 @@ namespace kvz_rtp {
|
|||
|
||||
class rtcp {
|
||||
public:
|
||||
rtcp(uint32_t ssrc, uint64_t clock_start, uint32_t clock_rate, uint32_t rtp_ts_start, bool receiver);
|
||||
rtcp(uint32_t ssrc, bool receiver);
|
||||
~rtcp();
|
||||
|
||||
/* start the RTCP runner thread
|
||||
|
@ -101,6 +101,10 @@ namespace kvz_rtp {
|
|||
void receiver_inc_sent_pkts(uint32_t sender_ssrc, size_t n);
|
||||
void receiver_update_stats(kvz_rtp::frame::rtp_frame *frame);
|
||||
|
||||
/* Set wallclock reading for t = 0 and random RTP timestamp from where the counting is started
|
||||
* + clock rate for calculating the correct increment */
|
||||
void set_sender_ts_info(uint64_t clock_start, uint32_t clock_rate, uint32_t rtp_ts_start);
|
||||
|
||||
private:
|
||||
static void rtcp_runner(rtcp *rtcp);
|
||||
|
||||
|
|
Loading…
Reference in New Issue