本文主要是介绍VoiceEngine之voice hardware Demo,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
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);
这篇关于VoiceEngine之voice hardware Demo的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!