SDKParameters.m 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. //
  2. // SDKParameters.m
  3. // sampleSDK
  4. //
  5. // Created by 王昭威 on 2023/1/21.
  6. //
  7. #import "SDKParameters.h"
  8. //#import <ui>
  9. @interface SDKParameters ()
  10. // cgrects
  11. @property (nonatomic, strong) NSDictionary<NSNumber*, NSValue*>* resolutionTable;
  12. @end
  13. @implementation SDKParameters
  14. + (instancetype)shared{
  15. static dispatch_once_t token;
  16. static SDKParameters* instance = nil;
  17. dispatch_once(&token, ^{
  18. instance = [[self alloc] init];
  19. });
  20. return instance;
  21. }
  22. - (CGSize)videoResolution{
  23. // NSValue* value = self.resolutionTable[@(self.videoQuality)];
  24. // if(value == nil){
  25. // return [self.resolutionTable[@(SDK_VIDEO_QUALITY_1080)] CGSizeValue];
  26. // }
  27. // return [value CGSizeValue];
  28. return CGSizeZero;
  29. }
  30. - (instancetype)init{
  31. self = [super init];
  32. if(self){
  33. // _limitRecordTime = 30;
  34. // _flashMode = SDK_FLASH_MODE_OFF;
  35. // _resolutionTable = @{
  36. // @(SDK_VIDEO_QUALITY_480): [NSValue valueWithCGSize:CGSizeMake(720, 480)],
  37. // @(SDK_VIDEO_QUALITY_720): [NSValue valueWithCGSize:CGSizeMake(1280, 720)],
  38. // @(SDK_VIDEO_QUALITY_1080): [NSValue valueWithCGSize:CGSizeMake(1920, 1080)],
  39. // @(SDK_VIDEO_QUALITY_2160): [NSValue valueWithCGSize:CGSizeMake(3840, 2160)],
  40. // };
  41. // _resolution = CGSizeMake(1280, 720);
  42. // _modeIndex = SDK_CAPTURE_MODE_CONTINUOUS;
  43. // _cameraPosition = SDK_CAMERA_PISITION_BACK;
  44. // _retainedMode = SDK_DATA_RETAINED_RETAIN;
  45. // _videoQuality = SDK_VIDEO_QUALITY_720;
  46. // _showPreviewForPanorama = NO;
  47. }
  48. return self;
  49. }
  50. @end
  51. @interface SDKParametersItem ()
  52. @property (nonatomic, strong) NSDictionary<NSNumber*, NSValue*>* resolutionTable;
  53. @end
  54. @implementation SDKParametersItem
  55. - (instancetype)init{
  56. self = [super init];
  57. if(self){
  58. _limitRecordTime = 30;
  59. _flashMode = SDK_FLASH_MODE_OFF;
  60. _resolutionTable = @{
  61. @(SDK_VIDEO_QUALITY_480): [NSValue valueWithCGSize:CGSizeMake(720, 480)],
  62. @(SDK_VIDEO_QUALITY_720): [NSValue valueWithCGSize:CGSizeMake(1280, 720)],
  63. @(SDK_VIDEO_QUALITY_1080): [NSValue valueWithCGSize:CGSizeMake(1920, 1080)],
  64. @(SDK_VIDEO_QUALITY_2160): [NSValue valueWithCGSize:CGSizeMake(3840, 2160)],
  65. };
  66. _resolution = CGSizeMake(1920, 1080);
  67. // _modeIndex = SDK_CAPTURE_MODE_CONTINUOUS;
  68. _cameraPosition = SDK_CAMERA_PISITION_BACK;
  69. // _retainedMode = SDK_DATA_RETAINED_RETAIN;
  70. _videoQuality = SDK_VIDEO_QUALITY_720;
  71. _showPreviewForPanorama = NO;
  72. }
  73. return self;
  74. }
  75. - (CGSize)videoResolution{
  76. NSValue* value = self.resolutionTable[@(self.videoQuality)];
  77. if(value == nil){
  78. return [self.resolutionTable[@(SDK_VIDEO_QUALITY_1080)] CGSizeValue];
  79. }
  80. return [value CGSizeValue];
  81. }
  82. @end