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