Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1651736
  • 博文数量: 245
  • 博客积分: 10378
  • 博客等级: 上将
  • 技术积分: 2571
  • 用 户 组: 普通用户
  • 注册时间: 2009-03-27 08:19
文章分类

全部博文(245)

文章存档

2013年(4)

2012年(8)

2011年(13)

2010年(68)

2009年(152)

分类: C/C++

2013-06-24 23:57:50

Target:  利用webrtc  voice engine 获取音频媒体设备信息

点击(此处)折叠或打开

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



阅读(3139) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~