webrtc/media/base/test_utils.cc
Philipp Hancke 0776415a41 Generalize stream parameter primary/secondary ssrc checks
to ensure consistency for both FID and FEC-FR ssrc-groups.

BUG=chromium:1454860

Change-Id: I61277e73e0a28f5773260ec62c268bdc8c2cd738
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/309760
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#40347}
2023-06-26 14:55:48 +00:00

55 lines
1.6 KiB
C++

/*
* Copyright (c) 2004 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "media/base/test_utils.h"
#include <cstdint>
#include "api/video/video_frame.h"
#include "api/video/video_source_interface.h"
namespace cricket {
cricket::StreamParams CreateSimStreamParams(
const std::string& cname,
const std::vector<uint32_t>& ssrcs) {
cricket::StreamParams sp;
cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, ssrcs);
sp.ssrcs = ssrcs;
sp.ssrc_groups.push_back(sg);
sp.cname = cname;
return sp;
}
// There should be an rtx_ssrc per ssrc.
cricket::StreamParams CreateSimWithRtxStreamParams(
const std::string& cname,
const std::vector<uint32_t>& ssrcs,
const std::vector<uint32_t>& rtx_ssrcs) {
cricket::StreamParams sp = CreateSimStreamParams(cname, ssrcs);
for (size_t i = 0; i < ssrcs.size(); ++i) {
sp.AddFidSsrc(ssrcs[i], rtx_ssrcs[i]);
}
return sp;
}
// There should be one fec ssrc per ssrc.
cricket::StreamParams CreatePrimaryWithFecFrStreamParams(
const std::string& cname,
uint32_t primary_ssrc,
uint32_t flexfec_ssrc) {
cricket::StreamParams sp;
sp.ssrcs = {primary_ssrc};
sp.cname = cname;
sp.AddFecFrSsrc(primary_ssrc, flexfec_ssrc);
return sp;
}
} // namespace cricket