1 /*
2 * Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "api/transport/network_types.h"
12
13 #include <algorithm>
14
15 namespace webrtc {
16 StreamsConfig::StreamsConfig() = default;
17 StreamsConfig::StreamsConfig(const StreamsConfig&) = default;
18 StreamsConfig::~StreamsConfig() = default;
19
20 TargetRateConstraints::TargetRateConstraints() = default;
21 TargetRateConstraints::TargetRateConstraints(const TargetRateConstraints&) =
22 default;
23 TargetRateConstraints::~TargetRateConstraints() = default;
24
25 NetworkRouteChange::NetworkRouteChange() = default;
26 NetworkRouteChange::NetworkRouteChange(const NetworkRouteChange&) = default;
27 NetworkRouteChange::~NetworkRouteChange() = default;
28
29 PacketResult::PacketResult() = default;
30 PacketResult::PacketResult(const PacketResult& other) = default;
31 PacketResult::~PacketResult() = default;
32
operator ()(const PacketResult & lhs,const PacketResult & rhs)33 bool PacketResult::ReceiveTimeOrder::operator()(const PacketResult& lhs,
34 const PacketResult& rhs) {
35 if (lhs.receive_time != rhs.receive_time)
36 return lhs.receive_time < rhs.receive_time;
37 if (lhs.sent_packet.send_time != rhs.sent_packet.send_time)
38 return lhs.sent_packet.send_time < rhs.sent_packet.send_time;
39 return lhs.sent_packet.sequence_number < rhs.sent_packet.sequence_number;
40 }
41
42 TransportPacketsFeedback::TransportPacketsFeedback() = default;
43 TransportPacketsFeedback::TransportPacketsFeedback(
44 const TransportPacketsFeedback& other) = default;
45 TransportPacketsFeedback::~TransportPacketsFeedback() = default;
46
ReceivedWithSendInfo() const47 std::vector<PacketResult> TransportPacketsFeedback::ReceivedWithSendInfo()
48 const {
49 std::vector<PacketResult> res;
50 for (const PacketResult& fb : packet_feedbacks) {
51 if (fb.IsReceived()) {
52 res.push_back(fb);
53 }
54 }
55 return res;
56 }
57
LostWithSendInfo() const58 std::vector<PacketResult> TransportPacketsFeedback::LostWithSendInfo() const {
59 std::vector<PacketResult> res;
60 for (const PacketResult& fb : packet_feedbacks) {
61 if (!fb.IsReceived()) {
62 res.push_back(fb);
63 }
64 }
65 return res;
66 }
67
PacketsWithFeedback() const68 std::vector<PacketResult> TransportPacketsFeedback::PacketsWithFeedback()
69 const {
70 return packet_feedbacks;
71 }
72
SortedByReceiveTime() const73 std::vector<PacketResult> TransportPacketsFeedback::SortedByReceiveTime()
74 const {
75 std::vector<PacketResult> res;
76 for (const PacketResult& fb : packet_feedbacks) {
77 if (fb.IsReceived()) {
78 res.push_back(fb);
79 }
80 }
81 std::sort(res.begin(), res.end(), PacketResult::ReceiveTimeOrder());
82 return res;
83 }
84
85 NetworkControlUpdate::NetworkControlUpdate() = default;
86 NetworkControlUpdate::NetworkControlUpdate(const NetworkControlUpdate&) =
87 default;
88 NetworkControlUpdate::~NetworkControlUpdate() = default;
89
90 PacedPacketInfo::PacedPacketInfo() = default;
91
PacedPacketInfo(int probe_cluster_id,int probe_cluster_min_probes,int probe_cluster_min_bytes)92 PacedPacketInfo::PacedPacketInfo(int probe_cluster_id,
93 int probe_cluster_min_probes,
94 int probe_cluster_min_bytes)
95 : probe_cluster_id(probe_cluster_id),
96 probe_cluster_min_probes(probe_cluster_min_probes),
97 probe_cluster_min_bytes(probe_cluster_min_bytes) {}
98
operator ==(const PacedPacketInfo & rhs) const99 bool PacedPacketInfo::operator==(const PacedPacketInfo& rhs) const {
100 return send_bitrate_bps == rhs.send_bitrate_bps &&
101 probe_cluster_id == rhs.probe_cluster_id &&
102 probe_cluster_min_probes == rhs.probe_cluster_min_probes &&
103 probe_cluster_min_bytes == rhs.probe_cluster_min_bytes;
104 }
105
106 } // namespace webrtc
107