ossu | a70695a | 2016-09-22 02:06:28 -0700 | [diff] [blame] | 1 | /* |
| 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 Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ |
| 12 | #define MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ |
ossu | a70695a | 2016-09-22 02:06:28 -0700 | [diff] [blame] | 13 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 14 | #include "modules/audio_coding/neteq/packet.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 15 | #include "rtc_base/constructor_magic.h" |
ossu | a70695a | 2016-09-22 02:06:28 -0700 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
ossu | a70695a | 2016-09-22 02:06:28 -0700 | [diff] [blame] | 19 | class DecoderDatabase; |
| 20 | |
Philipp Hancke | 2291fb3 | 2020-09-29 10:51:42 +0200 | [diff] [blame] | 21 | static const size_t kRedHeaderLength = 4; // 4 bytes RED header. |
| 22 | static const size_t kRedLastHeaderLength = |
| 23 | 1; // reduced size for last RED header. |
ossu | a70695a | 2016-09-22 02:06:28 -0700 | [diff] [blame] | 24 | // This class handles splitting of RED payloads into smaller parts. |
| 25 | // Codec-specific packet splitting can be performed by |
| 26 | // AudioDecoder::ParsePayload. |
| 27 | class RedPayloadSplitter { |
| 28 | public: |
| 29 | RedPayloadSplitter() {} |
| 30 | |
| 31 | virtual ~RedPayloadSplitter() {} |
| 32 | |
| 33 | // Splits each packet in |packet_list| into its separate RED payloads. Each |
| 34 | // RED payload is packetized into a Packet. The original elements in |
| 35 | // |packet_list| are properly deleted, and replaced by the new packets. |
| 36 | // Note that all packets in |packet_list| must be RED payloads, i.e., have |
| 37 | // RED headers according to RFC 2198 at the very beginning of the payload. |
| 38 | // Returns kOK or an error. |
| 39 | virtual bool SplitRed(PacketList* packet_list); |
| 40 | |
| 41 | // Checks all packets in |packet_list|. Packets that are DTMF events or |
| 42 | // comfort noise payloads are kept. Except that, only one single payload type |
Henrik Lundin | defa7a8 | 2018-07-03 13:07:30 +0200 | [diff] [blame] | 43 | // is accepted. Any packet with another payload type is discarded. |
| 44 | virtual void CheckRedPayloads(PacketList* packet_list, |
| 45 | const DecoderDatabase& decoder_database); |
ossu | a70695a | 2016-09-22 02:06:28 -0700 | [diff] [blame] | 46 | |
| 47 | private: |
| 48 | RTC_DISALLOW_COPY_AND_ASSIGN(RedPayloadSplitter); |
| 49 | }; |
| 50 | |
| 51 | } // namespace webrtc |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 52 | #endif // MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ |