Make Objective-C interface use SetDirectionWithError

Also moves implementation of legacy setDirection() without error to the
api/ directory.

This is one step in the plan for changing the API
to return RTCError.

Bug: chromium:980879
Change-Id: Ibce8edf8e3c6d41de7ce49d2ffc33f5b282a0e9f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/181520
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31943}
This commit is contained in:
Harald Alvestrand
2020-08-17 10:07:26 +02:00
committed by Commit Bot
parent 5b69aa6613
commit fcf5e7b131
4 changed files with 23 additions and 12 deletions

View File

@ -17,6 +17,8 @@
#import "base/RTCLogging.h"
#import "helpers/NSString+StdString.h"
NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver";
@implementation RTC_OBJC_TYPE (RTCRtpTransceiverInit)
@synthesize direction = _direction;
@ -75,9 +77,18 @@
rtpTransceiverDirectionFromNativeDirection:_nativeRtpTransceiver->direction()];
}
- (void)setDirection:(RTCRtpTransceiverDirection)direction {
_nativeRtpTransceiver->SetDirection(
- (void)setDirection:(RTCRtpTransceiverDirection)direction error:(NSError **)error {
webrtc::RTCError nativeError = _nativeRtpTransceiver->SetDirectionWithError(
[RTC_OBJC_TYPE(RTCRtpTransceiver) nativeRtpTransceiverDirectionFromDirection:direction]);
if (!nativeError.ok() && error) {
*error = [NSError errorWithDomain:kRTCRtpTransceiverErrorDomain
code:static_cast<int>(nativeError.type())
userInfo:@{
@"message" : [NSString stringWithCString:nativeError.message()
encoding:NSUTF8StringEncoding]
}];
}
}
- (BOOL)currentDirection:(RTCRtpTransceiverDirection *)currentDirectionOut {