blob: 46783a17f5242d4df526a8a7adfec75cdd9434ef [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellander1afca732016-02-07 20:46:45 -08002 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellander1afca732016-02-07 20:46:45 -08004 * 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.org28e20752013-07-10 00:45:36 +00009 */
10
Steve Anton10542f22019-01-11 09:11:00 -080011#ifndef MEDIA_BASE_TEST_UTILS_H_
12#define MEDIA_BASE_TEST_UTILS_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
14#include <string>
15#include <vector>
wu@webrtc.orgcadf9042013-08-30 21:24:16 +000016
Steve Anton10542f22019-01-11 09:11:00 -080017#include "media/base/media_channel.h"
18#include "media/base/video_common.h"
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020019#include "rtc_base/arraysize.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000020
nisseacd935b2016-11-11 03:55:13 -080021namespace webrtc {
22class VideoFrame;
23}
24
henrike@webrtc.org28e20752013-07-10 00:45:36 +000025namespace 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 Gerey665174f2018-06-19 15:03:05 +020032template <class T>
33inline std::vector<T> MakeVector(const T a[], size_t s) {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000034 return std::vector<T>(a, a + s);
35}
tfarina5237aaf2015-11-10 23:44:30 -080036#define MAKE_VECTOR(a) cricket::MakeVector(a, arraysize(a))
henrike@webrtc.org28e20752013-07-10 00:45:36 +000037
henrike@webrtc.org28e20752013-07-10 00:45:36 +000038// Checks whether |codecs| contains |codec|; checks using Codec::Matches().
39template <class C>
40bool 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.org5bc25c42013-12-05 00:24:06 +000049
50// Create Simulcast StreamParams with given |ssrcs| and |cname|.
Peter Boström0c4e06b2015-10-07 12:23:21 +020051cricket::StreamParams CreateSimStreamParams(const std::string& cname,
52 const std::vector<uint32_t>& ssrcs);
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +000053// Create Simulcast stream with given |ssrcs| and |rtx_ssrcs|.
54// The number of |rtx_ssrcs| must match number of |ssrcs|.
55cricket::StreamParams CreateSimWithRtxStreamParams(
Peter Boström0c4e06b2015-10-07 12:23:21 +020056 const std::string& cname,
57 const std::vector<uint32_t>& ssrcs,
58 const std::vector<uint32_t>& rtx_ssrcs);
sergeyu@chromium.org5bc25c42013-12-05 00:24:06 +000059
brandtr9688e382016-11-22 00:59:48 -080060// Create StreamParams with single primary SSRC and corresponding FlexFEC SSRC.
61cricket::StreamParams CreatePrimaryWithFecFrStreamParams(
62 const std::string& cname,
63 uint32_t primary_ssrc,
64 uint32_t flexfec_ssrc);
65
henrike@webrtc.org28e20752013-07-10 00:45:36 +000066} // namespace cricket
67
Steve Anton10542f22019-01-11 09:11:00 -080068#endif // MEDIA_BASE_TEST_UTILS_H_