test_utils.h (1944B)
1 /* 2 * Copyright (c) 2004 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 MEDIA_BASE_TEST_UTILS_H_ 12 #define MEDIA_BASE_TEST_UTILS_H_ 13 14 #include <cstddef> 15 #include <cstdint> 16 #include <string> 17 #include <vector> 18 19 #include "media/base/stream_params.h" 20 21 namespace webrtc { 22 class VideoFrame; 23 } 24 25 namespace webrtc { 26 27 // Returns size of 420 image with rounding on chroma for odd sizes. 28 #define I420_SIZE(w, h) (w * h + (((w + 1) / 2) * ((h + 1) / 2)) * 2) 29 // Returns size of ARGB image. 30 #define ARGB_SIZE(w, h) (w * h * 4) 31 32 template <class T> 33 inline std::vector<T> MakeVector(const T a[], size_t s) { 34 return std::vector<T>(a, a + s); 35 } 36 // Note that MAKE_VECTOR can be used outside of the webrtc namespace. 37 #define MAKE_VECTOR(a) webrtc::MakeVector(a, std::size(a)) 38 39 // Create Simulcast StreamParams with given `ssrcs` and `cname`. 40 StreamParams CreateSimStreamParams(const std::string& cname, 41 const std::vector<uint32_t>& ssrcs); 42 // Create Simulcast stream with given `ssrcs` and `rtx_ssrcs`. 43 // The number of `rtx_ssrcs` must match number of `ssrcs`. 44 StreamParams CreateSimWithRtxStreamParams( 45 const std::string& cname, 46 const std::vector<uint32_t>& ssrcs, 47 const std::vector<uint32_t>& rtx_ssrcs); 48 49 // Create StreamParams with single primary SSRC and corresponding FlexFEC SSRC. 50 StreamParams CreatePrimaryWithFecFrStreamParams(const std::string& cname, 51 uint32_t primary_ssrc, 52 uint32_t flexfec_ssrc); 53 54 } // namespace webrtc 55 56 57 #endif // MEDIA_BASE_TEST_UTILS_H_