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.

57 lines
2.5 KiB

  1. //
  2. // SCManagedCapturer.h
  3. // Snapchat
  4. //
  5. // Created by Liu Liu on 4/20/15.
  6. // Copyright (c) 2015 Liu Liu. All rights reserved.
  7. //
  8. #import "SCCaptureCommon.h"
  9. #import "SCCapturer.h"
  10. #import <SCFoundation/SCTraceODPCompatible.h>
  11. #import <AVFoundation/AVFoundation.h>
  12. #import <Foundation/Foundation.h>
  13. /**
  14. * Manage AVCaptureSession with SCManagedCapturerV1
  15. *
  16. * In phantom, there are a lot of places we use AVCaptureSession. However, since for each app, only one session
  17. * can run at the same time, we need some kind of management for the capture session.
  18. *
  19. * SCManagedCapturerV1 manages the state of capture session in following ways:
  20. *
  21. * All operations in SCManagedCapturerV1 are handled on a serial queue, to ensure its sequence. All callbacks (either
  22. * on the listener or the completion handler) are on the main thread. The state of SCManagedCapturerV1 are conveniently
  23. * maintained in a SCManagedCapturerState object, which is immutable and can be passed across threads, it mains a
  24. * consistent view of the capture session, if it is not delayed (thus, the state may deliver as current active device
  25. * is back camera on main thread, but in reality, on the serial queue, the active device switched to the front camera
  26. * already. However, this is OK because state.devicePosition will be back camera and with all its setup at that time.
  27. * Note that it is impossible to have an on-time view of the state across threads without blocking each other).
  28. *
  29. * For main use cases, you setup the capturer, add the preview layer, and then can call capture still image
  30. * or record video, and SCManagedCapturerV1 will do the rest (make sure it actually captures image / video, recover
  31. * from error, or setup our more advanced image / video post-process).
  32. *
  33. * The key classes that drive the recording flow are SCManagedVideoStreamer and SCManagedVideoFileStreamer which
  34. * conform to SCManagedVideoDataSource. They will stream images to consumers conforming to
  35. * SCManagedVideoDataSourceListener
  36. * such as SCManagedLensesProcessor, SCManagedDeviceCapacityAnalyzer, SCManagedVideoScanner and ultimately
  37. * SCManagedVideoCapturer and SCManagedStillImageCapturer which record the final output.
  38. *
  39. */
  40. @class SCCaptureResource;
  41. extern NSString *const kSCLensesTweaksDidChangeFileInput;
  42. @interface SCManagedCapturerV1 : NSObject <SCCapturer, SCTimeProfilable>
  43. + (SCManagedCapturerV1 *)sharedInstance;
  44. /*
  45. The following APIs are reserved to be only used for SCCaptureCore aka managedCapturerV2.
  46. */
  47. - (instancetype)initWithResource:(SCCaptureResource *)resource;
  48. @end