Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bug: write back actual sending time if no source time supplied #1497

Merged
merged 2 commits into from
Aug 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions srtcore/buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ void CSndBuffer::addBuffer(const char* data, int len, SRT_MSGCTRL& w_mctrl)
s->m_tsOriginTime = time;
s->m_tsRexmitTime = time_point();
s->m_iTTL = w_ttl;
// Rewrite the actual sending time back into w_srctime
// so that the calling facilities can reuse it
if (!w_srctime)
w_srctime = count_microseconds(s->m_tsOriginTime.time_since_epoch());
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved

// XXX unchecked condition: s->m_pNext == NULL.
// Should never happen, as the call to increase() should ensure enough buffers.
Expand Down Expand Up @@ -400,9 +404,7 @@ steady_clock::time_point CSndBuffer::getSourceTime(const CSndBuffer::Block& bloc
{
if (block.m_llSourceTime_us)
{
const steady_clock::duration since_epoch = block.m_tsOriginTime.time_since_epoch();
const steady_clock::duration delta = microseconds_from(block.m_llSourceTime_us) - since_epoch;
return block.m_tsOriginTime + delta;
return steady_clock::time_point() + microseconds_from(block.m_llSourceTime_us);
}

return block.m_tsOriginTime;
Expand Down
11 changes: 6 additions & 5 deletions srtcore/buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,20 @@ class CSndBuffer
public:

/// Insert a user buffer into the sending list.
/// For Message control data the following data are used:
/// For @a w_mctrl the following fields are used:
/// INPUT:
/// - msgttl: timeout for scheduling the messsage for sending
/// - msgttl: timeout for retransmitting the message, if lost
/// - inorder: request to deliver the message in order of sending
/// - srctime: local time as a base for packet's timestamp (0 if unused)
/// - pktseq: sequence number to be stamped on the packet (0 if unused)
/// - pktseq: sequence number to be stamped on the packet (-1 if unused)
/// - msgno: message number to be stamped on the packet (-1 if unused)
/// OUTPUT:
/// - srctime: local time that was used to stamp the packet
/// - srctime: local time stamped on the packet (same as input, if input wasn't 0)
/// - pktseq: sequence number to be stamped on the next packet
/// - msgno: message number stamped on the packet
/// @param [in] data pointer to the user data block.
/// @param [in] len size of the block.
/// @param [inout] r_mctrl Message control data
/// @param [inout] w_mctrl Message control data
void addBuffer(const char* data, int len, SRT_MSGCTRL& w_mctrl);

/// Read a block of data from file and insert it into the sending list.
Expand Down