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
11#ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_
12#define WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_
13
14#include "webrtc/modules/include/module_common_types.h"
15#include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
16
17namespace webrtc {
18
19const uint8_t kFecPayloadType = 96;
20const uint8_t kRedPayloadType = 97;
21const uint8_t kVp8PayloadType = 120;
22
23typedef ForwardErrorCorrection::Packet Packet;
24
25struct RtpPacket : public Packet {
26  WebRtcRTPHeader header;
27};
28
29class FrameGenerator {
30 public:
31  FrameGenerator();
32
33  void NewFrame(int num_packets);
34
35  uint16_t NextSeqNum();
36
37  RtpPacket* NextPacket(int offset, size_t length);
38
39  // Creates a new RtpPacket with the RED header added to the packet.
40  RtpPacket* BuildMediaRedPacket(const RtpPacket* packet);
41
42  // Creates a new RtpPacket with FEC payload and red header. Does this by
43  // creating a new fake media RtpPacket, clears the marker bit and adds a RED
44  // header. Finally replaces the payload with the content of |packet->data|.
45  RtpPacket* BuildFecRedPacket(const Packet* packet);
46
47  void SetRedHeader(Packet* red_packet, uint8_t payload_type,
48                    size_t header_length) const;
49
50 private:
51  static void BuildRtpHeader(uint8_t* data, const RTPHeader* header);
52
53  int num_packets_;
54  uint16_t seq_num_;
55  uint32_t timestamp_;
56};
57}  // namespace webrtc
58
59#endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_
60