xref: /aosp_15_r20/external/webrtc/pc/rtp_receiver.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2015 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 "pc/rtp_receiver.h"
12 
13 #include <stddef.h>
14 
15 #include <utility>
16 #include <vector>
17 
18 #include "pc/media_stream.h"
19 #include "pc/media_stream_proxy.h"
20 #include "rtc_base/thread.h"
21 
22 namespace webrtc {
23 
24 // This function is only expected to be called on the signalling thread.
GenerateUniqueId()25 int RtpReceiverInternal::GenerateUniqueId() {
26   static int g_unique_id = 0;
27 
28   return ++g_unique_id;
29 }
30 
31 std::vector<rtc::scoped_refptr<MediaStreamInterface>>
CreateStreamsFromIds(std::vector<std::string> stream_ids)32 RtpReceiverInternal::CreateStreamsFromIds(std::vector<std::string> stream_ids) {
33   std::vector<rtc::scoped_refptr<MediaStreamInterface>> streams(
34       stream_ids.size());
35   for (size_t i = 0; i < stream_ids.size(); ++i) {
36     streams[i] = MediaStreamProxy::Create(
37         rtc::Thread::Current(), MediaStream::Create(std::move(stream_ids[i])));
38   }
39   return streams;
40 }
41 
42 }  // namespace webrtc
43