Adds queue time when using demuxer with FakeNetworkPipe.

This ensures that packet time effects are simulated properly when using
a demuxer with FakeNetworkPipe. Previously this was only done using a
receiver.

This prepares for a CL with a test depending on this behavior.

Bug: webrtc:9054
Change-Id: I031acc9e18adc2891d3e396352dcd2614211909c
Reviewed-on: https://webrtc-review.googlesource.com/67342
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22918}
This commit is contained in:
Sebastian Jansson 2018-04-06 12:59:14 +02:00 committed by Commit Bot
parent d0fa820559
commit a44ab181bf

View File

@ -211,8 +211,9 @@ void FakeNetworkPipe::SetConfig(const FakeNetworkPipe::Config& config) {
void FakeNetworkPipe::SendPacket(const uint8_t* data, size_t data_length) { void FakeNetworkPipe::SendPacket(const uint8_t* data, size_t data_length) {
RTC_DCHECK(HasDemuxer()); RTC_DCHECK(HasDemuxer());
PacketTime packet_time(clock_->TimeInMicroseconds(), 0);
EnqueuePacket(rtc::CopyOnWriteBuffer(data, data_length), rtc::nullopt, false, EnqueuePacket(rtc::CopyOnWriteBuffer(data, data_length), rtc::nullopt, false,
MediaType::ANY, rtc::nullopt); MediaType::ANY, packet_time);
} }
bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet, bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet,
@ -386,16 +387,16 @@ void FakeNetworkPipe::Process() {
} }
void FakeNetworkPipe::DeliverPacket(NetworkPacket* packet) { void FakeNetworkPipe::DeliverPacket(NetworkPacket* packet) {
if (demuxer_) { if (transport_) {
demuxer_->DeliverPacket(packet, PacketTime()); RTC_DCHECK(!receiver_);
} else if (transport_) { RTC_DCHECK(!demuxer_);
if (packet->is_rtcp()) { if (packet->is_rtcp()) {
transport_->SendRtcp(packet->data(), packet->data_length()); transport_->SendRtcp(packet->data(), packet->data_length());
} else { } else {
transport_->SendRtp(packet->data(), packet->data_length(), transport_->SendRtp(packet->data(), packet->data_length(),
packet->packet_options()); packet->packet_options());
} }
} else if (receiver_) { } else {
PacketTime packet_time = packet->packet_time(); PacketTime packet_time = packet->packet_time();
if (packet_time.timestamp != -1) { if (packet_time.timestamp != -1) {
int64_t queue_time = packet->arrival_time() - packet->send_time(); int64_t queue_time = packet->arrival_time() - packet->send_time();
@ -403,9 +404,13 @@ void FakeNetworkPipe::DeliverPacket(NetworkPacket* packet) {
packet_time.timestamp += (queue_time * 1000); packet_time.timestamp += (queue_time * 1000);
packet_time.timestamp += (clock_offset_ms_ * 1000); packet_time.timestamp += (clock_offset_ms_ * 1000);
} }
if (demuxer_) {
demuxer_->DeliverPacket(packet, packet_time);
} else if (receiver_) {
receiver_->DeliverPacket(packet->media_type(), receiver_->DeliverPacket(packet->media_type(),
std::move(*packet->raw_packet()), packet_time); std::move(*packet->raw_packet()), packet_time);
} }
}
} }
int64_t FakeNetworkPipe::TimeUntilNextProcess() { int64_t FakeNetworkPipe::TimeUntilNextProcess() {