Add implicit conversion between rtc:PacketTime and int64_t.

This is a preparation for deleting rtc::PacketTime. Next step, after
downstream code has been updated to not access the |timestamp| member,
is to make rtc::PacketTime an alias for int64_t.

Also delete the unused member rtc::PacketTime::not_before.

Bug: webrtc:9584
Change-Id: Iba9d2d55047d69565ad62b1beb525591fd432ae2
Reviewed-on: https://webrtc-review.googlesource.com/c/108860
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25468}
This commit is contained in:
Niels Möller 2018-11-01 14:32:47 +01:00 committed by Commit Bot
parent 96965aeba9
commit 15ca5a9533
17 changed files with 46 additions and 45 deletions

View file

@ -169,9 +169,9 @@ class FakeNetworkInterface : public MediaChannel::NetworkInterface,
static_cast<rtc::TypedMessageData<rtc::CopyOnWriteBuffer>*>(msg->pdata);
if (dest_) {
if (msg->message_id == ST_RTP) {
dest_->OnPacketReceived(&msg_data->data(), rtc::CreatePacketTime(0));
dest_->OnPacketReceived(&msg_data->data(), rtc::TimeMicros());
} else {
dest_->OnRtcpReceived(&msg_data->data(), rtc::CreatePacketTime(0));
dest_->OnRtcpReceived(&msg_data->data(), rtc::TimeMicros());
}
}
delete msg_data;

View file

