gpt4 book ai didi

C - 如何在使用 pjsip 时解决这个错误?

转载 作者:太空狗 更新时间:2023-10-29 15:35:53 27 4
gpt4 key购买 nike

我在使用 pjsip 时遇到这个错误。如何解决这个问题?我的系统中有麦克风/扬声器,但无法获取设备。

http://paste.ubuntu.com/6504337/

/* Create audio device parameter to open the device */
static pj_status_t create_aud_param(pjmedia_aud_param *param,
pjmedia_aud_dev_index capture_dev,
pjmedia_aud_dev_index playback_dev,
unsigned clock_rate,
unsigned channel_count,
unsigned samples_per_frame,
unsigned bits_per_sample)
{
pj_status_t status;

/* Normalize device ID with new convention about default device ID */
if (playback_dev == PJMEDIA_AUD_DEFAULT_CAPTURE_DEV)
playback_dev = PJMEDIA_AUD_DEFAULT_PLAYBACK_DEV;

/* Create default parameters for the device */
status = pjmedia_aud_dev_default_param(capture_dev, param);
if (status != PJ_SUCCESS) {
pjsua_perror(THIS_FILE, "Error retrieving default audio "
"device parameters", status);
return status;
}
param->dir = PJMEDIA_DIR_CAPTURE_PLAYBACK;
param->rec_id = capture_dev;
param->play_id = playback_dev;
param->clock_rate = clock_rate;
param->channel_count = channel_count;
param->samples_per_frame = samples_per_frame;
param->bits_per_sample = bits_per_sample;

/* Update the setting with user preference */
#define update_param(cap, field) \
if (pjsua_var.aud_param.flags & cap) { \
param->flags |= cap; \
param->field = pjsua_var.aud_param.field; \
}
update_param( PJMEDIA_AUD_DEV_CAP_INPUT_VOLUME_SETTING, input_vol);
update_param( PJMEDIA_AUD_DEV_CAP_OUTPUT_VOLUME_SETTING, output_vol);
update_param( PJMEDIA_AUD_DEV_CAP_INPUT_ROUTE, input_route);
update_param( PJMEDIA_AUD_DEV_CAP_OUTPUT_ROUTE, output_route);
#undef update_param

/* Latency settings */
param->flags |= (PJMEDIA_AUD_DEV_CAP_INPUT_LATENCY |
PJMEDIA_AUD_DEV_CAP_OUTPUT_LATENCY);
param->input_latency_ms = pjsua_var.media_cfg.snd_rec_latency;
param->output_latency_ms = pjsua_var.media_cfg.snd_play_latency;

/* EC settings */
if (pjsua_var.media_cfg.ec_tail_len) {
param->flags |= (PJMEDIA_AUD_DEV_CAP_EC | PJMEDIA_AUD_DEV_CAP_EC_TAIL);
param->ec_enabled = PJ_TRUE;
param->ec_tail_ms = pjsua_var.media_cfg.ec_tail_len;
} else {
param->flags &= ~(PJMEDIA_AUD_DEV_CAP_EC|PJMEDIA_AUD_DEV_CAP_EC_TAIL);
}

/* VAD settings */
if (pjsua_var.media_cfg.no_vad) {
param->flags &= ~PJMEDIA_AUD_DEV_CAP_VAD;
} else {
param->flags |= PJMEDIA_AUD_DEV_CAP_VAD;
param->vad_enabled = PJ_TRUE;
}

return PJ_SUCCESS;
}

错误:

14:13:41.786    pjsua_aud.c  ..Error retrieving default audio device parameters: Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV) [status=420006]
Exception: Object: {Account <sip:192.168.1.16:60791>}, operation=make_call(), error=Unable to find default audio device (PJMEDIA_EAUD_NODEFDEV)

编辑:

检查我的系统是否有回放和捕获设备(如下图所示,它在没有 pjsip 的情况下 100% 工作):

