mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-13 05:40:42 +01:00
ringrtc: Clean up externally-specified keys code
This commit is contained in:
parent
1357e97179
commit
b25957f459
5 changed files with 25 additions and 6 deletions
|
@ -1102,6 +1102,16 @@ RTCError JsepTransportController::MaybeCreateJsepTransport(
|
||||||
return RTCError(RTCErrorType::INVALID_PARAMETER,
|
return RTCError(RTCErrorType::INVALID_PARAMETER,
|
||||||
"Manual keys and DTLS-SRTP cannot be enabled at the same time.");
|
"Manual keys and DTLS-SRTP cannot be enabled at the same time.");
|
||||||
}
|
}
|
||||||
|
if (content_desc->manually_specify_keys() &&
|
||||||
|
!content_desc->crypto().has_value()) {
|
||||||
|
return RTCError(RTCErrorType::INVALID_PARAMETER,
|
||||||
|
"Manual keys required but not specified.");
|
||||||
|
}
|
||||||
|
if (!content_desc->manually_specify_keys() &&
|
||||||
|
content_desc->crypto().has_value()) {
|
||||||
|
return RTCError(RTCErrorType::INVALID_PARAMETER,
|
||||||
|
"Manual keys specified in DTLS-SRTP mode.");
|
||||||
|
}
|
||||||
|
|
||||||
rtc::scoped_refptr<IceTransportInterface> ice =
|
rtc::scoped_refptr<IceTransportInterface> ice =
|
||||||
CreateIceTransport(content_info.name, /*rtcp=*/false);
|
CreateIceTransport(content_info.name, /*rtcp=*/false);
|
||||||
|
|
|
@ -1140,7 +1140,7 @@ bool IsMediaProtocolSupported(MediaType type,
|
||||||
// RingRTC: Allow out-of-band / "manual" key negotiation.
|
// RingRTC: Allow out-of-band / "manual" key negotiation.
|
||||||
void SetMediaProtocol(bool secure_transport, bool manually_specify_keys,
|
void SetMediaProtocol(bool secure_transport, bool manually_specify_keys,
|
||||||
MediaContentDescription* desc) {
|
MediaContentDescription* desc) {
|
||||||
if (desc->crypto().has_value() || manually_specify_keys)
|
if (manually_specify_keys)
|
||||||
desc->set_protocol(kMediaProtocolSavpf);
|
desc->set_protocol(kMediaProtocolSavpf);
|
||||||
else if (secure_transport)
|
else if (secure_transport)
|
||||||
desc->set_protocol(kMediaProtocolDtlsSavpf);
|
desc->set_protocol(kMediaProtocolDtlsSavpf);
|
||||||
|
@ -2058,6 +2058,10 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForOffer(
|
||||||
} else {
|
} else {
|
||||||
content_description = std::make_unique<VideoContentDescription>();
|
content_description = std::make_unique<VideoContentDescription>();
|
||||||
}
|
}
|
||||||
|
// RingRTC: Allow out-of-band / "manual" key negotiation.
|
||||||
|
if (manually_specify_keys()) {
|
||||||
|
content_description->set_manually_specify_keys(true);
|
||||||
|
}
|
||||||
|
|
||||||
auto error = CreateMediaContentOffer(
|
auto error = CreateMediaContentOffer(
|
||||||
media_description_options, session_options,
|
media_description_options, session_options,
|
||||||
|
@ -2226,6 +2230,10 @@ RTCError MediaSessionDescriptionFactory::AddRtpContentForAnswer(
|
||||||
} else {
|
} else {
|
||||||
answer_content = std::make_unique<VideoContentDescription>();
|
answer_content = std::make_unique<VideoContentDescription>();
|
||||||
}
|
}
|
||||||
|
// RingRTC: Allow out-of-band / "manual" key negotiation.
|
||||||
|
if (manually_specify_keys()) {
|
||||||
|
answer_content->set_manually_specify_keys(true);
|
||||||
|
}
|
||||||
if (!SetCodecsInAnswer(
|
if (!SetCodecsInAnswer(
|
||||||
offer_content_description, filtered_codecs, media_description_options,
|
offer_content_description, filtered_codecs, media_description_options,
|
||||||
session_options, ssrc_generator(), current_streams,
|
session_options, ssrc_generator(), current_streams,
|
||||||
|
|
|
@ -3557,11 +3557,7 @@ RTCError SdpOfferAnswerHandler::ValidateSessionDescription(
|
||||||
|
|
||||||
// Verify crypto settings.
|
// Verify crypto settings.
|
||||||
std::string crypto_error;
|
std::string crypto_error;
|
||||||
// RingRTC: Allow out-of-band / "manual" key negotiation.
|
if (pc_->dtls_enabled()) {
|
||||||
// Do not verify if "ManuallySpecifyKeys" is set; `VerifyCrypto` only makes
|
|
||||||
// sense for DTLS.
|
|
||||||
if (!webrtc_session_desc_factory_->ManuallySpecifyKeys() &&
|
|
||||||
pc_->dtls_enabled()) {
|
|
||||||
RTCError crypto_error = VerifyCrypto(
|
RTCError crypto_error = VerifyCrypto(
|
||||||
sdesc->description(), pc_->dtls_enabled(), bundle_groups_by_mid);
|
sdesc->description(), pc_->dtls_enabled(), bundle_groups_by_mid);
|
||||||
if (!crypto_error.ok()) {
|
if (!crypto_error.ok()) {
|
||||||
|
|
|
@ -128,6 +128,8 @@ class MediaContentDescription {
|
||||||
void set_crypto(const absl::optional<CryptoParams>& crypto) {
|
void set_crypto(const absl::optional<CryptoParams>& crypto) {
|
||||||
crypto_ = crypto;
|
crypto_ = crypto;
|
||||||
}
|
}
|
||||||
|
void set_manually_specify_keys(bool b) { manually_specify_keys_ = b;}
|
||||||
|
bool manually_specify_keys() const { return manually_specify_keys_; }
|
||||||
|
|
||||||
// List of RTP header extensions. URIs are **NOT** guaranteed to be unique
|
// List of RTP header extensions. URIs are **NOT** guaranteed to be unique
|
||||||
// as they can appear twice when both encrypted and non-encrypted extensions
|
// as they can appear twice when both encrypted and non-encrypted extensions
|
||||||
|
@ -270,6 +272,7 @@ class MediaContentDescription {
|
||||||
|
|
||||||
// RingRTC: Allow out-of-band / "manual" key negotiation.
|
// RingRTC: Allow out-of-band / "manual" key negotiation.
|
||||||
absl::optional<CryptoParams> crypto_;
|
absl::optional<CryptoParams> crypto_;
|
||||||
|
bool manually_specify_keys_ = false;
|
||||||
std::vector<webrtc::RtpExtension> rtp_header_extensions_;
|
std::vector<webrtc::RtpExtension> rtp_header_extensions_;
|
||||||
bool rtp_header_extensions_set_ = false;
|
bool rtp_header_extensions_set_ = false;
|
||||||
StreamParamsVec send_streams_;
|
StreamParamsVec send_streams_;
|
||||||
|
|
|
@ -352,6 +352,7 @@ Rust_sessionDescriptionFromV4(bool offer,
|
||||||
|
|
||||||
auto set_rtp_params = [] (cricket::MediaContentDescription* media) {
|
auto set_rtp_params = [] (cricket::MediaContentDescription* media) {
|
||||||
media->set_protocol(cricket::kMediaProtocolSavpf);
|
media->set_protocol(cricket::kMediaProtocolSavpf);
|
||||||
|
media->set_manually_specify_keys(true);
|
||||||
media->set_rtcp_mux(true);
|
media->set_rtcp_mux(true);
|
||||||
media->set_direction(webrtc::RtpTransceiverDirection::kSendRecv);
|
media->set_direction(webrtc::RtpTransceiverDirection::kSendRecv);
|
||||||
};
|
};
|
||||||
|
@ -547,6 +548,7 @@ CreateSessionDescriptionForGroupCall(bool local,
|
||||||
media->set_protocol(cricket::kMediaProtocolSavpf);
|
media->set_protocol(cricket::kMediaProtocolSavpf);
|
||||||
media->set_rtcp_mux(true);
|
media->set_rtcp_mux(true);
|
||||||
|
|
||||||
|
media->set_manually_specify_keys(true);
|
||||||
media->set_crypto(crypto_params);
|
media->set_crypto(crypto_params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue