Rename rtc::Packet to rtc::VirtualSocketPacket
Bug: webrtc:42222919 Change-Id: I476624e986d4ef9208ec8673d9f6968fe00ea498 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/366423 Auto-Submit: Florent Castelli <orphis@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43283}
This commit is contained in:
parent
3073c4809c
commit
c2180102e4
@ -61,16 +61,16 @@ const int NUM_SAMPLES = 1000;
|
||||
|
||||
// Packets are passed between sockets as messages. We copy the data just like
|
||||
// the kernel does.
|
||||
class Packet {
|
||||
class VirtualSocketPacket {
|
||||
public:
|
||||
Packet(const char* data, size_t size, const SocketAddress& from)
|
||||
VirtualSocketPacket(const char* data, size_t size, const SocketAddress& from)
|
||||
: size_(size), consumed_(0), from_(from) {
|
||||
RTC_DCHECK(nullptr != data);
|
||||
data_ = new char[size_];
|
||||
memcpy(data_, data, size_);
|
||||
}
|
||||
|
||||
~Packet() { delete[] data_; }
|
||||
~VirtualSocketPacket() { delete[] data_; }
|
||||
|
||||
const char* data() const { return data_ + consumed_; }
|
||||
size_t size() const { return size_ - consumed_; }
|
||||
@ -294,7 +294,7 @@ int VirtualSocket::SafetyBlock::RecvFrom(void* buffer,
|
||||
}
|
||||
|
||||
// Return the packet at the front of the queue.
|
||||
Packet& packet = *recv_buffer_.front();
|
||||
VirtualSocketPacket& packet = *recv_buffer_.front();
|
||||
size_t data_read = std::min(size, packet.size());
|
||||
memcpy(buffer, packet.data(), data_read);
|
||||
addr = packet.from();
|
||||
@ -401,7 +401,7 @@ int VirtualSocket::SetOption(Option opt, int value) {
|
||||
}
|
||||
|
||||
void VirtualSocket::PostPacket(TimeDelta delay,
|
||||
std::unique_ptr<Packet> packet) {
|
||||
std::unique_ptr<VirtualSocketPacket> packet) {
|
||||
rtc::scoped_refptr<SafetyBlock> safety = safety_;
|
||||
VirtualSocket* socket = this;
|
||||
server_->msg_queue_->PostDelayedTask(
|
||||
@ -414,7 +414,8 @@ void VirtualSocket::PostPacket(TimeDelta delay,
|
||||
delay);
|
||||
}
|
||||
|
||||
bool VirtualSocket::SafetyBlock::AddPacket(std::unique_ptr<Packet> packet) {
|
||||
bool VirtualSocket::SafetyBlock::AddPacket(
|
||||
std::unique_ptr<VirtualSocketPacket> packet) {
|
||||
MutexLock lock(&mutex_);
|
||||
if (alive_) {
|
||||
recv_buffer_.push_back(std::move(packet));
|
||||
@ -1103,8 +1104,9 @@ void VirtualSocketServer::AddPacketToNetwork(VirtualSocket* sender,
|
||||
if (ordered) {
|
||||
ts = sender->UpdateOrderedDelivery(ts);
|
||||
}
|
||||
recipient->PostPacket(TimeDelta::Millis(ts - cur_time),
|
||||
std::make_unique<Packet>(data, data_size, sender_addr));
|
||||
recipient->PostPacket(
|
||||
TimeDelta::Millis(ts - cur_time),
|
||||
std::make_unique<VirtualSocketPacket>(data, data_size, sender_addr));
|
||||
}
|
||||
|
||||
uint32_t VirtualSocketServer::SendDelay(uint32_t size) {
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
namespace rtc {
|
||||
|
||||
class Packet;
|
||||
class VirtualSocketPacket;
|
||||
class VirtualSocketServer;
|
||||
class SocketAddressPair;
|
||||
|
||||
@ -86,7 +86,8 @@ class VirtualSocket : public Socket, public sigslot::has_slots<> {
|
||||
// Removes stale packets from the network. Returns current size.
|
||||
size_t PurgeNetworkPackets(int64_t cur_time);
|
||||
|
||||
void PostPacket(webrtc::TimeDelta delay, std::unique_ptr<Packet> packet);
|
||||
void PostPacket(webrtc::TimeDelta delay,
|
||||
std::unique_ptr<VirtualSocketPacket> packet);
|
||||
void PostConnect(webrtc::TimeDelta delay, const SocketAddress& remote_addr);
|
||||
void PostDisconnect(webrtc::TimeDelta delay);
|
||||
|
||||
@ -118,7 +119,7 @@ class VirtualSocket : public Socket, public sigslot::has_slots<> {
|
||||
};
|
||||
AcceptResult Accept();
|
||||
|
||||
bool AddPacket(std::unique_ptr<Packet> packet);
|
||||
bool AddPacket(std::unique_ptr<VirtualSocketPacket> packet);
|
||||
void PostConnect(webrtc::TimeDelta delay, const SocketAddress& remote_addr);
|
||||
|
||||
private:
|
||||
@ -148,7 +149,8 @@ class VirtualSocket : public Socket, public sigslot::has_slots<> {
|
||||
PostedConnects posted_connects_ RTC_GUARDED_BY(mutex_);
|
||||
|
||||
// Data which has been received from the network
|
||||
std::list<std::unique_ptr<Packet>> recv_buffer_ RTC_GUARDED_BY(mutex_);
|
||||
std::list<std::unique_ptr<VirtualSocketPacket>> recv_buffer_
|
||||
RTC_GUARDED_BY(mutex_);
|
||||
|
||||
// Pending sockets which can be Accepted
|
||||
std::optional<std::deque<SocketAddress>> listen_queue_
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user