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.

56 lines
1.6 KiB

  1. //
  2. // SCCaptureConfiguration.m
  3. // Snapchat
  4. //
  5. // Created by Lin Jia on 10/2/17.
  6. //
  7. //
  8. #import "SCCaptureConfigurator.h"
  9. #import "SCCaptureConfigurationAnnouncer_Private.h"
  10. #import "SCCaptureConfiguration_Private.h"
  11. #import <SCFoundation/SCAssertWrapper.h>
  12. @interface SCCaptureConfigurator () {
  13. SCQueuePerformer *_performer;
  14. }
  15. @end
  16. @implementation SCCaptureConfigurator
  17. - (instancetype)initWithPerformer:(SCQueuePerformer *)performer
  18. {
  19. self = [super init];
  20. if (self) {
  21. _announcer = [[SCCaptureConfigurationAnnouncer alloc] initWithPerformer:performer configurator:self];
  22. _performer = performer;
  23. // TODO: initialize _currentConfiguration
  24. }
  25. return self;
  26. }
  27. - (void)commitConfiguration:(SCCaptureConfiguration *)configuration
  28. completionHandler:(SCCaptureConfigurationCompletionHandler)completionHandler
  29. {
  30. [configuration seal];
  31. [_performer perform:^() {
  32. SCAssert(configuration, @"Configuration must be a valid input parameter");
  33. NSArray<SCCaptureConfigurationDirtyKey *> *dirtyKeys = [configuration dirtyKeys];
  34. for (SCCaptureConfigurationDirtyKey *key in dirtyKeys) {
  35. [self _processKey:[key integerValue] configuration:configuration];
  36. }
  37. if (completionHandler) {
  38. // TODO: passing in right parameters.
  39. completionHandler(NULL, YES);
  40. }
  41. }];
  42. }
  43. - (void)_processKey:(SCCaptureConfigurationKey)key configuration:(SCCaptureConfiguration *)configuration
  44. {
  45. // Tune the hardware depending on what key is dirty, and what is the value is inside configuration.
  46. }
  47. @end