1 /* 2 * Copyright (c) 2021 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 #ifndef NET_DCSCTP_PUBLIC_PACKET_OBSERVER_H_ 11 #define NET_DCSCTP_PUBLIC_PACKET_OBSERVER_H_ 12 13 #include <stdint.h> 14 15 #include "api/array_view.h" 16 #include "net/dcsctp/public/types.h" 17 18 namespace dcsctp { 19 20 // A PacketObserver can be attached to a socket and will be called for 21 // all sent and received packets. 22 class PacketObserver { 23 public: 24 virtual ~PacketObserver() = default; 25 // Called when a packet is sent, with the current time (in milliseconds) as 26 // `now`, and the packet payload as `payload`. 27 virtual void OnSentPacket(TimeMs now, 28 rtc::ArrayView<const uint8_t> payload) = 0; 29 30 // Called when a packet is received, with the current time (in milliseconds) 31 // as `now`, and the packet payload as `payload`. 32 virtual void OnReceivedPacket(TimeMs now, 33 rtc::ArrayView<const uint8_t> payload) = 0; 34 }; 35 } // namespace dcsctp 36 37 #endif // NET_DCSCTP_PUBLIC_PACKET_OBSERVER_H_ 38