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
@ -299,10 +299,6 @@ RtpTransceiverDirection RtpTransceiver::direction() const {
|
|||||||
return direction_;
|
return direction_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RtpTransceiver::SetDirection(RtpTransceiverDirection new_direction) {
|
|
||||||
SetDirectionWithError(new_direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
RTCError RtpTransceiver::SetDirectionWithError(
|
RTCError RtpTransceiver::SetDirectionWithError(
|
||||||
RtpTransceiverDirection new_direction) {
|
RtpTransceiverDirection new_direction) {
|
||||||
if (unified_plan_ && stopping()) {
|
if (unified_plan_ && stopping()) {
|
||||||
|
@ -189,7 +189,6 @@ class RtpTransceiver final
|
|||||||
bool stopped() const override;
|
bool stopped() const override;
|
||||||
bool stopping() const override;
|
bool stopping() const override;
|
||||||
RtpTransceiverDirection direction() const override;
|
RtpTransceiverDirection direction() const override;
|
||||||
void SetDirection(RtpTransceiverDirection new_direction) override;
|
|
||||||
RTCError SetDirectionWithError(
|
RTCError SetDirectionWithError(
|
||||||
RtpTransceiverDirection new_direction) override;
|
RtpTransceiverDirection new_direction) override;
|
||||||
absl::optional<RtpTransceiverDirection> current_direction() const override;
|
absl::optional<RtpTransceiverDirection> current_direction() const override;
|
||||||
@ -248,7 +247,6 @@ PROXY_CONSTMETHOD0(rtc::scoped_refptr<RtpReceiverInterface>, receiver)
|
|||||||
PROXY_CONSTMETHOD0(bool, stopped)
|
PROXY_CONSTMETHOD0(bool, stopped)
|
||||||
PROXY_CONSTMETHOD0(bool, stopping)
|
PROXY_CONSTMETHOD0(bool, stopping)
|
||||||
PROXY_CONSTMETHOD0(RtpTransceiverDirection, direction)
|
PROXY_CONSTMETHOD0(RtpTransceiverDirection, direction)
|
||||||
PROXY_METHOD1(void, SetDirection, RtpTransceiverDirection)
|
|
||||||
PROXY_METHOD1(webrtc::RTCError, SetDirectionWithError, RtpTransceiverDirection)
|
PROXY_METHOD1(webrtc::RTCError, SetDirectionWithError, RtpTransceiverDirection)
|
||||||
PROXY_CONSTMETHOD0(absl::optional<RtpTransceiverDirection>, current_direction)
|
PROXY_CONSTMETHOD0(absl::optional<RtpTransceiverDirection>, current_direction)
|
||||||
PROXY_CONSTMETHOD0(absl::optional<RtpTransceiverDirection>, fired_direction)
|
PROXY_CONSTMETHOD0(absl::optional<RtpTransceiverDirection>, fired_direction)
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
|
extern NSString *const kRTCRtpTransceiverErrorDomain;
|
||||||
|
|
||||||
/** https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection */
|
/** https://w3c.github.io/webrtc-pc/#dom-rtcrtptransceiverdirection */
|
||||||
typedef NS_ENUM(NSInteger, RTCRtpTransceiverDirection) {
|
typedef NS_ENUM(NSInteger, RTCRtpTransceiverDirection) {
|
||||||
RTCRtpTransceiverDirectionSendRecv,
|
RTCRtpTransceiverDirectionSendRecv,
|
||||||
@ -98,12 +100,9 @@ RTC_OBJC_EXPORT
|
|||||||
|
|
||||||
/** The direction attribute indicates the preferred direction of this
|
/** The direction attribute indicates the preferred direction of this
|
||||||
* transceiver, which will be used in calls to createOffer and createAnswer.
|
* 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
|
* 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
|
/** The currentDirection attribute indicates the current direction negotiated
|
||||||
* for this transceiver. If this transceiver has never been represented in an
|
* for this transceiver. If this transceiver has never been represented in an
|
||||||
@ -119,6 +118,13 @@ RTC_OBJC_EXPORT
|
|||||||
*/
|
*/
|
||||||
- (void)stopInternal;
|
- (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
|
@end
|
||||||
|
|
||||||
RTC_OBJC_EXPORT
|
RTC_OBJC_EXPORT
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
#import "base/RTCLogging.h"
|
#import "base/RTCLogging.h"
|
||||||
#import "helpers/NSString+StdString.h"
|
#import "helpers/NSString+StdString.h"
|
||||||
|
|
||||||
|
NSString *const kRTCRtpTransceiverErrorDomain = @"org.webrtc.RTCRtpTranceiver";
|
||||||
|
|
||||||
@implementation RTC_OBJC_TYPE (RTCRtpTransceiverInit)
|
@implementation RTC_OBJC_TYPE (RTCRtpTransceiverInit)
|
||||||
|
|
||||||
@synthesize direction = _direction;
|
@synthesize direction = _direction;
|
||||||
@ -75,9 +77,18 @@
|
|||||||
rtpTransceiverDirectionFromNativeDirection:_nativeRtpTransceiver->direction()];
|
rtpTransceiverDirectionFromNativeDirection:_nativeRtpTransceiver->direction()];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setDirection:(RTCRtpTransceiverDirection)direction {
|
- (void)setDirection:(RTCRtpTransceiverDirection)direction error:(NSError **)error {
|
||||||
_nativeRtpTransceiver->SetDirection(
|
webrtc::RTCError nativeError = _nativeRtpTransceiver->SetDirectionWithError(
|
||||||
[RTC_OBJC_TYPE(RTCRtpTransceiver) nativeRtpTransceiverDirectionFromDirection:direction]);
|
[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 {
|
- (BOOL)currentDirection:(RTCRtpTransceiverDirection *)currentDirectionOut {
|
||||||
|
Reference in New Issue
Block a user