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.

70 lines
2.2 KiB

  1. //
  2. // SCCaptureUninitializedState.m
  3. // Snapchat
  4. //
  5. // Created by Lin Jia on 10/19/17.
  6. //
  7. //
  8. #import "SCCaptureUninitializedState.h"
  9. #import "SCManagedCapturerLogging.h"
  10. #import "SCManagedCapturerV1_Private.h"
  11. #import <SCFoundation/SCAssertWrapper.h>
  12. #import <SCFoundation/SCQueuePerformer.h>
  13. #import <SCFoundation/SCTraceODPCompatible.h>
  14. @interface SCCaptureUninitializedState () {
  15. __weak id<SCCaptureStateDelegate> _delegate;
  16. SCQueuePerformer *_performer;
  17. }
  18. @end
  19. @implementation SCCaptureUninitializedState
  20. - (instancetype)initWithPerformer:(SCQueuePerformer *)performer
  21. bookKeeper:(SCCaptureStateMachineBookKeeper *)bookKeeper
  22. delegate:(id<SCCaptureStateDelegate>)delegate
  23. {
  24. self = [super initWithPerformer:performer bookKeeper:bookKeeper delegate:delegate];
  25. if (self) {
  26. _delegate = delegate;
  27. _performer = performer;
  28. }
  29. return self;
  30. }
  31. - (void)didBecomeCurrentState:(SCStateTransitionPayload *)payload
  32. resource:(SCCaptureResource *)resource
  33. context:(NSString *)context
  34. {
  35. // No op.
  36. }
  37. - (SCCaptureStateMachineStateId)stateId
  38. {
  39. return SCCaptureUninitializedStateId;
  40. }
  41. - (void)initializeCaptureWithDevicePosition:(SCManagedCaptureDevicePosition)devicePosition
  42. resource:(SCCaptureResource *)resource
  43. completionHandler:(dispatch_block_t)completionHandler
  44. context:(NSString *)context
  45. {
  46. SCAssertPerformer(_performer);
  47. SCTraceODPCompatibleStart(2);
  48. SCLogCapturerInfo(@"Setting up with devicePosition:%lu", (unsigned long)devicePosition);
  49. // TODO: we need to push completionHandler to a payload and let intializedState handle.
  50. [[SCManagedCapturerV1 sharedInstance] setupWithDevicePosition:devicePosition completionHandler:completionHandler];
  51. [_delegate currentState:self requestToTransferToNewState:SCCaptureInitializedStateId payload:nil context:context];
  52. NSString *apiName =
  53. [NSString sc_stringWithFormat:@"%@/%@", NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
  54. [self.bookKeeper logAPICalled:apiName context:context];
  55. }
  56. @end