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_FORWARD_ERROR_CORRECTION_INTERNAL_H_
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_FORWARD_ERROR_CORRECTION_INTERNAL_H_
13 
14 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h"
15 #include "webrtc/typedefs.h"
16 
17 namespace webrtc {
18 
19 // Packet mask size in bytes (L bit is set).
20 static const int kMaskSizeLBitSet = 6;
21 // Packet mask size in bytes (L bit is cleared).
22 static const int kMaskSizeLBitClear = 2;
23 
24 namespace internal {
25 
26 class PacketMaskTable {
27  public:
28   PacketMaskTable(FecMaskType fec_mask_type, int num_media_packets);
~PacketMaskTable()29   ~PacketMaskTable() {}
fec_mask_type()30   FecMaskType fec_mask_type() const { return fec_mask_type_; }
fec_packet_mask_table()31   const uint8_t*** fec_packet_mask_table() const {
32     return fec_packet_mask_table_;
33   }
34 
35  private:
36   FecMaskType InitMaskType(FecMaskType fec_mask_type, int num_media_packets);
37   const uint8_t*** InitMaskTable(FecMaskType fec_mask_type_);
38   const FecMaskType fec_mask_type_;
39   const uint8_t*** fec_packet_mask_table_;
40 };
41 
42 // Returns an array of packet masks. The mask of a single FEC packet
43 // corresponds to a number of mask bytes. The mask indicates which
44 // media packets should be protected by the FEC packet.
45 
46 // \param[in]  num_media_packets       The number of media packets to protect.
47 //                                     [1, max_media_packets].
48 // \param[in]  num_fec_packets         The number of FEC packets which will
49 //                                     be generated. [1, num_media_packets].
50 // \param[in]  num_imp_packets         The number of important packets.
51 //                                     [0, num_media_packets].
52 //                                     num_imp_packets = 0 is the equal
53 //                                     protection scenario.
54 // \param[in]  use_unequal_protection  Enables unequal protection: allocates
55 //                                     more protection to the num_imp_packets.
56 // \param[in]  mask_table              An instance of the |PacketMaskTable|
57 //                                     class, which contains the type of FEC
58 //                                     packet mask used, and a pointer to the
59 //                                     corresponding packet masks.
60 // \param[out] packet_mask             A pointer to hold the packet mask array,
61 //                                     of size: num_fec_packets *
62 //                                     "number of mask bytes".
63 void GeneratePacketMasks(int num_media_packets, int num_fec_packets,
64                          int num_imp_packets, bool use_unequal_protection,
65                          const PacketMaskTable& mask_table,
66                          uint8_t* packet_mask);
67 
68 }  // namespace internal
69 }  // namespace webrtc
70 #endif  // WEBRTC_MODULES_RTP_RTCP_SOURCE_FORWARD_ERROR_CORRECTION_INTERNAL_H_
71