Skip to content
This repository has been archived by the owner on Aug 25, 2023. It is now read-only.

Commit

Permalink
(QualityIssues) Add logic for new in-call video streams layout
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirBrejcha committed Jun 1, 2021
1 parent 947efe4 commit 113010a
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 8 deletions.
7 changes: 4 additions & 3 deletions QualityIssues/UI/QICallViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
#import <UIKit/UIKit.h>

@class VICall;
@class ConferenceView;

NS_ASSUME_NONNULL_BEGIN

@interface QICallViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>

@property (strong, nonatomic) IBOutlet UIView *remoteView;
@property (strong, nonatomic) IBOutlet UIView *localView;
@property (weak, nonatomic) IBOutlet ConferenceView *participantsVideoView;
@property (strong, nonatomic) IBOutlet UIButton *holdButton;
@property (strong, nonatomic) IBOutlet UIButton *hangUpButton;
@property (strong, nonatomic) IBOutlet UITextView *issuesView;
Expand All @@ -21,7 +21,8 @@ NS_ASSUME_NONNULL_BEGIN
- (IBAction)holdTouched:(UIButton *)sender;
- (IBAction)hangUpTouched:(UIButton *)sender;

@property (strong, nonatomic) VICall *currentCall;
@property(strong, nonatomic) VICall *currentCall;
@property(assign, nonatomic) BOOL isConferenceCall;

@end

Expand Down
68 changes: 63 additions & 5 deletions QualityIssues/UI/QICallViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "QICallViewController.h"
#import "QIIssueCollectionViewCell.h"
#import "VoxBranding.h"
#import "Quality_Issues-Swift.h"

@import VoxImplantSDK;

Expand All @@ -19,11 +20,17 @@ @interface QICallViewController () <VICallDelegate, VIEndpointDelegate, VIQualit

@implementation QICallViewController

const NSString *myID = @"me";
static NSString *reuseIdentifier = @"QIIssueCollectionViewCell";


- (void)viewDidLoad {
[super viewDidLoad];
__weak QICallViewController *wSelf = self;
[_participantsVideoView addParticipantWithId:(NSString *)myID name:nil];
_participantsVideoView.enlargeParticipantHandler = ^(BOOL enlarged) {
__strong QICallViewController *sSelf = wSelf;
[sSelf.issuesView setHidden:enlarged];
};
}

- (void)setCurrentCall:(VICall *)currentCall {
Expand Down Expand Up @@ -106,6 +113,18 @@ - (void) call:(VICall *)call
fromEndpoint:(VIEndpoint *)endpoint
issueLevel:(VIQualityIssueLevel)level {
[self appendText:[NSString stringWithFormat:@"NoVideoReceive from: %@", endpoint.user] withLevel:level];
if (level == VIQualityIssueLevelNone) {
[_participantsVideoView requestRenderingWithParticipantId:endpoint.endpointId
render:^(UIView *view) {
if (view) {
VIVideoRendererView *renderView = [[VIVideoRendererView alloc] initWithContainerView:view];
[videoStream addRenderer:renderView];
}
}];
} else if (level == VIQualityIssueLevelCritical) {
[_participantsVideoView stopRenderingWithParticipantId:endpoint.endpointId];
[videoStream removeAllRenderers];
}
}

- (void)holdTouched:(UIButton *)sender {
Expand Down Expand Up @@ -141,27 +160,66 @@ - (void)hangUpTouched:(UIButton *)sender {
}

- (void)call:(VICall *)call didAddLocalVideoStream:(VIVideoStream *)videoStream {
VIVideoRendererView *rendererView = [[VIVideoRendererView alloc] initWithContainerView:_localView];
[videoStream addRenderer:rendererView];
[_participantsVideoView requestRenderingWithParticipantId:(NSString *)myID
render:^(UIView *view) {
if (view) {
VIVideoRendererView *renderView = [[VIVideoRendererView alloc] initWithContainerView:view];
[videoStream addRenderer:renderView];
}
}];
}

- (void)call:(VICall *)call didRemoveLocalVideoStream:(VIVideoStream *)videoStream {
[_participantsVideoView stopRenderingWithParticipantId:(NSString *)myID];
[videoStream removeAllRenderers];
}

- (void)call:(VICall *)call didAddEndpoint:(VIEndpoint *)endpoint {
endpoint.delegate = self;
if (_isConferenceCall && [endpoint.endpointId isEqualToString:call.callId]) {
return;
}
[_participantsVideoView addParticipantWithId:endpoint.endpointId
name:endpoint.userDisplayName ?: endpoint.user];
}

- (void)endpoint:(VIEndpoint *)endpoint didAddRemoteVideoStream:(VIVideoStream *)videoStream {
VIVideoRendererView *rendererView = [[VIVideoRendererView alloc] initWithContainerView:_remoteView];
[videoStream addRenderer:rendererView];
if (_isConferenceCall && [endpoint.endpointId isEqualToString:endpoint.call.callId]) {
return;
}
[_participantsVideoView requestRenderingWithParticipantId:endpoint.endpointId
render:^(UIView *view) {
if (view) {
VIVideoRendererView *renderView = [[VIVideoRendererView alloc] initWithContainerView:view];
[videoStream addRenderer:renderView];
}
}];
}

- (void)endpoint:(VIEndpoint *)endpoint didRemoveRemoteVideoStream:(VIVideoStream *)videoStream {
if (_isConferenceCall && [endpoint.endpointId isEqualToString:endpoint.call.callId]) {
return;
}
[_participantsVideoView stopRenderingWithParticipantId:endpoint.endpointId];
[videoStream removeAllRenderers];
}

- (void)endpointDidRemove:(VIEndpoint *)endpoint {
endpoint.delegate = nil;
if (_isConferenceCall && [endpoint.endpointId isEqualToString:endpoint.call.callId]) {
return;
}
[_participantsVideoView removeParticipantWithId:endpoint.endpointId];
}

- (void)endpointInfoDidUpdate:(VIEndpoint *)endpoint {
if (_isConferenceCall && [endpoint.endpointId isEqualToString:endpoint.call.callId]) {
return;
}
[_participantsVideoView updateParticipantNameWithId:endpoint.endpointId
name:endpoint.userDisplayName ?: endpoint.user];
}

- (void)call:(VICall *)call didDisconnectWithHeaders:(NSDictionary *)headers answeredElsewhere:(NSNumber *)answeredElsewhere {
[self dismissViewControllerAnimated:YES completion:nil];
}
Expand Down
2 changes: 2 additions & 0 deletions QualityIssues/UI/QIDialerViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ - (void)callTouched:(UIButton *)sender {
withVideoFlags:videoFlags
conference:NO];
[self showCallViewController:^(QICallViewController *vc) {
vc.isConferenceCall = NO;
vc.currentCall = call;
[call start];
}];
Expand All @@ -37,6 +38,7 @@ - (void)callConferenceTouched:(UIButton *)sender {
withVideoFlags:videoFlags
conference:YES];
[self showCallViewController:^(QICallViewController *vc) {
vc.isConferenceCall = YES;
vc.currentCall = callConference;
[callConference start];
}];
Expand Down

0 comments on commit 113010a

Please sign in to comment.