blob: 250dfbc9e234daff414ef45337177cda1347cb3d [file] [log] [blame]
Harald Alvestrand38b768c2020-09-29 11:54:051/*
2 * Copyright 2020 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/transceiver_list.h"
12
Harald Alvestrandc24a2182022-02-23 13:44:5913#include <string>
14
Harald Alvestrand5761e7b2021-01-29 14:45:0815#include "rtc_base/checks.h"
16
Harald Alvestrand38b768c2020-09-29 11:54:0517namespace webrtc {
18
19void TransceiverStableState::set_newly_created() {
20 RTC_DCHECK(!has_m_section_);
21 newly_created_ = true;
22}
23
24void TransceiverStableState::SetMSectionIfUnset(
25 absl::optional<std::string> mid,
26 absl::optional<size_t> mline_index) {
27 if (!has_m_section_) {
28 mid_ = mid;
29 mline_index_ = mline_index;
30 has_m_section_ = true;
31 }
32}
33
Henrik Boström0a162762022-05-02 13:47:5234void TransceiverStableState::SetRemoteStreamIds(
Harald Alvestrand38b768c2020-09-29 11:54:0535 const std::vector<std::string>& ids) {
36 if (!remote_stream_ids_.has_value()) {
37 remote_stream_ids_ = ids;
38 }
39}
40
Eldar Rello950d6b92021-04-06 19:38:0041void TransceiverStableState::SetInitSendEncodings(
42 const std::vector<RtpEncodingParameters>& encodings) {
43 init_send_encodings_ = encodings;
44}
45
Harald Alvestrand85466662021-04-19 21:21:3646std::vector<RtpTransceiver*> TransceiverList::ListInternal() const {
47 RTC_DCHECK_RUN_ON(&sequence_checker_);
48 std::vector<RtpTransceiver*> internals;
49 for (auto transceiver : transceivers_) {
50 internals.push_back(transceiver->internal());
51 }
52 return internals;
53}
54
Harald Alvestrand38b768c2020-09-29 11:54:0555RtpTransceiverProxyRefPtr TransceiverList::FindBySender(
56 rtc::scoped_refptr<RtpSenderInterface> sender) const {
Harald Alvestrand85466662021-04-19 21:21:3657 RTC_DCHECK_RUN_ON(&sequence_checker_);
Harald Alvestrand38b768c2020-09-29 11:54:0558 for (auto transceiver : transceivers_) {
59 if (transceiver->sender() == sender) {
60 return transceiver;
61 }
62 }
63 return nullptr;
64}
65
66RtpTransceiverProxyRefPtr TransceiverList::FindByMid(
67 const std::string& mid) const {
Harald Alvestrand85466662021-04-19 21:21:3668 RTC_DCHECK_RUN_ON(&sequence_checker_);
Harald Alvestrand38b768c2020-09-29 11:54:0569 for (auto transceiver : transceivers_) {
70 if (transceiver->mid() == mid) {
71 return transceiver;
72 }
73 }
74 return nullptr;
75}
76
77RtpTransceiverProxyRefPtr TransceiverList::FindByMLineIndex(
78 size_t mline_index) const {
Harald Alvestrand85466662021-04-19 21:21:3679 RTC_DCHECK_RUN_ON(&sequence_checker_);
Harald Alvestrand38b768c2020-09-29 11:54:0580 for (auto transceiver : transceivers_) {
81 if (transceiver->internal()->mline_index() == mline_index) {
82 return transceiver;
83 }
84 }
85 return nullptr;
86}
87
88} // namespace webrtc