GPUImageVideoCamera.h源码解析

颜色转换矩阵:
extern const GLfloat kColorConversion601[];//标准清晰度
extern const GLfloat kColorConversion601FullRange[];//全彩
extern const GLfloat kColorConversion709[];//高清晰度
片段着色器:
extern NSString *const kGPUImageYUVVideoRangeConversionForRGFragmentShaderString;
extern NSString *const kGPUImageYUVFullRangeConversionForLAFragmentShaderString;
extern NSString *const kGPUImageYUVVideoRangeConversionForLAFragmentShaderString;
代理:
@protocol GPUImageVideoCameraDelegate <NSObject>
@optional
-(void)willOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer;//将要输出samp leBuffer
@end
interface:
@interface GPUImageVideoCamera : GPUImageOutput <AVCaptureVideoDataOutputSampleBufferDelegate,
AVCaptureAudioDataOutputSampleBufferDelegate>
    { 
    
    NSUInteger numberOfFramesCaptured;//已采集的帧数
    CGFloat totalFrameTimeDuringCapture;//采集的总帧数
    AVCaptureSession *_captureSession;//采集会话层
    AVCaptureDevice *_inputCamera;//视频输入设备
    AVCaptureDevice *_microphone;//音频输入设备
    AVCaptureDeviceInput *videoInput;//视频输入
    AVCaptureVideoDataOutput *videoOutput;//视频数据输出

    BOOL capturePaused;//停止采集
    GPUImageRotationMode outputRotation, internalRotation;//输入和输出旋转方式
    dispatch_semaphore_t frameRenderingSemaphore;//帧渲染信号量
        
    BOOL captureAsYUV;//yuv格式采集
    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;

@end
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1._has_include()以前自己从没用过 __has_include() 这个宏,其实从字面意义也能猜出其...
    胡小夜大叔阅读 4,619评论 0 49
  • 《敦煌小记》 没有多少犹豫, 一如从成都, 来到这淡到没有风味的新疆。 我从西北的天寒地冻中, 踏入黄土高坡的扬尘...
    小沃姑娘阅读 3,325评论 4 10
  • 7天拆线。7天伤口都可以长好吧! 拆线的时候,在老家。拆线的医生说,你的线挺好的。。。。。。。一会看了下伤口,确实...
    令胡阅读 1,404评论 0 0
  • 回首过去的一年,还真的是发生了很多大事在我们这个小家庭里。年初四月份,先生遭遇到了intel十年一遇的大裁员,记得...
    gingercui阅读 1,618评论 0 0