Target: 利用webrtc voice engine 获取音频媒体设备信息
-
#include "webrtc\voice_engine\include\voe_base.h"
-
#include "webrtc\voice_engine\include\voe_hardware.h"
-
#include "webrtc\voice_engine\include\voe_errors.h"
-
-
VoiceEngine* pVoeEngine;
-
VoEHardware* pVoeHw;
-
VoEBase* pVoeBase ;
-
-
int main(int argc,char** argv)
-
{
-
-
pVoeEngine = VoiceEngine::Create(); // Get VoideEngine Factory
pVoeBase = VoEBase::GetInterface(pVoeEngine); // Use Voe Factor to get Voe Interface
-
pVoeBase->Init(); // Voe must init
-
pVoeHw = VoEHardware::GetInterface(pVoeEngine);
-
-
{
-
-
int res = 0 ;
-
int rd(0), pd(0);
-
res = pVoeHw->GetNumOfRecordingDevices(rd);
-
-
res = pVoeHw->GetNumOfPlayoutDevices(pd);
-
-
-
char dn[128] = { 0 };
-
char guid[128] = { 0 };
-
printf("\nPlayout devices (%d): \n", pd);
-
for (int j = 0; j < pd; ++j) {
-
res = pVoeHw->GetPlayoutDeviceName(j, dn, guid);
-
-
printf(" %d: %s \n", j, dn);
-
}
-
-
printf("Recording devices (%d): \n", rd);
-
for (int j = 0; j < rd; ++j) {
-
res = pVoeHw->GetRecordingDeviceName(j, dn, guid);
-
-
printf(" %d: %s \n", j, dn);
-
}
-
-
printf("Select playout device: ");
-
//ASSERT_EQ(1, scanf("%d", &pd));
-
res = pVoeHw->SetPlayoutDevice(pd);
-
-
printf("Select recording device: ");
-
//ASSERT_EQ(1, scanf("%d", &rd));
-
printf("Setting sound devices \n");
-
res = pVoeHw->SetRecordingDevice(rd);
-
-
}
-
-
}
VoiceEngine和VideoEngine一样, 使用Factory Model模式,Factory Model使用流程:
1. 创建VoiceEngine或者VideoEngine, 例如:
VoiceEngine::Create()
2. 获取Engine的Interface,
VoEBase::GetInterface(), Engine Interface获取必须init();
3. 在factory下,有很多interface,都可以利用2中方法获取。
4. 使用完释放: Terminate(),每个interface都要release();最后VoiceEngine::Delete( engine object);
阅读(3139) | 评论(0) | 转发(0) |