SKInCallViewController+juphoon.m 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. //
  2. // SKInCallViewController+juphoon.m
  3. // SikeyComm
  4. //
  5. // Created by 刘振兴 on 2025/2/13.
  6. // Copyright © 2025 BaH Cy. All rights reserved.
  7. //
  8. #import "SKInCallViewController+juphoon.h"
  9. #import "SKInCallViewController+time.h"
  10. #import "VideoManager+ringtone.h"
  11. #import "VideoManager+juphoon.h"
  12. @implementation SKInCallViewController (juphoon)
  13. - (void)updateUI:(NSNotification *)notification {
  14. NSInteger count = [VideoManager shared].mJuphoonCall.callItems.count;
  15. JCCallItem *activeCall = [[VideoManager shared] getActiveCall];
  16. HDNormalLog(([NSString stringWithFormat:@"VideoManager: updateUI count:%ld updateUI: %ld", count, activeCall.state]));
  17. if (activeCall.state == JCCallStateInit || activeCall.state == JCCallStatePending) {
  18. self.mInVideoView.hidden = !activeCall.video || activeCall.direction == JCCallDirectionOut;
  19. self.mOutView.hidden = activeCall.direction != JCCallDirectionOut;
  20. self.mWaitHeaderView.hidden = NO;
  21. self.mIngHeaderView.hidden = YES;
  22. self.mIngView.hidden = YES;
  23. self.mIngNameLabel.text = @"";
  24. self.mWaitNameLabel.text = [[VideoManager shared] getTalkName];
  25. self.mWaitInHintLabel.hidden = activeCall.direction != JCCallDirectionIn;
  26. self.mWaitOutHintLabel.hidden = activeCall.direction != JCCallDirectionOut;
  27. if (activeCall.video) {
  28. if (self.jcLocalCanvas == nil && activeCall.uploadVideoStreamSelf) {
  29. self.jcLocalCanvas = [[VideoManager shared] getLocalCanvas];
  30. //self.jcLocalCanvas.videoView.frame = CGRectMake(SCREEN_WIDTH - 150, SCREEN_HEIGHT - 150 - 160, 120, 160);
  31. self.jcLocalCanvas.videoView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
  32. [self.view insertSubview:self.jcLocalCanvas.videoView aboveSubview:self.backgroudView];
  33. }
  34. }
  35. } else if (activeCall.state == JCCallStateTalking) {
  36. self.mInVideoView.hidden = YES;
  37. self.mOutView.hidden = YES;
  38. self.mWaitHeaderView.hidden = YES;
  39. self.mIngHeaderView.hidden = NO;
  40. self.mIngView.hidden = NO;
  41. self.mIngNameLabel.text = [[VideoManager shared] getTalkName];
  42. self.switchCameraBtn.enabled = activeCall.video;
  43. self.holdBtn.enabled = !activeCall.held;
  44. self.holdBtn.selected = activeCall.hold;
  45. self.muteBtn.selected = activeCall.mute;
  46. self.speakerBtn.selected = [VideoManager shared].mJuphoonMediaDevice.isSpeakerOn;
  47. if (activeCall != nil && activeCall.audioRecord && (activeCall.hold || activeCall.held)) {
  48. [[VideoManager shared].mJuphoonCall audioRecord:activeCall enable:false filePath:@""];
  49. }
  50. if (activeCall != nil && activeCall.localVideoRecord && !activeCall.uploadVideoStreamSelf) {
  51. //[[VideoManager shared].mJuphoonCall videoRecord:activeCall enable:false remote:false width:0 height:0 filePath:@""];
  52. [[VideoManager shared].mJuphoonCall videoRecord:activeCall enable:false remote:false width:0 height:0 filePath:@"" bothAudio:false keyFrame:10];
  53. }
  54. if (activeCall != nil && activeCall.remoteVideoRecord && !activeCall.uploadVideoStreamOther) {
  55. [[VideoManager shared].mJuphoonCall videoRecord:activeCall enable:false remote:true width:0 height:0 filePath:@"" bothAudio:false keyFrame:10];
  56. }
  57. if (activeCall.video) {
  58. if (self.jcLocalCanvas != nil && activeCall.uploadVideoStreamSelf) {
  59. if (self.smallView == nil) {
  60. self.jcLocalCanvas.videoView.frame = CGRectMake(SCREEN_WIDTH - 130, SCREEN_STATUS_HEIGHT+10, 120, 160);
  61. }
  62. self.smallView = self.jcLocalCanvas.videoView;
  63. }
  64. if (self.jcRemoteCanvas == nil && activeCall.uploadVideoStreamOther) {
  65. self.jcRemoteCanvas = [[VideoManager shared] getRemoteCanvas];
  66. self.jcRemoteCanvas.videoView.frame = self.view.frame;
  67. self.jcRemoteCanvas.videoView.hidden = !activeCall.uploadVideoStreamSelf;
  68. [self.view insertSubview:self.jcRemoteCanvas.videoView aboveSubview:self.backgroudView];
  69. [[VideoManager shared].mJuphoonMediaDevice enableSpeaker:YES];
  70. } else if (self.jcRemoteCanvas != nil && !activeCall.uploadVideoStreamOther) {
  71. [[VideoManager shared].mJuphoonMediaDevice stopVideo:self.jcRemoteCanvas];
  72. [self.jcRemoteCanvas.videoView removeFromSuperview];
  73. self.jcRemoteCanvas = nil;
  74. }
  75. }
  76. [self startTimer];
  77. [[VideoManager shared] stopVideoRingtone];
  78. } else {
  79. self.mInVideoView.hidden = YES;
  80. }
  81. }
  82. - (NSString *)getNetStatus:(JCCallItem *)item {
  83. if (item.state != JCCallStateTalking) {
  84. return @"";
  85. }
  86. switch (item.videoNetSendStatus) {
  87. case JCCallNetWorkDisconnected:
  88. return NSLocalizedString(@"Video.Network.Status.0", nil);
  89. case JCCallNetWorkVeryBad:
  90. return NSLocalizedString(@"Video.Network.Status.1", nil);
  91. case JCCallNetWorkBad:
  92. return NSLocalizedString(@"Video.Network.Status.2", nil);
  93. case JCCallNetWorkNormal:
  94. return NSLocalizedString(@"Video.Network.Status.3", nil);
  95. case JCCallNetWorkGood:
  96. return NSLocalizedString(@"Video.Network.Status.4", nil);
  97. case JCCallNetWorkVeryGood:
  98. return NSLocalizedString(@"Video.Network.Status.5", nil);
  99. default:
  100. return @"";
  101. }
  102. }
  103. @end