packet_receiver.h (1504B)
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 #ifndef CALL_PACKET_RECEIVER_H_ 11 #define CALL_PACKET_RECEIVER_H_ 12 13 #include "absl/functional/any_invocable.h" 14 #include "api/media_types.h" 15 #include "modules/rtp_rtcp/source/rtp_packet_received.h" 16 #include "rtc_base/copy_on_write_buffer.h" 17 18 namespace webrtc { 19 20 class PacketReceiver { 21 public: 22 // Demux RTCP packets. Must be called on the worker thread. 23 virtual void DeliverRtcpPacket(CopyOnWriteBuffer packet) = 0; 24 25 // Invoked once when a packet is received that can not be demuxed. 26 // If the method returns true, a new attempt is made to demux the packet. 27 using OnUndemuxablePacketHandler = 28 absl::AnyInvocable<bool(const RtpPacketReceived& parsed_packet)>; 29 30 // Must be called on the worker thread. 31 // If `media_type` is not Audio or Video, packets may be used for BWE 32 // calculations but are not demuxed. 33 virtual void DeliverRtpPacket( 34 MediaType media_type, 35 RtpPacketReceived packet, 36 OnUndemuxablePacketHandler undemuxable_packet_handler) = 0; 37 38 protected: 39 virtual ~PacketReceiver() {} 40 }; 41 42 } // namespace webrtc 43 44 #endif // CALL_PACKET_RECEIVER_H_