如何在没有音频硬件设备的情况下从PJSIP获取音频流

您所在的位置:网站首页 允许此设备使用音频硬件加速 如何在没有音频硬件设备的情况下从PJSIP获取音频流

如何在没有音频硬件设备的情况下从PJSIP获取音频流

2024-07-12 14:59| 来源: 网络整理| 查看: 265

我想使用PJSIP的C API将传入的音频记录到没有硬件声音设备的机器上的文件中。

我不确定细节,但是PJSIP的稀疏文档表明通过pjsua_set_null_snd_dev()调用应该是可能的。

在下面的调用示例中,pjmedia_aud_dev_default_param(PJMEDIA_AUD_DEFAULT_CAPTURE_DEV, ¶m)返回状态下的PJMEDIA_AUD_INVALID_DEV。

当没有硬件音频设备时,代码会在Linux (Ubuntu 14)和Windows 10上生成相同的错误。如果安装了硬件音频设备驱动程序,那么相同的代码在两个OSes上都可以正常工作。

我已经在启用PJMEDIA_AUDIO_DEV_HAS_NULL_AUDIO的情况下编译了PJSIP库。在Linux上,模块snd-dummy的存在没有帮助。

如何在调用pjsua_set_null_snd_dev()后从SIP调用访问音频数据流

代码语言:javascript复制#include #include #include #include #include #include #include #include #include #include #include int main(int, char **) { // Create pjsua first! pj_status_t status = pjsua_create(); if (status != PJ_SUCCESS) { fprintf(stderr,"pjsua_create error\n"); return -1; } // Init pjsua pjsua_config cfg; pjsua_logging_config log_cfg; pjsua_config_default(&cfg); pjsua_logging_config_default(&log_cfg); log_cfg.console_level = 4; status = pjsua_init(&cfg, &log_cfg, NULL); if (status != PJ_SUCCESS) { fprintf(stderr,"pjsua_init error\n"); return -1; } // Proactively list known audio devices so we are sure there are NONE pjmedia_aud_dev_info info[64]; unsigned info_count = 64; pjsua_enum_aud_devs(info, &info_count); fprintf(stderr,"Listing known sound devices, total of [%u]\n", info_count); for (unsigned i = 0; iinfo); param.samples_per_frame = PJMEDIA_PIA_SPF(&wav->info); param.channel_count = PJMEDIA_PIA_CCNT(&wav->info); param.bits_per_sample = PJMEDIA_PIA_BITS(&wav->info); status = pjmedia_aud_stream_create(¶m, &test_rec_cb, &test_play_cb, wav, &strm); if (status != PJ_SUCCESS) { fprintf(stderr, "Error opening the sound stream"); return -1; } status = pjmedia_aud_stream_start(strm); if (status != PJ_SUCCESS) { fprintf(stderr, "Error starting the sound device"); return -1; } // Spend some time allowing the called party to pick up and recording to proceed Sleep(10000); // sleep 10 seconds // Clean up code omitted return 0; }

向纯粹的心道歉,因为上面的C和C++的混合。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3