OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_ |
12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_ |
13 | 13 |
14 #include "webrtc/base/basictypes.h" | |
15 #include "webrtc/base/random.h" | |
14 #include "webrtc/modules/include/module_common_types.h" | 16 #include "webrtc/modules/include/module_common_types.h" |
15 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" | 17 #include "webrtc/modules/rtp_rtcp/source/forward_error_correction.h" |
16 | 18 |
17 namespace webrtc { | 19 namespace webrtc { |
18 namespace test { | 20 namespace test { |
21 | |
22 // needed to not clash with another webrtc::FrameGenerator. | |
23 namespace fec { | |
24 | |
25 constexpr uint8_t kFecPayloadType = 96; | |
26 constexpr uint8_t kRedPayloadType = 97; | |
27 constexpr uint8_t kVp8PayloadType = 120; | |
28 | |
19 struct RawRtpPacket : public ForwardErrorCorrection::Packet { | 29 struct RawRtpPacket : public ForwardErrorCorrection::Packet { |
20 WebRtcRTPHeader header; | 30 WebRtcRTPHeader header; |
21 }; | 31 }; |
22 } // namespace test | |
23 | |
24 const uint8_t kFecPayloadType = 96; | |
25 const uint8_t kRedPayloadType = 97; | |
26 const uint8_t kVp8PayloadType = 120; | |
27 | 32 |
28 class FrameGenerator { | 33 class FrameGenerator { |
29 public: | 34 public: |
30 FrameGenerator(); | 35 FrameGenerator(); |
31 | 36 |
32 void NewFrame(int num_packets); | 37 void NewFrame(int num_packets); |
33 | 38 |
34 uint16_t NextSeqNum(); | 39 uint16_t NextSeqNum(); |
35 | 40 |
36 test::RawRtpPacket* NextPacket(int offset, size_t length); | 41 RawRtpPacket* NextPacket(int offset, size_t length); |
37 | 42 |
38 // Creates a new RtpPacket with the RED header added to the packet. | 43 // Creates a new RtpPacket with the RED header added to the packet. |
39 test::RawRtpPacket* BuildMediaRedPacket(const test::RawRtpPacket* packet); | 44 RawRtpPacket* BuildMediaRedPacket(const RawRtpPacket* packet); |
40 | 45 |
41 // Creates a new RtpPacket with FEC payload and red header. Does this by | 46 // Creates a new RtpPacket with FEC payload and red header. Does this by |
42 // creating a new fake media RtpPacket, clears the marker bit and adds a RED | 47 // creating a new fake media RtpPacket, clears the marker bit and adds a RED |
43 // header. Finally replaces the payload with the content of |packet->data|. | 48 // header. Finally replaces the payload with the content of |packet->data|. |
44 test::RawRtpPacket* BuildFecRedPacket( | 49 RawRtpPacket* BuildFecRedPacket(const ForwardErrorCorrection::Packet* packet); |
45 const ForwardErrorCorrection::Packet* packet); | |
46 | 50 |
47 void SetRedHeader(ForwardErrorCorrection::Packet* red_packet, | 51 void SetRedHeader(ForwardErrorCorrection::Packet* red_packet, |
48 uint8_t payload_type, | 52 uint8_t payload_type, |
49 size_t header_length) const; | 53 size_t header_length) const; |
50 | 54 |
51 private: | 55 private: |
52 static void BuildRtpHeader(uint8_t* data, const RTPHeader* header); | 56 static void BuildRtpHeader(uint8_t* data, const RTPHeader* header); |
53 | 57 |
54 int num_packets_; | 58 int num_packets_; |
55 uint16_t seq_num_; | 59 uint16_t seq_num_; |
56 uint32_t timestamp_; | 60 uint32_t timestamp_; |
57 }; | 61 }; |
62 | |
63 class MediaPacketGenerator { | |
danilchap
2016/08/22 13:00:41
Can you comment why do you need 2 packet generator
brandtr
2016/08/23 08:19:10
I think you mean why both FrameGenerator and Media
| |
64 public: | |
65 MediaPacketGenerator(uint32_t min_packet_size, | |
66 uint32_t max_packet_size, | |
67 Random* random) | |
68 : min_packet_size_(min_packet_size), | |
69 max_packet_size_(max_packet_size), | |
70 random_(random) {} | |
71 | |
72 // Construct the media packets, up to |num_media_packets| packets. | |
73 void ConstructMediaPacketsSeqNum(int num_media_packets, | |
74 uint16_t start_seq_num); | |
75 void ConstructMediaPackets(int num_media_packets); | |
76 | |
77 ForwardErrorCorrection::PacketList* GetMediaPackets(); | |
78 uint32_t GetSsrc(); | |
79 uint16_t GetFecSeqNum(); | |
80 | |
81 private: | |
82 uint32_t min_packet_size_; | |
83 uint32_t max_packet_size_; | |
84 Random* random_; | |
85 | |
86 ForwardErrorCorrection::PacketList media_packets_; | |
87 uint32_t ssrc_; | |
88 uint16_t fec_seq_num_; | |
89 }; | |
90 | |
91 } // namespace fec | |
92 } // namespace test | |
58 } // namespace webrtc | 93 } // namespace webrtc |
59 | 94 |
60 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_ | 95 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_ |
OLD | NEW |