OperationNodePanorama.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //
  2. // OperationNodePanoramic.m
  3. // LenzCameraNativeModuleForRN
  4. //
  5. // Created by 王昭威 on 2023/1/25.
  6. //
  7. #import "PCSBaseViewController.h"
  8. #import "OperationNodePanorama.h"
  9. #import "PanoramaGuideView.h"
  10. #import "PanoramaOrientationView.h"
  11. #import "LenzSDKConstant.h"
  12. @interface OperationNodePanorama ()
  13. @property (nonatomic, assign) BOOL isRecording;
  14. @property (nonatomic, assign) UIBackgroundTaskIdentifier bgTaskToken;
  15. @end
  16. @implementation OperationNodePanorama
  17. @dynamic isRecording;
  18. @synthesize controller = _controller;
  19. @synthesize modeTitleString = _modeTitleString;
  20. - (NSString *)modeTitleString{
  21. return LOCALIZATION_STRING_KEY_MODE_TITLE_PANORAMIC;
  22. }
  23. - (SDKCaptureModeIndex)modeIndex{
  24. return SDK_CAPTURE_MODE_PANORAMA;
  25. }
  26. - (NSString *)modeItemString{
  27. return @"全景";
  28. }
  29. - (nonnull instancetype)initWithController:(nonnull PCSBaseViewController *)controller {
  30. self = [super init];
  31. if(self){
  32. _controller = controller;
  33. }
  34. return self;
  35. }
  36. - (void)cleanOnCompleted:(void (^)(void))block{
  37. dispatch_async(dispatch_get_main_queue(), ^{
  38. block();
  39. });
  40. }
  41. - (BOOL)start{
  42. [super start];
  43. BOOL ret = [self.controller startVideoDataOutputing];
  44. if(ret){
  45. self.controller.panoramaGuideView.hidden = NO;
  46. self.controller.panoramOrientationGuideView.hidden = NO;
  47. }
  48. return ret;
  49. }
  50. - (void)stop{
  51. if (!NSThread.isMainThread) {
  52. __weak typeof(self) weakSelf = self;
  53. dispatch_async(dispatch_get_main_queue(), ^{
  54. // weakSelf.controller.switchButton.hidden = NO;
  55. // weakSelf.controller.panoramaGuideView.hidden = YES;
  56. // weakSelf.controller.panoramOrientationGuideView.hidden = YES;
  57. });
  58. } else {
  59. // self.controller.switchButton.hidden = NO;
  60. // self.controller.panoramaGuideView.hidden = YES;
  61. // self.controller.panoramOrientationGuideView.hidden = YES;
  62. }
  63. [super stop];
  64. dispatch_async(dispatch_get_main_queue(), ^{
  65. [self.controller stopVideoDataOutputing];
  66. });
  67. }
  68. - (void)save {
  69. // [self.controller show]
  70. }
  71. - (void)triggered {
  72. [self stop];
  73. }
  74. - (void)willQuitOnCompletion:(nonnull WillQuitCompletionBlockType)block {
  75. self.controller.panoramaGuideView.hidden = YES;
  76. self.controller.panoramOrientationGuideView.hidden = YES;
  77. }
  78. #pragma mark - background
  79. - (void)willEnterBackground:(NSNotification *)noti{
  80. self.bgTaskToken = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
  81. [[UIApplication sharedApplication] endBackgroundTask:self.bgTaskToken];
  82. self.bgTaskToken = UIBackgroundTaskInvalid;
  83. }];
  84. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
  85. [self triggered];
  86. [[UIApplication sharedApplication] endBackgroundTask:self.bgTaskToken];
  87. self.bgTaskToken = UIBackgroundTaskInvalid;
  88. });
  89. }
  90. @end