iOS: Move AppRTC logging methods to public headers.
BUG= Review URL: https://codereview.webrtc.org/1241283004 Cr-Commit-Position: refs/heads/master@{#9629}
This commit is contained in:
@ -25,44 +25,40 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "ARDLogging.h"
|
||||
#import "RTCLogging.h"
|
||||
|
||||
#include "webrtc/base/logging.h"
|
||||
|
||||
void ARDLogInit() {
|
||||
#ifndef _DEBUG
|
||||
// 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.
|
||||
rtc::LogMessage::LogToDebug(rtc::LS_WARNING);
|
||||
#endif
|
||||
}
|
||||
|
||||
void ARDLogToWebRTCLogger(ARDLogSeverity severity, NSString *logString) {
|
||||
if (logString.length) {
|
||||
const char* utf8String = logString.UTF8String;
|
||||
switch (severity) {
|
||||
case kARDLogSeverityVerbose:
|
||||
LOG(LS_VERBOSE) << utf8String;
|
||||
break;
|
||||
case kARDLogSeverityInfo:
|
||||
LOG(LS_INFO) << utf8String;
|
||||
break;
|
||||
case kARDLogSeverityWarning:
|
||||
LOG(LS_WARNING) << utf8String;
|
||||
break;
|
||||
case kARDLogSeverityError:
|
||||
LOG(LS_ERROR) << utf8String;
|
||||
break;
|
||||
}
|
||||
rtc::LoggingSeverity RTCGetNativeLoggingSeverity(RTCLoggingSeverity severity) {
|
||||
switch (severity) {
|
||||
case kRTCLoggingSeverityVerbose:
|
||||
return rtc::LS_VERBOSE;
|
||||
case kRTCLoggingSeverityInfo:
|
||||
return rtc::LS_INFO;
|
||||
case kRTCLoggingSeverityWarning:
|
||||
return rtc::LS_WARNING;
|
||||
case kRTCLoggingSeverityError:
|
||||
return rtc::LS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
NSString *ARDFileName(const char *filePath) {
|
||||
NSString *nsFilePath =
|
||||
[[NSString alloc] initWithBytesNoCopy:const_cast<char *>(filePath)
|
||||
void RTCLogEx(RTCLoggingSeverity severity, NSString* logString) {
|
||||
if (logString.length) {
|
||||
const char* utf8String = logString.UTF8String;
|
||||
LOG_V(RTCGetNativeLoggingSeverity(severity)) << utf8String;
|
||||
}
|
||||
}
|
||||
|
||||
void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity) {
|
||||
rtc::LogMessage::LogToDebug(RTCGetNativeLoggingSeverity(severity));
|
||||
}
|
||||
|
||||
NSString* RTCFileName(const char* filePath) {
|
||||
NSString* nsFilePath =
|
||||
[[NSString alloc] initWithBytesNoCopy:const_cast<char*>(filePath)
|
||||
length:strlen(filePath)
|
||||
encoding:NSUTF8StringEncoding
|
||||
freeWhenDone:NO];
|
||||
return nsFilePath.lastPathComponent;
|
||||
}
|
||||
|
@ -27,62 +27,66 @@
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
// We route all logging through the WebRTC logger. By doing this we will get
|
||||
// both app and WebRTC logs in the same place, which we can then route to a
|
||||
// file if we need to. A side effect of this is that we get severity for free.
|
||||
typedef NS_ENUM(NSInteger, ARDLogSeverity) {
|
||||
kARDLogSeverityVerbose,
|
||||
kARDLogSeverityInfo,
|
||||
kARDLogSeverityWarning,
|
||||
kARDLogSeverityError,
|
||||
// Subset of rtc::LoggingSeverity.
|
||||
typedef NS_ENUM(NSInteger, RTCLoggingSeverity) {
|
||||
kRTCLoggingSeverityVerbose,
|
||||
kRTCLoggingSeverityInfo,
|
||||
kRTCLoggingSeverityWarning,
|
||||
kRTCLoggingSeverityError,
|
||||
};
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" void ARDLogToWebRTCLogger(ARDLogSeverity severity,
|
||||
NSString *logString);
|
||||
extern "C" NSString *ARDFileName(const char *filePath);
|
||||
extern "C" void ARDLogInit();
|
||||
extern "C" void RTCLogEx(RTCLoggingSeverity severity, NSString* logString);
|
||||
extern "C" void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity);
|
||||
extern "C" NSString* RTCFileName(const char* filePath);
|
||||
#else
|
||||
// Logs |logString| to the WebRTC logger at the given severity.
|
||||
extern void ARDLogToWebRTCLogger(ARDLogSeverity severity, NSString *logString);
|
||||
|
||||
// Wrapper for C++ LOG(sev) macros.
|
||||
// Logs the log string to the webrtc logstream for the given severity.
|
||||
extern void RTCLogEx(RTCLoggingSeverity severity, NSString* logString);
|
||||
|
||||
// Wrapper for rtc::LogMessage::LogToDebug.
|
||||
// Sets the minimum severity to be logged to console.
|
||||
extern void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity);
|
||||
|
||||
// Returns the filename with the path prefix removed.
|
||||
extern NSString *ARDFileName(const char *filePath);
|
||||
// Initializes the correct logging levels. This should be called once on app
|
||||
// startup.
|
||||
extern void ARDLogInit();
|
||||
extern NSString* RTCFileName(const char* filePath);
|
||||
|
||||
#endif
|
||||
|
||||
#define ARDLogString(format, ...) \
|
||||
// Some convenience macros.
|
||||
|
||||
#define RTCLogString(format, ...) \
|
||||
[NSString stringWithFormat:@"(%@:%d %s): " format, \
|
||||
ARDFileName(__FILE__), \
|
||||
RTCFileName(__FILE__), \
|
||||
__LINE__, \
|
||||
__FUNCTION__, \
|
||||
##__VA_ARGS__]
|
||||
|
||||
#define ARDLogEx(severity, format, ...) \
|
||||
#define RTCLogFormat(severity, format, ...) \
|
||||
do { \
|
||||
NSString *logString = ARDLogString(format, ##__VA_ARGS__); \
|
||||
ARDLogToWebRTCLogger(severity, logString); \
|
||||
NSString *logString = RTCLogString(format, ##__VA_ARGS__); \
|
||||
RTCLogEx(severity, logString); \
|
||||
} while (false)
|
||||
|
||||
#define ARDLogVerbose(format, ...) \
|
||||
ARDLogEx(kARDLogSeverityVerbose, format, ##__VA_ARGS__) \
|
||||
#define RTCLogVerbose(format, ...) \
|
||||
RTCLogFormat(kRTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \
|
||||
|
||||
#define ARDLogInfo(format, ...) \
|
||||
ARDLogEx(kARDLogSeverityInfo, format, ##__VA_ARGS__) \
|
||||
#define RTCLogInfo(format, ...) \
|
||||
RTCLogFormat(kRTCLoggingSeverityInfo, format, ##__VA_ARGS__) \
|
||||
|
||||
#define ARDLogWarning(format, ...) \
|
||||
ARDLogEx(kARDLogSeverityWarning, format, ##__VA_ARGS__) \
|
||||
#define RTCLogWarning(format, ...) \
|
||||
RTCLogFormat(kRTCLoggingSeverityWarning, format, ##__VA_ARGS__) \
|
||||
|
||||
#define ARDLogError(format, ...) \
|
||||
ARDLogEx(kARDLogSeverityError, format, ##__VA_ARGS__) \
|
||||
#define RTCLogError(format, ...) \
|
||||
RTCLogFormat(kRTCLoggingSeverityError, format, ##__VA_ARGS__) \
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define ARDLogDebug(format, ...) ARDLogInfo(format, ##__VA_ARGS__)
|
||||
#define RTCLogDebug(format, ...) RTCLogInfo(format, ##__VA_ARGS__)
|
||||
#else
|
||||
#define ARDLogDebug(format, ...) \
|
||||
#define RTCLogDebug(format, ...) \
|
||||
do { \
|
||||
} while (false)
|
||||
#endif
|
||||
|
||||
#define ARDLog(format, ...) ARDLogInfo(format, ##__VA_ARGS__)
|
||||
#define RTCLog(format, ...) RTCLogInfo(format, ##__VA_ARGS__)
|
@ -32,17 +32,16 @@
|
||||
#endif
|
||||
#import "RTCFileLogger.h"
|
||||
#import "RTCICEServer.h"
|
||||
#import "RTCLogging.h"
|
||||
#import "RTCMediaConstraints.h"
|
||||
#import "RTCMediaStream.h"
|
||||
#import "RTCPair.h"
|
||||
#import "RTCPeerConnectionInterface.h"
|
||||
#import "RTCVideoCapturer.h"
|
||||
#import "RTCAVFoundationVideoSource.h"
|
||||
|
||||
#import "ARDAppEngineClient.h"
|
||||
#import "ARDCEODTURNClient.h"
|
||||
#import "ARDJoinResponse.h"
|
||||
#import "ARDLogging.h"
|
||||
#import "ARDMessageResponse.h"
|
||||
#import "ARDSDPUtils.h"
|
||||
#import "ARDSignalingMessage.h"
|
||||
@ -162,7 +161,8 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
||||
[_turnClient requestServersWithCompletionHandler:^(NSArray *turnServers,
|
||||
NSError *error) {
|
||||
if (error) {
|
||||
ARDLog("Error retrieving TURN servers: %@", error.localizedDescription);
|
||||
RTCLogError("Error retrieving TURN servers: %@",
|
||||
error.localizedDescription);
|
||||
}
|
||||
ARDAppClient *strongSelf = weakSelf;
|
||||
[strongSelf.iceServers addObjectsFromArray:turnServers];
|
||||
@ -181,12 +181,12 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
||||
NSError *joinError =
|
||||
[[strongSelf class] errorForJoinResultType:response.result];
|
||||
if (joinError) {
|
||||
ARDLog(@"Failed to join room:%@ on room server.", roomId);
|
||||
RTCLogError(@"Failed to join room:%@ on room server.", roomId);
|
||||
[strongSelf disconnect];
|
||||
[strongSelf.delegate appClient:strongSelf didError:joinError];
|
||||
return;
|
||||
}
|
||||
ARDLog(@"Joined room:%@ on room server.", roomId);
|
||||
RTCLog(@"Joined room:%@ on room server.", roomId);
|
||||
strongSelf.roomId = response.roomId;
|
||||
strongSelf.clientId = response.clientId;
|
||||
strongSelf.isInitiator = response.isInitiator;
|
||||
@ -278,13 +278,13 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
||||
|
||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||
signalingStateChanged:(RTCSignalingState)stateChanged {
|
||||
ARDLog(@"Signaling state changed: %d", stateChanged);
|
||||
RTCLog(@"Signaling state changed: %d", stateChanged);
|
||||
}
|
||||
|
||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||
addedStream:(RTCMediaStream *)stream {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
ARDLog(@"Received %lu video tracks and %lu audio tracks",
|
||||
RTCLog(@"Received %lu video tracks and %lu audio tracks",
|
||||
(unsigned long)stream.videoTracks.count,
|
||||
(unsigned long)stream.audioTracks.count);
|
||||
if (stream.videoTracks.count) {
|
||||
@ -296,17 +296,17 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
||||
|
||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||
removedStream:(RTCMediaStream *)stream {
|
||||
ARDLog(@"Stream was removed.");
|
||||
RTCLog(@"Stream was removed.");
|
||||
}
|
||||
|
||||
- (void)peerConnectionOnRenegotiationNeeded:
|
||||
(RTCPeerConnection *)peerConnection {
|
||||
ARDLog(@"WARNING: Renegotiation needed but unimplemented.");
|
||||
RTCLog(@"WARNING: Renegotiation needed but unimplemented.");
|
||||
}
|
||||
|
||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||
iceConnectionChanged:(RTCICEConnectionState)newState {
|
||||
ARDLog(@"ICE state changed: %d", newState);
|
||||
RTCLog(@"ICE state changed: %d", newState);
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
[_delegate appClient:self didChangeConnectionState:newState];
|
||||
});
|
||||
@ -314,7 +314,7 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
||||
|
||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||
iceGatheringChanged:(RTCICEGatheringState)newState {
|
||||
ARDLog(@"ICE gathering state changed: %d", newState);
|
||||
RTCLog(@"ICE gathering state changed: %d", newState);
|
||||
}
|
||||
|
||||
- (void)peerConnection:(RTCPeerConnection *)peerConnection
|
||||
@ -339,7 +339,7 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
||||
error:(NSError *)error {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (error) {
|
||||
ARDLog(@"Failed to create session description. Error: %@", error);
|
||||
RTCLogError(@"Failed to create session description. Error: %@", error);
|
||||
[self disconnect];
|
||||
NSDictionary *userInfo = @{
|
||||
NSLocalizedDescriptionKey: @"Failed to create session description.",
|
||||
@ -368,7 +368,7 @@ static NSInteger const kARDAppClientErrorInvalidRoom = -6;
|
||||
didSetSessionDescriptionWithError:(NSError *)error {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (error) {
|
||||
ARDLog(@"Failed to set session description. Error: %@", error);
|
||||
RTCLogError(@"Failed to set session description. Error: %@", error);
|
||||
[self disconnect];
|
||||
NSDictionary *userInfo = @{
|
||||
NSLocalizedDescriptionKey: @"Failed to set session description.",
|
||||
|
@ -27,8 +27,9 @@
|
||||
|
||||
#import "ARDAppEngineClient.h"
|
||||
|
||||
#import "RTCLogging.h"
|
||||
|
||||
#import "ARDJoinResponse.h"
|
||||
#import "ARDLogging.h"
|
||||
#import "ARDMessageResponse.h"
|
||||
#import "ARDSignalingMessage.h"
|
||||
#import "ARDUtilities.h"
|
||||
@ -58,7 +59,7 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
|
||||
NSString *urlString =
|
||||
[NSString stringWithFormat:kARDRoomServerJoinFormat, roomId];
|
||||
NSURL *roomURL = [NSURL URLWithString:urlString];
|
||||
ARDLog(@"Joining room:%@ on room server.", roomId);
|
||||
RTCLog(@"Joining room:%@ on room server.", roomId);
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:roomURL];
|
||||
request.HTTPMethod = @"POST";
|
||||
__weak ARDAppEngineClient *weakSelf = self;
|
||||
@ -102,7 +103,7 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
|
||||
[NSString stringWithFormat:
|
||||
kARDRoomServerMessageFormat, roomId, clientId];
|
||||
NSURL *url = [NSURL URLWithString:urlString];
|
||||
ARDLog(@"C->RS POST: %@", message);
|
||||
RTCLog(@"C->RS POST: %@", message);
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
|
||||
request.HTTPMethod = @"POST";
|
||||
request.HTTPBody = data;
|
||||
@ -148,19 +149,19 @@ static NSInteger const kARDAppEngineClientErrorBadResponse = -1;
|
||||
NSError *error = nil;
|
||||
// We want a synchronous request so that we know that we've left the room on
|
||||
// room server before we do any further work.
|
||||
ARDLog(@"C->RS: BYE");
|
||||
RTCLog(@"C->RS: BYE");
|
||||
[NSURLConnection sendSynchronousRequest:request
|
||||
returningResponse:&response
|
||||
error:&error];
|
||||
if (error) {
|
||||
ARDLog(@"Error leaving room %@ on room server: %@",
|
||||
RTCLogError(@"Error leaving room %@ on room server: %@",
|
||||
roomId, error.localizedDescription);
|
||||
if (completionHandler) {
|
||||
completionHandler(error);
|
||||
}
|
||||
return;
|
||||
}
|
||||
ARDLog(@"Left room:%@ on room server.", roomId);
|
||||
RTCLog(@"Left room:%@ on room server.", roomId);
|
||||
if (completionHandler) {
|
||||
completionHandler(nil);
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#import "ARDSDPUtils.h"
|
||||
|
||||
#import "ARDLogging.h"
|
||||
#import "RTCLogging.h"
|
||||
#import "RTCSessionDescription.h"
|
||||
|
||||
@implementation ARDSDPUtils
|
||||
@ -71,11 +71,11 @@
|
||||
}
|
||||
}
|
||||
if (mLineIndex == -1) {
|
||||
ARDLog(@"No m=video line, so can't prefer %@", codec);
|
||||
RTCLog(@"No m=video line, so can't prefer %@", codec);
|
||||
return description;
|
||||
}
|
||||
if (!codecRtpMap) {
|
||||
ARDLog(@"No rtpmap for %@", codec);
|
||||
RTCLog(@"No rtpmap for %@", codec);
|
||||
return description;
|
||||
}
|
||||
NSArray *origMLineParts =
|
||||
@ -99,7 +99,7 @@
|
||||
[lines replaceObjectAtIndex:mLineIndex
|
||||
withObject:newMLine];
|
||||
} else {
|
||||
ARDLog(@"Wrong SDP media description format: %@", lines[mLineIndex]);
|
||||
RTCLogWarning(@"Wrong SDP media description format: %@", lines[mLineIndex]);
|
||||
}
|
||||
NSString *mangledSdpString = [lines componentsJoinedByString:lineSeparator];
|
||||
return [[RTCSessionDescription alloc] initWithType:description.type
|
||||
|
@ -27,7 +27,8 @@
|
||||
|
||||
#import "ARDSignalingMessage.h"
|
||||
|
||||
#import "ARDLogging.h"
|
||||
#import "RTCLogging.h"
|
||||
|
||||
#import "ARDUtilities.h"
|
||||
#import "RTCICECandidate+JSON.h"
|
||||
#import "RTCSessionDescription+JSON.h"
|
||||
@ -53,7 +54,7 @@ static NSString const *kARDSignalingMessageTypeKey = @"type";
|
||||
+ (ARDSignalingMessage *)messageFromJSONString:(NSString *)jsonString {
|
||||
NSDictionary *values = [NSDictionary dictionaryWithJSONString:jsonString];
|
||||
if (!values) {
|
||||
ARDLog(@"Error parsing signaling message JSON.");
|
||||
RTCLogError(@"Error parsing signaling message JSON.");
|
||||
return nil;
|
||||
}
|
||||
|
||||
@ -72,7 +73,7 @@ static NSString const *kARDSignalingMessageTypeKey = @"type";
|
||||
} else if ([typeString isEqualToString:@"bye"]) {
|
||||
message = [[ARDByeMessage alloc] init];
|
||||
} else {
|
||||
ARDLog(@"Unexpected type: %@", typeString);
|
||||
RTCLogError(@"Unexpected type: %@", typeString);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
@ -27,10 +27,11 @@
|
||||
|
||||
#import "ARDWebSocketChannel.h"
|
||||
|
||||
#import "ARDLogging.h"
|
||||
#import "ARDUtilities.h"
|
||||
#import "RTCLogging.h"
|
||||
#import "SRWebSocket.h"
|
||||
|
||||
#import "ARDUtilities.h"
|
||||
|
||||
// TODO(tkchin): move these to a configuration object.
|
||||
static NSString const *kARDWSSMessageErrorKey = @"error";
|
||||
static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
@ -58,7 +59,7 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
_delegate = delegate;
|
||||
_socket = [[SRWebSocket alloc] initWithURL:url];
|
||||
_socket.delegate = self;
|
||||
ARDLog(@"Opening WebSocket.");
|
||||
RTCLog(@"Opening WebSocket.");
|
||||
[_socket open];
|
||||
}
|
||||
return self;
|
||||
@ -105,12 +106,12 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
NSString *messageString =
|
||||
[[NSString alloc] initWithData:messageJSONObject
|
||||
encoding:NSUTF8StringEncoding];
|
||||
ARDLog(@"C->WSS: %@", messageString);
|
||||
RTCLog(@"C->WSS: %@", messageString);
|
||||
[_socket send:messageString];
|
||||
} else {
|
||||
NSString *dataString =
|
||||
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
ARDLog(@"C->WSS POST: %@", dataString);
|
||||
RTCLog(@"C->WSS POST: %@", dataString);
|
||||
NSString *urlString =
|
||||
[NSString stringWithFormat:@"%@/%@/%@",
|
||||
[_restURL absoluteString], _roomId, _clientId];
|
||||
@ -127,7 +128,7 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
return;
|
||||
}
|
||||
[_socket close];
|
||||
ARDLog(@"C->WSS DELETE rid:%@ cid:%@", _roomId, _clientId);
|
||||
RTCLog(@"C->WSS DELETE rid:%@ cid:%@", _roomId, _clientId);
|
||||
NSString *urlString =
|
||||
[NSString stringWithFormat:@"%@/%@/%@",
|
||||
[_restURL absoluteString], _roomId, _clientId];
|
||||
@ -141,7 +142,7 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
#pragma mark - SRWebSocketDelegate
|
||||
|
||||
- (void)webSocketDidOpen:(SRWebSocket *)webSocket {
|
||||
ARDLog(@"WebSocket connection opened.");
|
||||
RTCLog(@"WebSocket connection opened.");
|
||||
self.state = kARDSignalingChannelStateOpen;
|
||||
if (_roomId.length && _clientId.length) {
|
||||
[self registerWithCollider];
|
||||
@ -155,24 +156,24 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
options:0
|
||||
error:nil];
|
||||
if (![jsonObject isKindOfClass:[NSDictionary class]]) {
|
||||
ARDLog(@"Unexpected message: %@", jsonObject);
|
||||
RTCLogError(@"Unexpected message: %@", jsonObject);
|
||||
return;
|
||||
}
|
||||
NSDictionary *wssMessage = jsonObject;
|
||||
NSString *errorString = wssMessage[kARDWSSMessageErrorKey];
|
||||
if (errorString.length) {
|
||||
ARDLog(@"WSS error: %@", errorString);
|
||||
RTCLogError(@"WSS error: %@", errorString);
|
||||
return;
|
||||
}
|
||||
NSString *payload = wssMessage[kARDWSSMessagePayloadKey];
|
||||
ARDSignalingMessage *signalingMessage =
|
||||
[ARDSignalingMessage messageFromJSONString:payload];
|
||||
ARDLog(@"WSS->C: %@", payload);
|
||||
RTCLog(@"WSS->C: %@", payload);
|
||||
[_delegate channel:self didReceiveMessage:signalingMessage];
|
||||
}
|
||||
|
||||
- (void)webSocket:(SRWebSocket *)webSocket didFailWithError:(NSError *)error {
|
||||
ARDLog(@"WebSocket error: %@", error);
|
||||
RTCLogError(@"WebSocket error: %@", error);
|
||||
self.state = kARDSignalingChannelStateError;
|
||||
}
|
||||
|
||||
@ -180,7 +181,7 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
didCloseWithCode:(NSInteger)code
|
||||
reason:(NSString *)reason
|
||||
wasClean:(BOOL)wasClean {
|
||||
ARDLog(@"WebSocket closed with code: %ld reason:%@ wasClean:%d",
|
||||
RTCLog(@"WebSocket closed with code: %ld reason:%@ wasClean:%d",
|
||||
(long)code, reason, wasClean);
|
||||
NSParameterAssert(_state != kARDSignalingChannelStateError);
|
||||
self.state = kARDSignalingChannelStateClosed;
|
||||
@ -205,7 +206,7 @@ static NSString const *kARDWSSMessagePayloadKey = @"msg";
|
||||
error:nil];
|
||||
NSString *messageString =
|
||||
[[NSString alloc] initWithData:message encoding:NSUTF8StringEncoding];
|
||||
ARDLog(@"Registering on WSS for rid:%@ cid:%@", _roomId, _clientId);
|
||||
RTCLog(@"Registering on WSS for rid:%@ cid:%@", _roomId, _clientId);
|
||||
// Registration can fail if server rejects it. For example, if the room is
|
||||
// full.
|
||||
[_socket send:messageString];
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#import "RTCICECandidate+JSON.h"
|
||||
|
||||
#import "ARDLogging.h"
|
||||
#import "RTCLogging.h"
|
||||
|
||||
static NSString const *kRTCICECandidateTypeKey = @"type";
|
||||
static NSString const *kRTCICECandidateTypeValue = @"candidate";
|
||||
@ -58,7 +58,7 @@ static NSString const *kRTCICECandidateSdpKey = @"candidate";
|
||||
options:NSJSONWritingPrettyPrinted
|
||||
error:&error];
|
||||
if (error) {
|
||||
ARDLog(@"Error serializing JSON: %@", error);
|
||||
RTCLogError(@"Error serializing JSON: %@", error);
|
||||
return nil;
|
||||
}
|
||||
return data;
|
||||
|
@ -25,9 +25,10 @@
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#import "ARDLogging.h"
|
||||
#import "ARDUtilities.h"
|
||||
|
||||
#import "RTCLogging.h"
|
||||
|
||||
@implementation NSDictionary (ARDUtilites)
|
||||
|
||||
+ (NSDictionary *)dictionaryWithJSONString:(NSString *)jsonString {
|
||||
@ -37,7 +38,7 @@
|
||||
NSDictionary *dict =
|
||||
[NSJSONSerialization JSONObjectWithData:data options:0 error:&error];
|
||||
if (error) {
|
||||
ARDLog(@"Error parsing JSON: %@", error.localizedDescription);
|
||||
RTCLogError(@"Error parsing JSON: %@", error.localizedDescription);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
@ -47,7 +48,7 @@
|
||||
NSDictionary *dict =
|
||||
[NSJSONSerialization JSONObjectWithData:jsonData options:0 error:&error];
|
||||
if (error) {
|
||||
ARDLog(@"Error parsing JSON: %@", error.localizedDescription);
|
||||
RTCLogError(@"Error parsing JSON: %@", error.localizedDescription);
|
||||
}
|
||||
return dict;
|
||||
}
|
||||
@ -85,7 +86,7 @@
|
||||
NSData *data,
|
||||
NSError *error) {
|
||||
if (error) {
|
||||
ARDLog(@"Error posting data: %@", error.localizedDescription);
|
||||
RTCLogError(@"Error posting data: %@", error.localizedDescription);
|
||||
if (completionHandler) {
|
||||
completionHandler(NO, data);
|
||||
}
|
||||
@ -96,7 +97,7 @@
|
||||
NSString *serverResponse = data.length > 0 ?
|
||||
[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] :
|
||||
nil;
|
||||
ARDLog(@"Received bad response: %@", serverResponse);
|
||||
RTCLogError(@"Received bad response: %@", serverResponse);
|
||||
if (completionHandler) {
|
||||
completionHandler(NO, data);
|
||||
}
|
||||
|
@ -27,10 +27,11 @@
|
||||
|
||||
#import "ARDAppDelegate.h"
|
||||
|
||||
#import "ARDLogging.h"
|
||||
#import "ARDMainViewController.h"
|
||||
#import "RTCLogging.h"
|
||||
#import "RTCPeerConnectionFactory.h"
|
||||
|
||||
#import "ARDMainViewController.h"
|
||||
|
||||
@implementation ARDAppDelegate {
|
||||
UIWindow *_window;
|
||||
}
|
||||
@ -44,7 +45,14 @@
|
||||
[_window makeKeyAndVisible];
|
||||
ARDMainViewController *viewController = [[ARDMainViewController alloc] init];
|
||||
_window.rootViewController = viewController;
|
||||
ARDLogInit();
|
||||
|
||||
#ifndef _DEBUG
|
||||
// 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);
|
||||
#endif
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
@ -28,9 +28,9 @@
|
||||
#import "ARDVideoCallViewController.h"
|
||||
|
||||
#import "RTCAVFoundationVideoSource.h"
|
||||
#import "RTCLogging.h"
|
||||
|
||||
#import "ARDAppClient.h"
|
||||
#import "ARDLogging.h"
|
||||
#import "ARDVideoCallView.h"
|
||||
|
||||
@interface ARDVideoCallViewController () <ARDAppClientDelegate,
|
||||
@ -70,13 +70,13 @@
|
||||
didChangeState:(ARDAppClientState)state {
|
||||
switch (state) {
|
||||
case kARDAppClientStateConnected:
|
||||
ARDLog(@"Client connected.");
|
||||
RTCLog(@"Client connected.");
|
||||
break;
|
||||
case kARDAppClientStateConnecting:
|
||||
ARDLog(@"Client connecting.");
|
||||
RTCLog(@"Client connecting.");
|
||||
break;
|
||||
case kARDAppClientStateDisconnected:
|
||||
ARDLog(@"Client disconnected.");
|
||||
RTCLog(@"Client disconnected.");
|
||||
[self hangup];
|
||||
break;
|
||||
}
|
||||
@ -84,7 +84,7 @@
|
||||
|
||||
- (void)appClient:(ARDAppClient *)client
|
||||
didChangeConnectionState:(RTCICEConnectionState)state {
|
||||
ARDLog(@"ICE state changed: %d", state);
|
||||
RTCLog(@"ICE state changed: %d", state);
|
||||
__weak ARDVideoCallViewController *weakSelf = self;
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
ARDVideoCallViewController *strongSelf = weakSelf;
|
||||
|
@ -247,6 +247,7 @@
|
||||
'app/webrtc/objc/RTCICECandidate.mm',
|
||||
'app/webrtc/objc/RTCICEServer+Internal.h',
|
||||
'app/webrtc/objc/RTCICEServer.mm',
|
||||
'app/webrtc/objc/RTCLogging.mm',
|
||||
'app/webrtc/objc/RTCMediaConstraints+Internal.h',
|
||||
'app/webrtc/objc/RTCMediaConstraints.mm',
|
||||
'app/webrtc/objc/RTCMediaConstraintsNative.cc',
|
||||
@ -285,6 +286,7 @@
|
||||
'app/webrtc/objc/public/RTCI420Frame.h',
|
||||
'app/webrtc/objc/public/RTCICECandidate.h',
|
||||
'app/webrtc/objc/public/RTCICEServer.h',
|
||||
'app/webrtc/objc/public/RTCLogging.h',
|
||||
'app/webrtc/objc/public/RTCMediaConstraints.h',
|
||||
'app/webrtc/objc/public/RTCMediaSource.h',
|
||||
'app/webrtc/objc/public/RTCMediaStream.h',
|
||||
|
@ -155,9 +155,10 @@
|
||||
{
|
||||
'target_name': 'apprtc_common',
|
||||
'type': 'static_library',
|
||||
'dependencies': [
|
||||
'libjingle.gyp:libjingle_peerconnection_objc',
|
||||
],
|
||||
'sources': [
|
||||
'examples/objc/AppRTCDemo/common/ARDLogging.h',
|
||||
'examples/objc/AppRTCDemo/common/ARDLogging.mm',
|
||||
'examples/objc/AppRTCDemo/common/ARDUtilities.h',
|
||||
'examples/objc/AppRTCDemo/common/ARDUtilities.m',
|
||||
],
|
||||
|
Reference in New Issue
Block a user