VoiceEngine获取硬件信息

  1. #include "webrtc\voice_engine\include\voe_base.h"
  2. #include "webrtc\voice_engine\include\voe_hardware.h"
  3. #include "webrtc\voice_engine\include\voe_errors.h"
  4. VoiceEngine* pVoeEngine;
  5. VoEHardware* pVoeHw;
  6. VoEBase* pVoeBase ;
  7. int main(int argc,char** argv)
  8. {
  9.     
  10.     pVoeEngine = VoiceEngine::Create();            // Get VoideEngine Factory        
          pVoeBase = VoEBase::GetInterface(pVoeEngine);  // Use Voe Factor to get Voe Interface
  1.     pVoeBase->Init();       // Voe must init
  2.     pVoeHw = VoEHardware::GetInterface(pVoeEngine);    
  3.    {
  4.             int res = 0 ;
  5.             int rd(0), pd(0);
  6.             res = pVoeHw->GetNumOfRecordingDevices(rd);
  7.             
  8.             res = pVoeHw->GetNumOfPlayoutDevices(pd);
  9.             
  10.             char dn[128] = { 0 };
  11.             char guid[128] = { 0 };
  12.             printf("\nPlayout devices (%d): \n", pd);
  13.             for (int j = 0; j < pd; ++j) {
  14.              res = pVoeHw->GetPlayoutDeviceName(j, dn, guid);
  15.             
  16.              printf(" %d: %s \n", j, dn);
  17.             }
  18.             printf("Recording devices (%d): \n", rd);
  19.             for (int j = 0; j < rd; ++j) {
  20.              res = pVoeHw->GetRecordingDeviceName(j, dn, guid);
  21.             
  22.              printf(" %d: %s \n", j, dn);
  23.             }
  24.             printf("Select playout device: ");
  25.             //ASSERT_EQ(1, scanf("%d", &pd));
  26.             res = pVoeHw->SetPlayoutDevice(pd);
  27.         
  28.             printf("Select recording device: ");
  29.             //ASSERT_EQ(1, scanf("%d", &rd));
  30.             printf("Setting sound devices \n");
  31.             res = pVoeHw->SetRecordingDevice(rd);
  32.             
  33.         }
  34.    
  35. }
 


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);

posted @ 2014-04-11 11:45  腐烂的翅膀  阅读(364)  评论(0编辑  收藏  举报