blob: 9431aab10aef42addf1e8a9170c21c62b6b51a26 [file] [log] [blame]
deadbeef6979b022015-09-24 23:47:531/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2015 The WebRTC project authors. All Rights Reserved.
deadbeef6979b022015-09-24 23:47:533 *
kjellanderb24317b2016-02-10 15:54:434 * 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.
deadbeef6979b022015-09-24 23:47:539 */
10
Steve Anton10542f22019-01-11 17:11:0011#include "pc/rtp_receiver.h"
deadbeef6979b022015-09-24 23:47:5312
Yves Gerey3e707812018-11-28 15:47:4913#include <stddef.h>
Jonas Olssona4d87372019-07-05 17:08:3314
Mirko Bonadeicc70a6d2024-01-25 08:34:2615#include <atomic>
Henrik Boström9e6fd2b2017-11-21 12:41:5116#include <utility>
Steve Anton36b29d12017-10-30 16:57:4217#include <vector>
18
Steve Anton10542f22019-01-11 17:11:0019#include "pc/media_stream.h"
Markus Handella1b82012021-05-26 16:56:3020#include "pc/media_stream_proxy.h"
Harald Alvestrandc24a2182022-02-23 13:44:5921#include "rtc_base/thread.h"
deadbeef70ab1a12015-09-28 23:53:5522
23namespace webrtc {
24
Harald Alvestrandc72af932018-01-11 16:18:1925// This function is only expected to be called on the signalling thread.
Mirko Bonadeicc70a6d2024-01-25 08:34:2626// On the other hand, some test or even production setups may use
27// several signaling threads.
Ruslan Burakov501bfba2019-02-11 09:29:1928int RtpReceiverInternal::GenerateUniqueId() {
Mirko Bonadeicc70a6d2024-01-25 08:34:2629 static std::atomic<int> g_unique_id{0};
Harald Alvestrandc72af932018-01-11 16:18:1930
31 return ++g_unique_id;
32}
33
Ruslan Burakov501bfba2019-02-11 09:29:1934std::vector<rtc::scoped_refptr<MediaStreamInterface>>
35RtpReceiverInternal::CreateStreamsFromIds(std::vector<std::string> stream_ids) {
Henrik Boström199e27b2018-07-04 18:51:5336 std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams(
37 stream_ids.size());
38 for (size_t i = 0; i < stream_ids.size(); ++i) {
39 streams[i] = MediaStreamProxy::Create(
40 rtc::Thread::Current(), MediaStream::Create(std::move(stream_ids[i])));
41 }
42 return streams;
43}
44
deadbeef70ab1a12015-09-28 23:53:5545} // namespace webrtc