
BUG=2535 R=andrew@webrtc.org, mflodman@webrtc.org, niklas.enbom@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2659004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5042 4adac7df-926f-26a2-2b94-8c16560cd09d
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
/*
|
|
* Copyright (c) 2013 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 "webrtc/test/generate_ssrcs.h"
|
|
|
|
#include <assert.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "webrtc/video_send_stream.h"
|
|
|
|
namespace webrtc {
|
|
namespace test {
|
|
|
|
void GenerateRandomSsrcs(VideoSendStream::Config* config,
|
|
std::map<uint32_t, bool>* reserved_ssrcs) {
|
|
size_t num_ssrcs = config->codec.numberOfSimulcastStreams;
|
|
std::vector<uint32_t>* ssrcs = &config->rtp.ssrcs;
|
|
assert(ssrcs->size() == 0);
|
|
|
|
if (num_ssrcs == 0) {
|
|
num_ssrcs = 1;
|
|
}
|
|
|
|
while (ssrcs->size() < num_ssrcs) {
|
|
uint32_t rand_ssrc = static_cast<uint32_t>(rand() + 1); // NOLINT
|
|
|
|
// Make sure the ssrc is unique per-call
|
|
while (true) {
|
|
if (!(*reserved_ssrcs)[rand_ssrc]) {
|
|
(*reserved_ssrcs)[rand_ssrc] = true;
|
|
break;
|
|
}
|
|
++rand_ssrc;
|
|
}
|
|
|
|
ssrcs->push_back(rand_ssrc);
|
|
}
|
|
}
|
|
|
|
} // namespace test
|
|
} // namespace webrtc
|