red_payload_splitter.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. #ifndef MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_
  11. #define MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_
  12. #include "modules/audio_coding/neteq/packet.h"
  13. #include "rtc_base/constructor_magic.h"
  14. namespace webrtc {
  15. class DecoderDatabase;
  16. static const size_t kRedHeaderLength = 4; // 4 bytes RED header.
  17. static const size_t kRedLastHeaderLength =
  18. 1; // reduced size for last RED header.
  19. // This class handles splitting of RED payloads into smaller parts.
  20. // Codec-specific packet splitting can be performed by
  21. // AudioDecoder::ParsePayload.
  22. class RedPayloadSplitter {
  23. public:
  24. RedPayloadSplitter() {}
  25. virtual ~RedPayloadSplitter() {}
  26. // Splits each packet in |packet_list| into its separate RED payloads. Each
  27. // RED payload is packetized into a Packet. The original elements in
  28. // |packet_list| are properly deleted, and replaced by the new packets.
  29. // Note that all packets in |packet_list| must be RED payloads, i.e., have
  30. // RED headers according to RFC 2198 at the very beginning of the payload.
  31. // Returns kOK or an error.
  32. virtual bool SplitRed(PacketList* packet_list);
  33. // Checks all packets in |packet_list|. Packets that are DTMF events or
  34. // comfort noise payloads are kept. Except that, only one single payload type
  35. // is accepted. Any packet with another payload type is discarded.
  36. virtual void CheckRedPayloads(PacketList* packet_list,
  37. const DecoderDatabase& decoder_database);
  38. private:
  39. RTC_DISALLOW_COPY_AND_ASSIGN(RedPayloadSplitter);
  40. };
  41. } // namespace webrtc
  42. #endif // MODULES_AUDIO_CODING_NETEQ_RED_PAYLOAD_SPLITTER_H_