blob: 2f48e4b7d48008395e0711c0f384a93f5b07d536 [file] [log] [blame]
ossua70695a2016-09-22 02:06:28 -07001/*
2 * Copyright (c) 2012 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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#ifndef MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_
12#define MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_
ossua70695a2016-09-22 02:06:28 -070013
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020014#include "modules/audio_coding/neteq/packet.h"
ossua70695a2016-09-22 02:06:28 -070015
16namespace webrtc {
17
ossua70695a2016-09-22 02:06:28 -070018class DecoderDatabase;
19
Philipp Hancke2291fb32020-09-29 10:51:42 +020020static const size_t kRedHeaderLength = 4; // 4 bytes RED header.
21static const size_t kRedLastHeaderLength =
22 1; // reduced size for last RED header.
ossua70695a2016-09-22 02:06:28 -070023// This class handles splitting of RED payloads into smaller parts.
24// Codec-specific packet splitting can be performed by
25// AudioDecoder::ParsePayload.
26class RedPayloadSplitter {
27 public:
28 RedPayloadSplitter() {}
29
30 virtual ~RedPayloadSplitter() {}
31
Byoungchan Lee604fd2f2022-01-21 09:49:39 +090032 RedPayloadSplitter(const RedPayloadSplitter&) = delete;
33 RedPayloadSplitter& operator=(const RedPayloadSplitter&) = delete;
34
Artem Titovd00ce742021-07-28 20:00:17 +020035 // Splits each packet in `packet_list` into its separate RED payloads. Each
ossua70695a2016-09-22 02:06:28 -070036 // RED payload is packetized into a Packet. The original elements in
Artem Titovd00ce742021-07-28 20:00:17 +020037 // `packet_list` are properly deleted, and replaced by the new packets.
38 // Note that all packets in `packet_list` must be RED payloads, i.e., have
ossua70695a2016-09-22 02:06:28 -070039 // RED headers according to RFC 2198 at the very beginning of the payload.
40 // Returns kOK or an error.
41 virtual bool SplitRed(PacketList* packet_list);
42
Artem Titovd00ce742021-07-28 20:00:17 +020043 // Checks all packets in `packet_list`. Packets that are DTMF events or
ossua70695a2016-09-22 02:06:28 -070044 // comfort noise payloads are kept. Except that, only one single payload type
Henrik Lundindefa7a82018-07-03 13:07:30 +020045 // is accepted. Any packet with another payload type is discarded.
46 virtual void CheckRedPayloads(PacketList* packet_list,
47 const DecoderDatabase& decoder_database);
ossua70695a2016-09-22 02:06:28 -070048};
49
50} // namespace webrtc
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020051#endif // MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_