From 8b9ca953a44ce074db848734cc8b3d6138d26e93 Mon Sep 17 00:00:00 2001 From: tkchin Date: Thu, 31 Mar 2016 12:08:03 -0700 Subject: [PATCH] Minor ObjC header updates. BUG= Review URL: https://codereview.webrtc.org/1845133002 Cr-Commit-Position: refs/heads/master@{#12183} --- webrtc/api/objc/RTCAVFoundationVideoSource.h | 1 - webrtc/api/objc/RTCAudioTrack+Private.h | 1 + webrtc/api/objc/RTCAudioTrack.h | 2 - webrtc/api/objc/RTCDataChannel.h | 22 +++++++--- webrtc/api/objc/RTCDataChannel.mm | 42 ++++++++++++------- webrtc/api/objc/RTCDataChannelConfiguration.h | 11 ++++- .../api/objc/RTCDataChannelConfiguration.mm | 22 ++++++++-- webrtc/api/objc/RTCVideoFrame.h | 1 + .../RTCDataChannelConfigurationTest.mm | 6 +-- webrtc/base/objc/RTCFileLogger.h | 17 +++++--- webrtc/base/objc/RTCFileLogger.mm | 20 ++++----- webrtc/base/objc/RTCLogging.h | 16 +++---- webrtc/base/objc/RTCLogging.mm | 8 ++-- webrtc/build/ios/export_headers | 17 +++++--- .../objc/AppRTCDemo/ios/ARDAppDelegate.m | 2 +- 15 files changed, 122 insertions(+), 66 deletions(-) diff --git a/webrtc/api/objc/RTCAVFoundationVideoSource.h b/webrtc/api/objc/RTCAVFoundationVideoSource.h index d7cdbef8ce..6d224d3f8e 100644 --- a/webrtc/api/objc/RTCAVFoundationVideoSource.h +++ b/webrtc/api/objc/RTCAVFoundationVideoSource.h @@ -38,5 +38,4 @@ NS_ASSUME_NONNULL_BEGIN @end - NS_ASSUME_NONNULL_END diff --git a/webrtc/api/objc/RTCAudioTrack+Private.h b/webrtc/api/objc/RTCAudioTrack+Private.h index bcedca65b6..ea86b1feaa 100644 --- a/webrtc/api/objc/RTCAudioTrack+Private.h +++ b/webrtc/api/objc/RTCAudioTrack+Private.h @@ -14,6 +14,7 @@ NS_ASSUME_NONNULL_BEGIN +@class RTCPeerConnectionFactory; @interface RTCAudioTrack () /** AudioTrackInterface created or passed in at construction. */ diff --git a/webrtc/api/objc/RTCAudioTrack.h b/webrtc/api/objc/RTCAudioTrack.h index 284206e7bc..c33a7b42bf 100644 --- a/webrtc/api/objc/RTCAudioTrack.h +++ b/webrtc/api/objc/RTCAudioTrack.h @@ -12,8 +12,6 @@ NS_ASSUME_NONNULL_BEGIN -@class RTCPeerConnectionFactory; - @interface RTCAudioTrack : RTCMediaStreamTrack - (instancetype)init NS_UNAVAILABLE; diff --git a/webrtc/api/objc/RTCDataChannel.h b/webrtc/api/objc/RTCDataChannel.h index 43f5767702..59ab2b8b26 100644 --- a/webrtc/api/objc/RTCDataChannel.h +++ b/webrtc/api/objc/RTCDataChannel.h @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#import #import NS_ASSUME_NONNULL_BEGIN @@ -32,7 +33,6 @@ NS_ASSUME_NONNULL_BEGIN @class RTCDataChannel; - @protocol RTCDataChannelDelegate /** The data channel state changed. */ @@ -43,7 +43,6 @@ NS_ASSUME_NONNULL_BEGIN didReceiveMessageWithBuffer:(RTCDataBuffer *)buffer; @optional - /** The data channel's |bufferedAmount| changed. */ - (void)dataChannel:(RTCDataChannel *)dataChannel didChangeBufferedAmount:(uint64_t)amount; @@ -53,12 +52,13 @@ NS_ASSUME_NONNULL_BEGIN /** Represents the state of the data channel. */ typedef NS_ENUM(NSInteger, RTCDataChannelState) { - RTCDataChannelStateConnecting, - RTCDataChannelStateOpen, - RTCDataChannelStateClosing, - RTCDataChannelStateClosed, + RTCDataChannelStateConnecting, + RTCDataChannelStateOpen, + RTCDataChannelStateClosing, + RTCDataChannelStateClosed, }; + @interface RTCDataChannel : NSObject /** @@ -67,9 +67,16 @@ typedef NS_ENUM(NSInteger, RTCDataChannelState) { */ @property(nonatomic, readonly) NSString *label; +/** Whether the data channel can send messages in unreliable mode. */ +@property(nonatomic, readonly) BOOL isReliable DEPRECATED_ATTRIBUTE; + /** Returns whether this data channel is ordered or not. */ @property(nonatomic, readonly) BOOL isOrdered; +/** Deprecated. Use maxPacketLifeTime. */ +@property(nonatomic, readonly) NSUInteger maxRetransmitTime + DEPRECATED_ATTRIBUTE; + /** * The length of the time window (in milliseconds) during which transmissions * and retransmissions may occur in unreliable mode. @@ -92,6 +99,9 @@ typedef NS_ENUM(NSInteger, RTCDataChannelState) { */ @property(nonatomic, readonly) BOOL isNegotiated; +/** Deprecated. Use channelId. */ +@property(nonatomic, readonly) NSInteger streamId DEPRECATED_ATTRIBUTE; + /** The identifier for this data channel. */ @property(nonatomic, readonly) int channelId; diff --git a/webrtc/api/objc/RTCDataChannel.mm b/webrtc/api/objc/RTCDataChannel.mm index 4be3a227be..a2c2e182ed 100644 --- a/webrtc/api/objc/RTCDataChannel.mm +++ b/webrtc/api/objc/RTCDataChannel.mm @@ -86,7 +86,7 @@ class DataChannelDelegateAdapter : public DataChannelObserver { @implementation RTCDataChannel { - rtc::scoped_refptr _nativDataChannel; + rtc::scoped_refptr _nativeDataChannel; rtc::scoped_ptr _observer; BOOL _isObserverRegistered; } @@ -100,40 +100,52 @@ class DataChannelDelegateAdapter : public DataChannelObserver { } - (NSString *)label { - return [NSString stringForStdString:_nativDataChannel->label()]; + return [NSString stringForStdString:_nativeDataChannel->label()]; +} + +- (BOOL)isReliable { + return _nativeDataChannel->reliable(); } - (BOOL)isOrdered { - return _nativDataChannel->ordered(); + return _nativeDataChannel->ordered(); +} + +- (NSUInteger)maxRetransmitTime { + return self.maxPacketLifeTime; } - (uint16_t)maxPacketLifeTime { - return _nativDataChannel->maxRetransmitTime(); + return _nativeDataChannel->maxRetransmitTime(); } - (uint16_t)maxRetransmits { - return _nativDataChannel->maxRetransmits(); + return _nativeDataChannel->maxRetransmits(); } - (NSString *)protocol { - return [NSString stringForStdString:_nativDataChannel->protocol()]; + return [NSString stringForStdString:_nativeDataChannel->protocol()]; } - (BOOL)isNegotiated { - return _nativDataChannel->negotiated(); + return _nativeDataChannel->negotiated(); +} + +- (NSInteger)streamId { + return self.channelId; } - (int)channelId { - return _nativDataChannel->id(); + return _nativeDataChannel->id(); } - (RTCDataChannelState)readyState { return [[self class] dataChannelStateForNativeState: - _nativDataChannel->state()]; + _nativeDataChannel->state()]; } - (uint64_t)bufferedAmount { - return _nativDataChannel->buffered_amount(); + return _nativeDataChannel->buffered_amount(); } - (void)setDelegate:(id)delegate { @@ -141,22 +153,22 @@ class DataChannelDelegateAdapter : public DataChannelObserver { return; } if (_isObserverRegistered) { - _nativDataChannel->UnregisterObserver(); + _nativeDataChannel->UnregisterObserver(); _isObserverRegistered = NO; } _delegate = delegate; if (_delegate) { - _nativDataChannel->RegisterObserver(_observer.get()); + _nativeDataChannel->RegisterObserver(_observer.get()); _isObserverRegistered = YES; } } - (void)close { - _nativDataChannel->Close(); + _nativeDataChannel->Close(); } - (BOOL)sendData:(RTCDataBuffer *)data { - return _nativDataChannel->Send(*data.nativeDataBuffer); + return _nativeDataChannel->Send(*data.nativeDataBuffer); } - (NSString *)description { @@ -173,7 +185,7 @@ class DataChannelDelegateAdapter : public DataChannelObserver { (rtc::scoped_refptr)nativeDataChannel { NSParameterAssert(nativeDataChannel); if (self = [super init]) { - _nativDataChannel = nativeDataChannel; + _nativeDataChannel = nativeDataChannel; _observer.reset(new webrtc::DataChannelDelegateAdapter(self)); } return self; diff --git a/webrtc/api/objc/RTCDataChannelConfiguration.h b/webrtc/api/objc/RTCDataChannelConfiguration.h index ef0562ed0a..fbe342d2c8 100644 --- a/webrtc/api/objc/RTCDataChannelConfiguration.h +++ b/webrtc/api/objc/RTCDataChannelConfiguration.h @@ -8,6 +8,7 @@ * be found in the AUTHORS file in the root of the source tree. */ +#import #import NS_ASSUME_NONNULL_BEGIN @@ -17,6 +18,9 @@ NS_ASSUME_NONNULL_BEGIN /** Set to YES if ordered delivery is required. */ @property(nonatomic, assign) BOOL isOrdered; +/** Deprecated. Use maxPacketLifeTime. */ +@property(nonatomic, assign) NSInteger maxRetransmitTimeMs DEPRECATED_ATTRIBUTE; + /** * Max period in milliseconds in which retransmissions will be sent. After this * time, no more retransmissions will be sent. -1 if unset. @@ -31,8 +35,11 @@ NS_ASSUME_NONNULL_BEGIN */ @property(nonatomic, assign) BOOL isNegotiated; -/** The stream id, or SID, for SCTP data channels. -1 if unset. */ -@property(nonatomic, assign) int streamId; +/** Deprecated. Use channelId. */ +@property(nonatomic, assign) int streamId DEPRECATED_ATTRIBUTE; + +/** The id of the data channel. */ +@property(nonatomic, assign) int channelId; /** Set by the application and opaque to the WebRTC implementation. */ @property(nonatomic) NSString *protocol; diff --git a/webrtc/api/objc/RTCDataChannelConfiguration.mm b/webrtc/api/objc/RTCDataChannelConfiguration.mm index 77de4eeb67..4a1dcb061c 100644 --- a/webrtc/api/objc/RTCDataChannelConfiguration.mm +++ b/webrtc/api/objc/RTCDataChannelConfiguration.mm @@ -25,6 +25,14 @@ _nativeDataChannelInit.ordered = isOrdered; } +- (NSInteger)maxRetransmitTimeMs { + return self.maxPacketLifeTime; +} + +- (void)setMaxRetransmitTimeMs:(NSInteger)maxRetransmitTimeMs { + self.maxPacketLifeTime = maxRetransmitTimeMs; +} + - (int)maxPacketLifeTime { return _nativeDataChannelInit.maxRetransmitTime; } @@ -58,11 +66,19 @@ } - (int)streamId { - return _nativeDataChannelInit.id; + return self.channelId; } - (void)setStreamId:(int)streamId { - _nativeDataChannelInit.id = streamId; + self.channelId = streamId; } -@end \ No newline at end of file +- (int)channelId { + return _nativeDataChannelInit.id; +} + +- (void)setChannelId:(int)channelId { + _nativeDataChannelInit.id = channelId; +} + +@end diff --git a/webrtc/api/objc/RTCVideoFrame.h b/webrtc/api/objc/RTCVideoFrame.h index 8ed23ba82c..8061047369 100644 --- a/webrtc/api/objc/RTCVideoFrame.h +++ b/webrtc/api/objc/RTCVideoFrame.h @@ -12,6 +12,7 @@ NS_ASSUME_NONNULL_BEGIN +// RTCVideoFrame is an ObjectiveC version of cricket::VideoFrame. @interface RTCVideoFrame : NSObject /** Width without rotation applied. */ diff --git a/webrtc/api/objctests/RTCDataChannelConfigurationTest.mm b/webrtc/api/objctests/RTCDataChannelConfigurationTest.mm index 2642717f42..1b3f21b8f9 100644 --- a/webrtc/api/objctests/RTCDataChannelConfigurationTest.mm +++ b/webrtc/api/objctests/RTCDataChannelConfigurationTest.mm @@ -27,7 +27,7 @@ int maxPacketLifeTime = 5; int maxRetransmits = 4; BOOL isNegotiated = YES; - int streamId = 4; + int channelId = 4; NSString *protocol = @"protocol"; RTCDataChannelConfiguration *dataChannelConfig = @@ -36,7 +36,7 @@ dataChannelConfig.maxPacketLifeTime = maxPacketLifeTime; dataChannelConfig.maxRetransmits = maxRetransmits; dataChannelConfig.isNegotiated = isNegotiated; - dataChannelConfig.streamId = streamId; + dataChannelConfig.channelId = channelId; dataChannelConfig.protocol = protocol; webrtc::DataChannelInit nativeInit = dataChannelConfig.nativeDataChannelInit; @@ -44,7 +44,7 @@ EXPECT_EQ(maxPacketLifeTime, nativeInit.maxRetransmitTime); EXPECT_EQ(maxRetransmits, nativeInit.maxRetransmits); EXPECT_EQ(isNegotiated, nativeInit.negotiated); - EXPECT_EQ(streamId, nativeInit.id); + EXPECT_EQ(channelId, nativeInit.id); EXPECT_EQ(protocol.stdString, nativeInit.protocol); } diff --git a/webrtc/base/objc/RTCFileLogger.h b/webrtc/base/objc/RTCFileLogger.h index c736012c25..281be4e31f 100644 --- a/webrtc/base/objc/RTCFileLogger.h +++ b/webrtc/base/objc/RTCFileLogger.h @@ -11,17 +11,19 @@ #import typedef NS_ENUM(NSUInteger, RTCFileLoggerSeverity) { - kRTCFileLoggerSeverityVerbose, - kRTCFileLoggerSeverityInfo, - kRTCFileLoggerSeverityWarning, - kRTCFileLoggerSeverityError + RTCFileLoggerSeverityVerbose, + RTCFileLoggerSeverityInfo, + RTCFileLoggerSeverityWarning, + RTCFileLoggerSeverityError }; typedef NS_ENUM(NSUInteger, RTCFileLoggerRotationType) { - kRTCFileLoggerTypeCall, - kRTCFileLoggerTypeApp, + RTCFileLoggerTypeCall, + RTCFileLoggerTypeApp, }; +NS_ASSUME_NONNULL_BEGIN + // This class intercepts WebRTC logs and saves them to a file. The file size // will not exceed the given maximum bytesize. When the maximum bytesize is // reached, logs are rotated according to the rotationType specified. @@ -67,3 +69,6 @@ typedef NS_ENUM(NSUInteger, RTCFileLoggerRotationType) { - (NSData *)logData; @end + +NS_ASSUME_NONNULL_END + diff --git a/webrtc/base/objc/RTCFileLogger.mm b/webrtc/base/objc/RTCFileLogger.mm index cc3a39d0be..bf61794bd1 100644 --- a/webrtc/base/objc/RTCFileLogger.mm +++ b/webrtc/base/objc/RTCFileLogger.mm @@ -45,7 +45,7 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; maxFileSize:(NSUInteger)maxFileSize { return [self initWithDirPath:dirPath maxFileSize:maxFileSize - rotationType:kRTCFileLoggerTypeCall]; + rotationType:RTCFileLoggerTypeCall]; } - (instancetype)initWithDirPath:(NSString *)dirPath @@ -72,7 +72,7 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; } _dirPath = dirPath; _maxFileSize = maxFileSize; - _severity = kRTCFileLoggerSeverityInfo; + _severity = RTCFileLoggerSeverityInfo; } return self; } @@ -86,14 +86,14 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; return; } switch (_rotationType) { - case kRTCFileLoggerTypeApp: + case RTCFileLoggerTypeApp: _logSink.reset( new rtc::FileRotatingLogSink(_dirPath.UTF8String, kRTCFileLoggerRotatingLogPrefix, _maxFileSize, _maxFileSize / 10)); break; - case kRTCFileLoggerTypeCall: + case RTCFileLoggerTypeCall: _logSink.reset( new rtc::CallSessionFileRotatingLogSink(_dirPath.UTF8String, _maxFileSize)); @@ -131,12 +131,12 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; NSMutableData* logData = [NSMutableData data]; rtc::scoped_ptr stream; switch(_rotationType) { - case kRTCFileLoggerTypeApp: + case RTCFileLoggerTypeApp: stream.reset( new rtc::FileRotatingStream(_dirPath.UTF8String, kRTCFileLoggerRotatingLogPrefix)); break; - case kRTCFileLoggerTypeCall: + case RTCFileLoggerTypeCall: stream.reset(new rtc::CallSessionFileRotatingStream(_dirPath.UTF8String)); break; } @@ -161,13 +161,13 @@ const char *kRTCFileLoggerRotatingLogPrefix = "rotating_log"; - (rtc::LoggingSeverity)rtcSeverity { switch (_severity) { - case kRTCFileLoggerSeverityVerbose: + case RTCFileLoggerSeverityVerbose: return rtc::LS_VERBOSE; - case kRTCFileLoggerSeverityInfo: + case RTCFileLoggerSeverityInfo: return rtc::LS_INFO; - case kRTCFileLoggerSeverityWarning: + case RTCFileLoggerSeverityWarning: return rtc::LS_WARNING; - case kRTCFileLoggerSeverityError: + case RTCFileLoggerSeverityError: return rtc::LS_ERROR; } } diff --git a/webrtc/base/objc/RTCLogging.h b/webrtc/base/objc/RTCLogging.h index 19fade5cfc..fbc4ffade2 100644 --- a/webrtc/base/objc/RTCLogging.h +++ b/webrtc/base/objc/RTCLogging.h @@ -12,10 +12,10 @@ // Subset of rtc::LoggingSeverity. typedef NS_ENUM(NSInteger, RTCLoggingSeverity) { - kRTCLoggingSeverityVerbose, - kRTCLoggingSeverityInfo, - kRTCLoggingSeverityWarning, - kRTCLoggingSeverityError, + RTCLoggingSeverityVerbose, + RTCLoggingSeverityInfo, + RTCLoggingSeverityWarning, + RTCLoggingSeverityError, }; #if defined(__cplusplus) @@ -53,16 +53,16 @@ extern NSString* RTCFileName(const char* filePath); } while (false) #define RTCLogVerbose(format, ...) \ - RTCLogFormat(kRTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \ + RTCLogFormat(RTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \ #define RTCLogInfo(format, ...) \ - RTCLogFormat(kRTCLoggingSeverityInfo, format, ##__VA_ARGS__) \ + RTCLogFormat(RTCLoggingSeverityInfo, format, ##__VA_ARGS__) \ #define RTCLogWarning(format, ...) \ - RTCLogFormat(kRTCLoggingSeverityWarning, format, ##__VA_ARGS__) \ + RTCLogFormat(RTCLoggingSeverityWarning, format, ##__VA_ARGS__) \ #define RTCLogError(format, ...) \ - RTCLogFormat(kRTCLoggingSeverityError, format, ##__VA_ARGS__) \ + RTCLogFormat(RTCLoggingSeverityError, format, ##__VA_ARGS__) \ #if !defined(NDEBUG) #define RTCLogDebug(format, ...) RTCLogInfo(format, ##__VA_ARGS__) diff --git a/webrtc/base/objc/RTCLogging.mm b/webrtc/base/objc/RTCLogging.mm index e9afe725d1..598d52de66 100644 --- a/webrtc/base/objc/RTCLogging.mm +++ b/webrtc/base/objc/RTCLogging.mm @@ -14,13 +14,13 @@ rtc::LoggingSeverity RTCGetNativeLoggingSeverity(RTCLoggingSeverity severity) { switch (severity) { - case kRTCLoggingSeverityVerbose: + case RTCLoggingSeverityVerbose: return rtc::LS_VERBOSE; - case kRTCLoggingSeverityInfo: + case RTCLoggingSeverityInfo: return rtc::LS_INFO; - case kRTCLoggingSeverityWarning: + case RTCLoggingSeverityWarning: return rtc::LS_WARNING; - case kRTCLoggingSeverityError: + case RTCLoggingSeverityError: return rtc::LS_ERROR; } } diff --git a/webrtc/build/ios/export_headers b/webrtc/build/ios/export_headers index 6808e67e14..84e738c050 100755 --- a/webrtc/build/ios/export_headers +++ b/webrtc/build/ios/export_headers @@ -18,16 +18,20 @@ import shutil import sys LEGACY_HEADER_DIRS = ['talk/app/webrtc/objc/public', 'webrtc/base/objc/'] -HEADER_DIRS = ['webrtc/api/objc/', 'webrtc/base/objc/'] +HEADER_DIRS = ['webrtc/api/objc/', 'webrtc/base/objc/', + 'webrtc/modules/audio_device/ios/objc'] # Individual header files that should also be exported. LEGACY_HEADER_INCLUDES = [] HEADER_INCLUDES = [] # Individual header files that should not be exported. LEGACY_HEADER_EXCLUDES = ['talk/app/webrtc/objc/public/RTCNSGLVideoView.h'] -HEADER_EXCLUDES = ['webrtc/api/objc/avfoundationvideocapturer.h', - 'webrtc/api/objc/RTCNSGLVideoView.h', - 'webrtc/base/objc/NSString+StdString.h', - 'webrtc/base/objc/RTCUIApplication.h',] +HEADER_EXCLUDES = [ + 'webrtc/api/objc/avfoundationvideocapturer.h', + 'webrtc/api/objc/RTCNSGLVideoView.h', + 'webrtc/base/objc/NSString+StdString.h', + 'webrtc/base/objc/RTCUIApplication.h', + 'webrtc/modules/audio_device/ios/objc/RTCAudioSessionDelegateAdapter.h', +] def ExportHeaders(include_base_dir, use_legacy_headers): """Exports iOS header files. @@ -41,6 +45,9 @@ def ExportHeaders(include_base_dir, use_legacy_headers): include_dir_name = 'include' include_path = os.path.join(include_base_dir, include_dir_name) + # Remove existing directory first in case files change. + if (os.path.exists(include_path)): + shutil.rmtree(include_path) script_path = sys.path[0] webrtc_base_path = os.path.join(script_path, '../../..') diff --git a/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m b/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m index b169ca41fb..c18c81827c 100644 --- a/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m +++ b/webrtc/examples/objc/AppRTCDemo/ios/ARDAppDelegate.m @@ -37,7 +37,7 @@ // In debug builds the default level is LS_INFO and in non-debug builds it is // disabled. Continue to log to console in non-debug builds, but only // warnings and errors. - RTCSetMinDebugLogLevel(kRTCLoggingSeverityWarning); + RTCSetMinDebugLogLevel(RTCLoggingSeverityWarning); #endif return YES;