Skip to content

Commit

Permalink
Return CallStackCall
Browse files Browse the repository at this point in the history
  • Loading branch information
artemkrachulov committed Sep 14, 2023
1 parent ad19168 commit a55cced
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
16 changes: 5 additions & 11 deletions MatrixSDK/VoIP/CallStack/MXCallStackCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@

NS_ASSUME_NONNULL_BEGIN

@class MXCall;

@protocol MXCallStackCallDelegate;

/**
Expand Down Expand Up @@ -64,7 +62,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
Terminate the call.
*/
- (void)endCall:(MXCall*)call;
- (void)end;

/**
Add TURN or STUN servers.
Expand Down Expand Up @@ -97,8 +95,7 @@ NS_ASSUME_NONNULL_BEGIN
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
*/
- (void)handleCall:(MXCall*)call
offer:(NSString *)sdpOffer
- (void)handleOffer:(NSString *)sdpOffer
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure;

Expand All @@ -114,8 +111,7 @@ NS_ASSUME_NONNULL_BEGIN
of the answer.
@param failure A block object called when the operation fails.
*/
- (void)createAnswer:(MXCall*)call
success:(void (^)(NSString *sdpAnswer))success
- (void)createAnswer:(void (^)(NSString *sdpAnswer))success
failure:(void (^)(NSError *error))failure;

#pragma mark - Outgoing call
Expand All @@ -128,8 +124,7 @@ NS_ASSUME_NONNULL_BEGIN
of the offer.
@param failure A block object called when the operation fails.
*/
- (void)createCall:(MXCall*)call
offer:(void (^)(NSString *sdp))success
- (void)createOffer:(void (^)(NSString *sdp))success
failure:(void (^)(NSError *error))failure;

/**
Expand All @@ -141,8 +136,7 @@ NS_ASSUME_NONNULL_BEGIN
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
*/
- (void)handleAnswer:(MXCall*)call
offer:(NSString *)sdp
- (void)handleAnswer:(NSString *)sdp
success:(void (^)(void))success
failure:(void (^)(NSError *error))failure;

Expand Down
20 changes: 10 additions & 10 deletions MatrixSDK/VoIP/MXCall.m
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ - (void)callWithVideo:(BOOL)video
#endif

MXWeakify(self);
[self->callStackCall createCall: self offer:^(NSString *sdp) {
[self->callStackCall createOffer:^(NSString *sdp) {
MXStrongifyAndReturnIfNil(self);

[self setState:MXCallStateCreateOffer reason:nil];
Expand Down Expand Up @@ -388,7 +388,7 @@ - (void)answer
[self setState:MXCallStateConnecting reason:nil];

MXWeakify(self);
[self->callStackCall createAnswer: self success:^(NSString *sdpAnswer) {
[self->callStackCall createAnswer:^(NSString *sdpAnswer) {
MXStrongifyAndReturnIfNil(self);

MXLogDebug(@"[MXCall][%@] answer - Created SDP:\n%@", self.callId, sdpAnswer);
Expand Down Expand Up @@ -840,7 +840,7 @@ - (void)setState:(MXCallState)state reason:(MXEvent *)event
incoming:self.isIncoming];

// Terminate the call at the stack level
[callStackCall endCall: self];
[callStackCall end];
}
else if (MXCallStateInviteSent == state)
{
Expand Down Expand Up @@ -1158,7 +1158,7 @@ - (void)handleCallInvite:(MXEvent *)event
[self.audioOutputRouter reroute];
#endif

[self->callStackCall handleCall: self offer:self->callInviteEventContent.offer.sdp
[self->callStackCall handleAnswer:self->callInviteEventContent.offer.sdp
success:^{
MXStrongifyAndReturnIfNil(self);

Expand Down Expand Up @@ -1251,7 +1251,7 @@ - (void)handleCallAnswer:(MXEvent *)event
[self setState:MXCallStateConnecting reason:event];

MXWeakify(self);
[self->callStackCall handleAnswer:self offer:content.answer.sdp
[self->callStackCall handleAnswer:content.answer.sdp
success:^{}
failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
Expand Down Expand Up @@ -1449,14 +1449,14 @@ - (void)handleCallNegotiate:(MXEvent *)event
self.isVideoCall = content.isVideoCall;

MXWeakify(self);
[self->callStackCall handleCall: self offer:content.sessionDescription.sdp
[self->callStackCall handleOffer:content.sessionDescription.sdp
success:^{
MXStrongifyAndReturnIfNil(self);

// TODO: Get offer type from handleOffer and decide auto-accept it or not
// auto-accept negotiations for now
MXWeakify(self);
[self->callStackCall createAnswer:self success:^(NSString * _Nonnull sdpAnswer) {
[self->callStackCall createAnswer:^(NSString * _Nonnull sdpAnswer) {
MXStrongifyAndReturnIfNil(self);

MXLogDebug(@"[MXCall][%@] handleCallNegotiate: answer negotiation - Created SDP:\n%@", self.callId, sdpAnswer);
Expand Down Expand Up @@ -1497,7 +1497,7 @@ - (void)handleCallNegotiate:(MXEvent *)event
else if (content.sessionDescription.type == MXCallSessionDescriptionTypeAnswer)
{
MXWeakify(self);
[self->callStackCall handleAnswer:self offer:content.sessionDescription.sdp
[self->callStackCall handleAnswer:content.sessionDescription.sdp
success:^{}
failure:^(NSError *error) {
MXStrongifyAndReturnIfNil(self);
Expand Down Expand Up @@ -1631,7 +1631,7 @@ - (void)terminateWithReason:(MXEvent *)event
localIceGatheringTimer = nil;

// Terminate the call at the stack level
[callStackCall endCall:self];
[callStackCall end];

// Determine call end reason
if (event)
Expand Down Expand Up @@ -1731,7 +1731,7 @@ - (void)expireCallInvite
if (!_isIncoming)
{
// Terminate the call at the stack level we initiated
[callStackCall endCall: self];
[callStackCall end];
}

// If the call is not aleady ended
Expand Down

0 comments on commit a55cced

Please sign in to comment.