2010-11-08 52 views
0

我有一些class file.h,其中public:bool frameSendingFinished;被定義。 因此,在類邏輯我創建和編碼視頻幀,現在我想發送到一些服務器使用ffmpeg。我想在單獨的線程中發送所以在我的班級功能之一(file.cpp)我做的:Boost線程和FFmpeg:這樣簡單的代碼給我錯誤C2064。我做錯了什麼方式?

if (frameSendingFinished) 
    { 
     boost::thread UrlWriteFrame(url_context, (unsigned char *)pb_buffer, len); 
    } 

....// some other functions code etc. 

    void VideoEncoder::UrlWriteFrame(URLContext *h, const unsigned char *buf, int size) 
{ 
    frameSendingFinished =false; 
    url_write (h, (unsigned char *)buf, size); 
    frameSendingFinished =true; 
} 

它與創造出新的線程。在談到螺紋線使得它編譯...

這樣的錯誤是error c2064 term does not evaluate to a function taking 2 arguments

所以 - 我該怎麼辦我的代碼,使升壓工作,在我的課?

回答

1

當你寫:

boost::thread UrlWriteFrame(url_context, (unsigned char *)pb_buffer, len); 

創建一個名爲UrlWriteFrame一個線程對象,並通過url_contextpb_bufferlen的升壓::線程構造函數。其中一個boost :: thread的ctors需要一些可調用的(函數指針,函數對象)作爲第一個參數,並將其他參數轉發給該函數。在你的榜樣,它最終想是這樣的:

url_context(pb_buffer, len); 

這可能是什麼觸發了「不評估服用2個參數的函數」的錯誤。

IIUC,您想在新線程中調用UrlWriteFrame函數。正確的方法做,與升壓::線程會是這樣的:

boost::thread (&VideoEncoder::UrlWriteFrame, this, url_context, (unsigned char *)pb_buffer, len); 

(假設這是從視頻編碼的方法之一調用)