GPUImageVideoCamera 方法解析
顏色矩陣轉(zhuǎn)換
extern const GLfloat kColorConversion601[];//標(biāo)準(zhǔn)清晰度
extern const GLfloat kColorConversion601FullRange[];//全彩
extern const GLfloat kColorConversion709[];//高清晰度
片段著色器:
extern NSString *const kGPUImageYUVVideoRangeConversionForRGFragmentShaderString;
extern NSString *const kGPUImageYUVFullRangeConversionForLAFragmentShaderString;
extern NSString *const kGPUImageYUVVideoRangeConversionForLAFragmentShaderString;
代理:
-(void)willOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer;//將要輸出samp leBuffer
私有屬性:
NSUInteger numberOfFramesCaptured;//已采集的幀數(shù)
CGFloat totalFrameTimeDuringCapture;//采集的總幀數(shù)
AVCaptureSession *_captureSession;//采集會話層
AVCaptureDevice *_inputCamera;//視頻輸入設(shè)備
AVCaptureDevice *_microphone;//音頻輸入設(shè)備
AVCaptureDeviceInput *videoInput;//視頻輸入
AVCaptureVideoDataOutput *videoOutput;//視頻數(shù)據(jù)輸出
BOOL capturePaused;//停止采集
GPUImageRotationMode outputRotation, internalRotation;//輸入和輸出旋轉(zhuǎn)方式
dispatch_semaphore_t frameRenderingSemaphore;//幀渲染信號量
BOOL captureAsYUV;//yuv格式采集
GLuint luminanceTexture, chrominanceTexture;//亮度紋理炉峰、色度紋理
__unsafe_unretained id<GPUImageVideoCameraDelegate> _delegate;//攝像頭采集協(xié)議
屬性:
@property(readonly, retain, nonatomic) AVCaptureSession *captureSession;//會話層
@property (readwrite, nonatomic, copy) NSString *captureSessionPreset;//采集分辨率
@property (readwrite) int32_t frameRate;//幀率
@property (readonly, getter = isFrontFacingCameraPresent) BOOL frontFacingCameraPresent;//前置攝像頭
@property (readonly, getter = isBackFacingCameraPresent) BOOL backFacingCameraPresent;//后置攝像頭
@property(readwrite, nonatomic) BOOL runBenchmark;//基準(zhǔn)
@property(readonly) AVCaptureDevice *inputCamera;//輸入攝像頭
@property(readwrite, nonatomic) UIInterfaceOrientation outputImageOrientation;//攝像頭朝向
@property(readwrite, nonatomic) BOOL horizontallyMirrorFrontFacingCamera, horizontallyMirrorRearFacingCamera;//前者攝像頭水平鏡像说贝,后置攝像頭水平鏡像
@property(nonatomic, assign) id<GPUImageVideoCameraDelegate> delegate;//攝像頭代理
方法集合:
-(id)initWithSessionPreset:(NSString *)sessionPreset cameraPosition:(AVCaptureDevicePosition)cameraPosition;//根據(jù)分辨率缨该、攝像頭朝向初始化攝像頭
-(BOOL)addAudioInputsAndOutputs;//添加音頻的輸入和輸出
-(BOOL)removeAudioInputsAndOutputs;//移除音頻的輸入和輸出
-(void)removeInputsAndOutputs;//移除輸入和輸出設(shè)備
-(void)startCameraCapture;//開始采集
-(void)stopCameraCapture;//停止采集
-(void)pauseCameraCapture;//暫停采集
-(void)resumeCameraCapture;//恢復(fù)采集
-(void)processVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer;//處理視頻數(shù)據(jù)
-(void)processAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer;//處理音頻數(shù)據(jù)
-(AVCaptureDevicePosition)cameraPosition;//攝像頭位置(前置/后置)
-(AVCaptureConnection *)videoCaptureConnection;//視頻連接
-(void)rotateCamera;//轉(zhuǎn)換攝像頭
-(CGFloat)averageFrameDurationDuringCapture;//平均幀時長
- (void)resetBenchmarkAverage;
+ (BOOL)isBackFacingCameraPresent;
+ (BOOL)isFrontFacingCameraPresent;