You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*
  2. * Copyright 2015 The WebRTC Project Authors. All rights reserved.
  3. *
  4. * Use of this source code is governed by a BSD-style license
  5. * that can be found in the LICENSE file in the root of the source
  6. * tree. An additional intellectual property rights grant can be found
  7. * in the file PATENTS. All contributing project authors may
  8. * be found in the AUTHORS file in the root of the source tree.
  9. */
  10. #import "ARDStatsView.h"
  11. #import <WebRTC/RTCLegacyStatsReport.h>
  12. #import "ARDStatsBuilder.h"
  13. @implementation ARDStatsView {
  14. UILabel *_statsLabel;
  15. ARDStatsBuilder *_statsBuilder;
  16. }
  17. - (instancetype)initWithFrame:(CGRect)frame {
  18. if (self = [super initWithFrame:frame]) {
  19. _statsLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  20. _statsLabel.numberOfLines = 0;
  21. _statsLabel.font = [UIFont fontWithName:@"Roboto" size:12];
  22. _statsLabel.adjustsFontSizeToFitWidth = YES;
  23. _statsLabel.minimumScaleFactor = 0.6;
  24. _statsLabel.textColor = [UIColor greenColor];
  25. [self addSubview:_statsLabel];
  26. self.backgroundColor = [UIColor colorWithWhite:0 alpha:.6];
  27. _statsBuilder = [[ARDStatsBuilder alloc] init];
  28. }
  29. return self;
  30. }
  31. - (void)setStats:(NSArray *)stats {
  32. for (RTCLegacyStatsReport *report in stats) {
  33. [_statsBuilder parseStatsReport:report];
  34. }
  35. _statsLabel.text = _statsBuilder.statsString;
  36. }
  37. - (void)layoutSubviews {
  38. _statsLabel.frame = self.bounds;
  39. }
  40. - (CGSize)sizeThatFits:(CGSize)size {
  41. return [_statsLabel sizeThatFits:size];
  42. }
  43. @end