Browse Source

视频 manager兼容

liuzhenxing1118 7 months ago
parent
commit
9b7fcf53de

+ 1 - 1
artimenring-iOS/Artimenring/Classes/Chat/ZSChat/SKChatMembersViewController.m

@@ -161,7 +161,7 @@ static NSString * const HeaderReuseIdentifier = @"SKChatMembersHeaderID";
     SessionMemberModel* model = [[self.mSessionModel getMembers] objectAtIndex:index];
     ChildModel* childModel = [[DataManager shared] getChild:model.refId];
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[VideoManager shared] videoStart:self.mSessionModel.sid ticket:childModel.device.ticket];
+        [[VideoManager shared] videoCallStart:self.mSessionModel.sid ticket:childModel.device.ticket];
     });
 }
 

+ 1 - 1
artimenring-iOS/Artimenring/Classes/Chat/ZSChat/SKChatViewController+more.m

@@ -71,7 +71,7 @@
 - (void)showVideoEx {
     ChildModel* childModel = [[DataManager shared] getChild:[self.mSessionModel getChildId]];
     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
-        [[VideoManager shared] videoStart:self.mSessionModel.sid ticket:childModel.device.ticket];
+        [[VideoManager shared] videoCallStart:self.mSessionModel.sid ticket:childModel.device.ticket];
     });
 }
 

+ 1 - 0
artimenring-iOS/Artimenring/Classes/Data/VideoManager+agora.h

@@ -13,6 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
 @interface VideoManager (agora)
 
 - (BOOL)initAgora;
+- (void)termAgora;
 - (void)clearAgora;
 
 - (NSString*)getChannelName:(NSString*)sid ticket:(NSString*)ticket;

+ 9 - 3
artimenring-iOS/Artimenring/Classes/Data/VideoManager+agora.m

@@ -44,21 +44,27 @@
     int result = [self.agoraKit joinChannelByToken:token channelId:channelId uid:uid mediaOptions:options joinSuccess:nil];
 }
 
+// 成功加入频道回调
 - (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didJoinChannel:(NSString * _Nonnull)channel withUid:(NSUInteger)uid elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:didJoinChannel:withUid:elapsed:)) {
     
 }
 
