webrtc视频引擎之 vedio_capture_module介绍
来源:互联网 发布:安徽移动网络速度慢 编辑:程序博客网 时间:2024/06/10 22:47
此部分为webrtc采集视频图像之用,源码结构如下:
如上代码结构:
1,能直接看到的代码,是视频采集适配源码,用于不同平台的适配;
2,文件夹android为采集android设备的视频信息;
3,文件夹 ios为采集ios设备的视频信息;
4,文件夹linux为采集linux设备的视频信息;
5,文件夹mac为采集mac设备的视频信息;
6,文件夹windows为采集Windows设备的视频信息;
以下为视频采集模块的接口类:
主要的接口如Create函数,传入一个视频设备创建一个视频捕获实例;
StartCapture函数启动视频采集;
StopCapture函数停止视频采集;
IncomingFrame/IncomingI420VideoFrame 函数为采集帧回调函数,当开始采集视频的时候,采集到的每一帧的数据将通过该函数回调出来;根据你需要选择你的回调。
class VideoCaptureImpl: public VideoCaptureModule, public VideoCaptureExternal{public: /* * Create a video capture module object * * id - unique identifier of this video capture module object * deviceUniqueIdUTF8 - name of the device. Available names can be found by using GetDeviceName */ static VideoCaptureModule* Create(const int32_t id, const char* deviceUniqueIdUTF8); /* * Create a video capture module object used for external capture. * * id - unique identifier of this video capture module object * externalCapture - [out] interface to call when a new frame is captured. */ static VideoCaptureModule* Create(const int32_t id, VideoCaptureExternal*& externalCapture); static DeviceInfo* CreateDeviceInfo(const int32_t id); // Helpers for converting between (integral) degrees and // VideoCaptureRotation values. Return 0 on success. static int32_t RotationFromDegrees(int degrees, VideoCaptureRotation* rotation); static int32_t RotationInDegrees(VideoCaptureRotation rotation, int* degrees); // Implements Module declared functions. virtual int32_t ChangeUniqueId(const int32_t id); //Call backs virtual int32_t RegisterCaptureDataCallback(VideoCaptureDataCallback& dataCallback); virtual int32_t DeRegisterCaptureDataCallback(); virtual int32_t RegisterCaptureCallback(VideoCaptureFeedBack& callBack); virtual int32_t DeRegisterCaptureCallback(); virtual int32_t SetCaptureDelay(int32_t delayMS); virtual int32_t CaptureDelay(); virtual int32_t SetCaptureRotation(VideoCaptureRotation rotation); virtual int32_t EnableFrameRateCallback(const bool enable); virtual int32_t EnableNoPictureAlarm(const bool enable); virtual const char* CurrentDeviceName() const; // Module handling virtual int32_t TimeUntilNextProcess(); virtual int32_t Process(); // Implement VideoCaptureExternal // |capture_time| must be specified in the NTP time format in milliseconds. virtual int32_t <span style="color:#ff0000;">IncomingFrame</span>(uint8_t* videoFrame, int32_t videoFrameLength, const VideoCaptureCapability& frameInfo, int64_t captureTime = 0); virtual int32_t IncomingI420VideoFrame(I420VideoFrame* video_frame, int64_t captureTime = 0); // Platform dependent virtual int32_t <span style="color:#ff0000;">StartCapture</span>(const VideoCaptureCapability& capability) { _requestedCapability = capability; return -1; } virtual int32_t <span style="color:#ff0000;">StopCapture</span>() { return -1; } virtual bool CaptureStarted() {return false; } virtual int32_t CaptureSettings(VideoCaptureCapability& /*settings*/) { return -1; } VideoCaptureEncodeInterface* GetEncodeInterface(const VideoCodec& /*codec*/) { return NULL; }protected: VideoCaptureImpl(const int32_t id); virtual ~VideoCaptureImpl(); int32_t DeliverCapturedFrame(I420VideoFrame& captureFrame, int64_t capture_time); int32_t _id; // Module ID char* _deviceUniqueId; // current Device unique name; CriticalSectionWrapper& _apiCs; int32_t _captureDelay; // Current capture delay. May be changed of platform dependent parts. VideoCaptureCapability _requestedCapability; // Should be set by platform dependent code in StartCapture.private: void UpdateFrameCount(); uint32_t CalculateFrameRate(const TickTime& now); CriticalSectionWrapper& _callBackCs; TickTime _lastProcessTime; // last time the module process function was called. TickTime _lastFrameRateCallbackTime; // last time the frame rate callback function was called. bool _frameRateCallBack; // true if EnableFrameRateCallback bool _noPictureAlarmCallBack; //true if EnableNoPictureAlarm VideoCaptureAlarm _captureAlarm; // current value of the noPictureAlarm int32_t _setCaptureDelay; // The currently used capture delay VideoCaptureDataCallback* _dataCallBack; VideoCaptureFeedBack* _captureCallBack; TickTime _lastProcessFrameCount; TickTime _incomingFrameTimes[kFrameRateCountHistorySize];// timestamp for local captured frames VideoRotationMode _rotateFrame; //Set if the frame should be rotated by the capture module. I420VideoFrame _captureFrame; VideoFrame _capture_encoded_frame; // Used to make sure incoming timestamp is increasing for every frame. int64_t last_capture_time_; // Delta used for translating between NTP and internal timestamps. const int64_t delta_ntp_internal_ms_;};
其实对于专业要求不高的开发者,直接调用这些接口就可以实现视频的采集, 当然如果你对视频采集的专业性要求非常高,可能需要你去专门去研究针对每种设备的采集实现也就是上图中的几种设备的采集源码。现在直播这么火热,又是移动互联网时代,有兴趣的可以多研究研究android和IOS视频采集的方式。
0 0
- webrtc视频引擎之 vedio_capture_module介绍
- webrtc视频引擎之video_render(视频渲染)介绍
- webrtc音频引擎模块之 audio_device介绍
- webrtc音频引擎之audio_processing介绍
- webrtc音频引擎之CNG模块介绍
- webrtc音频引擎之common_audio介绍
- webrtc音频引擎之压缩格式介绍
- webrtc音频引擎模块之 audio_device介绍
- Android之WebRTC介绍
- Android之WebRTC介绍
- Android之WebRTC介绍
- Android之WebRTC介绍
- Android之WebRTC介绍
- webrtc之本地视频传输
- Android之WebRTC介绍(一)
- Android之WebRTC介绍(二)
- webrtc引擎
- WebRTC音视频引擎研究(1)--整体架构分析
- poj 2976(01分数规划+二分)
- c++ map删除元素的三种方式
- HDU4597:Play Game(记忆化搜索(dp))(博弈)
- hihocoder1363 图像算子
- Struts2框架10.方法拦截器
- webrtc视频引擎之 vedio_capture_module介绍
- 修改VNCSERVER的分辨率
- 关于PHP中复选框CheckBox的数据库存取使用方法总结
- ajax 如何 读取 xml 文档
- Android中多图片选择器PhotoPicker库的使用(仿微信,秒杀MultiImageSelector)自己修改的多选
- 注意点小结(Java)
- RasDeleteSubEntry
- 数据---File
- apicloud中多个按钮的切换