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.

75 lines
2.3 KiB

  1. //
  2. // SCCaptureScanningState.m
  3. // Snapchat
  4. //
  5. // Created by Xiaokang Liu on 09/01/2018.
  6. //
  7. #import "SCCaptureScanningState.h"
  8. #import "SCManagedCapturerLogging.h"
  9. #import "SCManagedCapturerV1_Private.h"
  10. #import <SCFoundation/SCAssertWrapper.h>
  11. #import <SCFoundation/SCQueuePerformer.h>
  12. #import <SCFoundation/SCTraceODPCompatible.h>
  13. @interface SCCaptureScanningState () {
  14. __weak id<SCCaptureStateDelegate> _delegate;
  15. SCQueuePerformer *_performer;
  16. }
  17. @end
  18. @implementation SCCaptureScanningState
  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. SCAssert(delegate, @"");
  26. SCAssert(performer, @"");
  27. SCAssert(bookKeeper, @"");
  28. _delegate = delegate;
  29. _performer = performer;
  30. }
  31. return self;
  32. }
  33. - (void)didBecomeCurrentState:(SCStateTransitionPayload *)payload
  34. resource:(SCCaptureResource *)resource
  35. context:(NSString *)context
  36. {
  37. // No op.
  38. }
  39. - (SCCaptureStateMachineStateId)stateId
  40. {
  41. return SCCaptureScanningStateId;
  42. }
  43. - (void)stopScanWithCompletionHandler:(dispatch_block_t)completionHandler
  44. resource:(SCCaptureResource *)resource
  45. context:(NSString *)context
  46. {
  47. SCAssertPerformer(_performer);
  48. SCTraceODPCompatibleStart(2);
  49. SCLogCapturerInfo(@"stop scan asynchronously.");
  50. [SCCaptureWorker stopScanWithCompletionHandler:completionHandler resource:resource];
  51. [_delegate currentState:self requestToTransferToNewState:SCCaptureRunningStateId 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. - (void)cancelRecordingWithResource:(SCCaptureResource *)resource context:(NSString *)context
  57. {
  58. // Intentionally No Op, this will be removed once CCAM-13851 gets resolved.
  59. NSString *apiName =
  60. [NSString sc_stringWithFormat:@"%@/%@", NSStringFromClass([self class]), NSStringFromSelector(_cmd)];
  61. [self.bookKeeper logAPICalled:apiName context:context];
  62. }
  63. @end