前面我们分析了VideoCaptureInputTest的实现,从中了解到了VideoCaptureInput的基本用法:
1.VideoCaptureInput类成员分析:
关键成员变量:
- encoder_thread_,对输入video数据进行处理的主线程
- capture_event_,控制encoder_thread_执行,通过Wait()函数阻塞线程,当数据ready后,通过Set()函数激活
- module_process_thread_,没搞明白
- frame_callback_,通过callback方法获取video数据
- stats_proxy_,发送端video数据信息的变量,需要即时更新
- local_renderer_,本地图像渲染
- incoming_frame_,当前收到的frame
- VideoCaptureInput构造函数,初始化相关变量
- EncoderThreadFunction,encoder_thread_的具体实现
- IncomingCapturedFrame,将数据保存至captured_frame_,并驱动EncodeProcess
2. 创建VideoCaptureInput对象
- ThreadWrapper::CreateThread(EncoderThreadFunction>..)
- capture_event_(EventWrapper::Create())
VideoCaptureInput::VideoCaptureInput(
ProcessThread* module_process_thread,
VideoCaptureCallback* frame_callback,
VideoRenderer* local_renderer,
SendStatisticsProxy* stats_proxy,
CpuOveruseObserver* overuse_observer,
EncodingTimeObserver* encoding_time_observer)
: capture_cs_(CriticalSectionWrapper::CreateCriticalSection()),
module_process_thread_(module_process_thread),
frame_callback_(frame_callback),
local_renderer_(local_renderer),
stats_proxy_(stats_proxy),
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
//创建encode thread
encoder_thread_(ThreadWrapper::CreateThread(E