151 lines
4.7 KiB
Objective-C
151 lines
4.7 KiB
Objective-C
//
|
||
// SCLiveStatsView.m
|
||
// SellyCloudSDK_Example
|
||
//
|
||
// Created by Caleb on 21/10/25.
|
||
// Copyright © 2025 Caleb. All rights reserved.
|
||
//
|
||
|
||
#import "SCLiveStatsView.h"
|
||
|
||
@interface SCLiveStatsView ()
|
||
@property (nonatomic, strong)UILabel *protocolLabel;
|
||
@property (nonatomic, strong)UILabel *appCPULabel;
|
||
@property (nonatomic, strong)UILabel *sysCPULabel;
|
||
@property (nonatomic, strong)UILabel *audioBitrateLabel;
|
||
@property (nonatomic, strong)UILabel *videoBitrateLabel;
|
||
@property (nonatomic, strong)UILabel *fpsLabel;
|
||
@property (nonatomic, strong)UILabel *rttLabel;
|
||
@end
|
||
|
||
@implementation SCLiveStatsView
|
||
|
||
- (instancetype)init
|
||
{
|
||
self = [super init];
|
||
if (self) {
|
||
self.backgroundColor = [UIColor colorWithWhite:0 alpha:0.1];
|
||
[self setupView];
|
||
}
|
||
return self;
|
||
}
|
||
|
||
- (void)setupView {
|
||
[self addSubview:self.protocolLabel];
|
||
[self.protocolLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.top.offset(10);
|
||
}];
|
||
|
||
[self addSubview:self.appCPULabel];
|
||
[self.appCPULabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.offset(10);
|
||
make.top.equalTo(self.protocolLabel.mas_bottom).offset(10);
|
||
}];
|
||
|
||
[self addSubview:self.sysCPULabel];
|
||
[self.sysCPULabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.offset(10);
|
||
make.top.equalTo(self.appCPULabel.mas_bottom).offset(10);
|
||
}];
|
||
|
||
[self addSubview:self.audioBitrateLabel];
|
||
[self.audioBitrateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.appCPULabel);
|
||
make.top.equalTo(self.sysCPULabel.mas_bottom).offset(10);
|
||
}];
|
||
|
||
[self addSubview:self.videoBitrateLabel];
|
||
[self.videoBitrateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.equalTo(self.appCPULabel);
|
||
make.top.equalTo(self.audioBitrateLabel.mas_bottom).offset(10);
|
||
}];
|
||
|
||
[self addSubview:self.fpsLabel];
|
||
[self.fpsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.offset(10);
|
||
make.top.equalTo(self.videoBitrateLabel.mas_bottom).offset(10);
|
||
}];
|
||
|
||
[self addSubview:self.rttLabel];
|
||
[self.rttLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||
make.left.offset(10);
|
||
make.top.equalTo(self.fpsLabel.mas_bottom).offset(10);
|
||
}];
|
||
|
||
}
|
||
|
||
- (void)setStats:(SellyLivePusherStats *)stats {
|
||
_stats = stats;
|
||
self.protocolLabel.text = [NSString stringWithFormat:@"protocol:%@",stats.protocol];
|
||
self.appCPULabel.text = [NSString stringWithFormat:@"app cpu:%ld%%",stats.appCpu];
|
||
self.sysCPULabel.text = [NSString stringWithFormat:@"system cpu:%ld%%",stats.systemCpu];
|
||
self.audioBitrateLabel.text = [NSString stringWithFormat:@"audio bitrate:%ld kbps",stats.audioBitrate];
|
||
self.videoBitrateLabel.text = [NSString stringWithFormat:@"video bitrate:%ld kbps",stats.videoBitrate];
|
||
self.fpsLabel.text = [NSString stringWithFormat:@"fps:%ld",stats.fps];
|
||
self.rttLabel.text = [NSString stringWithFormat:@"rtt:%ld ms",stats.rtt];
|
||
}
|
||
|
||
- (UILabel *)protocolLabel {
|
||
if (!_protocolLabel) {
|
||
_protocolLabel = [[UILabel alloc] init];
|
||
_protocolLabel.font = [UIFont systemFontOfSize:16];
|
||
_protocolLabel.textColor = UIColor.blackColor;
|
||
}
|
||
return _protocolLabel;
|
||
}
|
||
|
||
- (UILabel *)appCPULabel {
|
||
if (!_appCPULabel) {
|
||
_appCPULabel = [[UILabel alloc] init];
|
||
_appCPULabel.font = [UIFont systemFontOfSize:16];
|
||
_appCPULabel.textColor = UIColor.blackColor;
|
||
}
|
||
return _appCPULabel;
|
||
}
|
||
|
||
- (UILabel *)sysCPULabel {
|
||
if (!_sysCPULabel) {
|
||
_sysCPULabel = [[UILabel alloc] init];
|
||
_sysCPULabel.font = [UIFont systemFontOfSize:16];
|
||
_sysCPULabel.textColor = UIColor.blackColor;
|
||
}
|
||
return _sysCPULabel;
|
||
}
|
||
|
||
- (UILabel *)audioBitrateLabel {
|
||
if (!_audioBitrateLabel) {
|
||
_audioBitrateLabel = [[UILabel alloc] init];
|
||
_audioBitrateLabel.font = [UIFont systemFontOfSize:16];
|
||
_audioBitrateLabel.textColor = UIColor.blackColor;
|
||
}
|
||
return _audioBitrateLabel;
|
||
}
|
||
|
||
- (UILabel *)videoBitrateLabel {
|
||
if (!_videoBitrateLabel) {
|
||
_videoBitrateLabel = [[UILabel alloc] init];
|
||
_videoBitrateLabel.font = [UIFont systemFontOfSize:16];
|
||
_videoBitrateLabel.textColor = UIColor.blackColor;
|
||
}
|
||
return _videoBitrateLabel;
|
||
}
|
||
|
||
- (UILabel *)fpsLabel {
|
||
if (!_fpsLabel) {
|
||
_fpsLabel = [[UILabel alloc] init];
|
||
_fpsLabel.font = [UIFont systemFontOfSize:16];
|
||
_fpsLabel.textColor = UIColor.blackColor;
|
||
}
|
||
return _fpsLabel;
|
||
}
|
||
|
||
- (UILabel *)rttLabel {
|
||
if (!_rttLabel) {
|
||
_rttLabel = [[UILabel alloc] init];
|
||
_rttLabel.font = [UIFont systemFontOfSize:16];
|
||
_rttLabel.textColor = UIColor.blackColor;
|
||
}
|
||
return _rttLabel;
|
||
}
|
||
@end
|