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.

63 lines
1.7 KiB

  1. //
  2. // SCManagedCaptureDeviceAutoExposureHandler.m
  3. // Snapchat
  4. //
  5. // Created by Derek Peirce on 3/21/17.
  6. // Copyright © 2017 Snapchat, Inc. All rights reserved.
  7. //
  8. #import "SCManagedCaptureDeviceAutoExposureHandler.h"
  9. #import "AVCaptureDevice+ConfigurationLock.h"
  10. #import "SCManagedCaptureDeviceExposureHandler.h"
  11. #import <SCFoundation/SCTrace.h>
  12. @import AVFoundation;
  13. @implementation SCManagedCaptureDeviceAutoExposureHandler {
  14. CGPoint _exposurePointOfInterest;
  15. AVCaptureDevice *_device;
  16. }
  17. - (instancetype)initWithDevice:(AVCaptureDevice *)device pointOfInterest:(CGPoint)pointOfInterest
  18. {
  19. if (self = [super init]) {
  20. _device = device;
  21. _exposurePointOfInterest = pointOfInterest;
  22. }
  23. return self;
  24. }
  25. - (CGPoint)getExposurePointOfInterest
  26. {
  27. return _exposurePointOfInterest;
  28. }
  29. - (void)setExposurePointOfInterest:(CGPoint)pointOfInterest fromUser:(BOOL)fromUser
  30. {
  31. SCTraceStart();
  32. if (!CGPointEqualToPoint(pointOfInterest, _exposurePointOfInterest)) {
  33. if ([_device isExposureModeSupported:AVCaptureExposureModeContinuousAutoExposure] &&
  34. [_device isExposurePointOfInterestSupported]) {
  35. [_device runTask:@"set exposure"
  36. withLockedConfiguration:^() {
  37. // Set exposure point before changing focus mode
  38. // Be noticed that order does matter
  39. _device.exposurePointOfInterest = pointOfInterest;
  40. _device.exposureMode = AVCaptureExposureModeContinuousAutoExposure;
  41. }];
  42. }
  43. _exposurePointOfInterest = pointOfInterest;
  44. }
  45. }
  46. - (void)setStableExposure:(BOOL)stableExposure
  47. {
  48. }
  49. - (void)setVisible:(BOOL)visible
  50. {
  51. }
  52. @end