Skip to content

Commit

Permalink
UDP packet has timestamp field
Browse files Browse the repository at this point in the history
UDP::enqueue_ts is filled in
ReceiverSession::route_packet() right before
the packet gets into jitter buffer queue.
  • Loading branch information
baranovmv committed Apr 28, 2024
1 parent 7c3b835 commit f372581
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/internal_modules/roc_packet/target_libuv/roc_packet/udp.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ struct UDP {
uv_udp_send_t request;

UDP();

//! It points to a moment when the packet was transferred to a sink-thread, that
//! "consumes" this packet. The reason to have it separate is that this allows
//! us to account additional jitter introduced by thread-switch time.
core::nanoseconds_t enqueue_ts;
};

} // namespace packet
Expand Down
1 change: 1 addition & 0 deletions src/internal_modules/roc_pipeline/receiver_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ audio::IFrameReader& ReceiverSession::frame_reader() {
status::StatusCode ReceiverSession::route_packet(const packet::PacketPtr& packet) {
roc_panic_if(!is_valid());

packet->udp()->enqueue_ts = core::timestamp(core::ClockUnix);
return packet_router_->write(packet);
}

Expand Down
3 changes: 2 additions & 1 deletion src/tests/roc_rtp/test_link_meter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ packet::PacketPtr new_packet(packet::seqnum_t sn) {
packet::PacketPtr packet = packet_factory.new_packet();
CHECK(packet);

packet->add_flags(packet::Packet::FlagRTP);
packet->add_flags(packet::Packet::FlagRTP | packet::Packet::FlagUDP);
packet->rtp()->payload_type = PayloadType_L16_Stereo;
packet->rtp()->seqnum = sn;
packet->udp()->enqueue_ts = 666;

return packet;
}
Expand Down

0 comments on commit f372581

Please sign in to comment.