Home | History | Annotate | Download | only in source
      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   kFecPayloadType = 96
     21 };
     22 enum {
     23   kRedPayloadType = 97
     24 };
     25 enum {
     26   kVp8PayloadType = 120
     27 };
     28 
     29 typedef ForwardErrorCorrection::Packet Packet;
     30 
     31 struct RtpPacket : public Packet {
     32   WebRtcRTPHeader header;
     33 };
     34 
     35 class FrameGenerator {
     36  public:
     37   FrameGenerator();
     38 
     39   void NewFrame(int num_packets);
     40 
     41   uint16_t NextSeqNum();
     42 
     43   RtpPacket* NextPacket(int offset, size_t length);
     44 
     45   // Creates a new RtpPacket with the RED header added to the packet.
     46   RtpPacket* BuildMediaRedPacket(const RtpPacket* packet);
     47 
     48   // Creates a new RtpPacket with FEC payload and red header. Does this by
     49   // creating a new fake media RtpPacket, clears the marker bit and adds a RED
     50   // header. Finally replaces the payload with the content of |packet->data|.
     51   RtpPacket* BuildFecRedPacket(const Packet* packet);
     52 
     53   void SetRedHeader(Packet* red_packet, uint8_t payload_type,
     54                     int header_length) const;
     55 
     56  private:
     57   static void BuildRtpHeader(uint8_t* data, const RTPHeader* header);
     58 
     59   int num_packets_;
     60   uint16_t seq_num_;
     61   uint32_t timestamp_;
     62 };
     63 }
     64 
     65 #endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_
     66