友善之臂视频监控方案源码学习(5) - 输入控制(11)
时间:2026-01-26
时间:2026-01-26
4 input_run分析
input_run看上去十分简单: [html] view plaincopy 1. int input_run(void) {
2. pglobal->buf = malloc(videoIn->framesizeIn); 3. if (pglobal->buf == NULL) {
4. fprintf(stderr, "could not allocate memory\n"); 5. exit(EXIT_FAILURE);
6. }
7.
8. pthread_create(&cam, 0, cam_thread, NULL);
9. pthread_detach(cam);
10.
11. return 0;
12. }
input_run只做了两件事:
(1) 分配视频数据存储空间
(2) 开辟视频采集线程。后续文章详细分析。
5 input_stop分析
input_stop主要功能是关闭视频采集线程
[html] view plaincopy
1.
2.
3.
4.
5.
6.
int input_stop(void) { DBG("will cancel input thread\n"); pthread_cancel(cam); return 0; }
6 input_cmd分析