Niels Möller | 7008287 | 2018-08-07 11:03:12 +0200 | [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 14:01:39 +0100 | [diff] [blame^] | 13 | #include "absl/functional/any_invocable.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 14 | #include "api/media_types.h" |
Per K | cf439a0 | 2023-01-05 14:01:39 +0100 | [diff] [blame^] | 15 | #include "modules/rtp_rtcp/source/rtp_packet_received.h" |
| 16 | #include "rtc_base/checks.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 17 | #include "rtc_base/copy_on_write_buffer.h" |
Niels Möller | 7008287 | 2018-08-07 11:03:12 +0200 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | class PacketReceiver { |
| 22 | public: |
| 23 | enum DeliveryStatus { |
| 24 | DELIVERY_OK, |
| 25 | DELIVERY_UNKNOWN_SSRC, |
| 26 | DELIVERY_PACKET_ERROR, |
| 27 | }; |
| 28 | |
| 29 | virtual DeliveryStatus DeliverPacket(MediaType media_type, |
| 30 | rtc::CopyOnWriteBuffer packet, |
Niels Möller | f189c48 | 2018-08-17 09:49:20 +0200 | [diff] [blame] | 31 | int64_t packet_time_us) = 0; |
Niels Möller | 7008287 | 2018-08-07 11:03:12 +0200 | [diff] [blame] | 32 | |
Per K | cf439a0 | 2023-01-05 14:01:39 +0100 | [diff] [blame^] | 33 | // Demux RTCP packets. Must be called on the worker thread. |
| 34 | virtual void DeliverRtcpPacket(rtc::CopyOnWriteBuffer packet) { |
| 35 | // TODO(perkj, https://bugs.webrtc.org/7135): Implement in FakeCall and |
| 36 | // FakeNetworkPipe. |
| 37 | RTC_CHECK_NOTREACHED(); |
| 38 | } |
| 39 | |
| 40 | // Invoked once when a packet packet is received that can not be demuxed. |
| 41 | // If the method returns true, a new attempt is made to demux the packet. |
| 42 | using OnUndemuxablePacketHandler = |
| 43 | absl::AnyInvocable<bool(const RtpPacketReceived& parsed_packet)>; |
| 44 | |
| 45 | // Demux RTP packets. Must be called on the worker thread. |
| 46 | virtual void DeliverRtpPacket( |
| 47 | MediaType media_type, |
| 48 | RtpPacketReceived packet, |
| 49 | OnUndemuxablePacketHandler undemuxable_packet_handler) { |
| 50 | // TODO(perkj, https://bugs.webrtc.org/7135): Implement in FakeCall and |
| 51 | // FakeNetworkPipe. |
| 52 | RTC_CHECK_NOTREACHED(); |
| 53 | } |
| 54 | |
Niels Möller | 7008287 | 2018-08-07 11:03:12 +0200 | [diff] [blame] | 55 | protected: |
| 56 | virtual ~PacketReceiver() {} |
| 57 | }; |
| 58 | |
| 59 | } // namespace webrtc |
| 60 | |
| 61 | #endif // CALL_PACKET_RECEIVER_H_ |