WebRTC音视频通话-WebRTC推拉流过程中日志log输出

WebRTC音视频通话-WebRTC推拉流过程中日志log输出

之前实现iOS端调用ossrs服务实现推拉流流程。
推流:https://blog.csdn.net/gloryFlow/article/details/132262724
拉流:https://blog.csdn.net/gloryFlow/article/details/132417602

在推拉流过程中的WebRTC的相关日志log输出可以看到一些相关描述信息。在WebRTC日志需要用到RTCCallbackLogger,使用startWithMessageAndSeverityHandler来处理日志输出。

WebRTC音视频通话-WebRTC推拉流过程中日志log输出_第1张图片

一、实现log输出WebRTCLogger

实现开启log,启动startWithMessageAndSeverityHandler将在执行日志记录回调。

- (void)start {
    __weak typeof(self) weakSelf = self;
    [weakSelf.logger startWithMessageAndSeverityHandler:^(NSString * _Nonnull message, RTCLoggingSeverity severity) {
        DebugLog(@"WebRTCLogger startWithMessageAndSeverityHandler severity:%@,message:%@", [weakSelf loggingSeverityDescription:severity], message);
    }];
}

完整代码如下

WebRTCLogger.h

#import <Foundation/Foundation.h>
#import <WebRTC/WebRTC.h>
#import <UIKit/UIKit.h>

@interface WebRTCLogger : NSObject

- (void)start;

- (void)stop;

@end

WebRTCLogger.m

#import "WebRTCLogger.h"

@interface WebRTCLogger ()

@property (nonatomic, strong) RTCCallbackLogger *logger;

@end

@implementation WebRTCLogger

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.logger.severity = RTCLoggingSeverityVerbose;
        // 设置日志记录器
        RTCSetMinDebugLogLevel(RTCLoggingSeverityVerbose);
    }
    return self;
}

- (void)start {
    __weak typeof(self) weakSelf = self;
    [weakSelf.logger startWithMessageAndSeverityHandler:^(NSString * _Nonnull message, RTCLoggingSeverity severity) {
        DebugLog(@"WebRTCLogger startWithMessageAndSeverityHandler severity:%@,message:%@", [weakSelf loggingSeverityDescription:severity], message);
    }];
}

- (void)stop {
    [self.logger stop];
}

- (NSString *)loggingSeverityDescription:(RTCLoggingSeverity)severity {
    if (RTCLoggingSeverityVerbose == severity) {
        return @"RTCLoggingSeverityVerbose";
    }
    
    if (RTCLoggingSeverityInfo == severity) {
        return @"RTCLoggingSeverityInfo";
    }
    
    if (RTCLoggingSeverityWarning == severity) {
        return @"RTCLoggingSeverityWarning";
    }
    
    if (RTCLoggingSeverityError == severity) {
        return @"RTCLoggingSeverityError";
    }
    
    if (RTCLoggingSeverityNone == severity) {
        return @"RTCLoggingSeverityNone";
    }
    
    return @"RTCLoggingSeverityNone";
}

#pragma mark - Lazy
- (RTCCallbackLogger *)logger {
    if (!_logger) {
        _logger = [[RTCCallbackLogger alloc] init];
    }
    return _logger;
}

@end

二、使用WebRTCLogger

我们需要启动WebRTCLogger,我们在使用地方,创建实例对象。

- (WebRTCLogger *)webRTCLogger {
    if (!_webRTCLogger) {
        _webRTCLogger = [[WebRTCLogger alloc] init];
    }
    return _webRTCLogger;
}

在需要的地方开启日志log

/**
 开启RTCLogger
 */
- (void)startWebRTCLogger {
    [self.webRTCLogger start];
}

当关闭推拉流后关闭日子log

/**
 停止RTCLogger
 */
- (void)stopWebRTCLogger {
    [self.webRTCLogger stop];
}

至此,通过webRTCLogger看到WebRTC在推拉流过程中输出的相关日志信息

其他
之前搭建ossrs服务,可以查看:https://blog.csdn.net/gloryFlow/article/details/132257196
之前实现iOS端调用ossrs音视频通话,可以查看:https://blog.csdn.net/gloryFlow/article/details/132262724
之前WebRTC音视频通话高分辨率不显示画面问题,可以查看:https://blog.csdn.net/gloryFlow/article/details/132240952
修改SDP中的码率Bitrate,可以查看:https://blog.csdn.net/gloryFlow/article/details/132263021
GPUImage视频通话视频美颜滤镜,可以查看:https://blog.csdn.net/gloryFlow/article/details/132265842
RTC直播本地视频或相册视频,可以查看:https://blog.csdn.net/gloryFlow/article/details/132267068
实现ossrs拉流,可以查看:https://blog.csdn.net/gloryFlow/article/details/132417602

三、小结

WebRTC音视频通话-WebRTC推拉流过程中日志log输出。在WebRTC日志需要用到RTCCallbackLogger,使用startWithMessageAndSeverityHandler来处理日志输出。

https://blog.csdn.net/gloryFlow/article/details/132598363

学习记录,每天不停进步。

你可能感兴趣的:(移动开发,iphone开发,Objective-c,webrtc,音视频,直播推流,直播拉流,直播,日志)