@ -1379,7 +1379,7 @@ void WebRtcVideoChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
const rtc::PacketTime& packet_time) {
const webrtc::PacketReceiver::DeliveryStatus delivery_result =
call_->Receiver()->DeliverPacket(webrtc::MediaType::VIDEO, *packet,
packet_time.timestamp);
packet_time);
switch (delivery_result) {
case webrtc::PacketReceiver::DELIVERY_OK:
return;
@ -1427,7 +1427,7 @@ void WebRtcVideoChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
}
if (call_->Receiver()->DeliverPacket(webrtc::MediaType::VIDEO, *packet,
packet_time.timestamp) !=
packet_time) !=
webrtc::PacketReceiver::DELIVERY_OK) {
RTC_LOG(LS_WARNING) << "Failed to deliver RTP packet on re-delivery.";
return;
@ -1441,7 +1441,7 @@ void WebRtcVideoChannel::OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
// filter RTCP anymore incoming RTCP packets could've been going to audio (so
// logging failures spam the log).
call_->Receiver()->DeliverPacket(webrtc::MediaType::VIDEO, *packet,
packet_time.timestamp);
packet_time);
}
void WebRtcVideoChannel::OnReadyToSend(bool ready) {

View file

@ -2036,7 +2036,7 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
webrtc::PacketReceiver::DeliveryStatus delivery_result =
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, *packet,
packet_time.timestamp);
packet_time);
if (delivery_result != webrtc::PacketReceiver::DELIVERY_UNKNOWN_SSRC) {
return;
}
@ -2088,8 +2088,8 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
SetRawAudioSink(ssrc, std::move(proxy_sink));
}
delivery_result = call_->Receiver()->DeliverPacket(
webrtc::MediaType::AUDIO, *packet, packet_time.timestamp);
delivery_result = call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO,
*packet, packet_time);
RTC_DCHECK_NE(webrtc::PacketReceiver::DELIVERY_UNKNOWN_SSRC, delivery_result);
}
@ -2100,7 +2100,7 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(
// Forward packet to Call as well.
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, *packet,
packet_time.timestamp);
packet_time);
}
void WebRtcVoiceMediaChannel::OnNetworkRouteChanged(

View file

@ -112,7 +112,7 @@ void AsyncStunTCPSocket::ProcessInput(char* data, size_t* len) {
}
SignalReadPacket(this, data, expected_pkt_len, remote_addr,
rtc::CreatePacketTime(0));
rtc::TimeMicros());
*len -= actual_length;
if (*len > 0) {

View file

@ -652,7 +652,7 @@ void DtlsTransport::OnDtlsEvent(rtc::StreamInterface* dtls, int sig, int err) {
do {
ret = dtls_->Read(buf, sizeof(buf), &read, &read_error);
if (ret == rtc::SR_SUCCESS) {
SignalReadPacket(this, buf, read, rtc::CreatePacketTime(0), 0);
SignalReadPacket(this, buf, read, rtc::TimeMicros(), 0);
} else if (ret == rtc::SR_EOS) {
// Remote peer shut down the association with no error.
RTC_LOG(LS_INFO) << ToString() << ": DTLS transport closed";

View file

@ -266,7 +266,7 @@ class FakeIceTransport : public IceTransportInternal {
if (dest_) {
last_sent_packet_ = packet;
dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(),
rtc::CreatePacketTime(0), 0);
rtc::TimeMicros(), 0);
}
}

View file

@ -119,7 +119,7 @@ class FakePacketTransport : public PacketTransportInternal {
last_sent_packet_ = packet;
if (dest_) {
dest_->SignalReadPacket(dest_, packet.data<char>(), packet.size(),
CreatePacketTime(0), 0);
TimeMicros(), 0);
}
}

View file

@ -3203,7 +3203,7 @@ class P2PTransportChannelPingTest : public testing::Test,
msg.AddFingerprint();
rtc::ByteBufferWriter buf;
msg.Write(&buf);
conn->OnReadPacket(buf.Data(), buf.Length(), rtc::CreatePacketTime(0));
conn->OnReadPacket(buf.Data(), buf.Length(), rtc::TimeMicros());
}
void OnReadyToSend(rtc::PacketTransportInternal* transport) {
@ -3612,7 +3612,7 @@ TEST_F(P2PTransportChannelPingTest, TestReceivingStateChange) {
clock.AdvanceTime(webrtc::TimeDelta::seconds(1));
conn1->ReceivedPing();
conn1->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0));
conn1->OnReadPacket("ABC", 3, rtc::TimeMicros());
EXPECT_TRUE_SIMULATED_WAIT(ch.receiving(), kShortTimeout, clock);
EXPECT_TRUE_SIMULATED_WAIT(!ch.receiving(), kShortTimeout, clock);
}
@ -3803,7 +3803,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
Connection* conn2 = WaitForConnectionTo(&ch, "2.2.2.2", 2);
ASSERT_TRUE(conn2 != nullptr);
conn2->ReceivedPingResponse(LOW_RTT, "id"); // Become writable and receiving.
conn2->OnReadPacket("ABC", 3, rtc::CreatePacketTime(0));
conn2->OnReadPacket("ABC", 3, rtc::TimeMicros());
EXPECT_EQ(conn2, ch.selected_connection());
conn2->ReceivedPingResponse(LOW_RTT, "id"); // Become writable.
@ -3831,7 +3831,7 @@ TEST_F(P2PTransportChannelPingTest, TestSelectConnectionBasedOnMediaReceived) {
// selected connection was nominated by the controlling side.
conn2->ReceivedPing();
conn2->ReceivedPingResponse(LOW_RTT, "id");
conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
conn2->OnReadPacket("XYZ", 3, rtc::TimeMicros());
EXPECT_EQ_WAIT(conn3, ch.selected_connection(), kDefaultTimeout);
}
@ -3860,12 +3860,12 @@ TEST_F(P2PTransportChannelPingTest,
// Advance the clock by 1ms so that the last data receiving timestamp of
// conn2 is larger.
SIMULATED_WAIT(false, 1, clock);
conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
conn2->OnReadPacket("XYZ", 3, rtc::TimeMicros());
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn2));
// conn1 also receives data; it becomes selected due to priority again.
conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
conn1->OnReadPacket("XYZ", 3, rtc::TimeMicros());
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn2));
@ -3874,7 +3874,7 @@ TEST_F(P2PTransportChannelPingTest,
SIMULATED_WAIT(false, 1, clock);
// Need to become writable again because it was pruned.
conn2->ReceivedPingResponse(LOW_RTT, "id");
conn2->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
conn2->OnReadPacket("XYZ", 3, rtc::TimeMicros());
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn2));
@ -3904,7 +3904,7 @@ TEST_F(P2PTransportChannelPingTest,
// conn1 received data; it is the selected connection.
// Advance the clock to have a non-zero last-data-receiving time.
SIMULATED_WAIT(false, 1, clock);
conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
conn1->OnReadPacket("XYZ", 3, rtc::TimeMicros());
EXPECT_EQ(1, reset_selected_candidate_pair_switches());
EXPECT_TRUE(CandidatePairMatchesNetworkRoute(conn1));
@ -4125,7 +4125,7 @@ TEST_F(P2PTransportChannelPingTest, TestDontPruneHighPriorityConnections) {
// conn2.
NominateConnection(conn1);
SIMULATED_WAIT(false, 1, clock);
conn1->OnReadPacket("XYZ", 3, rtc::CreatePacketTime(0));
conn1->OnReadPacket("XYZ", 3, rtc::TimeMicros());
SIMULATED_WAIT(conn2->pruned(), 100, clock);
EXPECT_FALSE(conn2->pruned());
}

View file

@ -1031,8 +1031,7 @@ TEST_F(TurnPortTest, TestTurnAllocateMismatch) {
std::string test_packet = "Test packet";
EXPECT_FALSE(turn_port_->HandleIncomingPacket(
socket_.get(), test_packet.data(), test_packet.size(),
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0),
rtc::CreatePacketTime(0)));
rtc::SocketAddress(kTurnUdpExtAddr.ipaddr(), 0), rtc::TimeMicros()));
}
// Tests that a shared-socket-TurnPort creates its own socket after

