SKInCallViewController+juphoon.m 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 "VideoManager+ringtone.h"
  10. @implementation SKInCallViewController (juphoon)
  11. - (void)updateUI:(NSNotification *)notification {
  12. NSInteger count = [VideoManager shared].mJuphoonCall.callItems.count;
  13. JCCallItem *activeCall = [VideoManager shared].mJuphoonCall.callItems.firstObject;
  14. HDNormalLog(([NSString stringWithFormat:@"VideoManager: updateUI count:%ld updateUI: %ld", count, activeCall.state]));
  15. if (activeCall.state == JCCallStateInit || activeCall.state == JCCallStatePending) {
  16. self.mInVideoView.hidden = !activeCall.video || activeCall.direction == JCCallDirectionOut;
  17. self.mOutView.hidden = activeCall.direction != JCCallDirectionOut;
  18. self.mWaitHeaderView.hidden = NO;
  19. self.mIngHeaderView.hidden = YES;
  20. self.mIngView.hidden = YES;
  21. self.mIngNameLabel.text = @"";
  22. self.mWaitNameLabel.text = [[VideoManager shared] getTalkName];
  23. self.mWaitInHintLabel.hidden = activeCall.direction != JCCallDirectionIn;
  24. self.mWaitOutHintLabel.hidden = activeCall.direction != JCCallDirectionOut;
  25. if (activeCall.video) {
  26. if (self.jcLocalCanvas == nil && activeCall.uploadVideoStreamSelf) {
  27. self.jcLocalCanvas = [[VideoManager shared].mJuphoonMediaDevice startCameraVideo:JCMediaDeviceRenderFullScreen];
  28. //self.jcLocalCanvas.videoView.frame = CGRectMake(SCREEN_WIDTH - 150, SCREEN_HEIGHT - 150 - 160, 120, 160);
  29. self.jcLocalCanvas.videoView.frame = CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
  30. [self.view insertSubview:self.jcLocalCanvas.videoView aboveSubview:self.backgroudView];
  31. } else if (self.jcLocalCanvas != nil && !activeCall.uploadVideoStreamSelf) {
  32. [[VideoManager shared].mJuphoonMediaDevice stopVideo:self.jcLocalCanvas];
  33. [self.jcLocalCanvas.videoView removeFromSuperview];
  34. self.jcLocalCanvas = nil;
  35. }
  36. }
  37. } else if (activeCall.state == JCCallStateTalking) {
  38. self.mInVideoView.hidden = YES;
  39. self.mOutView.hidden = YES;
  40. self.mWaitHeaderView.hidden = YES;
  41. self.mIngHeaderView.hidden = NO;
  42. self.mIngView.hidden = NO;
  43. self.mIngNameLabel.text = [[VideoManager shared] getTalkName];
  44. self.switchCameraBtn.enabled = activeCall.video;
  45. self.holdBtn.enabled = !activeCall.held;
  46. self.holdBtn.selected = activeCall.hold;
  47. self.muteBtn.selected = activeCall.mute;
  48. self.speakerBtn.selected = [VideoManager shared].mJuphoonMediaDevice.isSpeakerOn;
  49. if (activeCall != nil && activeCall.audioRecord && (activeCall.hold || activeCall.held)) {
  50. [[VideoManager shared].mJuphoonCall audioRecord:activeCall enable:false filePath:@""];
  51. }
  52. if (activeCall != nil && activeCall.localVideoRecord && !activeCall.uploadVideoStreamSelf) {
  53. //[[VideoManager shared].mJuphoonCall videoRecord:activeCall enable:false remote:false width:0 height:0 filePath:@""];
  54. [[VideoManager shared].mJuphoonCall videoRecord:activeCall enable:false remote:false width:0 height:0 filePath:@"" bothAudio:false keyFrame:10];
  55. }
  56. if (activeCall != nil && activeCall.remoteVideoRecord && !activeCall.uploadVideoStreamOther) {
  57. [[VideoManager shared].mJuphoonCall videoRecord:activeCall enable:false remote:true width:0 height:0 filePath:@"" bothAudio:false keyFrame:10];
  58. }
  59. if (activeCall.video) {
  60. if (self.jcLocalCanvas != nil && activeCall.uploadVideoStreamSelf) {
  61. if (self.smallView == nil) {
  62. self.jcLocalCanvas.videoView.frame = CGRectMake(SCREEN_WIDTH - 130, SCREEN_STATUS_HEIGHT+10, 120, 160);
  63. }
  64. self.smallView = self.jcLocalCanvas.videoView;
  65. }
  66. if (self.jcRemoteCanvas == nil && activeCall.uploadVideoStreamOther) {
  67. self.jcRemoteCanvas = [[VideoManager shared].mJuphoonMediaDevice startVideo:activeCall.renderId renderType:JCMediaDeviceRenderFullContent];
  68. self.jcRemoteCanvas.videoView.frame = self.view.frame;
  69. self.jcRemoteCanvas.videoView.hidden = !activeCall.uploadVideoStreamSelf;
  70. [self.view insertSubview:self.jcRemoteCanvas.videoView aboveSubview:self.backgroudView];
  71. [[VideoManager shared].mJuphoonMediaDevice enableSpeaker:YES];
  72. } else if (self.jcRemoteCanvas != nil && !activeCall.uploadVideoStreamOther) {
  73. [[VideoManager shared].mJuphoonMediaDevice stopVideo:self.jcRemoteCanvas];
  74. [self.jcRemoteCanvas.videoView removeFromSuperview];
  75. self.jcRemoteCanvas = nil;
  76. }
  77. }
  78. [self startTimer];
  79. [[VideoManager shared] stopVideoRingtone];
  80. } else {
  81. self.mInVideoView.hidden = YES;
  82. }
  83. if (!activeCall.video) {
  84. [self removeCanvas];
  85. }
  86. }
  87. - (NSString *)getNetStatus:(JCCallItem *)item {
  88. if (item.state != JCCallStateTalking) {
  89. return @"";
  90. }
  91. switch (item.videoNetSendStatus) {
  92. case JCCallNetWorkDisconnected:
  93. return NSLocalizedString(@"Video.Network.Status.0", nil);
  94. case JCCallNetWorkVeryBad:
  95. return NSLocalizedString(@"Video.Network.Status.1", nil);
  96. case JCCallNetWorkBad:
  97. return NSLocalizedString(@"Video.Network.Status.2", nil);
  98. case JCCallNetWorkNormal:
  99. return NSLocalizedString(@"Video.Network.Status.3", nil);
  100. case JCCallNetWorkGood:
  101. return NSLocalizedString(@"Video.Network.Status.4", nil);
  102. case JCCallNetWorkVeryGood:
  103. return NSLocalizedString(@"Video.Network.Status.5", nil);
  104. default:
  105. return @"";
  106. }
  107. }
  108. - (NSObject*)getRemoteCanvas {
  109. return self.jcRemoteCanvas;
  110. }
  111. - (void)removeCanvas {
  112. if (self.jcLocalCanvas) {
  113. [[VideoManager shared].mJuphoonMediaDevice stopVideo:self.jcLocalCanvas];
  114. [self.jcLocalCanvas.videoView removeFromSuperview];
  115. self.jcLocalCanvas = nil;
  116. self.smallView = nil;
  117. }
  118. if (self.jcRemoteCanvas) {
  119. [[VideoManager shared].mJuphoonMediaDevice stopVideo:self.jcRemoteCanvas];
  120. [self.jcRemoteCanvas.videoView removeFromSuperview];
  121. self.jcRemoteCanvas = nil;
  122. }
  123. }
  124. @end