1 /* 2 * Copyright (c) 2011 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 // This file contains the class RtpFormatVp8TestHelper. The class is 12 // responsible for setting up a fake VP8 bitstream according to the 13 // RTPVideoHeaderVP8 header, and partition information. After initialization, 14 // an RTPFragmentationHeader is provided so that the tester can create a 15 // packetizer. The packetizer can then be provided to this helper class, which 16 // will then extract all packets and compare to the expected outcome. 17 18 #ifndef MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_TEST_HELPER_H_ 19 #define MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_TEST_HELPER_H_ 20 21 #include "modules/include/module_common_types.h" 22 #include "modules/rtp_rtcp/source/rtp_format_vp8.h" 23 #include "modules/rtp_rtcp/source/rtp_packet_to_send.h" 24 #include "rtc_base/constructormagic.h" 25 #include "typedefs.h" // NOLINT(build/include) 26 27 namespace webrtc { 28 29 namespace test { 30 31 class RtpFormatVp8TestHelper { 32 public: 33 explicit RtpFormatVp8TestHelper(const RTPVideoHeaderVP8* hdr); 34 ~RtpFormatVp8TestHelper(); 35 bool Init(const size_t* partition_sizes, size_t num_partitions); 36 void GetAllPacketsAndCheck(RtpPacketizerVp8* packetizer, 37 const size_t* expected_sizes, 38 const int* expected_part, 39 const bool* expected_frag_start, 40 size_t expected_num_packets); 41 payload_data()42 uint8_t* payload_data() const { return payload_data_; } payload_size()43 size_t payload_size() const { return payload_size_; } fragmentation()44 RTPFragmentationHeader* fragmentation() const { return fragmentation_; } buffer_size()45 size_t buffer_size() const { 46 static constexpr size_t kVp8PayloadDescriptorMaxSize = 6; 47 return payload_size_ + kVp8PayloadDescriptorMaxSize; 48 } set_sloppy_partitioning(bool value)49 void set_sloppy_partitioning(bool value) { sloppy_partitioning_ = value; } 50 51 private: 52 void CheckHeader(bool frag_start); 53 void CheckPictureID(); 54 void CheckTl0PicIdx(); 55 void CheckTIDAndKeyIdx(); 56 void CheckPayload(); 57 void CheckLast(bool last) const; 58 void CheckPacket(size_t expect_bytes, bool last, bool frag_start); 59 60 RtpPacketToSend packet_; 61 uint8_t* payload_data_; 62 uint8_t* data_ptr_; 63 RTPFragmentationHeader* fragmentation_; 64 const RTPVideoHeaderVP8* hdr_info_; 65 int payload_start_; 66 size_t payload_size_; 67 bool sloppy_partitioning_; 68 bool inited_; 69 70 RTC_DISALLOW_COPY_AND_ASSIGN(RtpFormatVp8TestHelper); 71 }; 72 73 } // namespace test 74 75 } // namespace webrtc 76 77 #endif // MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_TEST_HELPER_H_ 78