WebRTC audio and video calls - log output during WebRTC push-pull streaming

WebRTC audio and video calls - log output during WebRTC push-pull streaming

Previously, the iOS side called the ossrs service to implement the push-pull flow process.
Push flow: https://blog.csdn.net/gloryFlow/article/details/132262724
Pull flow: https://blog.csdn.net/gloryFlow/article/details/132417602

In the log output related to WebRTC during the push-pull flow, you can see some related description information. RTCCallbackLogger is required for WebRTC logs, and startWithMessageAndSeverityHandler is used to process log output.

insert image description here

1. Realize log output WebRTCLogger

Realize opening the log, and starting startWithMessageAndSeverityHandler will execute the logging callback.

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

The complete code is as follows

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

Two, use WebRTC Logger

We need to start WebRTCLogger, where we use it, and create an instance object.

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

Enable logging where needed

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

Close the day log when the push-pull stream is closed

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

So far, through webRTCLogger, you can see the relevant log information output by WebRTC during the push-pull flow process

Others
Before setting up the ossrs service, you can check: https://blog.csdn.net/gloryFlow/article/details/132257196
Before implementing iOS to call ossrs audio and video calls, you can check: https://blog.csdn.net/gloryFlow /article/details/132262724
Before WebRTC audio and video calls did not display high-resolution images, you can check: https://blog.csdn.net/gloryFlow/article/details/132240952
Modify the bit rate in SDP, you can check: https://blog.csdn.net/gloryFlow/article/details/132263021
GPUImage video call video beauty filter, you can view: https://blog.csdn.net/gloryFlow/article/details/132265842
RTC live local video Or album video, you can view: https://blog.csdn.net/gloryFlow/article/details/132267068
To achieve ossrs pull flow, you can view: https://blog.csdn.net/gloryFlow/article/details/132417602

3. Summary

WebRTC audio and video call - log output during WebRTC push-pull streaming. RTCCallbackLogger is required for WebRTC logs, and startWithMessageAndSeverityHandler is used to process log output.

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

Learning records, keep improving every day.

Guess you like

Origin blog.csdn.net/gloryFlow/article/details/132598363