Deprecate bad signature for CreateSessionDescription.

Bug: webrtc:360909068
Change-Id: I8640dcf3cb89b1e07ea6745887d152fdeb7479c9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/360020
Reviewed-by: Henrik Andreassson <henrika@webrtc.org>
Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42932}
This commit is contained in:
Kári Tristan Helgason 2024-08-30 12:38:27 +02:00 committed by WebRTC LUCI CQ
parent e432503389
commit 682f7945d5
6 changed files with 33 additions and 19 deletions

View File

@ -192,12 +192,14 @@ class RTC_EXPORT SessionDescriptionInterface {
// Creates a SessionDescriptionInterface based on the SDP string and the type.
// Returns null if the sdp string can't be parsed or the type is unsupported.
// `error` may be null.
// TODO(steveanton): This function is deprecated. Please use the functions below
// which take an SdpType enum instead. Remove this once it is no longer used.
RTC_EXPORT SessionDescriptionInterface* CreateSessionDescription(
const std::string& type,
const std::string& sdp,
SdpParseError* error);
// TODO(https://issues.webrtc.org/360909068): This function is deprecated.
// Please use the functions below which take an SdpType enum instead. Remove
// this once it is no longer used.
[[deprecated("Use version with SdpType argument")]] RTC_EXPORT
SessionDescriptionInterface*
CreateSessionDescription(const std::string& type,
const std::string& sdp,
SdpParseError* error);
// Creates a SessionDescriptionInterface based on the SDP string and the type.
// Returns null if the SDP string cannot be parsed.

View File

@ -1180,6 +1180,7 @@ if (is_ios || is_mac) {
":videoframebuffer_objc",
":videosource_objc",
":videotoolbox_objc",
"../api:libjingle_peerconnection_api",
"../api:scoped_refptr",
"../api/audio:audio_device",
"../api/audio:audio_processing",

View File

@ -13,6 +13,7 @@
#import "base/RTCLogging.h"
#import "helpers/NSString+StdString.h"
#include "api/jsep.h"
#include "rtc_base/checks.h"
@implementation RTC_OBJC_TYPE (RTCSessionDescription)
@ -51,7 +52,7 @@
webrtc::SdpParseError error;
std::unique_ptr<webrtc::SessionDescriptionInterface> description(webrtc::CreateSessionDescription(
[[self class] stdStringForType:_type], _sdp.stdString, &error));
[[self class] nativeTypeForType:_type], _sdp.stdString, &error));
if (!description) {
RTCLogError(@"Failed to create session description: %s\nline: %s",
@ -101,4 +102,17 @@
}
}
+ (webrtc::SdpType)nativeTypeForType:(RTCSdpType)type {
switch (type) {
case RTCSdpTypeOffer:
return webrtc::SdpType::kOffer;
case RTCSdpTypePrAnswer:
return webrtc::SdpType::kPrAnswer;
case RTCSdpTypeAnswer:
return webrtc::SdpType::kAnswer;
case RTCSdpTypeRollback:
return webrtc::SdpType::kRollback;
}
}
@end

View File

@ -11,6 +11,7 @@
#import <Foundation/Foundation.h>
#import <XCTest/XCTest.h>
#include "api/jsep.h"
#include "rtc_base/gunit.h"
#import "api/peerconnection/RTCSessionDescription+Private.h"
@ -42,15 +43,11 @@
}
- (void)testInitFromNativeSessionDescription {
webrtc::SessionDescriptionInterface *nativeDescription;
const auto nativeDescription =
webrtc::CreateSessionDescription(webrtc::SdpType::kAnswer, [self sdp].stdString, nullptr);
nativeDescription = webrtc::CreateSessionDescription(
webrtc::SessionDescriptionInterface::kAnswer,
[self sdp].stdString,
nullptr);
RTC_OBJC_TYPE(RTCSessionDescription) *description =
[[RTC_OBJC_TYPE(RTCSessionDescription) alloc] initWithNativeDescription:nativeDescription];
RTC_OBJC_TYPE(RTCSessionDescription) *description = [[RTC_OBJC_TYPE(RTCSessionDescription) alloc]
initWithNativeDescription:nativeDescription.get()];
EXPECT_EQ(webrtc::SessionDescriptionInterface::kAnswer,
[RTC_OBJC_TYPE(RTCSessionDescription) stdStringForType:description.type]);
EXPECT_TRUE([[self sdp] isEqualToString:description.sdp]);

View File

@ -30,8 +30,8 @@ class FuzzerTest : public PeerConnectionIntegrationBaseTest {
rtc::make_ref_counted<FakeSetRemoteDescriptionObserver>();
SdpParseError error;
std::unique_ptr<SessionDescriptionInterface> sdp(
CreateSessionDescription("offer", std::string(message), &error));
std::unique_ptr<SessionDescriptionInterface> sdp =
CreateSessionDescription(SdpType::kOffer, std::string(message), &error);
caller()->pc()->SetRemoteDescription(std::move(sdp), srd_observer);
// Wait a short time for observer to be called. Timeout is short
// because the fuzzer should be trying many branches.

View File

@ -21,8 +21,8 @@ void FuzzOneInput(const uint8_t* data, size_t size) {
std::string message(reinterpret_cast<const char*>(data), size);
webrtc::SdpParseError error;
std::unique_ptr<webrtc::SessionDescriptionInterface> sdp(
CreateSessionDescription("offer", message, &error));
std::unique_ptr<webrtc::SessionDescriptionInterface> sdp =
CreateSessionDescription(SdpType::kOffer, message, &error);
}
} // namespace webrtc