sun@sun-M14xR2:/var/tmp/pjproject-2.1.0/pjsip/src/pjsua-lib$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: CA0132 Analog [CA0132 Analog]
Subdevices: 1/1
Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 3: HDMI 0 [HDMI 0]
Subdevices: 0/1
Subdevice #0: subdevice #0
card 1: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
Subdevices: 1/1
Subdevice #0: subdevice #0

sun@sun-M14xR2:/var/tmp/pjproject-2.1.0/pjsip/src/pjsua-lib$ cat /proc/asound/cards
0 [PCH ]: HDA-Intel - HDA Intel PCH
HDA Intel PCH at 0xd2710000 irq 47
1 [NVidia ]: HDA-Intel - HDA NVidia
HDA NVidia at 0xd1000000 irq 17
2 [U0x46d0x825 ]: USB-Audio - USB Device 0x46d:0x825
USB Device 0x46d:0x825 at usb-0000:00:14.0-4, high speed


sun@sun-M14xR2:/var/tmp/pjproject-2.1.0/pjsip/src/pjsua-lib$ gst-launch-0.10 -v alsasrc device=hw:2 ! audioresample ! audio/x-raw-int,rate=48000 ! autoaudiosink
Setting pipeline to PAUSED ...
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-buffer-time = 200000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: actual-latency-time = 10000
/GstPipeline:pipeline0/GstAlsaSrc:alsasrc0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
Pipeline is live and does not need PREROLL ...
Setting pipeline to PLAYING ...
New clock: GstAudioSrcClock
/GstPipeline:pipeline0/GstAudioResample:audioresample0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
/GstPipeline:pipeline0/GstAudioResample:audioresample0.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
/GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0/GstPulseSink:autoaudiosink0-actual-sink-pulse.GstPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
/GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0.GstGhostPad:sink: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
/GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0.GstGhostPad:sink.GstProxyPad:proxypad0: caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
/GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0/GstPulseSink:autoaudiosink0-actual-sink-pulse: volume = 1.000000
/GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0/GstPulseSink:autoaudiosink0-actual-sink-pulse: mute = FALSE
/GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0/GstPulseSink:autoaudiosink0-actual-sink-pulse: volume = 1.000000
/GstPipeline:pipeline0/GstAutoAudioSink:autoaudiosink0/GstPulseSink:autoaudiosink0-actual-sink-pulse: mute = FALSE
WARNING: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Can't record audio fast enough
Additional debug info:
gstbaseaudiosrc.c(840): gst_base_audio_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0:
Dropped 10560 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.
WARNING: from element /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0: Can't record audio fast enough
Additional debug info:
gstbaseaudiosrc.c(840): gst_base_audio_src_create (): /GstPipeline:pipeline0/GstAlsaSrc:alsasrc0:
Dropped 9600 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

最佳答案

您的问题与音频系统有关。大多数 Linux 系统运行 PulseAudioAlsa ,就像你的一样(你可以在 GStreamer 的日志中看到这个)但是默认情况下 pjsip 为 Linux 启用 PortAudio 驱动程序。

要修复它,您可以通过添加以下内容启用可用的 Alsa 驱动程序:

#define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 0
#define PJMEDIA_AUDIO_DEV_HAS_ALSA 1

到 pjlib/include/pj/config_site.h。如果它不存在,您可以像这样创建它:

#define PJMEDIA_AUDIO_DEV_HAS_PORTAUDIO 0
#define PJMEDIA_AUDIO_DEV_HAS_ALSA 1
#include <pj/config_site_sample.h>

然后重建(你只能直接重建 pjmedia:在 pjmedia/build 文件夹中运行 make)。

注意:您可能需要通过编辑 pjmedia/build/os-linux.mak 并将 AC_PJMEDIA_SND 设置为不同的值来禁用当前配置的驱动程序(例如阿尔萨)

关于C - 如何在使用 pjsip 时解决这个错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20312927/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com