+// 当远端用户加入频道后,显示指定 uid 的远端视频流
 - (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed NS_SWIFT_NAME(rtcEngine(_:didJoinedOfUid:elapsed:)) {
-    
+    [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_AGORA object:@(uid)];
 }
 
+// 远端用户或主播离开当前频道回调
 - (void)rtcEngine:(AgoraRtcEngineKit * _Nonnull)engine didOfflineOfUid:(NSUInteger)uid reason:(AgoraUserOfflineReason)reason NS_SWIFT_NAME(rtcEngine(_:didOfflineOfUid:reason:)) {
-    
+    [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_AGORA object:@(-1)];
 }
 
-- (void)clearAgora {
+- (void)termAgora {
     [self.agoraKit stopPreview];
     [self.agoraKit leaveChannel:nil];
+}
+
+- (void)clearAgora {
     [AgoraRtcEngineKit destroy];
 }
 

+ 2 - 2
artimenring-iOS/Artimenring/Classes/Data/VideoManager+juphoon.h

@@ -19,8 +19,8 @@ NS_ASSUME_NONNULL_BEGIN
 - (JCMediaDeviceVideoCanvas*)getLocalCanvas;
 - (JCMediaDeviceVideoCanvas*)getRemoteCanvas;
 
-- (BOOL)call:(NSString*)sid ticket:(NSString*)ticket;
-- (void)autoTerm;
+- (BOOL)call:(NSString*)uid ticket:(NSString*)ticket;
+- (void)termJuphoon;
 
 @end
 

+ 6 - 7
artimenring-iOS/Artimenring/Classes/Data/VideoManager+juphoon.m

@@ -26,6 +26,7 @@
     
     self.mJuphoonMediaDevice.videoAngle = JCMediaDeviceVideoAngel0;
     [self.mJuphoonMediaDevice setCameraProperty:640 height:360 framerate:10];
+    [self.mJuphoonMediaDevice enableSpeaker:YES];
     
     //Zmf_VideoCaptureListenRotation(0, 0);
     //Zmf_VideoRenderListenRotation(0,0);
@@ -57,15 +58,13 @@
     return [self.mJuphoonMediaDevice startVideo:activeCall.renderId renderType:JCMediaDeviceRenderFullContent];
 }
 
-- (BOOL)call:(NSString*)sid ticket:(NSString*)ticket {
-    self.mSID = sid;
-    self.mTicket = ticket;
+- (BOOL)call:(NSString*)uid ticket:(NSString*)ticket {
     JCCallParam* callParam = [JCCallParam callParamWithExtraParam:@"" ticket:ticket];
     return [self.mJuphoonCall call:ticket video:true callParam:callParam];
 }
 
 //挂断
-- (void)autoTerm {
+- (void)termJuphoon {
     for (JCCallItem* item in self.mJuphoonCall.callItems) {
         if (item.active) {
             [self.mJuphoonCall term:item reason:JCCallReasonNone description:@"test"];
@@ -144,7 +143,7 @@
 - (void)onCallItemAdd:(JCCallItem* __nonnull)item {
     HDNormalLog(([NSString stringWithFormat:@"VideoManager: onCallItemAdd direction: %ld", (long)item.direction]));
     NSDictionary *dic = @{kCallIetmKey:item};
-    [[NSNotificationCenter defaultCenter] postNotificationName:kCallNotification object:nil userInfo:dic];
+    [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_JUPHOON object:nil userInfo:dic];
     if (self.mJuphoonCall.callItems.count == 1) {
         [self showInCallVC];
     }
@@ -161,7 +160,7 @@
  */
 - (void)onCallItemRemove:(JCCallItem *)item reason:(JCCallReason)reason description:(NSString *)description {
     HDNormalLog(([NSString stringWithFormat:@"VideoManager: onCallItemRemove reason:%ld", reason]));
-    [[NSNotificationCenter defaultCenter] postNotificationName:kCallNotification object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_JUPHOON object:nil];
     [self removeInCallVC];
     switch (reason) {
         case JCCallReasonNone:
@@ -207,7 +206,7 @@
     if (item.state == JCCallStateTalking && [self getRemoteCanvas] == nil && item.uploadVideoStreamOther) {
         [self stopTimeoutTimer];
     }
-    [[NSNotificationCenter defaultCenter] postNotificationName:kCallNotification object:nil];
+    [[NSNotificationCenter defaultCenter] postNotificationName:NOTIFICATION_JUPHOON object:nil];
 }
 
 @end

+ 1 - 1
artimenring-iOS/Artimenring/Classes/Data/VideoManager+timer.m

@@ -18,7 +18,7 @@
 
 - (void)timeoutCallback:(id)sender {
     [self stopTimeoutTimer];
-    [self autoTermWithTimeout];
+    [self termWithTimeout];
 }
 
 #pragma mark - stopTimer

+ 8 - 4
artimenring-iOS/Artimenring/Classes/Data/VideoManager.h

@@ -12,7 +12,8 @@
 
 NS_ASSUME_NONNULL_BEGIN
 
-#define kCallNotification @"kCallNotification"
+#define NOTIFICATION_JUPHOON @"NOTIFICATION_JUPHOON"
+#define NOTIFICATION_AGORA @"NOTIFICATION_AGORA"
 
 
 @interface VideoManager : NSObject
@@ -33,17 +34,20 @@ NS_ASSUME_NONNULL_BEGIN
 @property(nonatomic, strong) AgoraMediaRecorder *localRecorder;
 @property(nonatomic, strong) AgoraMediaRecorder *remoteRecorder;
 
-@property(nonatomic, strong) NSString* mSID;
+@property(nonatomic, strong) NSString* uid;
 @property(nonatomic, strong) NSString* mTicket;
 
+@property(nonatomic, strong) NSString* mToken;
+@property(nonatomic, strong) NSString* mChannelName;
+
 - (void)initManager;
 - (void)clear;
 
-- (void)videoStart:(NSString*)accountId ticket:(NSString*)ticket;
+- (void)videoCallStart:(NSString*)uid ticket:(NSString*)ticket;
 - (void)videoEnd:(BOOL)isIncomming isSendMessage:(BOOL)isSendMessage;
 
 - (void)actionFromSocket:(SocketModel*)model dial:(NSInteger)dial;
-- (void)autoTermWithTimeout;
+- (void)termWithTimeout;
 - (void)showInCallVC;
 - (void)removeInCallVC;
 

+ 60 - 63
artimenring-iOS/Artimenring/Classes/Data/VideoManager.m

@@ -32,28 +32,28 @@
     [self clearAgora];
 }
 
-- (void)requestVideo:(NSString*)sid ticket:(NSString*)ticket dial:(NSInteger)dial callback:(void(^)(BOOL isOK, NSString* token))callback {
+- (void)requestVideo:(NSString*)uid ticket:(NSString*)ticket dial:(NSInteger)dial callback:(void(^)(BOOL isOK, NSString* token))callback {
     HDNormalLog(([NSString stringWithFormat:@"VideoManager: requestVideo ticket:%@ dial:%ld", ticket, dial]));
     if (dial > 0) {
         DeviceModel* model = [[DataManager shared] getDeviceWithTicket:ticket];
         if (model.videoType == VIDEO_TYPE_AGORA) {
-            [self requestAgoraToken:sid ticket:ticket callback:^(BOOL isOK, NSString *token) {
-                [self requestVideoEx:sid ticket:ticket token:token dial:dial callback:^(BOOL isOK) {
+            [self requestAgoraToken:uid ticket:ticket callback:^(BOOL isOK, NSString *token) {
+                [self requestVideoEx:uid ticket:ticket token:token dial:dial callback:^(BOOL isOK) {
                     callback(isOK, token);
                 }];
             }];
         }
     } else {
-        [self requestVideoEx:sid ticket:ticket token:@"" dial:dial callback:^(BOOL isOK) {
+        [self requestVideoEx:uid ticket:ticket token:@"" dial:dial callback:^(BOOL isOK) {
             callback(isOK, @"");
         }];
     }
 }
 
-- (void)requestAgoraToken:(NSString*)sid ticket:(NSString*)ticket callback:(void(^)(BOOL isOK, NSString* token))callback {
+- (void)requestAgoraToken:(NSString*)uid ticket:(NSString*)ticket callback:(void(^)(BOOL isOK, NSString* token))callback {
     HDNormalLog(([NSString stringWithFormat:@"VideoManager: requestAgoraToken ticket:%@", ticket]));
     NSDictionary *param = @{
-        @"channelName":[self getChannelName:sid ticket:ticket],
+        @"channelName":[self getChannelName:uid ticket:ticket],
     };
     [ERequest httpRequest:param httpURL:URL_VIDEO_TOKEN httpMethod:@"GET" onSuccess:^(NSDictionary *result) {
         if ([ERequest isSuccessWithResult:result]) {
@@ -68,10 +68,10 @@
     }];
 }
 
-- (void)requestVideoEx:(NSString*)sid ticket:(NSString*)ticket token:(NSString*)token dial:(NSInteger)dial callback:(void(^)(BOOL isOK))callback {
+- (void)requestVideoEx:(NSString*)uid ticket:(NSString*)ticket token:(NSString*)token dial:(NSInteger)dial callback:(void(^)(BOOL isOK))callback {
     HDNormalLog(([NSString stringWithFormat:@"VideoManager: requestVideoEx ticket:%@ dial:%ld token:%@", ticket, dial, token]));
     NSDictionary *param = @{
-        @"sid":sid,
+        @"sid":uid,
         @"roomId":ticket,
         @"token":token,
         @"dial":@(dial), //是否是拨号 -1 挂断 1 拨号
@@ -93,67 +93,87 @@
 #pragma mark -
 - (void)actionFromSocket:(SocketModel*)model dial:(NSInteger)dial {
     if (dial <= 0) {
-        NSString* talkId = [self getJuphoonName];
-        ChildModel* childModel = [[DataManager shared] getChildWithTicket:talkId];
+        ChildModel* childModel = [[DataManager shared] getChildWithTicket:self.mTicket];
         BOOL isEquel = [model.sendId isEqualToString:childModel.cid];
         if (isEquel) {
             [EasyTextView showInfoText:NSLocalizedString(@"Video.Error.Hangup", nil)];
-            [self autoTerm];
+            [self term];
         }
     } else {
-        [self loginJuphoon];
+        self.uid = [DataManager shared].loginModel.uid;
+        self.mTicket = [[DataManager shared] getDevice:model.sendId].ticket;
+        self.mToken = ((SocketContentModel*)model.content).token;
+        self.mChannelName = ((SocketContentModel*)model.content).channelName;
+        [self videoReceiveStart];
     }
 }
 
-- (void)videoStart:(NSString*)sid ticket:(NSString*)ticket {
+- (void)videoCallStart:(NSString*)uid ticket:(NSString*)ticket {
+    @weakify(self);
     BOOL isReachable = [[AFNetworkReachabilityManager sharedManager] isReachable];
     if (!isReachable) {
         [EasyTextView showErrorText:NSLocalizedString(@"Network.Error", nil)];
         return;
     }
-    HDNormalLog(([NSString stringWithFormat:@"VideoManager: videoStart: sid:%@  ticket:%@", sid, ticket]));
+    HDNormalLog(([NSString stringWithFormat:@"VideoManager: videoCallStart: uid:%@  ticket:%@", uid, ticket]));
     DeviceModel* model = [[DataManager shared]getDeviceWithTicket:ticket];
+    if (!model)
+        return;
+    self.uid = uid;
+    self.mTicket = ticket;
+    
     if (model.videoType == VIDEO_TYPE_JUPHOON) {
-        BOOL isok = [self call:sid ticket:ticket];
+        BOOL isok = [self call:uid ticket:ticket];
         if (!isok) {
             //如果失败,很有可能登录失败,重新登录//
             [self loginJuphoon];
             [EasyTextView showErrorText:[NSString stringWithFormat:NSLocalizedString(@"Video.Error.User.Login", nil)]];
         } else {
-            [self requestVideo:sid ticket:ticket dial:1 callback:^(BOOL isOK, NSString *token) {
+            [self requestVideo:uid ticket:ticket dial:1 callback:^(BOOL isOK, NSString *token) {
             }];
             [self startTimeoutTimer];
         }
     } else if (model.videoType == VIDEO_TYPE_AGORA) {
-        [self requestVideo:sid ticket:ticket dial:1 callback:^(BOOL isOK, NSString *token) {
+        [self requestVideo:uid ticket:ticket dial:1 callback:^(BOOL isOK, NSString *token) {
             if (isOK && token.length > 0) {
-                [self joinChannel:token channelId:[self getChannelName:sid ticket:ticket] uid:0];
+                [weak_self joinChannel:token channelId:[self getChannelName:uid ticket:ticket] uid:0];
+                [weak_self startTimeoutTimer];
             }
         }];
     }
 }
 
+- (void)videoReceiveStart {
+    DeviceModel* model = [[DataManager shared]getDeviceWithTicket:self.mTicket];
+    if (model.videoType == VIDEO_TYPE_JUPHOON) {
+        [self loginJuphoon];
+    } else if (model.videoType == VIDEO_TYPE_AGORA) {
+        [self joinChannel:self.mToken channelId:self.mChannelName uid:0];
+    }
+}
+
 - (void)videoEnd:(BOOL)isIncomming isSendMessage:(BOOL)isSendMessage {
     HDNormalLog(([NSString stringWithFormat:@"VideoManager: videoEnd:%d", isIncomming]));
     //发消息
     if (isSendMessage) {
-        JCCallItem *activeCall = [self getActiveCall];
-        if(activeCall.state == JCCallStateInit || activeCall.state == JCCallStatePending) {
-            NSString* ticket = [self getJuphoonName];
-            NSString* sid = [self getJuphoonSID];
-            [self requestVideo:sid ticket:ticket dial:-1 callback:^(BOOL isOK, NSString *token) {
-            }];
-        }
+        [self requestVideo:self.uid ticket:self.mTicket dial:-1 callback:^(BOOL isOK, NSString *token) {
+        }];
     }
-    [self autoTerm];
+    [self term];
 }
 
-- (void)joinRoom {
-    
+- (void)termWithTimeout {
+    [EasyTextView showErrorText:NSLocalizedString(@"Video.Error.Timeout", nil)];
+    [self videoEnd:YES isSendMessage:YES];
 }
 
-- (void)leaveRoom {
-    
+- (void)term {
+    DeviceModel* model = [[DataManager shared] getDeviceWithTicket:self.mTicket];
+    if (model.videoType == VIDEO_TYPE_JUPHOON) {
+        [self termJuphoon];
+    } else if (model.videoType == VIDEO_TYPE_AGORA) {
+        [self termAgora];
+    }
 }
 
 - (void)showInCallVC {
@@ -173,20 +193,15 @@
     self.mInCallVC = nil;
 }
 
-- (void)autoTermWithTimeout {
-    NSString* sid = [self getJuphoonSID];
-    NSString* ticket = [self getJuphoonName];
-    if (!ticket || ticket.length <= 0)
-        return;
-    [EasyTextView showErrorText:NSLocalizedString(@"Video.Error.Timeout", nil)];
-    [self requestVideo:sid ticket:ticket dial:-1 callback:^(BOOL isOK, NSString *token) {
-    }];
-    [self autoTerm];
-}
-
 - (BOOL)isVideoTalking {
-    JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
-    return activeCall.video || activeCall.state == JCCallStateTalking;
+    DeviceModel* model = [[DataManager shared] getDeviceWithTicket:self.mTicket];
+    if (model.videoType == VIDEO_TYPE_JUPHOON) {
+        JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
+        return activeCall.video || activeCall.state == JCCallStateTalking;
+    } else if (model.videoType == VIDEO_TYPE_AGORA) {
+        return self.uid.length > 0 && self.mChannelName.length > 0;
+    }
+    return NO;
 }
 
 - (JCCallItem*)getActiveCall {
@@ -198,32 +213,14 @@
     return nil;
 }
 
-- (NSString*)getJuphoonSID {
-    JCCallItem *activeCall = [self getActiveCall];
-    if (activeCall.direction == JCCallDirectionOut) {
-        return self.mSID;
-    } else {
-        return activeCall.userId;
-    }
-}
-
-- (NSString*)getJuphoonName {
-    JCCallItem *activeCall = [self getActiveCall];
-    if (activeCall.direction == JCCallDirectionOut) {
-        return self.mTicket;
-    } else {
-        return activeCall.userId;
-    }
-}
-
 - (NSString*)getTalkName {
-    NSString* talkId = [self getJuphoonName];
+    NSString* talkId = self.mTicket;
     ChildModel* model = [[DataManager shared] getChildWithTicket:talkId];
     return model ? model.name : @"";
 }
 
 - (NSString*)getTalkHeadImageURL {
-    NSString* talkId = [self getJuphoonName];
+    NSString* talkId = self.mTicket;
     ChildModel* model = [[DataManager shared] getChildWithTicket:talkId];
     return model ? model.avatar : @"";
 }

+ 2 - 0
artimenring-iOS/Artimenring/Classes/Model/EModel.h

@@ -310,6 +310,8 @@ typedef enum : NSUInteger {
 
 @interface SocketContentModel : BaseModel
 @property(nonatomic, copy) NSString* raw;
+@property(nonatomic, copy) NSString* token;
+@property(nonatomic, copy) NSString* channelName;
 @end
 
 @interface SocketModel : BaseModel

+ 3 - 0
artimenring-iOS/Artimenring/Classes/ViewController/Call/SKInCallViewController+agora.h

@@ -15,6 +15,9 @@ NS_ASSUME_NONNULL_BEGIN
 @property (nonatomic, strong) UIView* localView;
 @property (nonatomic, strong) UIView* remoteView;
 
+- (void)initAgoraView;
+- (void)updateAgoraUI:(NSNotification* __nullable)notification;
+
 @end
 
 NS_ASSUME_NONNULL_END

+ 8 - 1
artimenring-iOS/Artimenring/Classes/ViewController/Call/SKInCallViewController+agora.m

@@ -10,7 +10,7 @@
 
 @implementation SKInCallViewController (agora)
 
-- (void)initView {
+- (void)initAgoraView {
     self.localView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
     [self.view insertSubview:self.localView aboveSubview:self.backgroudView];
     
@@ -37,4 +37,11 @@
     [[VideoManager shared].agoraKit setupRemoteVideo:videoCanvas];
 }
 
+- (void)updateAgoraUI:(NSNotification *)notification {
+    NSInteger uid = [notification.object integerValue];
+    if (uid != -1) {
+        [self startRemote:uid];
+    }
+}
+
 @end

+ 2 - 2
artimenring-iOS/Artimenring/Classes/ViewController/Call/SKInCallViewController+juphoon.h

@@ -15,8 +15,8 @@ NS_ASSUME_NONNULL_BEGIN
 @property(nonatomic, strong) JCMediaDeviceVideoCanvas* jcLocalCanvas;
 @property(nonatomic, strong) JCMediaDeviceVideoCanvas* jcRemoteCanvas;
 
-- (void)updateUI:(NSNotification *)notification;
-- (NSString *)getNetStatus:(JCCallItem *)item;
+- (void)updateJuphoonUI:(NSNotification* __nullable)notification;
+- (NSString *)getNetStatus:(JCCallItem*)item;
 
 @end
 

+ 2 - 2
artimenring-iOS/Artimenring/Classes/ViewController/Call/SKInCallViewController+juphoon.m

@@ -13,10 +13,10 @@
 
 @implementation SKInCallViewController (juphoon)
 
-- (void)updateUI:(NSNotification *)notification {
+- (void)updateJuphoonUI:(NSNotification *)notification {
     NSInteger count = [VideoManager shared].mJuphoonCall.callItems.count;
     JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
-    HDNormalLog(([NSString stringWithFormat:@"VideoManager: updateUI count:%ld updateUI: %ld", count, activeCall.state]));
+    HDNormalLog(([NSString stringWithFormat:@"VideoManager: updateJuphoonUI count:%ld updateJuphoonUI: %ld", count, activeCall.state]));
 
     if (activeCall.state == JCCallStateInit || activeCall.state == JCCallStatePending) {
         self.mInVideoView.hidden = !activeCall.video || activeCall.direction == JCCallDirectionOut;

+ 13 - 12
artimenring-iOS/Artimenring/Classes/ViewController/Call/SKInCallViewController.m

@@ -21,8 +21,7 @@
     
     _smallView = nil;
     [self initView];
-    [self updateUI:nil];
-    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateUI:) name:kCallNotification object:nil];
+    [self initType];
     [[VideoManager shared] playVideoWaitingRingtone];
 }
 
@@ -38,15 +37,20 @@
     [EUtil setURLImage:self.mWaitHeadImage placeHolderName:@"avatar" imageURL:[[VideoManager shared] getTalkHeadImageURL] cornerRadius:self.mWaitHeadImage.frame.size.width/2];
 }
 
+- (void)initType {
+    if ([VideoManager shared].mVideoType == VIDEO_TYPE_JUPHOON) {
+        [self updateJuphoonUI:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateJuphoonUI:) name:NOTIFICATION_JUPHOON object:nil];
+    } else {
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateAgoraUI:) name:NOTIFICATION_AGORA object:nil];
+    }
+}
+
 - (void)viewWillAppear:(BOOL)animated {
     [super viewWillAppear:animated];
     [self.navigationController setNavigationBarHidden:YES animated:NO];
 }
 
-- (void)viewDidAppear:(BOOL)animated {
-    [[VideoManager shared].mJuphoonMediaDevice enableSpeaker:YES];
-}
-
 - (void)viewWillDisappear:(BOOL)animated {
     [super viewWillDisappear:animated];
     [self.navigationController setNavigationBarHidden:NO animated:NO];
@@ -81,13 +85,7 @@
     [[VideoManager shared].mJuphoonCall answer:activeCall video:true];
 }
 
-- (IBAction)voiceAnswer:(id)sender {
-    JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
-    [[VideoManager shared].mJuphoonCall answer:activeCall video:false];
-}
-
 #pragma mark - In Calling Actions
-
 - (IBAction)setCameraState:(id)sender {
     JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
     [[VideoManager shared].mJuphoonCall enableUploadVideoStream:activeCall];
@@ -110,6 +108,9 @@
     [[VideoManager shared].mJuphoonCall mute:activeCall];
 }
 
+- (IBAction)voiceAnswer:(id)sender {
+}
+
 - (IBAction)audioRecord:(id)sender {
 }