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:

committed by
Commit Bot

parent
5b69aa6613
commit
fcf5e7b131
@ -16,6 +16,8 @@
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
extern NSString *const kRTCRtpTransceiverErrorDomain;
|
||||
|
||||
/** https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection */
|
||||
typedef NS_ENUM(NSInteger, RTCRtpTransceiverDirection) {
|
||||
RTCRtpTransceiverDirectionSendRecv,
|
||||
@ -98,12 +100,9 @@ RTC_OBJC_EXPORT
|
||||
|
||||
/** The direction attribute indicates the preferred direction of this
|
||||
* transceiver, which will be used in calls to createOffer and createAnswer.
|
||||
* An update of directionality does not take effect immediately. Instead,
|
||||
* future calls to createOffer and createAnswer mark the corresponding media
|
||||
* descriptions as sendrecv, sendonly, recvonly, or inactive.
|
||||
* https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction
|
||||
*/
|
||||
@property(nonatomic) RTCRtpTransceiverDirection direction;
|
||||
@property(nonatomic, readonly) RTCRtpTransceiverDirection direction;
|
||||
|
||||
/** The currentDirection attribute indicates the current direction negotiated
|
||||
* for this transceiver. If this transceiver has never been represented in an
|
||||
@ -119,6 +118,13 @@ RTC_OBJC_EXPORT
|
||||
*/
|
||||
- (void)stopInternal;
|
||||
|
||||
/** An update of directionality does not take effect immediately. Instead,
|
||||
* future calls to createOffer and createAnswer mark the corresponding media
|
||||
* descriptions as sendrecv, sendonly, recvonly, or inactive.
|
||||
* https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiver-direction
|
||||
*/
|
||||
- (void)setDirection:(RTCRtpTransceiverDirection)direction error:(NSError **)error;
|
||||
|
||||
@end
|
||||
|
||||
RTC_OBJC_EXPORT
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user