?? audio_cap_thread.cpp
字號(hào):
///////////////////////////////////////////////////////// FileName: audio_cap_thread.cpp// Author: b1gm0use// Project: myaudio#include <iostream>#include "network.h"#include "audio_cap_thread.h"#include "common.h"#include "audio_cap.h"#include "network_audio_send.h"#include "audio_send.h"#include "avi.h"using namespace std;///////////////////////////////////////////////////////// Public Functions///////////////////////////////////////////////////////// 構(gòu)造函數(shù)// 傳入?yún)?shù)為// ap_in 上層AudioPlayer對(duì)象指針// stackSize QThread所用的參數(shù)audio_cap_thread::audio_cap_thread ( avi * avi_ptr_in, AudioPlayer * ap_in, unsigned int stackSize ) :QThread( stackSize ) // {{{{ verbose_output( 2, "create audio_cap_thread." ); ap = ap_in; ns = NULL; as = NULL; avi_ptr = avi_ptr_in;} // }}}audio_cap_thread::~audio_cap_thread ( void ) // {{{{ delete as; delete ns;} // }}}// 運(yùn)行部分,線程代碼在這里void audio_cap_thread::run ( void ) // {{{{ int size = 0; BUFF * image = NULL; audio_cap * ac = NULL; verbose_output( 1, "running new audio_cap_thread." ); // 如果是standalone會(huì)創(chuàng)建一個(gè)audio_cap對(duì)象 // 如果是listen會(huì)再創(chuàng)建一個(gè)network_send對(duì)象 ac = new audio_cap( avi_ptr ); ac->init(); if ( avi_ptr->net_mode == LISTEN ) { verbose_output( 3, "net_mode LISTEN" ); ns = new network_audio_send( avi_ptr ); ns->init(); } // 創(chuàng)建audio_send對(duì)象,用于向主體發(fā)送捕捉完畢信號(hào) if ( avi_ptr->net_mode == STANDALONE ) { as = new audio_send; as->init( ap ); } verbose_output( 1, "begin audio capture loop." ); while ( 1 ) { // 取得一幀 if ( ac->get_image ( image, &size ) == FAILED ) { cerr << "Warning! get image error" << endl; continue; } if ( image == NULL ) { cerr << "Can't get new audio frame" << endl; ::exit( 1 ); } // 發(fā)出信號(hào) if ( avi_ptr->net_mode == STANDALONE ) { as->send_image( image, size ); } // 如果做為listen方,則向其它c(diǎn)onnect方傳送圖像 if ( avi_ptr->net_mode == LISTEN ) { ns->send_image( image, size ); } } return ;} // }}}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -