Added SetClockOffset on FakeNetworkPipe.
Added functionality on the FakeNetworkPipe to introduce arbitrary clock offsets. This offset is added to the reported receive time of all packets. This prepares for a later CL using this to test correction of receive time stamps. Bug: webrtc:9054 Change-Id: I811b3aa8359bc917f59443088d8a418368242db9 Reviewed-on: https://webrtc-review.googlesource.com/64726 Reviewed-by: Stefan Holmer <stefan@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22763}
This commit is contained in:
committed by
Commit Bot
parent
645e2e0a29
commit
7e85d67031
@ -117,6 +117,7 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||
receiver_(nullptr),
|
||||
transport_(nullptr),
|
||||
random_(seed),
|
||||
clock_offset_ms_(0),
|
||||
config_(),
|
||||
dropped_packets_(0),
|
||||
sent_packets_(0),
|
||||
@ -134,6 +135,7 @@ FakeNetworkPipe::FakeNetworkPipe(Clock* clock,
|
||||
receiver_(nullptr),
|
||||
transport_(transport),
|
||||
random_(1),
|
||||
clock_offset_ms_(0),
|
||||
config_(),
|
||||
dropped_packets_(0),
|
||||
sent_packets_(0),
|
||||
@ -179,6 +181,11 @@ PacketReceiver::DeliveryStatus FakeNetworkPipe::DeliverPacket(
|
||||
: PacketReceiver::DELIVERY_PACKET_ERROR;
|
||||
}
|
||||
|
||||
void FakeNetworkPipe::SetClockOffset(int64_t offset_ms) {
|
||||
rtc::CritScope crit(&config_lock_);
|
||||
clock_offset_ms_ = offset_ms;
|
||||
}
|
||||
|
||||
void FakeNetworkPipe::SetConfig(const FakeNetworkPipe::Config& config) {
|
||||
rtc::CritScope crit(&config_lock_);
|
||||
config_ = config; // Shallow copy of the struct.
|
||||
@ -394,6 +401,7 @@ void FakeNetworkPipe::DeliverPacket(NetworkPacket* packet) {
|
||||
int64_t queue_time = packet->arrival_time() - packet->send_time();
|
||||
RTC_CHECK(queue_time >= 0);
|
||||
packet_time.timestamp += (queue_time * 1000);
|
||||
packet_time.timestamp += (clock_offset_ms_ * 1000);
|
||||
}
|
||||
receiver_->DeliverPacket(packet->media_type(),
|
||||
std::move(*packet->raw_packet()), packet_time);
|
||||
|
||||
@ -149,6 +149,8 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
||||
|
||||
virtual ~FakeNetworkPipe();
|
||||
|
||||
void SetClockOffset(int64_t offset_ms);
|
||||
|
||||
// Sets a new configuration. This won't affect packets already in the pipe.
|
||||
void SetConfig(const FakeNetworkPipe::Config& config);
|
||||
|
||||
@ -229,6 +231,8 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
||||
|
||||
std::deque<NetworkPacket> delay_link_;
|
||||
|
||||
int64_t clock_offset_ms_ RTC_GUARDED_BY(config_lock_);
|
||||
|
||||
// Link configuration.
|
||||
Config config_ RTC_GUARDED_BY(config_lock_);
|
||||
|
||||
|
||||
@ -68,6 +68,10 @@ DirectTransport::~DirectTransport() {
|
||||
task_queue_->CancelTask(next_scheduled_task_);
|
||||
}
|
||||
|
||||
void DirectTransport::SetClockOffset(int64_t offset_ms) {
|
||||
fake_network_->SetClockOffset(offset_ms);
|
||||
}
|
||||
|
||||
void DirectTransport::SetConfig(const FakeNetworkPipe::Config& config) {
|
||||
fake_network_->SetConfig(config);
|
||||
}
|
||||
|
||||
@ -51,6 +51,8 @@ class DirectTransport : public Transport {
|
||||
|
||||
~DirectTransport() override;
|
||||
|
||||
void SetClockOffset(int64_t offset_ms);
|
||||
|
||||
void SetConfig(const FakeNetworkPipe::Config& config);
|
||||
|
||||
RTC_DEPRECATED void StopSending();
|
||||
|
||||
Reference in New Issue
Block a user