VoiceEngine之voice hardware Demo

4 篇文章 0 订阅
4 篇文章 0 订阅
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);


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值