2014 snapchat source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.7 KiB

  1. //
  2. // SCManagedDeviceCapacityAnalyzerHandler.m
  3. // Snapchat
  4. //
  5. // Created by Jingtian Yang on 11/12/2017.
  6. //
  7. #import "SCManagedDeviceCapacityAnalyzerHandler.h"
  8. #import "SCCaptureResource.h"
  9. #import "SCManagedCapturer.h"
  10. #import "SCManagedCapturerLogging.h"
  11. #import "SCManagedCapturerState.h"
  12. #import "SCManagedCapturerStateBuilder.h"
  13. #import <SCFoundation/SCAssertWrapper.h>
  14. #import <SCFoundation/SCQueuePerformer.h>
  15. #import <SCFoundation/SCThreadHelpers.h>
  16. #import <SCFoundation/SCTraceODPCompatible.h>
  17. @interface SCManagedDeviceCapacityAnalyzerHandler () {
  18. __weak SCCaptureResource *_captureResource;
  19. }
  20. @end
  21. @implementation SCManagedDeviceCapacityAnalyzerHandler
  22. - (instancetype)initWithCaptureResource:(SCCaptureResource *)captureResource
  23. {
  24. self = [super init];
  25. if (self) {
  26. SCAssert(captureResource, @"");
  27. _captureResource = captureResource;
  28. }
  29. return self;
  30. }
  31. - (void)managedDeviceCapacityAnalyzer:(SCManagedDeviceCapacityAnalyzer *)managedDeviceCapacityAnalyzer
  32. didChangeLowLightCondition:(BOOL)lowLightCondition
  33. {
  34. SCTraceODPCompatibleStart(2);
  35. SCLogCapturerInfo(@"Change Low Light Condition %d", lowLightCondition);
  36. [_captureResource.queuePerformer perform:^{
  37. _captureResource.state = [[[SCManagedCapturerStateBuilder withManagedCapturerState:_captureResource.state]
  38. setLowLightCondition:lowLightCondition] build];
  39. SCManagedCapturerState *state = [_captureResource.state copy];
  40. runOnMainThreadAsynchronously(^{
  41. [_captureResource.announcer managedCapturer:[SCManagedCapturer sharedInstance] didChangeState:state];
  42. [_captureResource.announcer managedCapturer:[SCManagedCapturer sharedInstance]
  43. didChangeLowLightCondition:state];
  44. });
  45. }];
  46. }
  47. - (void)managedDeviceCapacityAnalyzer:(SCManagedDeviceCapacityAnalyzer *)managedDeviceCapacityAnalyzer
  48. didChangeAdjustingExposure:(BOOL)adjustingExposure
  49. {
  50. SCTraceODPCompatibleStart(2);
  51. SCLogCapturerInfo(@"Capacity Analyzer Changes adjustExposure %d", adjustingExposure);
  52. [_captureResource.queuePerformer perform:^{
  53. _captureResource.state = [[[SCManagedCapturerStateBuilder withManagedCapturerState:_captureResource.state]
  54. setAdjustingExposure:adjustingExposure] build];
  55. SCManagedCapturerState *state = [_captureResource.state copy];
  56. runOnMainThreadAsynchronously(^{
  57. [_captureResource.announcer managedCapturer:[SCManagedCapturer sharedInstance] didChangeState:state];
  58. [_captureResource.announcer managedCapturer:[SCManagedCapturer sharedInstance]
  59. didChangeAdjustingExposure:state];
  60. });
  61. }];
  62. }
  63. @end