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.

80 lines
2.7 KiB

  1. //
  2. // SCManagedCapturePreviewLayerController.h
  3. // Snapchat
  4. //
  5. // Created by Liu Liu on 5/5/15.
  6. // Copyright (c) 2015 Snapchat, Inc. All rights reserved.
  7. //
  8. #import <SCCameraFoundation/SCManagedVideoDataSource.h>
  9. #import <SCFoundation/SCAssertWrapper.h>
  10. #import <SCGhostToSnappable/SCGhostToSnappableSignal.h>
  11. #import <AVFoundation/AVFoundation.h>
  12. #import <Foundation/Foundation.h>
  13. #import <Metal/Metal.h>
  14. #import <UIKit/UIKit.h>
  15. @protocol SCCapturer;
  16. @class LSAGLView, SCBlackCameraDetector, SCManagedCapturePreviewLayerController;
  17. @protocol SCManagedCapturePreviewLayerControllerDelegate
  18. - (SCBlackCameraDetector *)blackCameraDetectorForManagedCapturePreviewLayerController:
  19. (SCManagedCapturePreviewLayerController *)controller;
  20. - (sc_create_g2s_ticket_f)g2sTicketForManagedCapturePreviewLayerController:
  21. (SCManagedCapturePreviewLayerController *)controller;
  22. @end
  23. /**
  24. * SCManagedCapturePreviewLayerController controls display of frame in a view. The controller has 3
  25. * different methods for this.
  26. * AVCaptureVideoPreviewLayer: This is a feed coming straight from the camera and does not allow any
  27. * image processing or modification of the frames displayed.
  28. * LSAGLView: OpenGL based video for displaying video that is being processed (Lenses etc.)
  29. * CAMetalLayer: Metal layer drawing textures on a vertex quad for display on screen.
  30. */
  31. @interface SCManagedCapturePreviewLayerController : NSObject <SCManagedSampleBufferDisplayController>
  32. @property (nonatomic, strong, readonly) UIView *view;
  33. @property (nonatomic, strong, readonly) AVCaptureVideoPreviewLayer *videoPreviewLayer;
  34. @property (nonatomic, strong, readonly) LSAGLView *videoPreviewGLView;
  35. @property (nonatomic, weak) id<SCManagedCapturePreviewLayerControllerDelegate> delegate;
  36. + (instancetype)sharedInstance;
  37. - (void)pause;
  38. - (void)resume;
  39. - (UIView *)newStandInViewWithRect:(CGRect)rect;
  40. - (void)setManagedCapturer:(id<SCCapturer>)managedCapturer;
  41. // This method returns a token that you can hold on to. As long as the token is hold,
  42. // an outdated view will be hold unless the app backgrounded.
  43. - (NSString *)keepDisplayingOutdatedPreview;
  44. // End displaying the outdated frame with an issued keep token. If there is no one holds
  45. // any token any more, this outdated view will be flushed.
  46. - (void)endDisplayingOutdatedPreview:(NSString *)keepToken;
  47. // Create views for Metal, this method need to be called on the main thread.
  48. - (void)setupPreviewLayer;
  49. // Create render pipeline state, setup shaders for Metal, this need to be called off the main thread.
  50. - (void)setupRenderPipeline;
  51. - (void)applicationDidEnterBackground;
  52. - (void)applicationWillEnterForeground;
  53. - (void)applicationWillResignActive;
  54. - (void)applicationDidBecomeActive;
  55. @end