OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ |
12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ |
13 | 13 |
14 #include "webrtc/base/constructormagic.h" | 14 #include "webrtc/base/constructormagic.h" |
15 #include "webrtc/modules/audio_coding/neteq/packet.h" | 15 #include "webrtc/modules/audio_coding/neteq/packet.h" |
16 | 16 |
17 namespace webrtc { | 17 namespace webrtc { |
18 | 18 |
19 // Forward declarations. | 19 // Forward declarations. |
20 class DecoderDatabase; | 20 class DecoderDatabase; |
21 | 21 |
22 // This class handles splitting of payloads into smaller parts. | 22 // This class handles splitting of RED payloads into smaller parts. |
| 23 // Codec-specific packet splitting can be performed by |
| 24 // AudioDecoder::ParsePayload. |
| 25 class RedPayloadSplitter { |
| 26 public: |
| 27 RedPayloadSplitter() {} |
23 | 28 |
24 // For RED and FEC the splitting is done internally. Other codecs' packets are | 29 virtual ~RedPayloadSplitter() {} |
25 // split by calling AudioDecoder::SplitPacket. | |
26 class PayloadSplitter { | |
27 public: | |
28 enum SplitterReturnCodes { | |
29 kOK = 0, | |
30 kNoSplit = 1, | |
31 kFrameSplitError = -2, | |
32 kUnknownPayloadType = -3, | |
33 kRedLengthMismatch = -4, | |
34 kFecSplitError = -5, | |
35 }; | |
36 | |
37 PayloadSplitter() {} | |
38 | |
39 virtual ~PayloadSplitter() {} | |
40 | 30 |
41 // Splits each packet in |packet_list| into its separate RED payloads. Each | 31 // Splits each packet in |packet_list| into its separate RED payloads. Each |
42 // RED payload is packetized into a Packet. The original elements in | 32 // RED payload is packetized into a Packet. The original elements in |
43 // |packet_list| are properly deleted, and replaced by the new packets. | 33 // |packet_list| are properly deleted, and replaced by the new packets. |
44 // Note that all packets in |packet_list| must be RED payloads, i.e., have | 34 // Note that all packets in |packet_list| must be RED payloads, i.e., have |
45 // RED headers according to RFC 2198 at the very beginning of the payload. | 35 // RED headers according to RFC 2198 at the very beginning of the payload. |
46 // Returns kOK or an error. | 36 // Returns kOK or an error. |
47 virtual int SplitRed(PacketList* packet_list); | 37 virtual bool SplitRed(PacketList* packet_list); |
48 | |
49 // Iterates through |packet_list| and, duplicate each audio payload that has | |
50 // FEC as new packet for redundant decoding. The decoder database is needed to | |
51 // get information about which payload type each packet contains. | |
52 virtual int SplitFec(PacketList* packet_list, | |
53 DecoderDatabase* decoder_database); | |
54 | 38 |
55 // Checks all packets in |packet_list|. Packets that are DTMF events or | 39 // Checks all packets in |packet_list|. Packets that are DTMF events or |
56 // comfort noise payloads are kept. Except that, only one single payload type | 40 // comfort noise payloads are kept. Except that, only one single payload type |
57 // is accepted. Any packet with another payload type is discarded. | 41 // is accepted. Any packet with another payload type is discarded. Returns |
| 42 // the number of discarded packets. |
58 virtual int CheckRedPayloads(PacketList* packet_list, | 43 virtual int CheckRedPayloads(PacketList* packet_list, |
59 const DecoderDatabase& decoder_database); | 44 const DecoderDatabase& decoder_database); |
60 | 45 |
61 private: | 46 private: |
62 RTC_DISALLOW_COPY_AND_ASSIGN(PayloadSplitter); | 47 RTC_DISALLOW_COPY_AND_ASSIGN(RedPayloadSplitter); |
63 }; | 48 }; |
64 | 49 |
65 } // namespace webrtc | 50 } // namespace webrtc |
66 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_PAYLOAD_SPLITTER_H_ | 51 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_ |
OLD | NEW |