henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 2 | * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-07 20:46:45 -0800 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef MEDIA_BASE_TEST_UTILS_H_ |
| 12 | #define MEDIA_BASE_TEST_UTILS_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
| 14 | #include <string> |
| 15 | #include <vector> |
wu@webrtc.org | cadf904 | 2013-08-30 21:24:16 +0000 | [diff] [blame] | 16 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 17 | #include "media/base/media_channel.h" |
| 18 | #include "media/base/video_common.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 19 | #include "rtc_base/arraysize.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 20 | |
nisse | acd935b | 2016-11-11 03:55:13 -0800 | [diff] [blame] | 21 | namespace webrtc { |
| 22 | class VideoFrame; |
| 23 | } |
| 24 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 25 | namespace cricket { |
| 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 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 32 | template <class T> |
| 33 | inline std::vector<T> MakeVector(const T a[], size_t s) { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | return std::vector<T>(a, a + s); |
| 35 | } |
tfarina | 5237aaf | 2015-11-10 23:44:30 -0800 | [diff] [blame] | 36 | #define MAKE_VECTOR(a) cricket::MakeVector(a, arraysize(a)) |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 37 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 38 | // Checks whether |codecs| contains |codec|; checks using Codec::Matches(). |
| 39 | template <class C> |
| 40 | bool ContainsMatchingCodec(const std::vector<C>& codecs, const C& codec) { |
| 41 | typename std::vector<C>::const_iterator it; |
| 42 | for (it = codecs.begin(); it != codecs.end(); ++it) { |
| 43 | if (it->Matches(codec)) { |
| 44 | return true; |
| 45 | } |
| 46 | } |
| 47 | return false; |
| 48 | } |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 49 | |
| 50 | // Create Simulcast StreamParams with given |ssrcs| and |cname|. |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 51 | cricket::StreamParams CreateSimStreamParams(const std::string& cname, |
| 52 | const std::vector<uint32_t>& ssrcs); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 53 | // Create Simulcast stream with given |ssrcs| and |rtx_ssrcs|. |
| 54 | // The number of |rtx_ssrcs| must match number of |ssrcs|. |
| 55 | cricket::StreamParams CreateSimWithRtxStreamParams( |
Peter Boström | 0c4e06b | 2015-10-07 12:23:21 +0200 | [diff] [blame] | 56 | const std::string& cname, |
| 57 | const std::vector<uint32_t>& ssrcs, |
| 58 | const std::vector<uint32_t>& rtx_ssrcs); |
sergeyu@chromium.org | 5bc25c4 | 2013-12-05 00:24:06 +0000 | [diff] [blame] | 59 | |
brandtr | 9688e38 | 2016-11-22 00:59:48 -0800 | [diff] [blame] | 60 | // Create StreamParams with single primary SSRC and corresponding FlexFEC SSRC. |
| 61 | cricket::StreamParams CreatePrimaryWithFecFrStreamParams( |
| 62 | const std::string& cname, |
| 63 | uint32_t primary_ssrc, |
| 64 | uint32_t flexfec_ssrc); |
| 65 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 66 | } // namespace cricket |
| 67 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 68 | #endif // MEDIA_BASE_TEST_UTILS_H_ |