Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/fec_test_helper.h

Issue 2267393002: Generalize FEC unit tests and rename GenerateFec. (pt. 3) (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@header_reader_writer-pt2-producer_fec_mini_fixes
Patch Set: Rebase. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
danilchap 2016/08/23 13:08:50 Uppercase 1st letter: 'Needed'. Though probably be
brandtr 2016/08/23 14:05:07 See https://codereview.webrtc.org/2276473002/diff/
danilchap 2016/08/23 14:51:18 Ok, Uppercase 1st letter then for now.
brandtr 2016/08/23 15:08:00 Done.
23 namespace fec {
24
19 struct RawRtpPacket : public ForwardErrorCorrection::Packet { 25 struct RawRtpPacket : public ForwardErrorCorrection::Packet {
20 WebRtcRTPHeader header; 26 WebRtcRTPHeader header;
21 }; 27 };
22 } // namespace test
23
24 const uint8_t kFecPayloadType = 96;
25 const uint8_t kRedPayloadType = 97;
26 const uint8_t kVp8PayloadType = 120;
27 28
28 class FrameGenerator { 29 class FrameGenerator {
29 public: 30 public:
30 FrameGenerator(); 31 FrameGenerator();
31 32
32 void NewFrame(int num_packets); 33 void NewFrame(int num_packets);
33 34
34 uint16_t NextSeqNum(); 35 uint16_t NextSeqNum();
35 36
36 test::RawRtpPacket* NextPacket(int offset, size_t length); 37 RawRtpPacket* NextPacket(int offset, size_t length);
37 38
38 // Creates a new RtpPacket with the RED header added to the packet. 39 // Creates a new RtpPacket with the RED header added to the packet.
39 test::RawRtpPacket* BuildMediaRedPacket(const test::RawRtpPacket* packet); 40 RawRtpPacket* BuildMediaRedPacket(const RawRtpPacket* packet);
40 41
41 // Creates a new RtpPacket with FEC payload and red header. Does this by 42 // 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 43 // 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|. 44 // header. Finally replaces the payload with the content of |packet->data|.
44 test::RawRtpPacket* BuildFecRedPacket( 45 RawRtpPacket* BuildFecRedPacket(const ForwardErrorCorrection::Packet* packet);
45 const ForwardErrorCorrection::Packet* packet);
46 46
47 void SetRedHeader(ForwardErrorCorrection::Packet* red_packet, 47 void SetRedHeader(ForwardErrorCorrection::Packet* red_packet,
48 uint8_t payload_type, 48 uint8_t payload_type,
49 size_t header_length) const; 49 size_t header_length) const;
50 50
51 private: 51 private:
52 static void BuildRtpHeader(uint8_t* data, const RTPHeader* header); 52 static void BuildRtpHeader(uint8_t* data, const RTPHeader* header);
53 53
54 int num_packets_; 54 int num_packets_;
55 uint16_t seq_num_; 55 uint16_t seq_num_;
56 uint32_t timestamp_; 56 uint32_t timestamp_;
57 }; 57 };
58
59 class MediaPacketGenerator {
60 public:
61 MediaPacketGenerator(uint32_t min_packet_size,
62 uint32_t max_packet_size,
63 Random* random)
64 : min_packet_size_(min_packet_size),
65 max_packet_size_(max_packet_size),
66 random_(random) {}
67
68 // Construct the media packets, up to |num_media_packets| packets.
69 void ConstructMediaPacketsSeqNum(int num_media_packets,
70 uint16_t start_seq_num);
71 void ConstructMediaPackets(int num_media_packets);
72
73 ForwardErrorCorrection::PacketList* GetMediaPackets();
74 uint32_t GetSsrc();
75 uint16_t GetFecSeqNum();
76
77 private:
78 uint32_t min_packet_size_;
79 uint32_t max_packet_size_;
80 Random* random_;
81
82 ForwardErrorCorrection::PacketList media_packets_;
83 uint32_t ssrc_;
84 uint16_t fec_seq_num_;
85 };
86
87 } // namespace fec
88 } // namespace test
58 } // namespace webrtc 89 } // namespace webrtc
59 90
60 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_ 91 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_FEC_TEST_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698