Make mid_ a private member variable

Bug: webrtc:42233761
Change-Id: I17458a5b8c2d1999b40e4272dd51502ca6099219
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/374665
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43791}
This commit is contained in:
Tommi 2025-01-21 22:34:35 +01:00 committed by WebRTC LUCI CQ
parent 7fe307df59
commit a70cc7886c
5 changed files with 87 additions and 88 deletions

View File

@ -223,7 +223,7 @@ bool JsepSessionDescription::AddCandidate(
if (mediasection_index >= number_of_mediasections())
return false;
const std::string& content_name =
description_->contents()[mediasection_index].name;
description_->contents()[mediasection_index].mid();
const cricket::TransportInfo* transport_info =
description_->GetTransportInfoByName(content_name);
if (!transport_info) {
@ -314,7 +314,7 @@ bool JsepSessionDescription::GetMediasectionIndex(
bool found = false;
// Try to match the sdp_mid with content name.
for (size_t i = 0; i < description_->contents().size(); ++i) {
if (candidate->sdp_mid() == description_->contents().at(i).name) {
if (candidate->sdp_mid() == description_->contents().at(i).mid()) {
*index = i;
found = true;
break;
@ -333,7 +333,7 @@ int JsepSessionDescription::GetMediasectionIndex(const Candidate& candidate) {
// Find the description with a matching transport name of the candidate.
const std::string& transport_name = candidate.transport_name();
for (size_t i = 0; i < description_->contents().size(); ++i) {
if (transport_name == description_->contents().at(i).name) {
if (transport_name == description_->contents().at(i).mid()) {
return static_cast<int>(i);
}
}

View File

@ -385,7 +385,7 @@ std::vector<const ContentInfo*> GetActiveContents(
const MediaDescriptionOptions& media_options =
session_options.media_description_options[i];
if (!content.rejected && !media_options.stopped &&
content.name == media_options.mid) {
content.mid() == media_options.mid) {
active_contents.push_back(&content);
}
}
@ -1145,13 +1145,13 @@ webrtc::RTCErrorOr<std::vector<Codec>> GetNegotiatedCodecsForOffer(
// Add the codecs from current content if it exists and is not rejected nor
// recycled.
if (current_content && !current_content->rejected &&
current_content->name == media_description_options.mid) {
current_content->mid() == media_description_options.mid) {
if (!IsMediaContentOfType(current_content,
media_description_options.type)) {
// Can happen if the remote side re-uses a MID while recycling.
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
"Media type for content with mid='" +
current_content->name +
current_content->mid() +
"' does not match previous type.");
}
const MediaContentDescription* mcd = current_content->media_description();
@ -1223,13 +1223,13 @@ webrtc::RTCErrorOr<Codecs> GetNegotiatedCodecsForAnswer(
// Add the codecs from current content if it exists and is not rejected nor
// recycled.
if (current_content && !current_content->rejected &&
current_content->name == media_description_options.mid) {
current_content->mid() == media_description_options.mid) {
if (!IsMediaContentOfType(current_content,
media_description_options.type)) {
// Can happen if the remote side re-uses a MID while recycling.
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
"Media type for content with mid='" +
current_content->name +
current_content->mid() +
"' does not match previous type.");
}
const MediaContentDescription* mcd = current_content->media_description();
@ -1492,7 +1492,7 @@ MediaSessionDescriptionFactory::CreateOfferOrError(
// type to represent different codecs, or same IDs for different header
// extensions. We need to detect this and not try to bundle those media
// descriptions together.
offer_bundle.AddContentName(content.name);
offer_bundle.AddContentName(content.mid());
}
if (!offer_bundle.content_names().empty()) {
offer->AddGroup(offer_bundle);
@ -1606,7 +1606,7 @@ MediaSessionDescriptionFactory::CreateAnswerOrError(
// MediaDescriptionOptions.
RTC_DCHECK(
IsMediaContentOfType(offer_content, media_description_options.type));
RTC_DCHECK(media_description_options.mid == offer_content->name);
RTC_DCHECK(media_description_options.mid == offer_content->mid());
// Get the index of the BUNDLE group that this MID belongs to, if any.
std::optional<size_t> bundle_index;
for (size_t i = 0; i < offer_bundles.size(); ++i) {
@ -1673,10 +1673,10 @@ MediaSessionDescriptionFactory::CreateAnswerOrError(
if (!added.rejected && session_options.bundle_enabled &&
bundle_index.has_value()) {
// The `bundle_index` is for `media_description_options.mid`.
RTC_DCHECK_EQ(media_description_options.mid, added.name);
answer_bundles[bundle_index.value()].AddContentName(added.name);
RTC_DCHECK_EQ(media_description_options.mid, added.mid());
answer_bundles[bundle_index.value()].AddContentName(added.mid());
bundle_transports[bundle_index.value()].reset(
new TransportInfo(*answer->GetTransportInfoByName(added.name)));
new TransportInfo(*answer->GetTransportInfoByName(added.mid())));
}
}

View File

@ -288,7 +288,7 @@ bool MediaSectionsInSameOrder(const SessionDescription& current_desc,
// valid for the MID and media type to change.
continue;
}
if (new_desc.contents()[i].name != current_desc.contents()[i].name) {
if (new_desc.contents()[i].mid() != current_desc.contents()[i].mid()) {
return false;
}
const MediaContentDescription* new_desc_mdesc =
@ -320,7 +320,7 @@ RTCError VerifyCrypto(const SessionDescription* desc,
if (content_info.rejected) {
continue;
}
const std::string& mid = content_info.name;
const auto mid = content_info.mid();
auto it = bundle_groups_by_mid.find(mid);
const cricket::ContentGroup* bundle =
it != bundle_groups_by_mid.end() ? it->second : nullptr;
@ -362,7 +362,7 @@ bool VerifyIceUfragPwdPresent(
if (content_info.rejected) {
continue;
}
const std::string& mid = content_info.name;
const auto mid = content_info.mid();
auto it = bundle_groups_by_mid.find(mid);
const cricket::ContentGroup* bundle =
it != bundle_groups_by_mid.end() ? it->second : nullptr;
@ -393,18 +393,18 @@ bool VerifyIceUfragPwdPresent(
RTCError ValidateMids(const cricket::SessionDescription& description) {
std::set<std::string> mids;
for (const cricket::ContentInfo& content : description.contents()) {
if (content.name.empty()) {
if (content.mid().empty()) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
"A media section is missing a MID attribute.");
}
if (content.name.size() > kMidMaxSize) {
if (content.mid().size() > kMidMaxSize) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
"The MID attribute exceeds the maximum supported "
"length of 16 characters.");
}
if (!mids.insert(content.name).second) {
if (!mids.insert(content.mid()).second) {
LOG_AND_RETURN_ERROR(RTCErrorType::INVALID_PARAMETER,
"Duplicate a=mid value '" + content.name + "'.");
"Duplicate a=mid value '" + content.mid() + "'.");
}
}
return RTCError::OK();
@ -919,7 +919,7 @@ void UpdateRtpHeaderExtensionPreferencesFromSdpMunging(
RTC_DCHECK(description);
RTC_DCHECK(transceivers);
for (const auto& content : description->contents()) {
auto transceiver = transceivers->FindByMid(content.name);
auto transceiver = transceivers->FindByMid(content.mid());
if (!transceiver) {
continue;
}
@ -2115,9 +2115,9 @@ void SdpOfferAnswerHandler::ApplyRemoteDescription(
// remote description, this should reset pending_ice_restarts and compare
// against the current description.
if (CheckForRemoteIceRestart(operation->old_remote_description(),
remote_description(), content.name)) {
remote_description(), content.mid())) {
if (operation->type() == SdpType::kOffer) {
pending_ice_restarts_.insert(content.name);
pending_ice_restarts_.insert(content.mid());
}
} else {
// We retain all received candidates only if ICE is not restarted.
@ -2128,7 +2128,7 @@ void SdpOfferAnswerHandler::ApplyRemoteDescription(
// description plus any candidates added since then. We should remove
// this once we're sure it won't break anything.
WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription(
operation->old_remote_description(), content.name,
operation->old_remote_description(), content.mid(),
mutable_remote_description());
}
}
@ -2226,7 +2226,7 @@ void SdpOfferAnswerHandler::ApplyRemoteDescriptionUpdateTransceiverState(
stream_ids = media_desc->streams()[0].stream_ids();
}
RTC_LOG(LS_INFO) << "Processing the MSIDs for MID=" << content->name
RTC_LOG(LS_INFO) << "Processing the MSIDs for MID=" << content->mid()
<< " (" << GetStreamIdsString(stream_ids) << ").";
SetAssociatedRemoteStreams(transceiver->receiver_internal(), stream_ids,
&added_streams, &removed_streams);
@ -2237,7 +2237,7 @@ void SdpOfferAnswerHandler::ApplyRemoteDescriptionUpdateTransceiverState(
if (!transceiver->fired_direction() ||
!RtpTransceiverDirectionHasRecv(*transceiver->fired_direction())) {
RTC_LOG(LS_INFO) << "Processing the addition of a remote track for MID="
<< content->name << ".";
<< content->mid() << ".";
// Since the transceiver is passed to the user in an
// OnTrack event, we must use the proxied transceiver.
now_receiving_transceivers.push_back(transceiver_ext);
@ -2281,7 +2281,7 @@ void SdpOfferAnswerHandler::ApplyRemoteDescriptionUpdateTransceiverState(
// 2.2.8.1.12: If the media description is rejected, and transceiver is
// not already stopped, stop the RTCRtpTransceiver transceiver.
if (content->rejected && !transceiver->stopped()) {
RTC_LOG(LS_INFO) << "Stopping transceiver for MID=" << content->name
RTC_LOG(LS_INFO) << "Stopping transceiver for MID=" << content->mid()
<< " since the media section was rejected.";
transceiver->StopTransceiverProcedure();
}
@ -3535,7 +3535,7 @@ bool SdpOfferAnswerHandler::CheckIfNegotiationIsNeeded() {
const cricket::ContentInfo* remote_data_content =
current_remote_description()
? current_remote_description()->description()->GetContentByName(
data_content->name)
data_content->mid())
: nullptr;
if (remote_data_content && remote_data_content->rejected) {
return true;
@ -3839,8 +3839,8 @@ RTCError SdpOfferAnswerHandler::UpdateTransceiversAndDataChannels(
for (size_t i = 0; i < new_contents.size(); ++i) {
const cricket::ContentInfo& new_content = new_contents[i];
cricket::MediaType media_type = new_content.media_description()->type();
mid_generator_.AddKnownId(new_content.name);
auto it = bundle_groups_by_mid.find(new_content.name);
mid_generator_.AddKnownId(new_content.mid());
auto it = bundle_groups_by_mid.find(new_content.mid());
const cricket::ContentGroup* bundle_group =
it != bundle_groups_by_mid.end() ? it->second : nullptr;
if (media_type == cricket::MEDIA_TYPE_AUDIO ||
@ -3907,10 +3907,10 @@ RTCError SdpOfferAnswerHandler::UpdateTransceiversAndDataChannels(
}
} else if (media_type == cricket::MEDIA_TYPE_DATA) {
const auto data_mid = pc_->sctp_mid();
if (data_mid && new_content.name != data_mid.value()) {
if (data_mid && new_content.mid() != data_mid.value()) {
// Ignore all but the first data section.
RTC_LOG(LS_INFO) << "Ignoring data media section with MID="
<< new_content.name;
<< new_content.mid();
continue;
}
RTCError error =
@ -3946,10 +3946,9 @@ SdpOfferAnswerHandler::AssociateTransceiver(
// should have been removed by RemoveStoppedtransceivers()->
if (IsMediaSectionBeingRecycled(type, content, old_local_content,
old_remote_content)) {
const std::string& old_mid =
(old_local_content && old_local_content->rejected)
? old_local_content->name
: old_remote_content->name;
const auto old_mid = (old_local_content && old_local_content->rejected)
? old_local_content->mid()
: old_remote_content->mid();
auto old_transceiver = transceivers()->FindByMid(old_mid);
// The transceiver should be disassociated in RemoveStoppedTransceivers()
RTC_DCHECK(!old_transceiver);
@ -3957,7 +3956,7 @@ SdpOfferAnswerHandler::AssociateTransceiver(
#endif
const MediaContentDescription* media_desc = content.media_description();
auto transceiver = transceivers()->FindByMid(content.name);
auto transceiver = transceivers()->FindByMid(content.mid());
if (source == cricket::CS_LOCAL) {
// Find the RtpTransceiver that corresponds to this m= section, using the
// mapping between transceivers and m= section indices established when
@ -3986,7 +3985,7 @@ SdpOfferAnswerHandler::AssociateTransceiver(
if (!transceiver) {
RTC_LOG(LS_INFO) << "Adding "
<< cricket::MediaTypeToString(media_desc->type())
<< " transceiver for MID=" << content.name
<< " transceiver for MID=" << content.mid()
<< " at i=" << mline_index
<< " in response to the remote description.";
std::string sender_id = rtc::CreateRandomUuid();
@ -4047,7 +4046,7 @@ SdpOfferAnswerHandler::AssociateTransceiver(
}
}
if (type == SdpType::kOffer) {
bool state_changes = transceiver->internal()->mid() != content.name ||
bool state_changes = transceiver->internal()->mid() != content.mid() ||
transceiver->internal()->mline_index() != mline_index;
if (state_changes) {
transceivers()
@ -4060,7 +4059,7 @@ SdpOfferAnswerHandler::AssociateTransceiver(
// setting the value of the RtpTransceiver's mid property to the MID of the m=
// section, and establish a mapping between the transceiver and the index of
// the m= section.
transceiver->internal()->set_mid(content.name);
transceiver->internal()->set_mid(content.mid());
transceiver->internal()->set_mline_index(mline_index);
return std::move(transceiver);
}
@ -4081,7 +4080,7 @@ RTCError SdpOfferAnswerHandler::UpdateTransceiverChannel(
} else {
if (!channel) {
auto error = transceiver->internal()->CreateChannel(
content.name, pc_->call_ptr(), pc_->configuration()->media_config,
content.mid(), pc_->call_ptr(), pc_->configuration()->media_config,
pc_->SrtpRequired(), pc_->GetCryptoOptions(), audio_options(),
video_options(), video_bitrate_allocator_factory_.get(),
[&](absl::string_view mid) {
@ -4109,7 +4108,7 @@ RTCError SdpOfferAnswerHandler::UpdateDataChannelTransport(
RTCError error(RTCErrorType::OPERATION_ERROR_WITH_DATA, sb.Release());
error.set_error_detail(RTCErrorDetailType::DATA_CHANNEL_FAILURE);
pc_->DestroyDataChannelTransport(error);
} else if (!pc_->CreateDataChannelTransport(content.name)) {
} else if (!pc_->CreateDataChannelTransport(content.mid())) {
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
"Failed to create data channel.");
}
@ -4153,17 +4152,17 @@ void SdpOfferAnswerHandler::FillInMissingRemoteMids(
: no_infos);
for (size_t i = 0; i < new_remote_description->contents().size(); ++i) {
cricket::ContentInfo& content = new_remote_description->contents()[i];
if (!content.name.empty()) {
if (!content.mid().empty()) {
continue;
}
std::string new_mid;
absl::string_view source_explanation;
if (IsUnifiedPlan()) {
if (i < local_contents.size()) {
new_mid = local_contents[i].name;
new_mid = local_contents[i].mid();
source_explanation = "from the matching local media section";
} else if (i < remote_contents.size()) {
new_mid = remote_contents[i].name;
new_mid = remote_contents[i].mid();
source_explanation = "from the matching previous remote media section";
} else {
new_mid = mid_generator_.GenerateString();
@ -4175,7 +4174,7 @@ void SdpOfferAnswerHandler::FillInMissingRemoteMids(
source_explanation = "to match pre-existing behavior";
}
RTC_DCHECK(!new_mid.empty());
content.name = new_mid;
content.set_mid(new_mid);
new_remote_description->transport_infos()[i].content_name = new_mid;
RTC_LOG(LS_INFO) << "SetRemoteDescription: Remote media section at i=" << i
<< " is missing an a=mid line. Filling in the value '"
@ -4388,7 +4387,7 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanOffer(
(current_local_content && current_local_content->rejected) ||
(current_remote_content && current_remote_content->rejected);
const std::string& mid =
(local_content ? local_content->name : remote_content->name);
(local_content ? local_content->mid() : remote_content->mid());
cricket::MediaType media_type =
(local_content ? local_content->media_description()->type()
: remote_content->media_description()->type());
@ -4605,24 +4604,24 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanAnswer(
cricket::MediaType media_type = content.media_description()->type();
if (media_type == cricket::MEDIA_TYPE_AUDIO ||
media_type == cricket::MEDIA_TYPE_VIDEO) {
auto transceiver = transceivers()->FindByMid(content.name);
auto transceiver = transceivers()->FindByMid(content.mid());
if (transceiver) {
session_options->media_description_options.push_back(
GetMediaDescriptionOptionsForTransceiver(
transceiver->internal(), content.name,
transceiver->internal(), content.mid(),
/*is_create_offer=*/false));
} else {
// This should only happen with rejected transceivers.
RTC_DCHECK(content.rejected);
session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(media_type, content.name,
cricket::MediaDescriptionOptions(media_type, content.mid(),
RtpTransceiverDirection::kInactive,
/*stopped=*/true));
}
} else if (media_type == cricket::MEDIA_TYPE_UNSUPPORTED) {
RTC_DCHECK(content.rejected);
session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(media_type, content.name,
cricket::MediaDescriptionOptions(media_type, content.mid(),
RtpTransceiverDirection::kInactive,
/*stopped=*/true));
} else {
@ -4630,12 +4629,14 @@ void SdpOfferAnswerHandler::GetOptionsForUnifiedPlanAnswer(
// Reject all data sections if data channels are disabled.
// Reject a data section if it has already been rejected.
// Reject all data sections except for the first one.
if (content.rejected || content.name != *(pc_->sctp_mid())) {
auto sctp_mid = pc_->sctp_mid();
if (content.rejected ||
(sctp_mid.has_value() && content.mid() != *sctp_mid)) {
session_options->media_description_options.push_back(
GetMediaDescriptionOptionsForRejectedData(content.name));
GetMediaDescriptionOptionsForRejectedData(content.mid()));
} else {
session_options->media_description_options.push_back(
GetMediaDescriptionOptionsForActiveData(content.name));
GetMediaDescriptionOptionsForActiveData(content.mid()));
}
}
}
@ -5152,7 +5153,7 @@ void SdpOfferAnswerHandler::RemoveUnusedChannels(
pc_->DestroyDataChannelTransport(error);
} else if (data_info->rejected) {
rtc::StringBuilder sb;
sb << "Rejected data channel with mid=" << data_info->name << ".";
sb << "Rejected data channel with mid=" << data_info->mid() << ".";
RTCError error(RTCErrorType::OPERATION_ERROR_WITH_DATA, sb.Release());
error.set_error_detail(RTCErrorDetailType::DATA_CHANNEL_FAILURE);
@ -5225,7 +5226,7 @@ bool SdpOfferAnswerHandler::UseCandidate(
return true;
}
pc_->AddRemoteCandidate(result.value()->name, c);
pc_->AddRemoteCandidate(result.value()->mid(), c);
return true;
}
@ -5308,7 +5309,7 @@ RTCError SdpOfferAnswerHandler::CreateChannels(const SessionDescription& desc) {
!rtp_manager()->GetAudioTransceiver()->internal()->channel()) {
auto error =
rtp_manager()->GetAudioTransceiver()->internal()->CreateChannel(
voice->name, pc_->call_ptr(), pc_->configuration()->media_config,
voice->mid(), pc_->call_ptr(), pc_->configuration()->media_config,
pc_->SrtpRequired(), pc_->GetCryptoOptions(), audio_options(),
video_options(), video_bitrate_allocator_factory_.get(),
[&](absl::string_view mid) {
@ -5325,7 +5326,7 @@ RTCError SdpOfferAnswerHandler::CreateChannels(const SessionDescription& desc) {
!rtp_manager()->GetVideoTransceiver()->internal()->channel()) {
auto error =
rtp_manager()->GetVideoTransceiver()->internal()->CreateChannel(
video->name, pc_->call_ptr(), pc_->configuration()->media_config,
video->mid(), pc_->call_ptr(), pc_->configuration()->media_config,
pc_->SrtpRequired(), pc_->GetCryptoOptions(),
audio_options(), video_options(),
@ -5339,7 +5340,8 @@ RTCError SdpOfferAnswerHandler::CreateChannels(const SessionDescription& desc) {
}
const cricket::ContentInfo* data = cricket::GetFirstDataContent(&desc);
if (data && !data->rejected && !pc_->CreateDataChannelTransport(data->name)) {
if (data && !data->rejected &&
!pc_->CreateDataChannelTransport(data->mid())) {
LOG_AND_RETURN_ERROR(RTCErrorType::INTERNAL_ERROR,
"Failed to create data channel.");
}
@ -5388,13 +5390,13 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions(
if (*audio_index) {
session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(
cricket::MEDIA_TYPE_AUDIO, content.name,
cricket::MEDIA_TYPE_AUDIO, content.mid(),
RtpTransceiverDirection::kInactive, /*stopped=*/true));
} else {
bool stopped = (audio_direction == RtpTransceiverDirection::kInactive);
session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(cricket::MEDIA_TYPE_AUDIO,
content.name, audio_direction,
content.mid(), audio_direction,
stopped));
*audio_index = session_options->media_description_options.size() - 1;
}
@ -5405,13 +5407,13 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions(
if (*video_index) {
session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(
cricket::MEDIA_TYPE_VIDEO, content.name,
cricket::MEDIA_TYPE_VIDEO, content.mid(),
RtpTransceiverDirection::kInactive, /*stopped=*/true));
} else {
bool stopped = (video_direction == RtpTransceiverDirection::kInactive);
session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(cricket::MEDIA_TYPE_VIDEO,
content.name, video_direction,
content.mid(), video_direction,
stopped));
*video_index = session_options->media_description_options.size() - 1;
}
@ -5420,7 +5422,7 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions(
} else if (IsUnsupportedContent(&content)) {
session_options->media_description_options.push_back(
cricket::MediaDescriptionOptions(cricket::MEDIA_TYPE_UNSUPPORTED,
content.name,
content.mid(),
RtpTransceiverDirection::kInactive,
/*stopped=*/true));
} else {
@ -5428,10 +5430,10 @@ void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions(
// If we already have an data m= section, reject this extra one.
if (*data_index) {
session_options->media_description_options.push_back(
GetMediaDescriptionOptionsForRejectedData(content.name));
GetMediaDescriptionOptionsForRejectedData(content.mid()));
} else {
session_options->media_description_options.push_back(
GetMediaDescriptionOptionsForActiveData(content.name));
GetMediaDescriptionOptionsForActiveData(content.mid()));
*data_index = session_options->media_description_options.size() - 1;
}
}
@ -5489,7 +5491,7 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState(
bool mid_header_extension_missing_audio = false;
bool mid_header_extension_missing_video = false;
for (auto& content_info : sdesc->description()->contents()) {
auto it = bundle_groups_by_mid.find(content_info.name);
auto it = bundle_groups_by_mid.find(content_info.mid());
const cricket::ContentGroup* bundle_group =
it != bundle_groups_by_mid.end() ? it->second : nullptr;
// If this m= section isn't bundled, it's safe to demux by payload type

View File

@ -149,9 +149,7 @@ void SessionDescription::AddContent(
const std::string& name,
MediaProtocolType type,
std::unique_ptr<MediaContentDescription> description) {
ContentInfo content(type, std::move(description));
content.name = name;
AddContent(std::move(content));
AddContent(ContentInfo(type, name, std::move(description)));
}
void SessionDescription::AddContent(
@ -159,10 +157,7 @@ void SessionDescription::AddContent(
MediaProtocolType type,
bool rejected,
std::unique_ptr<MediaContentDescription> description) {
ContentInfo content(type, std::move(description));
content.name = name;
content.rejected = rejected;
AddContent(std::move(content));
AddContent(ContentInfo(type, name, std::move(description), rejected));
}
void SessionDescription::AddContent(
@ -171,11 +166,8 @@ void SessionDescription::AddContent(
bool rejected,
bool bundle_only,
std::unique_ptr<MediaContentDescription> description) {
ContentInfo content(type, std::move(description));
content.name = name;
content.rejected = rejected;
content.bundle_only = bundle_only;
AddContent(std::move(content));
AddContent(
ContentInfo(type, name, std::move(description), rejected, bundle_only));
}
void SessionDescription::AddContent(ContentInfo&& content) {
@ -282,10 +274,10 @@ ContentInfo::~ContentInfo() {}
// Copy operator.
ContentInfo::ContentInfo(const ContentInfo& o)
: name(o.name),
type(o.type),
: type(o.type),
rejected(o.rejected),
bundle_only(o.bundle_only),
mid_(o.mid_),
description_(o.description_->Clone()) {}
const MediaContentDescription* ContentInfo::media_description() const {

View File

@ -400,8 +400,15 @@ class RTC_EXPORT ContentInfo {
public:
explicit ContentInfo(MediaProtocolType type) : type(type) {}
ContentInfo(MediaProtocolType type,
std::unique_ptr<MediaContentDescription> description)
: type(type), description_(std::move(description)) {}
absl::string_view mid,
std::unique_ptr<MediaContentDescription> description,
bool rejected = false,
bool bundle_only = false)
: type(type),
rejected(rejected),
bundle_only(bundle_only),
mid_(mid),
description_(std::move(description)) {}
~ContentInfo();
// Copy ctor and assignment will clone `description_`.
@ -412,22 +419,20 @@ class RTC_EXPORT ContentInfo {
ContentInfo(ContentInfo&& o) = default;
ContentInfo& operator=(ContentInfo&& o) = default;
// Alias for `name`.
// TODO(tommi): change return type to string_view.
const std::string& mid() const { return name; }
void set_mid(absl::string_view mid) { name = std::string(mid); }
const std::string& mid() const { return mid_; }
void set_mid(absl::string_view mid) { mid_ = std::string(mid); }
// Alias for `description`.
MediaContentDescription* media_description();
const MediaContentDescription* media_description() const;
// TODO(bugs.webrtc.org/8620): Rename this to mid and make private.
std::string name;
MediaProtocolType type;
bool rejected = false;
bool bundle_only = false;
private:
std::string mid_;
friend class SessionDescription;
std::unique_ptr<MediaContentDescription> description_;
};