Minor ObjC header updates.

BUG=

Review URL: https://codereview.webrtc.org/1845133002

Cr-Commit-Position: refs/heads/master@{#12183}
This commit is contained in:
tkchin 2016-03-31 12:08:03 -07:00 committed by Commit bot
parent 4a206a96c1
commit 8b9ca953a4
15 changed files with 122 additions and 66 deletions

View File

@ -38,5 +38,4 @@ NS_ASSUME_NONNULL_BEGIN
@end
NS_ASSUME_NONNULL_END

View File

@ -14,6 +14,7 @@
NS_ASSUME_NONNULL_BEGIN
@class RTCPeerConnectionFactory;
@interface RTCAudioTrack ()
/** AudioTrackInterface created or passed in at construction. */

View File

@ -12,8 +12,6 @@
NS_ASSUME_NONNULL_BEGIN
@class RTCPeerConnectionFactory;
@interface RTCAudioTrack : RTCMediaStreamTrack
- (instancetype)init NS_UNAVAILABLE;

View File

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#import <AvailabilityMacros.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@ -32,7 +33,6 @@ NS_ASSUME_NONNULL_BEGIN
@class RTCDataChannel;
@protocol RTCDataChannelDelegate <NSObject>
/** 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;

View File

@ -86,7 +86,7 @@ class DataChannelDelegateAdapter : public DataChannelObserver {
@implementation RTCDataChannel {
rtc::scoped_refptr<webrtc::DataChannelInterface> _nativDataChannel;
rtc::scoped_refptr<webrtc::DataChannelInterface> _nativeDataChannel;
rtc::scoped_ptr<webrtc::DataChannelDelegateAdapter> _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<RTCDataChannelDelegate>)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<webrtc::DataChannelInterface>)nativeDataChannel {
NSParameterAssert(nativeDataChannel);
if (self = [super init]) {
_nativDataChannel = nativeDataChannel;
_nativeDataChannel = nativeDataChannel;
_observer.reset(new webrtc::DataChannelDelegateAdapter(self));
}
return self;

View File

@ -8,6 +8,7 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#import <AvailabilityMacros.h>
#import <Foundation/Foundation.h>
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;

View File

@ -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
- (int)channelId {
return _nativeDataChannelInit.id;
}
- (void)setChannelId:(int)channelId {
_nativeDataChannelInit.id = channelId;
}
@end

View File

@ -12,6 +12,7 @@
NS_ASSUME_NONNULL_BEGIN
// RTCVideoFrame is an ObjectiveC version of cricket::VideoFrame.
@interface RTCVideoFrame : NSObject
/** Width without rotation applied. */

View File

@ -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);
}

View File

@ -11,17 +11,19 @@
#import <Foundation/Foundation.h>
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

View File

@ -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<rtc::FileRotatingStream> 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;
}
}

View File

@ -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__)

View File

@ -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;
}
}

View File

@ -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, '../../..')

View File

@ -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;