diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /third_party/libwebrtc/pc/sdp_offer_answer.cc | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/libwebrtc/pc/sdp_offer_answer.cc')
-rw-r--r-- | third_party/libwebrtc/pc/sdp_offer_answer.cc | 105 |
1 files changed, 46 insertions, 59 deletions
diff --git a/third_party/libwebrtc/pc/sdp_offer_answer.cc b/third_party/libwebrtc/pc/sdp_offer_answer.cc index 0261195bb0..1e43833a0b 100644 --- a/third_party/libwebrtc/pc/sdp_offer_answer.cc +++ b/third_party/libwebrtc/pc/sdp_offer_answer.cc @@ -86,8 +86,7 @@ namespace webrtc { namespace { -typedef webrtc::PeerConnectionInterface::RTCOfferAnswerOptions - RTCOfferAnswerOptions; +typedef PeerConnectionInterface::RTCOfferAnswerOptions RTCOfferAnswerOptions; // Error messages const char kInvalidSdp[] = "Invalid session description."; @@ -566,22 +565,9 @@ RTCError ValidatePayloadTypes(const cricket::SessionDescription& description) { continue; } const auto type = media_description->type(); - if (type == cricket::MEDIA_TYPE_AUDIO) { - RTC_DCHECK(media_description->as_audio()); - for (const auto& codec : media_description->as_audio()->codecs()) { - if (!cricket::UsedPayloadTypes::IsIdValid( - codec, media_description->rtcp_mux())) { - LOG_AND_RETURN_ERROR( - RTCErrorType::INVALID_PARAMETER, - "The media section with MID='" + content.mid() + - "' used an invalid payload type " + rtc::ToString(codec.id) + - " for codec '" + codec.name + ", rtcp-mux:" + - (media_description->rtcp_mux() ? "enabled" : "disabled")); - } - } - } else if (type == cricket::MEDIA_TYPE_VIDEO) { - RTC_DCHECK(media_description->as_video()); - for (const auto& codec : media_description->as_video()->codecs()) { + if (type == cricket::MEDIA_TYPE_AUDIO || + type == cricket::MEDIA_TYPE_VIDEO) { + for (const auto& codec : media_description->codecs()) { if (!cricket::UsedPayloadTypes::IsIdValid( codec, media_description->rtcp_mux())) { LOG_AND_RETURN_ERROR( @@ -834,8 +820,8 @@ std::string GenerateRtcpCname() { } // Check if we can send `new_stream` on a PeerConnection. -bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams, - webrtc::MediaStreamInterface* new_stream) { +bool CanAddLocalMediaStream(StreamCollectionInterface* current_streams, + MediaStreamInterface* new_stream) { if (!new_stream || !current_streams) { return false; } @@ -847,7 +833,7 @@ bool CanAddLocalMediaStream(webrtc::StreamCollectionInterface* current_streams, return true; } -rtc::scoped_refptr<webrtc::DtlsTransport> LookupDtlsTransportByMid( +rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMid( rtc::Thread* network_thread, JsepTransportController* controller, const std::string& mid) { @@ -1888,8 +1874,8 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( if (audio_content->rejected) { RemoveSenders(cricket::MEDIA_TYPE_AUDIO); } else { - const cricket::AudioContentDescription* audio_desc = - audio_content->media_description()->as_audio(); + const cricket::MediaContentDescription* audio_desc = + audio_content->media_description(); UpdateLocalSenders(audio_desc->streams(), audio_desc->type()); } } @@ -1900,8 +1886,8 @@ RTCError SdpOfferAnswerHandler::ApplyLocalDescription( if (video_content->rejected) { RemoveSenders(cricket::MEDIA_TYPE_VIDEO); } else { - const cricket::VideoContentDescription* video_desc = - video_content->media_description()->as_video(); + const cricket::MediaContentDescription* video_desc = + video_content->media_description(); UpdateLocalSenders(video_desc->streams(), video_desc->type()); } } @@ -2010,8 +1996,11 @@ RTCError SdpOfferAnswerHandler::ReplaceRemoteDescription( const cricket::SessionDescription* session_desc = remote_description()->description(); + const auto* local = local_description(); + // NOTE: This will perform a BlockingCall() to the network thread. - return transport_controller_s()->SetRemoteDescription(sdp_type, session_desc); + return transport_controller_s()->SetRemoteDescription( + sdp_type, local ? local->description() : nullptr, session_desc); } void SdpOfferAnswerHandler::ApplyRemoteDescription( @@ -4932,13 +4921,15 @@ RTCError SdpOfferAnswerHandler::PushdownTransportDescription( if (source == cricket::CS_LOCAL) { const SessionDescriptionInterface* sdesc = local_description(); RTC_DCHECK(sdesc); - return transport_controller_s()->SetLocalDescription(type, - sdesc->description()); + const auto* remote = remote_description(); + return transport_controller_s()->SetLocalDescription( + type, sdesc->description(), remote ? remote->description() : nullptr); } else { const SessionDescriptionInterface* sdesc = remote_description(); RTC_DCHECK(sdesc); - return transport_controller_s()->SetRemoteDescription(type, - sdesc->description()); + const auto* local = local_description(); + return transport_controller_s()->SetRemoteDescription( + type, local ? local->description() : nullptr, sdesc->description()); } } @@ -5366,44 +5357,40 @@ bool SdpOfferAnswerHandler::UpdatePayloadTypeDemuxingState( // Ignore transceivers that are not receiving. continue; } - switch (content_info.media_description()->type()) { - case cricket::MediaType::MEDIA_TYPE_AUDIO: { - if (!mid_header_extension_missing_audio) { - mid_header_extension_missing_audio = - !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri); - } - const cricket::AudioContentDescription* audio_desc = - content_info.media_description()->as_audio(); - for (const cricket::AudioCodec& audio : audio_desc->codecs()) { - if (payload_types->audio_payload_types.count(audio.id)) { + const cricket::MediaType media_type = + content_info.media_description()->type(); + if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO || + media_type == cricket::MediaType::MEDIA_TYPE_VIDEO) { + if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO && + !mid_header_extension_missing_audio) { + mid_header_extension_missing_audio = + !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri); + } else if (media_type == cricket::MEDIA_TYPE_VIDEO && + !mid_header_extension_missing_video) { + mid_header_extension_missing_video = + !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri); + } + const cricket::MediaContentDescription* media_desc = + content_info.media_description(); + for (const cricket::Codec& codec : media_desc->codecs()) { + if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) { + if (payload_types->audio_payload_types.count(codec.id)) { // Two m= sections are using the same payload type, thus demuxing // by payload type is not possible. - payload_types->pt_demuxing_possible_audio = false; + if (media_type == cricket::MediaType::MEDIA_TYPE_AUDIO) { + payload_types->pt_demuxing_possible_audio = false; + } } - payload_types->audio_payload_types.insert(audio.id); - } - break; - } - case cricket::MediaType::MEDIA_TYPE_VIDEO: { - if (!mid_header_extension_missing_video) { - mid_header_extension_missing_video = - !ContentHasHeaderExtension(content_info, RtpExtension::kMidUri); - } - const cricket::VideoContentDescription* video_desc = - content_info.media_description()->as_video(); - for (const cricket::VideoCodec& video : video_desc->codecs()) { - if (payload_types->video_payload_types.count(video.id)) { + payload_types->audio_payload_types.insert(codec.id); + } else if (media_type == cricket::MEDIA_TYPE_VIDEO) { + if (payload_types->video_payload_types.count(codec.id)) { // Two m= sections are using the same payload type, thus demuxing // by payload type is not possible. payload_types->pt_demuxing_possible_video = false; } - payload_types->video_payload_types.insert(video.id); + payload_types->video_payload_types.insert(codec.id); } - break; } - default: - // Ignore data channels. - continue; } } |