Niels Möller | 7008287 | 2018-08-07 09:03:12 | [diff] [blame] | 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 | |
Per K | cf439a0 | 2023-01-05 13:01:39 | [diff] [blame] | 13 | #include "absl/functional/any_invocable.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 14 | #include "api/media_types.h" |
Per K | cf439a0 | 2023-01-05 13:01:39 | [diff] [blame] | 15 | #include "modules/rtp_rtcp/source/rtp_packet_received.h" |
| 16 | #include "rtc_base/checks.h" |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 17 | #include "rtc_base/copy_on_write_buffer.h" |
Niels Möller | 7008287 | 2018-08-07 09:03:12 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | class PacketReceiver { |
| 22 | public: |
Per K | cf439a0 | 2023-01-05 13:01:39 | [diff] [blame] | 23 | // Demux RTCP packets. Must be called on the worker thread. |
Per K | 664cf14 | 2023-01-25 14:19:11 | [diff] [blame] | 24 | virtual void DeliverRtcpPacket(rtc::CopyOnWriteBuffer packet) = 0; |
Per K | cf439a0 | 2023-01-05 13:01:39 | [diff] [blame] | 25 | |
Per K | d440358 | 2024-02-22 12:45:16 | [diff] [blame] | 26 | // Invoked once when a packet is received that can not be demuxed. |
Per K | cf439a0 | 2023-01-05 13:01:39 | [diff] [blame] | 27 | // If the method returns true, a new attempt is made to demux the packet. |
| 28 | using OnUndemuxablePacketHandler = |
| 29 | absl::AnyInvocable<bool(const RtpPacketReceived& parsed_packet)>; |
| 30 | |
Per K | f6ce1d3 | 2023-03-28 15:27:47 | [diff] [blame] | 31 | // Must be called on the worker thread. |
| 32 | // If `media_type` is not Audio or Video, packets may be used for BWE |
| 33 | // calculations but are not demuxed. |
Per K | cf439a0 | 2023-01-05 13:01:39 | [diff] [blame] | 34 | virtual void DeliverRtpPacket( |
| 35 | MediaType media_type, |
| 36 | RtpPacketReceived packet, |
Per K | 664cf14 | 2023-01-25 14:19:11 | [diff] [blame] | 37 | OnUndemuxablePacketHandler undemuxable_packet_handler) = 0; |
Per K | cf439a0 | 2023-01-05 13:01:39 | [diff] [blame] | 38 | |
Niels Möller | 7008287 | 2018-08-07 09:03:12 | [diff] [blame] | 39 | protected: |
| 40 | virtual ~PacketReceiver() {} |
| 41 | }; |
| 42 | |
| 43 | } // namespace webrtc |
| 44 | |
| 45 | #endif // CALL_PACKET_RECEIVER_H_ |