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 #include "media/base/test_utils.h"
12 
13 #include <cstdint>
14 
15 #include "api/video/video_frame.h"
16 #include "api/video/video_source_interface.h"
17 
18 namespace cricket {
19 
CreateSimStreamParams(const std::string & cname,const std::vector<uint32_t> & ssrcs)20 cricket::StreamParams CreateSimStreamParams(
21     const std::string& cname,
22     const std::vector<uint32_t>& ssrcs) {
23   cricket::StreamParams sp;
24   cricket::SsrcGroup sg(cricket::kSimSsrcGroupSemantics, ssrcs);
25   sp.ssrcs = ssrcs;
26   sp.ssrc_groups.push_back(sg);
27   sp.cname = cname;
28   return sp;
29 }
30 
31 // There should be an rtx_ssrc per ssrc.
CreateSimWithRtxStreamParams(const std::string & cname,const std::vector<uint32_t> & ssrcs,const std::vector<uint32_t> & rtx_ssrcs)32 cricket::StreamParams CreateSimWithRtxStreamParams(
33     const std::string& cname,
34     const std::vector<uint32_t>& ssrcs,
35     const std::vector<uint32_t>& rtx_ssrcs) {
36   cricket::StreamParams sp = CreateSimStreamParams(cname, ssrcs);
37   for (size_t i = 0; i < ssrcs.size(); ++i) {
38     sp.ssrcs.push_back(rtx_ssrcs[i]);
39     std::vector<uint32_t> fid_ssrcs;
40     fid_ssrcs.push_back(ssrcs[i]);
41     fid_ssrcs.push_back(rtx_ssrcs[i]);
42     cricket::SsrcGroup fid_group(cricket::kFidSsrcGroupSemantics, fid_ssrcs);
43     sp.ssrc_groups.push_back(fid_group);
44   }
45   return sp;
46 }
47 
CreatePrimaryWithFecFrStreamParams(const std::string & cname,uint32_t primary_ssrc,uint32_t flexfec_ssrc)48 cricket::StreamParams CreatePrimaryWithFecFrStreamParams(
49     const std::string& cname,
50     uint32_t primary_ssrc,
51     uint32_t flexfec_ssrc) {
52   cricket::StreamParams sp;
53   cricket::SsrcGroup sg(cricket::kFecFrSsrcGroupSemantics,
54                         {primary_ssrc, flexfec_ssrc});
55   sp.ssrcs = {primary_ssrc};
56   sp.ssrc_groups.push_back(sg);
57   sp.cname = cname;
58   return sp;
59 }
60 
61 }  // namespace cricket
62