blob: a97bb965ff81ff4c2bbb4906a85f178b7c1a03e1 [file] [log] [blame]
Niels Möller70082872018-08-07 11:03:12 +02001/*
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 Kcf439a02023-01-05 14:01:39 +010013#include "absl/functional/any_invocable.h"
Steve Anton10542f22019-01-11 09:11:00 -080014#include "api/media_types.h"
Per Kcf439a02023-01-05 14:01:39 +010015#include "modules/rtp_rtcp/source/rtp_packet_received.h"
16#include "rtc_base/checks.h"
Steve Anton10542f22019-01-11 09:11:00 -080017#include "rtc_base/copy_on_write_buffer.h"
Niels Möller70082872018-08-07 11:03:12 +020018
19namespace webrtc {
20
21class 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öllerf189c482018-08-17 09:49:20 +020031 int64_t packet_time_us) = 0;
Niels Möller70082872018-08-07 11:03:12 +020032
Per Kcf439a02023-01-05 14:01:39 +010033 // 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öller70082872018-08-07 11:03:12 +020055 protected:
56 virtual ~PacketReceiver() {}
57};
58
59} // namespace webrtc
60
61#endif // CALL_PACKET_RECEIVER_H_