View file

@ -446,9 +446,8 @@ void BaseChannel::OnRtpPacket(const webrtc::RtpPacketReceived& parsed_packet) {
if (parsed_packet.arrival_time_ms() > 0) {
timestamp = parsed_packet.arrival_time_ms() * 1000;
}
rtc::PacketTime packet_time(timestamp, /*not_before=*/0);
OnPacketReceived(/*rtcp=*/false, parsed_packet.Buffer(), packet_time);
OnPacketReceived(/*rtcp=*/false, parsed_packet.Buffer(), timestamp);
}
void BaseChannel::UpdateRtpHeaderExtensionMap(

View file

@ -195,8 +195,8 @@ void RtpTransport::DemuxPacket(rtc::CopyOnWriteBuffer* packet,
return;
}
if (time.timestamp != -1) {
parsed_packet.set_arrival_time_ms((time.timestamp + 500) / 1000);
if (time != -1) {
parsed_packet.set_arrival_time_ms((time + 500) / 1000);
}
rtp_demuxer_.OnRtpPacket(parsed_packet);
}

View file

@ -699,6 +699,9 @@ rtc_static_library("rtc_base") {
defines = []
deps = [
":checks",
# For deprecation of rtc::PacketTime, in asyncpacketsocket.h.
":deprecation",
":stringutils",
"..:webrtc_common",
"../api:array_view",

View file

@ -12,6 +12,7 @@
#define RTC_BASE_ASYNCPACKETSOCKET_H_
#include "rtc_base/constructormagic.h"
#include "rtc_base/deprecation.h"
#include "rtc_base/dscp.h"
#include "rtc_base/socket.h"
#include "rtc_base/third_party/sigslot/sigslot.h"
@ -53,21 +54,21 @@ struct PacketOptions {
// This structure will have the information about when packet is actually
// received by socket.
struct PacketTime {
PacketTime() : timestamp(-1), not_before(-1) {}
PacketTime(int64_t timestamp, int64_t not_before)
: timestamp(timestamp), not_before(not_before) {}
PacketTime() : timestamp(-1) {}
// Intentionally implicit.
PacketTime(int64_t timestamp) : timestamp(timestamp) {}
// Deprecated
PacketTime(int64_t timestamp, int64_t /* not_before */)
: timestamp(timestamp) {}
operator int64_t() const { return timestamp; }
int64_t timestamp; // Receive time after socket delivers the data.
// Earliest possible time the data could have arrived, indicating the
// potential error in the |timestamp| value, in case the system, is busy. For
// example, the time of the last select() call.
// If unknown, this value will be set to zero.
int64_t not_before;
};
inline PacketTime CreatePacketTime(int64_t not_before) {
return PacketTime(TimeMicros(), not_before);
// Deprecated
inline PacketTime CreatePacketTime(int64_t /* not_before */) {
return TimeMicros();
}
// Provides the ability to receive packets asynchronously. Sends are not

View file

@ -321,7 +321,7 @@ void AsyncTCPSocket::ProcessInput(char* data, size_t* len) {
return;
SignalReadPacket(this, data + kPacketLenSize, pkt_len, remote_addr,
CreatePacketTime(0));
TimeMicros());
*len -= kPacketLenSize + pkt_len;
if (*len > 0) {

View file

@ -122,9 +122,8 @@ void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) {
// TODO: Make sure that we got all of the packet.
// If we did not, then we should resize our buffer to be large enough.
SignalReadPacket(
this, buf_, static_cast<size_t>(len), remote_addr,
(timestamp > -1 ? PacketTime(timestamp, 0) : CreatePacketTime(0)));
SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr,
(timestamp > -1 ? timestamp : TimeMicros()));
}
void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) {

View file

@ -97,7 +97,7 @@ bool TestClient::CheckNextPacket(const char* buf,
std::unique_ptr<Packet> packet = NextPacket(kTimeoutMs);
if (packet) {
res = (packet->size == size && memcmp(packet->buf, buf, size) == 0 &&
CheckTimestamp(packet->packet_time.timestamp));
CheckTimestamp(packet->packet_time));
if (addr)
*addr = packet->addr;
}

View file

@ -109,7 +109,7 @@ void TestController::OnReadPacket(rtc::AsyncPacketSocket* socket,
break;
}
case NetworkTesterPacket::TEST_DATA: {
packet.set_arrival_timestamp(packet_time.timestamp);
packet.set_arrival_timestamp(packet_time);
packet.set_packet_size(len);
packet_logger_.LogPacket(packet);
break;