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.

102 lines
4.5 KiB

  1. //
  2. // SCManagedVideoCapturer.h
  3. // Snapchat
  4. //
  5. // Created by Liu Liu on 5/1/15.
  6. // Copyright (c) 2015 Liu Liu. All rights reserved.
  7. //
  8. #import "SCManagedRecordedVideo.h"
  9. #import "SCManagedVideoCapturerOutputSettings.h"
  10. #import "SCVideoCaptureSessionInfo.h"
  11. #import <SCCameraFoundation/SCManagedAudioDataSource.h>
  12. #import <SCCameraFoundation/SCManagedVideoDataSourceListener.h>
  13. #import <SCFoundation/SCFuture.h>
  14. #import <AVFoundation/AVFoundation.h>
  15. #import <Foundation/Foundation.h>
  16. typedef void (^sc_managed_video_capturer_recording_completion_handler_t)(NSURL *fileURL, NSError *error);
  17. @class SCManagedVideoCapturer, SCTimedTask;
  18. @protocol SCManagedVideoCapturerDelegate <NSObject>
  19. // All these calbacks are invoked on a private queue for video recording channels
  20. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  21. didBeginVideoRecording:(SCVideoCaptureSessionInfo)sessionInfo;
  22. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  23. didBeginAudioRecording:(SCVideoCaptureSessionInfo)sessionInfo;
  24. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  25. willStopWithRecordedVideoFuture:(SCFuture<id<SCManagedRecordedVideo>> *)videoProviderFuture
  26. videoSize:(CGSize)videoSize
  27. placeholderImage:(UIImage *)placeholderImage
  28. session:(SCVideoCaptureSessionInfo)sessionInfo;
  29. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  30. didSucceedWithRecordedVideo:(SCManagedRecordedVideo *)recordedVideo
  31. session:(SCVideoCaptureSessionInfo)sessionInfo;
  32. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  33. didFailWithError:(NSError *)error
  34. session:(SCVideoCaptureSessionInfo)sessionInfo;
  35. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  36. didCancelVideoRecording:(SCVideoCaptureSessionInfo)sessionInfo;
  37. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  38. didGetError:(NSError *)error
  39. forType:(SCManagedVideoCapturerInfoType)type
  40. session:(SCVideoCaptureSessionInfo)sessionInfo;
  41. - (NSDictionary *)managedVideoCapturerGetExtraFrameHealthInfo:(SCManagedVideoCapturer *)managedVideoCapturer;
  42. - (void)managedVideoCapturer:(SCManagedVideoCapturer *)managedVideoCapturer
  43. didAppendVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer
  44. presentationTimestamp:(CMTime)presentationTimestamp;
  45. @end
  46. /**
  47. * AVFoundation backed class that writes frames to an output file. SCManagedVideoCapturer
  48. * uses SCManagedVideoCapturerOutputSettings to determine output settings. If no output
  49. * settings are passed in (nil) SCManagedVideoCapturer will fall back on default settings.
  50. */
  51. @interface SCManagedVideoCapturer : NSObject <SCManagedVideoDataSourceListener, SCManagedAudioDataSource>
  52. /**
  53. * Return the output URL that passed into beginRecordingToURL method
  54. */
  55. @property (nonatomic, copy, readonly) NSURL *outputURL;
  56. @property (nonatomic, weak) id<SCManagedVideoCapturerDelegate> delegate;
  57. @property (nonatomic, readonly) SCVideoCaptureSessionInfo activeSession;
  58. @property (nonatomic, assign, readonly) CMTime firstWrittenAudioBufferDelay;
  59. @property (nonatomic, assign, readonly) BOOL audioQueueStarted;
  60. - (instancetype)initWithQueuePerformer:(SCQueuePerformer *)queuePerformer;
  61. - (void)prepareForRecordingWithAudioConfiguration:(SCAudioConfiguration *)configuration;
  62. - (SCVideoCaptureSessionInfo)startRecordingAsynchronouslyWithOutputSettings:
  63. (SCManagedVideoCapturerOutputSettings *)outputSettings
  64. audioConfiguration:(SCAudioConfiguration *)audioConfiguration
  65. maxDuration:(NSTimeInterval)maxDuration
  66. toURL:(NSURL *)URL
  67. deviceFormat:(AVCaptureDeviceFormat *)deviceFormat
  68. orientation:(AVCaptureVideoOrientation)videoOrientation
  69. captureSessionID:(NSString *)captureSessionID;
  70. - (void)stopRecordingAsynchronously;
  71. - (void)cancelRecordingAsynchronously;
  72. // Schedule a task to run, it is thread safe.
  73. - (void)addTimedTask:(SCTimedTask *)task;
  74. // Clear all tasks, it is thread safe.
  75. - (void)clearTimedTasks;
  76. @end