Delete struct webrtc::PacketTime.
Replaced by a int64_t representing time in us. Bug: webtrc:9584 Change-Id: I0505c020ef741ad940203ec300e8adb103856dda Reviewed-on: https://webrtc-review.googlesource.com/91840 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24204}
This commit is contained in:
@ -236,11 +236,11 @@ TEST(AudioReceiveStreamTest, ReceiveRtpPacket) {
|
||||
const int kTransportSequenceNumberValue = 1234;
|
||||
std::vector<uint8_t> rtp_packet = CreateRtpHeaderWithOneByteExtension(
|
||||
kTransportSequenceNumberId, kTransportSequenceNumberValue, 2);
|
||||
PacketTime packet_time(5678000, 0);
|
||||
constexpr int64_t packet_time_us = 5678000;
|
||||
|
||||
RtpPacketReceived parsed_packet;
|
||||
ASSERT_TRUE(parsed_packet.Parse(&rtp_packet[0], rtp_packet.size()));
|
||||
parsed_packet.set_arrival_time_ms((packet_time.timestamp + 500) / 1000);
|
||||
parsed_packet.set_arrival_time_ms((packet_time_us + 500) / 1000);
|
||||
|
||||
EXPECT_CALL(*helper.channel_proxy(),
|
||||
OnRtpPacket(testing::Ref(parsed_packet)));
|
||||
|
||||
@ -20,6 +20,8 @@ rtc_source_set("call_interfaces") {
|
||||
"call_config.h",
|
||||
"flexfec_receive_stream.cc",
|
||||
"flexfec_receive_stream.h",
|
||||
"packet_receiver.cc",
|
||||
"packet_receiver.h",
|
||||
"syncable.cc",
|
||||
"syncable.h",
|
||||
]
|
||||
|
||||
19
call/call.cc
19
call/call.cc
@ -210,7 +210,7 @@ class Call final : public webrtc::Call,
|
||||
// Implements PacketReceiver.
|
||||
DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) override;
|
||||
int64_t packet_time_us) override;
|
||||
|
||||
// Implements RecoveredPacketReceiver.
|
||||
void OnRecoveredPacket(const uint8_t* packet, size_t length) override;
|
||||
@ -241,7 +241,7 @@ class Call final : public webrtc::Call,
|
||||
size_t length);
|
||||
DeliveryStatus DeliverRtp(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time);
|
||||
int64_t packet_time_us);
|
||||
void ConfigureSync(const std::string& sync_group)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(receive_crit_);
|
||||
|
||||
@ -1218,20 +1218,19 @@ PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type,
|
||||
|
||||
PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) {
|
||||
int64_t packet_time_us) {
|
||||
TRACE_EVENT0("webrtc", "Call::DeliverRtp");
|
||||
|
||||
RtpPacketReceived parsed_packet;
|
||||
if (!parsed_packet.Parse(std::move(packet)))
|
||||
return DELIVERY_PACKET_ERROR;
|
||||
|
||||
if (packet_time.timestamp != -1) {
|
||||
int64_t timestamp_us = packet_time.timestamp;
|
||||
if (packet_time_us != -1) {
|
||||
if (receive_time_calculator_) {
|
||||
timestamp_us = receive_time_calculator_->ReconcileReceiveTimes(
|
||||
packet_time.timestamp, clock_->TimeInMicroseconds());
|
||||
packet_time_us = receive_time_calculator_->ReconcileReceiveTimes(
|
||||
packet_time_us, clock_->TimeInMicroseconds());
|
||||
}
|
||||
parsed_packet.set_arrival_time_ms((timestamp_us + 500) / 1000);
|
||||
parsed_packet.set_arrival_time_ms((packet_time_us + 500) / 1000);
|
||||
} else {
|
||||
parsed_packet.set_arrival_time_ms(clock_->TimeInMilliseconds());
|
||||
}
|
||||
@ -1297,12 +1296,12 @@ PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
|
||||
PacketReceiver::DeliveryStatus Call::DeliverPacket(
|
||||
MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) {
|
||||
int64_t packet_time_us) {
|
||||
RTC_DCHECK_CALLED_SEQUENTIALLY(&configuration_sequence_checker_);
|
||||
if (RtpHeaderParser::IsRtcp(packet.cdata(), packet.size()))
|
||||
return DeliverRtcp(media_type, packet.cdata(), packet.size());
|
||||
|
||||
return DeliverRtp(media_type, std::move(packet), packet_time);
|
||||
return DeliverRtp(media_type, std::move(packet), packet_time_us);
|
||||
}
|
||||
|
||||
void Call::OnRecoveredPacket(const uint8_t* packet, size_t length) {
|
||||
|
||||
17
call/call.h
17
call/call.h
@ -20,6 +20,7 @@
|
||||
#include "call/audio_send_stream.h"
|
||||
#include "call/call_config.h"
|
||||
#include "call/flexfec_receive_stream.h"
|
||||
#include "call/packet_receiver.h"
|
||||
#include "call/rtp_transport_controller_send_interface.h"
|
||||
#include "call/video_receive_stream.h"
|
||||
#include "call/video_send_stream.h"
|
||||
@ -31,22 +32,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class PacketReceiver {
|
||||
public:
|
||||
enum DeliveryStatus {
|
||||
DELIVERY_OK,
|
||||
DELIVERY_UNKNOWN_SSRC,
|
||||
DELIVERY_PACKET_ERROR,
|
||||
};
|
||||
|
||||
virtual DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~PacketReceiver() {}
|
||||
};
|
||||
|
||||
// A Call instance can contain several send and/or receive streams. All streams
|
||||
// are assumed to have the same remote endpoint and will share bitrate estimates
|
||||
// etc.
|
||||
|
||||
@ -191,9 +191,9 @@ bool DegradedCall::SendRtcp(const uint8_t* packet, size_t length) {
|
||||
PacketReceiver::DeliveryStatus DegradedCall::DeliverPacket(
|
||||
MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) {
|
||||
PacketReceiver::DeliveryStatus status =
|
||||
receive_pipe_->DeliverPacket(media_type, std::move(packet), packet_time);
|
||||
int64_t packet_time_us) {
|
||||
PacketReceiver::DeliveryStatus status = receive_pipe_->DeliverPacket(
|
||||
media_type, std::move(packet), packet_time_us);
|
||||
// This is not optimal, but there are many places where there are thread
|
||||
// checks that fail if we're not using the worker thread call into this
|
||||
// method. If we want to fix this we probably need a task queue to do handover
|
||||
|
||||
@ -84,7 +84,7 @@ class DegradedCall : public Call, private Transport, private PacketReceiver {
|
||||
// Implements PacketReceiver.
|
||||
DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) override;
|
||||
int64_t packet_time_us) override;
|
||||
|
||||
private:
|
||||
Clock* const clock_;
|
||||
|
||||
@ -35,14 +35,30 @@ NetworkPacket::NetworkPacket(rtc::CopyOnWriteBuffer packet,
|
||||
absl::optional<PacketOptions> packet_options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type,
|
||||
absl::optional<PacketTime> packet_time)
|
||||
absl::optional<int64_t> packet_time_us)
|
||||
: packet_(std::move(packet)),
|
||||
send_time_(send_time),
|
||||
arrival_time_(arrival_time),
|
||||
packet_options_(packet_options),
|
||||
is_rtcp_(is_rtcp),
|
||||
media_type_(media_type),
|
||||
packet_time_(packet_time) {}
|
||||
packet_time_us_(packet_time_us) {}
|
||||
NetworkPacket::NetworkPacket(rtc::CopyOnWriteBuffer packet,
|
||||
int64_t send_time,
|
||||
int64_t arrival_time,
|
||||
absl::optional<PacketOptions> packet_options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type,
|
||||
absl::optional<PacketTime> packet_time)
|
||||
: NetworkPacket(packet,
|
||||
send_time,
|
||||
arrival_time,
|
||||
packet_options,
|
||||
is_rtcp,
|
||||
media_type,
|
||||
packet_time
|
||||
? absl::optional<int64_t>(packet_time->timestamp)
|
||||
: absl::nullopt) {}
|
||||
|
||||
NetworkPacket::NetworkPacket(NetworkPacket&& o)
|
||||
: packet_(std::move(o.packet_)),
|
||||
@ -51,7 +67,7 @@ NetworkPacket::NetworkPacket(NetworkPacket&& o)
|
||||
packet_options_(o.packet_options_),
|
||||
is_rtcp_(o.is_rtcp_),
|
||||
media_type_(o.media_type_),
|
||||
packet_time_(o.packet_time_) {}
|
||||
packet_time_us_(o.packet_time_us_) {}
|
||||
|
||||
NetworkPacket::~NetworkPacket() = default;
|
||||
|
||||
@ -62,7 +78,7 @@ NetworkPacket& NetworkPacket::operator=(NetworkPacket&& o) {
|
||||
packet_options_ = o.packet_options_;
|
||||
is_rtcp_ = o.is_rtcp_;
|
||||
media_type_ = o.media_type_;
|
||||
packet_time_ = o.packet_time_;
|
||||
packet_time_us_ = o.packet_time_us_;
|
||||
|
||||
return *this;
|
||||
}
|
||||
@ -117,23 +133,23 @@ bool FakeNetworkPipe::SendRtp(const uint8_t* packet,
|
||||
const PacketOptions& options) {
|
||||
RTC_DCHECK(HasTransport());
|
||||
EnqueuePacket(rtc::CopyOnWriteBuffer(packet, length), options, false,
|
||||
MediaType::ANY, absl::nullopt);
|
||||
MediaType::ANY);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool FakeNetworkPipe::SendRtcp(const uint8_t* packet, size_t length) {
|
||||
RTC_DCHECK(HasTransport());
|
||||
EnqueuePacket(rtc::CopyOnWriteBuffer(packet, length), absl::nullopt, true,
|
||||
MediaType::ANY, absl::nullopt);
|
||||
MediaType::ANY);
|
||||
return true;
|
||||
}
|
||||
|
||||
PacketReceiver::DeliveryStatus FakeNetworkPipe::DeliverPacket(
|
||||
MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) {
|
||||
int64_t packet_time_us) {
|
||||
return EnqueuePacket(std::move(packet), absl::nullopt, false, media_type,
|
||||
packet_time)
|
||||
packet_time_us)
|
||||
? PacketReceiver::DELIVERY_OK
|
||||
: PacketReceiver::DELIVERY_PACKET_ERROR;
|
||||
}
|
||||
@ -226,6 +242,18 @@ absl::optional<int64_t> SimulatedNetwork::NextDeliveryTimeUs() const {
|
||||
FakeNetworkPipe::StoredPacket::StoredPacket(NetworkPacket&& packet)
|
||||
: packet(std::move(packet)) {}
|
||||
|
||||
bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet,
|
||||
absl::optional<PacketOptions> options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type,
|
||||
absl::optional<int64_t> packet_time_us) {
|
||||
absl::optional<PacketTime> packet_time;
|
||||
if (packet_time_us) {
|
||||
packet_time = PacketTime(*packet_time_us, -1);
|
||||
}
|
||||
return EnqueuePacket(packet, options, is_rtcp, media_type, packet_time);
|
||||
}
|
||||
|
||||
bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet,
|
||||
absl::optional<PacketOptions> options,
|
||||
bool is_rtcp,
|
||||
@ -234,8 +262,10 @@ bool FakeNetworkPipe::EnqueuePacket(rtc::CopyOnWriteBuffer packet,
|
||||
int64_t time_now_us = clock_->TimeInMicroseconds();
|
||||
rtc::CritScope crit(&process_lock_);
|
||||
size_t packet_size = packet.size();
|
||||
NetworkPacket net_packet(std::move(packet), time_now_us, time_now_us, options,
|
||||
is_rtcp, media_type, packet_time);
|
||||
NetworkPacket net_packet(
|
||||
std::move(packet), time_now_us, time_now_us, options, is_rtcp, media_type,
|
||||
packet_time ? absl::optional<int64_t>(packet_time->timestamp)
|
||||
: absl::nullopt);
|
||||
|
||||
packets_in_flight_.emplace_back(StoredPacket(std::move(net_packet)));
|
||||
int64_t packet_id = reinterpret_cast<uint64_t>(&packets_in_flight_.back());
|
||||
@ -415,7 +445,7 @@ void FakeNetworkPipe::Process() {
|
||||
while (!packets_to_deliver.empty()) {
|
||||
NetworkPacket packet = std::move(packets_to_deliver.front());
|
||||
packets_to_deliver.pop();
|
||||
DeliverPacket(&packet);
|
||||
DeliverNetworkPacket(&packet);
|
||||
}
|
||||
absl::optional<int64_t> delivery_us =
|
||||
network_simulation_->NextDeliveryTimeUs();
|
||||
@ -424,7 +454,7 @@ void FakeNetworkPipe::Process() {
|
||||
: time_now_us + kDefaultProcessIntervalMs * 1000;
|
||||
}
|
||||
|
||||
void FakeNetworkPipe::DeliverPacket(NetworkPacket* packet) {
|
||||
void FakeNetworkPipe::DeliverNetworkPacket(NetworkPacket* packet) {
|
||||
if (transport_) {
|
||||
RTC_DCHECK(!receiver_);
|
||||
if (packet->is_rtcp()) {
|
||||
@ -434,15 +464,15 @@ void FakeNetworkPipe::DeliverPacket(NetworkPacket* packet) {
|
||||
packet->packet_options());
|
||||
}
|
||||
} else if (receiver_) {
|
||||
PacketTime packet_time = packet->packet_time();
|
||||
if (packet_time.timestamp != -1) {
|
||||
int64_t packet_time_us = packet->packet_time_us().value_or(-1);
|
||||
if (packet_time_us != -1) {
|
||||
int64_t queue_time_us = packet->arrival_time() - packet->send_time();
|
||||
RTC_CHECK(queue_time_us >= 0);
|
||||
packet_time.timestamp += queue_time_us;
|
||||
packet_time.timestamp += (clock_offset_ms_ * 1000);
|
||||
packet_time_us += queue_time_us;
|
||||
packet_time_us += (clock_offset_ms_ * 1000);
|
||||
}
|
||||
receiver_->DeliverPacket(packet->media_type(),
|
||||
std::move(*packet->raw_packet()), packet_time);
|
||||
std::move(*packet->raw_packet()), packet_time_us);
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,7 +493,7 @@ bool FakeNetworkPipe::HasReceiver() const {
|
||||
|
||||
void FakeNetworkPipe::DeliverPacketWithLock(NetworkPacket* packet) {
|
||||
rtc::CritScope crit(&config_lock_);
|
||||
DeliverPacket(packet);
|
||||
DeliverNetworkPacket(packet);
|
||||
}
|
||||
|
||||
void FakeNetworkPipe::ResetStats() {
|
||||
|
||||
@ -42,8 +42,17 @@ class NetworkPacket {
|
||||
int64_t arrival_time,
|
||||
absl::optional<PacketOptions> packet_options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type_,
|
||||
absl::optional<PacketTime> packet_time_);
|
||||
MediaType media_type,
|
||||
absl::optional<int64_t> packet_time_us);
|
||||
// TODO(nisse): Deprecated.
|
||||
NetworkPacket(rtc::CopyOnWriteBuffer packet,
|
||||
int64_t send_time,
|
||||
int64_t arrival_time,
|
||||
absl::optional<PacketOptions> packet_options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type,
|
||||
absl::optional<PacketTime> packet_time);
|
||||
|
||||
// Disallow copy constructor and copy assignment (no deep copies of |data_|).
|
||||
NetworkPacket(const NetworkPacket&) = delete;
|
||||
~NetworkPacket();
|
||||
@ -65,7 +74,11 @@ class NetworkPacket {
|
||||
}
|
||||
bool is_rtcp() const { return is_rtcp_; }
|
||||
MediaType media_type() const { return media_type_; }
|
||||
PacketTime packet_time() const { return packet_time_.value_or(PacketTime()); }
|
||||
absl::optional<int64_t> packet_time_us() const { return packet_time_us_; }
|
||||
// TODO(nisse): Deprecated.
|
||||
PacketTime packet_time() const {
|
||||
return PacketTime(packet_time_us_.value_or(-1), -1);
|
||||
}
|
||||
|
||||
private:
|
||||
rtc::CopyOnWriteBuffer packet_;
|
||||
@ -82,7 +95,7 @@ class NetworkPacket {
|
||||
// forwarded. The PacketTime might be altered to reflect time spent in fake
|
||||
// network pipe.
|
||||
MediaType media_type_;
|
||||
absl::optional<PacketTime> packet_time_;
|
||||
absl::optional<int64_t> packet_time_us_;
|
||||
};
|
||||
|
||||
// Class simulating a network link. This is a simple and naive solution just
|
||||
@ -179,10 +192,13 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
||||
// SetReceiver(), without passing through a Demuxer. The receive time in
|
||||
// PacketTime will be increased by the amount of time the packet spent in the
|
||||
// fake network pipe.
|
||||
PacketReceiver::DeliveryStatus DeliverPacket(
|
||||
MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) override;
|
||||
PacketReceiver::DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
int64_t packet_time_us) override;
|
||||
|
||||
// TODO(bugs.webrtc.org/9584): Needed to inherit the alternative signature for
|
||||
// this method.
|
||||
using PacketReceiver::DeliverPacket;
|
||||
|
||||
// Processes the network queues and trigger PacketReceiver::IncomingPacket for
|
||||
// packets ready to be delivered.
|
||||
@ -217,12 +233,27 @@ class FakeNetworkPipe : public Transport, public PacketReceiver, public Module {
|
||||
};
|
||||
|
||||
// Returns true if enqueued, or false if packet was dropped.
|
||||
virtual bool EnqueuePacket(rtc::CopyOnWriteBuffer packet,
|
||||
absl::optional<PacketOptions> options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type,
|
||||
absl::optional<int64_t> packet_time_us);
|
||||
|
||||
// TODO(nisse): Deprecated. Delete as soon as overrides in downstream code are
|
||||
// updated.
|
||||
virtual bool EnqueuePacket(rtc::CopyOnWriteBuffer packet,
|
||||
absl::optional<PacketOptions> options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type,
|
||||
absl::optional<PacketTime> packet_time);
|
||||
void DeliverPacket(NetworkPacket* packet)
|
||||
bool EnqueuePacket(rtc::CopyOnWriteBuffer packet,
|
||||
absl::optional<PacketOptions> options,
|
||||
bool is_rtcp,
|
||||
MediaType media_type) {
|
||||
return EnqueuePacket(packet, options, is_rtcp, media_type,
|
||||
absl::optional<PacketTime>());
|
||||
}
|
||||
void DeliverNetworkPacket(NetworkPacket* packet)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(config_lock_);
|
||||
bool HasTransport() const;
|
||||
bool HasReceiver() const;
|
||||
|
||||
31
call/packet_receiver.cc
Normal file
31
call/packet_receiver.cc
Normal file
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "call/packet_receiver.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
PacketReceiver::DeliveryStatus PacketReceiver::DeliverPacket(
|
||||
MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
int64_t packet_time_us) {
|
||||
return DeliverPacket(media_type, packet, PacketTime(packet_time_us, -1));
|
||||
}
|
||||
|
||||
// TODO(bugs.webrtc.org/9584): Deprecated. Over the transition, default
|
||||
// implementations are used, and subclasses must override one or the other.
|
||||
PacketReceiver::DeliveryStatus PacketReceiver::DeliverPacket(
|
||||
MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) {
|
||||
return DeliverPacket(media_type, packet, packet_time.timestamp);
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
48
call/packet_receiver.h
Normal file
48
call/packet_receiver.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license
|
||||
* that can be found in the LICENSE file in the root of the source
|
||||
* tree. An additional intellectual property rights grant can be found
|
||||
* in the file PATENTS. All contributing project authors may
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
#ifndef CALL_PACKET_RECEIVER_H_
|
||||
#define CALL_PACKET_RECEIVER_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/mediatypes.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
#include "rtc_base/copyonwritebuffer.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class PacketReceiver {
|
||||
public:
|
||||
enum DeliveryStatus {
|
||||
DELIVERY_OK,
|
||||
DELIVERY_UNKNOWN_SSRC,
|
||||
DELIVERY_PACKET_ERROR,
|
||||
};
|
||||
|
||||
virtual DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
int64_t packet_time_us);
|
||||
|
||||
// TODO(bugs.webrtc.org/9584): Deprecated. Over the transition, default
|
||||
// implementations are used, and subclasses must override one or the other.
|
||||
virtual DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time);
|
||||
|
||||
protected:
|
||||
virtual ~PacketReceiver() {}
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // CALL_PACKET_RECEIVER_H_
|
||||
@ -28,9 +28,7 @@ namespace webrtc {
|
||||
class MockReceiver : public PacketReceiver {
|
||||
public:
|
||||
MOCK_METHOD3(DeliverPacket,
|
||||
DeliveryStatus(MediaType,
|
||||
rtc::CopyOnWriteBuffer,
|
||||
const PacketTime&));
|
||||
DeliveryStatus(MediaType, rtc::CopyOnWriteBuffer, int64_t));
|
||||
virtual ~MockReceiver() = default;
|
||||
};
|
||||
|
||||
@ -38,7 +36,7 @@ class ReorderTestReceiver : public MockReceiver {
|
||||
public:
|
||||
DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) override {
|
||||
int64_t /* packet_time_us */) override {
|
||||
RTC_DCHECK_GE(packet.size(), sizeof(int));
|
||||
int seq_num;
|
||||
memcpy(&seq_num, packet.data<uint8_t>(), sizeof(int));
|
||||
@ -61,7 +59,7 @@ class FakeNetworkPipeTest : public ::testing::Test {
|
||||
// using the first bytes in the packet.
|
||||
memcpy(packet.get(), &i, sizeof(int));
|
||||
rtc::CopyOnWriteBuffer buffer(packet.get(), packet_size);
|
||||
pipe->DeliverPacket(MediaType::ANY, buffer, PacketTime());
|
||||
pipe->DeliverPacket(MediaType::ANY, buffer, /* packet_time_us */ -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -409,6 +409,9 @@ struct OverUseDetectorOptions {
|
||||
double initial_var_noise;
|
||||
};
|
||||
|
||||
// TODO(nisse): This struct is phased out, delete as soon as down stream code is
|
||||
// updated.
|
||||
|
||||
// This structure will have the information about when packet is actually
|
||||
// received by socket.
|
||||
struct PacketTime {
|
||||
|
||||
@ -90,7 +90,7 @@ bool FakeAudioReceiveStream::VerifyLastPacket(const uint8_t* data,
|
||||
|
||||
bool FakeAudioReceiveStream::DeliverRtp(const uint8_t* packet,
|
||||
size_t length,
|
||||
const webrtc::PacketTime& packet_time) {
|
||||
int64_t /* packet_time_us */) {
|
||||
++received_packets_;
|
||||
last_packet_.SetData(packet, length);
|
||||
return true;
|
||||
@ -582,10 +582,9 @@ webrtc::PacketReceiver* FakeCall::Receiver() {
|
||||
return this;
|
||||
}
|
||||
|
||||
FakeCall::DeliveryStatus FakeCall::DeliverPacket(
|
||||
webrtc::MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const webrtc::PacketTime& packet_time) {
|
||||
FakeCall::DeliveryStatus FakeCall::DeliverPacket(webrtc::MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
int64_t packet_time_us) {
|
||||
EXPECT_GE(packet.size(), 12u);
|
||||
RTC_DCHECK(media_type == webrtc::MediaType::AUDIO ||
|
||||
media_type == webrtc::MediaType::VIDEO);
|
||||
@ -603,7 +602,7 @@ FakeCall::DeliveryStatus FakeCall::DeliverPacket(
|
||||
if (media_type == webrtc::MediaType::AUDIO) {
|
||||
for (auto receiver : audio_receive_streams_) {
|
||||
if (receiver->GetConfig().rtp.remote_ssrc == ssrc) {
|
||||
receiver->DeliverRtp(packet.cdata(), packet.size(), packet_time);
|
||||
receiver->DeliverRtp(packet.cdata(), packet.size(), packet_time_us);
|
||||
return DELIVERY_OK;
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,9 +92,7 @@ class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream {
|
||||
bool VerifyLastPacket(const uint8_t* data, size_t length) const;
|
||||
const webrtc::AudioSinkInterface* sink() const { return sink_; }
|
||||
float gain() const { return gain_; }
|
||||
bool DeliverRtp(const uint8_t* packet,
|
||||
size_t length,
|
||||
const webrtc::PacketTime& packet_time);
|
||||
bool DeliverRtp(const uint8_t* packet, size_t length, int64_t packet_time_us);
|
||||
bool started() const { return started_; }
|
||||
|
||||
private:
|
||||
@ -306,7 +304,7 @@ class FakeCall final : public webrtc::Call, public webrtc::PacketReceiver {
|
||||
|
||||
DeliveryStatus DeliverPacket(webrtc::MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const webrtc::PacketTime& packet_time) override;
|
||||
int64_t packet_time_us) override;
|
||||
|
||||
webrtc::RtpTransportControllerSendInterface* GetTransportControllerSend()
|
||||
override {
|
||||
|
||||
@ -1430,11 +1430,9 @@ void WebRtcVideoChannel::FillSendAndReceiveCodecStats(
|
||||
|
||||
void WebRtcVideoChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
|
||||
const rtc::PacketTime& packet_time) {
|
||||
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
|
||||
packet_time.not_before);
|
||||
const webrtc::PacketReceiver::DeliveryStatus delivery_result =
|
||||
call_->Receiver()->DeliverPacket(webrtc::MediaType::VIDEO, *packet,
|
||||
webrtc_packet_time);
|
||||
packet_time.timestamp);
|
||||
switch (delivery_result) {
|
||||
case webrtc::PacketReceiver::DELIVERY_OK:
|
||||
return;
|
||||
@ -1478,7 +1476,7 @@ void WebRtcVideoChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
|
||||
}
|
||||
|
||||
if (call_->Receiver()->DeliverPacket(webrtc::MediaType::VIDEO, *packet,
|
||||
webrtc_packet_time) !=
|
||||
packet_time.timestamp) !=
|
||||
webrtc::PacketReceiver::DELIVERY_OK) {
|
||||
RTC_LOG(LS_WARNING) << "Failed to deliver RTP packet on re-delivery.";
|
||||
return;
|
||||
@ -1487,14 +1485,12 @@ void WebRtcVideoChannel::OnPacketReceived(rtc::CopyOnWriteBuffer* packet,
|
||||
|
||||
void WebRtcVideoChannel::OnRtcpReceived(rtc::CopyOnWriteBuffer* packet,
|
||||
const rtc::PacketTime& packet_time) {
|
||||
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
|
||||
packet_time.not_before);
|
||||
// TODO(pbos): Check webrtc::PacketReceiver::DELIVERY_OK once we deliver
|
||||
// for both audio and video on the same path. Since BundleFilter doesn't
|
||||
// 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,
|
||||
webrtc_packet_time);
|
||||
packet_time.timestamp);
|
||||
}
|
||||
|
||||
void WebRtcVideoChannel::OnReadyToSend(bool ready) {
|
||||
|
||||
@ -2008,11 +2008,9 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
|
||||
const rtc::PacketTime& packet_time) {
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
|
||||
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
|
||||
packet_time.not_before);
|
||||
webrtc::PacketReceiver::DeliveryStatus delivery_result =
|
||||
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, *packet,
|
||||
webrtc_packet_time);
|
||||
packet_time.timestamp);
|
||||
if (delivery_result != webrtc::PacketReceiver::DELIVERY_UNKNOWN_SSRC) {
|
||||
return;
|
||||
}
|
||||
@ -2065,7 +2063,7 @@ void WebRtcVoiceMediaChannel::OnPacketReceived(
|
||||
}
|
||||
|
||||
delivery_result = call_->Receiver()->DeliverPacket(
|
||||
webrtc::MediaType::AUDIO, *packet, webrtc_packet_time);
|
||||
webrtc::MediaType::AUDIO, *packet, packet_time.timestamp);
|
||||
RTC_DCHECK_NE(webrtc::PacketReceiver::DELIVERY_UNKNOWN_SSRC, delivery_result);
|
||||
}
|
||||
|
||||
@ -2075,10 +2073,8 @@ void WebRtcVoiceMediaChannel::OnRtcpReceived(
|
||||
RTC_DCHECK(worker_thread_checker_.CalledOnValidThread());
|
||||
|
||||
// Forward packet to Call as well.
|
||||
const webrtc::PacketTime webrtc_packet_time(packet_time.timestamp,
|
||||
packet_time.not_before);
|
||||
call_->Receiver()->DeliverPacket(webrtc::MediaType::AUDIO, *packet,
|
||||
webrtc_packet_time);
|
||||
packet_time.timestamp);
|
||||
}
|
||||
|
||||
void WebRtcVoiceMediaChannel::OnNetworkRouteChanged(
|
||||
|
||||
@ -22,7 +22,6 @@ namespace rtc {
|
||||
|
||||
class CopyOnWriteBuffer;
|
||||
struct PacketOptions;
|
||||
struct PacketTime;
|
||||
class PacketTransportInternal;
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
@ -116,7 +116,7 @@ void DirectTransport::SendPacket(const uint8_t* data, size_t length) {
|
||||
MediaType media_type = demuxer_.GetMediaType(data, length);
|
||||
int64_t send_time = clock_->TimeInMicroseconds();
|
||||
fake_network_->DeliverPacket(media_type, rtc::CopyOnWriteBuffer(data, length),
|
||||
PacketTime(send_time, -1));
|
||||
send_time);
|
||||
}
|
||||
|
||||
int DirectTransport::GetAverageDelayMs() {
|
||||
|
||||
@ -52,13 +52,13 @@ TEST_F(SsrcEndToEndTest, UnknownRtpPacketGivesUnknownSsrcReturnCode) {
|
||||
private:
|
||||
DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) override {
|
||||
int64_t packet_time_us) override {
|
||||
if (RtpHeaderParser::IsRtcp(packet.cdata(), packet.size())) {
|
||||
return receiver_->DeliverPacket(media_type, std::move(packet),
|
||||
packet_time);
|
||||
packet_time_us);
|
||||
} else {
|
||||
DeliveryStatus delivery_status = receiver_->DeliverPacket(
|
||||
media_type, std::move(packet), packet_time);
|
||||
media_type, std::move(packet), packet_time_us);
|
||||
EXPECT_EQ(DELIVERY_UNKNOWN_SSRC, delivery_status);
|
||||
delivered_packet_.Set();
|
||||
return delivery_status;
|
||||
|
||||
@ -313,7 +313,8 @@ void RtpReplay() {
|
||||
++num_packets;
|
||||
switch (call->Receiver()->DeliverPacket(
|
||||
webrtc::MediaType::VIDEO,
|
||||
rtc::CopyOnWriteBuffer(packet.data, packet.length), PacketTime())) {
|
||||
rtc::CopyOnWriteBuffer(packet.data, packet.length),
|
||||
/* packet_time_us */ -1)) {
|
||||
case PacketReceiver::DELIVERY_OK:
|
||||
break;
|
||||
case PacketReceiver::DELIVERY_UNKNOWN_SSRC: {
|
||||
|
||||
@ -175,11 +175,12 @@ rtc::VideoSourceInterface<VideoFrame>* VideoAnalyzer::OutputInterface() {
|
||||
PacketReceiver::DeliveryStatus VideoAnalyzer::DeliverPacket(
|
||||
MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) {
|
||||
int64_t packet_time_us) {
|
||||
// Ignore timestamps of RTCP packets. They're not synchronized with
|
||||
// RTP packet timestamps and so they would confuse wrap_handler_.
|
||||
if (RtpHeaderParser::IsRtcp(packet.cdata(), packet.size())) {
|
||||
return receiver_->DeliverPacket(media_type, std::move(packet), packet_time);
|
||||
return receiver_->DeliverPacket(media_type, std::move(packet),
|
||||
packet_time_us);
|
||||
}
|
||||
|
||||
if (rtp_file_writer_) {
|
||||
@ -207,7 +208,8 @@ PacketReceiver::DeliveryStatus VideoAnalyzer::DeliverPacket(
|
||||
Clock::GetRealTimeClock()->CurrentNtpInMilliseconds();
|
||||
}
|
||||
|
||||
return receiver_->DeliverPacket(media_type, std::move(packet), packet_time);
|
||||
return receiver_->DeliverPacket(media_type, std::move(packet),
|
||||
packet_time_us);
|
||||
}
|
||||
|
||||
void VideoAnalyzer::PreEncodeOnFrame(const VideoFrame& video_frame) {
|
||||
|
||||
@ -55,7 +55,7 @@ class VideoAnalyzer : public PacketReceiver,
|
||||
|
||||
DeliveryStatus DeliverPacket(MediaType media_type,
|
||||
rtc::CopyOnWriteBuffer packet,
|
||||
const PacketTime& packet_time) override;
|
||||
int64_t packet_time_us) override;
|
||||
|
||||
void PreEncodeOnFrame(const VideoFrame& video_frame);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user