iOS GPUImage之视频采集GPUImageVideoCamera

一、颜色转换矩阵
  • 标准清晰度:
    extern const GLfloat kColorConversion601[];
  • 全彩:
    extern const GLfloat kColorConversion601FullRange[];
  • 高清晰度:
    extern const GLfloat kColorConversion709[];
二、片元着色器
  • extern NSString *const kGPUImageYUVVideoRangeConversionForRGFragmentShaderString;
  • extern NSString *const kGPUImageYUVFullRangeConversionForLAFragmentShaderString;
  • extern NSString *const kGPUImageYUVVideoRangeConversionForLAFragmentShaderString;
三、代理

将要输出的sampleBuffer

@protocol GPUImageVideoCameraDelegate <NSObject>
@optional
-(void)willOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer;
@end
四、延展解析
	// 已采集的帧数
	NSUInteger numberOfFramesCaptured;
	// 采集的总帧数
    CGFloat totalFrameTimeDuringCapture;
    // 采集会话层
    AVCaptureSession *_captureSession;
	// 视频输入设备
    AVCaptureDevice *_inputCamera;
    // 音频输入设备
    AVCaptureDevice *_microphone;
    // 视频输入
    AVCaptureDeviceInput *videoInput;
    // 视频数据输出
    AVCaptureVideoDataOutput *videoOutput;

	// 停止采集
    BOOL capturePaused;
    // 输入和输出旋转方式
    GPUImageRotationMode outputRotation, internalRotation;
    // 帧渲染信号量
    dispatch_semaphore_t frameRenderingSemaphore;
        
    // yuv格式采集
    BOOL captureAsYUV;
    // 亮度纹理、色度纹理
    GLuint luminanceTexture, chrominanceTexture;
    
    // 摄像头采集协议
    __unsafe_unretained id<GPUImageVideoCameraDelegate> _delegate;
五、属性解析
	// 会话层
 	@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;
    // 输入摄像头
    @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;
	// 添加音频的输入和输出
    -(BOOL)addAudioInputsAndOutputs;
    // 移除音频的输入和输出
    -(BOOL)removeAudioInputsAndOutputs;
    // 移除输入和输出设备
    -(void)removeInputsAndOutputs;
    // 开始采集
    -(void)startCameraCapture;
    // 停止采集
    -(void)stopCameraCapture;
    // 暂停采集
    -(void)pauseCameraCapture;
    // 恢复采集
    -(void)resumeCameraCapture;
    // 处理视频数据
    -(void)processVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer;
    // 处理音频数据
    -(void)processAudioSampleBuffer:(CMSampleBufferRef)sampleBuffer;
    // 摄像头位置(前置/后置)
    -(AVCaptureDevicePosition)cameraPosition;
    // 视频连接
    -(AVCaptureConnection *)videoCaptureConnection;
    // 转换摄像头
    -(void)rotateCamera;
    // 平均帧时长
    -(CGFloat)averageFrameDurationDuringCapture;
    - (void)resetBenchmarkAverage;
    + (BOOL)isBackFacingCameraPresent;
    + (BOOL)isFrontFacingCameraPresent;

你可能感兴趣的:(iOS高级进阶,GPUImage,OpenGL,ES)