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 WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_TEST_HELPER_H_ 19 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_TEST_HELPER_H_ 20 21 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/modules/interface/module_common_types.h" 23 #include "webrtc/modules/rtp_rtcp/source/rtp_format_vp8.h" 24 #include "webrtc/typedefs.h" 25 26 namespace webrtc { 27 28 namespace test { 29 30 class RtpFormatVp8TestHelper { 31 public: 32 explicit RtpFormatVp8TestHelper(const RTPVideoHeaderVP8* hdr); 33 ~RtpFormatVp8TestHelper(); 34 bool Init(const int* partition_sizes, int num_partitions); 35 void GetAllPacketsAndCheck(RtpPacketizerVp8* packetizer, 36 const int* expected_sizes, 37 const int* expected_part, 38 const bool* expected_frag_start, 39 int expected_num_packets); 40 41 uint8_t* payload_data() const { return payload_data_; } 42 int payload_size() const { return payload_size_; } 43 RTPFragmentationHeader* fragmentation() const { return fragmentation_; } 44 int buffer_size() const { return buffer_size_; } 45 void set_sloppy_partitioning(bool value) { sloppy_partitioning_ = value; } 46 47 private: 48 void CheckHeader(bool frag_start); 49 void CheckPictureID(); 50 void CheckTl0PicIdx(); 51 void CheckTIDAndKeyIdx(); 52 void CheckPayload(int payload_end); 53 void CheckLast(bool last) const; 54 void CheckPacket(int send_bytes, int expect_bytes, bool last, 55 bool frag_start); 56 57 uint8_t* payload_data_; 58 uint8_t* buffer_; 59 uint8_t* data_ptr_; 60 RTPFragmentationHeader* fragmentation_; 61 const RTPVideoHeaderVP8* hdr_info_; 62 int payload_start_; 63 int payload_size_; 64 int buffer_size_; 65 bool sloppy_partitioning_; 66 bool inited_; 67 68 DISALLOW_COPY_AND_ASSIGN(RtpFormatVp8TestHelper); 69 }; 70 71 } // namespace test 72 73 } // namespace webrtc 74 75 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTP_FORMAT_VP8_TEST_HELPER_H_ 76