test_utils.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef MEDIA_BASE_TEST_UTILS_H_
  11. #define MEDIA_BASE_TEST_UTILS_H_
  12. #include <string>
  13. #include <vector>
  14. #include "media/base/media_channel.h"
  15. #include "media/base/video_common.h"
  16. #include "rtc_base/arraysize.h"
  17. namespace webrtc {
  18. class VideoFrame;
  19. }
  20. namespace cricket {
  21. // Returns size of 420 image with rounding on chroma for odd sizes.
  22. #define I420_SIZE(w, h) (w * h + (((w + 1) / 2) * ((h + 1) / 2)) * 2)
  23. // Returns size of ARGB image.
  24. #define ARGB_SIZE(w, h) (w * h * 4)
  25. template <class T>
  26. inline std::vector<T> MakeVector(const T a[], size_t s) {
  27. return std::vector<T>(a, a + s);
  28. }
  29. #define MAKE_VECTOR(a) cricket::MakeVector(a, arraysize(a))
  30. // Checks whether |codecs| contains |codec|; checks using Codec::Matches().
  31. template <class C>
  32. bool ContainsMatchingCodec(const std::vector<C>& codecs, const C& codec) {
  33. typename std::vector<C>::const_iterator it;
  34. for (it = codecs.begin(); it != codecs.end(); ++it) {
  35. if (it->Matches(codec)) {
  36. return true;
  37. }
  38. }
  39. return false;
  40. }
  41. // Create Simulcast StreamParams with given |ssrcs| and |cname|.
  42. cricket::StreamParams CreateSimStreamParams(const std::string& cname,
  43. const std::vector<uint32_t>& ssrcs);
  44. // Create Simulcast stream with given |ssrcs| and |rtx_ssrcs|.
  45. // The number of |rtx_ssrcs| must match number of |ssrcs|.
  46. cricket::StreamParams CreateSimWithRtxStreamParams(
  47. const std::string& cname,
  48. const std::vector<uint32_t>& ssrcs,
  49. const std::vector<uint32_t>& rtx_ssrcs);
  50. // Create StreamParams with single primary SSRC and corresponding FlexFEC SSRC.
  51. cricket::StreamParams CreatePrimaryWithFecFrStreamParams(
  52. const std::string& cname,
  53. uint32_t primary_ssrc,
  54. uint32_t flexfec_ssrc);
  55. } // namespace cricket
  56. #endif // MEDIA_BASE_TEST_UTILS_H_