blob: 1ce0d3b122aaef18f3cbb6e2c43983cca3788cc2 [file] [log] [blame]
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +00001/*
2 * Copyright 2015 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
Steve Anton10542f22019-01-11 09:11:00 -080011#include "rtc_base/async_packet_socket.h"
Jonas Olssona4d87372019-07-05 19:08:33 +020012
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000013namespace rtc {
14
Qingsi Wang6e641e62018-04-11 20:14:17 -070015PacketTimeUpdateParams::PacketTimeUpdateParams() = default;
16
17PacketTimeUpdateParams::PacketTimeUpdateParams(
18 const PacketTimeUpdateParams& other) = default;
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000019
20PacketTimeUpdateParams::~PacketTimeUpdateParams() = default;
21
Qingsi Wang6e641e62018-04-11 20:14:17 -070022PacketOptions::PacketOptions() = default;
23PacketOptions::PacketOptions(DiffServCodePoint dscp) : dscp(dscp) {}
24PacketOptions::PacketOptions(const PacketOptions& other) = default;
25PacketOptions::~PacketOptions() = default;
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000026
Tomas Gunnarssonf15189d2022-04-13 09:03:52 +000027AsyncPacketSocket::AsyncPacketSocket() {
28 network_checker_.Detach();
29}
Qingsi Wang6e641e62018-04-11 20:14:17 -070030
31AsyncPacketSocket::~AsyncPacketSocket() = default;
32
Tomas Gunnarssonf15189d2022-04-13 09:03:52 +000033void AsyncPacketSocket::SubscribeClose(
34 const void* removal_tag,
35 std::function<void(AsyncPacketSocket*, int)> callback) {
36 RTC_DCHECK_RUN_ON(&network_checker_);
37 on_close_.AddReceiver(removal_tag, std::move(callback));
38}
39
40void AsyncPacketSocket::UnsubscribeClose(const void* removal_tag) {
41 RTC_DCHECK_RUN_ON(&network_checker_);
42 on_close_.RemoveReceivers(removal_tag);
43}
44
Qingsi Wang6e641e62018-04-11 20:14:17 -070045void CopySocketInformationToPacketInfo(size_t packet_size_bytes,
46 const AsyncPacketSocket& socket_from,
Qingsi Wang4ea53b32018-04-16 18:22:31 -070047 bool is_connectionless,
Qingsi Wang6e641e62018-04-11 20:14:17 -070048 rtc::PacketInfo* info) {
49 info->packet_size_bytes = packet_size_bytes;
Sebastian Janssondb5d7e42020-03-02 11:32:23 +010050 info->ip_overhead_bytes = socket_from.GetLocalAddress().ipaddr().overhead();
kwiberg@webrtc.org67186fe2015-03-09 22:21:53 +000051}
52
Nico Weber22f99252019-02-20 10:13:16 -050053} // namespace rtc