📄 video_send.cpp
字号:
///////////////////////////////////////////////////////// FileName: video_send.cpp// Author: b1gm0use// Project: myvideo#include <iostream>#include <qapplication.h>#include <string.h>#include <qsemaphore.h>#include "capture_event.h"#include "video_send.h"#include "video.h"#include "avi.h"using namespace std;///////////////////////////////////////////////////////// Public Functions///////////////////////////////////////////////////////void dump_image ( const BUFF * image, size_t size, const char * filename );// 构造函数video_send::video_send ( avi * avi_ptr_in ) // {{{{ verbose_output( 2, "create video_send" ); vp = NULL; last_image[0] = last_image[1] = last_image[2] = NULL; frame = 0; avi_ptr = avi_ptr_in;} // }}}// 析构函数video_send::~video_send ( void ) // {{{{ delete [] last_image[0]; delete [] last_image[1]; delete [] last_image[2];} // }}} // 初始化函数int video_send::init ( VideoPlayer * vp_in ) // {{{{ vp = vp_in; //开辟缓冲区 last_image[0] = new BUFF [ avi_ptr->video_opt.min_width * avi_ptr->video_opt.factor * avi_ptr->video_opt.min_height * avi_ptr->video_opt.factor * 3 ]; last_image[1] = new BUFF [ avi_ptr->video_opt.min_width * avi_ptr->video_opt.factor * avi_ptr->video_opt.min_height * avi_ptr->video_opt.factor * 3 ]; last_image[2] = new BUFF [ avi_ptr->video_opt.min_width * avi_ptr->video_opt.factor * avi_ptr->video_opt.min_height * avi_ptr->video_opt.factor * 3 ]; return 0;} // }}}// 发送捕捉图像完成的消息// 维护两个缓冲区,交替使用// 这个函数中的缓冲区有待优化int video_send::send_image ( const BUFF * image, int size ) // {{{{ verbose_output( 2, "create video_send" ); (*(avi_ptr->video_send_semaphore))++; memcpy( last_image[frame], image, size ); (*(avi_ptr->video_send_semaphore))--; //发送消息 capture_event * event = new capture_event( VIDEO_EVENT, last_image[frame], size ); verbose_output( 3, "sending new image change event." ); QApplication::postEvent( (QObject *) vp, (QEvent *) event ); frame = ( frame + 1 ) % 3; return 0;} // }}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -