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 <string>
15 #include <vector>
16
17 #include "media/base/media_channel.h"
18 #include "media/base/video_common.h"
19 #include "rtc_base/arraysize.h"
20
21 namespace webrtc {
22 class VideoFrame;
23 }
24
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
32 template <class T>
MakeVector(const T a[],size_t s)33 inline std::vector<T> MakeVector(const T a[], size_t s) {
34 return std::vector<T>(a, a + s);
35 }
36 #define MAKE_VECTOR(a) cricket::MakeVector(a, arraysize(a))
37
38 // Checks whether |codecs| contains |codec|; checks using Codec::Matches().
39 template <class C>
ContainsMatchingCodec(const std::vector<C> & codecs,const C & codec)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 }
49
50 // Create Simulcast StreamParams with given |ssrcs| and |cname|.
51 cricket::StreamParams CreateSimStreamParams(const std::string& cname,
52 const std::vector<uint32_t>& ssrcs);
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(
56 const std::string& cname,
57 const std::vector<uint32_t>& ssrcs,
58 const std::vector<uint32_t>& rtx_ssrcs);
59
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
66 } // namespace cricket
67
68 #endif // MEDIA_BASE_TEST_UTILS_H_
69