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.

68 lines
2.0 KiB

  1. //
  2. // SCCaptureInitializedState.m
  3. // Snapchat
  4. //
  5. // Created by Jingtian Yang on 20/12/2017.
  6. //
  7. #import "SCCaptureInitializedState.h"
  8. #import "SCCapturerToken.h"
  9. #import "SCManagedCapturerLogging.h"
  10. #import "SCManagedCapturerV1_Private.h"
  11. #import <SCFoundation/SCAssertWrapper.h>
  12. #import <SCFoundation/SCQueuePerformer.h>
  13. @interface SCCaptureInitializedState () {
  14. __weak id<SCCaptureStateDelegate> _delegate;
  15. SCQueuePerformer *_performer;
  16. }
  17. @end
  18. @implementation SCCaptureInitializedState
  19. - (instancetype)initWithPerformer:(SCQueuePerformer *)performer
  20. bookKeeper:(SCCaptureStateMachineBookKeeper *)bookKeeper
  21. delegate:(id<SCCaptureStateDelegate>)delegate
  22. {
  23. self = [super initWithPerformer:performer bookKeeper:bookKeeper delegate:delegate];
  24. if (self) {
  25. _delegate = delegate;
  26. _performer = performer;
  27. }
  28. return self;
  29. }
  30. - (void)didBecomeCurrentState:(SCStateTransitionPayload *)payload
  31. resource:(SCCaptureResource *)resource
  32. context:(NSString *)context
  33. {
  34. // No op.
  35. }
  36. - (SCCaptureStateMachineStateId)stateId
  37. {
  38. return SCCaptureInitializedStateId;
  39. }
  40. - (void)startRunningWithCapturerToken:(SCCapturerToken *)token
  41. resource:(SCCaptureResource *)resource
  42. completionHandler:(dispatch_block_t)completionHandler
  43. context:(NSString *)context
  44. {
  45. SCAssertPerformer(_performer);
  46. SCTraceODPCompatibleStart(2);
  47. SCLogCapturerInfo(@"startRunningAsynchronouslyWithCompletionHandler called. token: %@", token);
  48. [SCCaptureWorker startRunningWithCaptureResource:resource token:token completionHandler:completionHandler];
  49. [_delegate currentState:self requestToTransferToNewState:SCCaptureRunningStateId payload:nil context:context];
  50. NSString *apiName =
  51. [NSString sc_stringWithFormat:@"%@/%@", NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
  52. [self.bookKeeper logAPICalled:apiName context:context];
  53. }
  54. @end