1 /* 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 13 #include <string> 14 15 #include "rtc_base/checks.h" 16 17 namespace webrtc { 18 set_newly_created()19void TransceiverStableState::set_newly_created() { 20 RTC_DCHECK(!has_m_section_); 21 newly_created_ = true; 22 } 23 SetMSectionIfUnset(absl::optional<std::string> mid,absl::optional<size_t> mline_index)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 SetRemoteStreamIds(const std::vector<std::string> & ids)34void TransceiverStableState::SetRemoteStreamIds( 35 const std::vector<std::string>& ids) { 36 if (!remote_stream_ids_.has_value()) { 37 remote_stream_ids_ = ids; 38 } 39 } 40 SetInitSendEncodings(const std::vector<RtpEncodingParameters> & encodings)41void TransceiverStableState::SetInitSendEncodings( 42 const std::vector<RtpEncodingParameters>& encodings) { 43 init_send_encodings_ = encodings; 44 } 45 ListInternal() const46std::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 FindBySender(rtc::scoped_refptr<RtpSenderInterface> sender) const55RtpTransceiverProxyRefPtr TransceiverList::FindBySender( 56 rtc::scoped_refptr<RtpSenderInterface> sender) const { 57 RTC_DCHECK_RUN_ON(&sequence_checker_); 58 for (auto transceiver : transceivers_) { 59 if (transceiver->sender() == sender) { 60 return transceiver; 61 } 62 } 63 return nullptr; 64 } 65 FindByMid(const std::string & mid) const66RtpTransceiverProxyRefPtr TransceiverList::FindByMid( 67 const std::string& mid) const { 68 RTC_DCHECK_RUN_ON(&sequence_checker_); 69 for (auto transceiver : transceivers_) { 70 if (transceiver->mid() == mid) { 71 return transceiver; 72 } 73 } 74 return nullptr; 75 } 76 FindByMLineIndex(size_t mline_index) const77RtpTransceiverProxyRefPtr TransceiverList::FindByMLineIndex( 78 size_t mline_index) const { 79 RTC_DCHECK_RUN_ON(&sequence_checker_); 80 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 89