简体   繁体   English

使用 PJSIP 的两个声音设备

[英]Use two sound device with PJSIP

Here is my problem: I want to develop a SIP client with PJSIP and more precisely with PJSUA.这是我的问题:我想用 PJSIP 开发一个 SIP 客户端,更准确地说是用 PJSUA。 With this SIP client I want to be able to output sound from a call by three differents ways.使用这个 SIP 客户端,我希望能够通过三种不同的方式从呼叫中输出声音。

  1. Inside my headset only仅在我的耳机内
  2. On my speakers only仅在我的扬声器上
  3. Inside my headset and on my speakers both and at the same time同时在我的耳机和我的扬声器上

Below is a code example of what I tried:下面是我尝试过的代码示例:

int listeningMethod = message[0];
pjmedia_aud_dev_route media;
switch (listeningMethod) {
case (int)EnumListeningDevice::SPEAKER:
    printf("Operator asked for SPEAKER\r\n");
    media = PJMEDIA_AUD_DEV_ROUTE_LOUDSPEAKER;
    int idMicro;
    int idOutput;
    if (pjsua_get_snd_dev(&idMicro, &idOutput) == -1) {
        printf("Error pjsua_get_snd_dev\r\n");
    }
    idOutput = obj_PJSIP_Phonie.getIdLoudspeaker();
    if (pjsua_set_snd_dev(idMicro, idOutput) != PJ_SUCCESS) {
        printf("Error pjsua_set_snd_dev ID OUTPUT = %d\r\n", idOutput);
    }
    break;
case (int)EnumListeningDevice::HEADSET:
    media = PJMEDIA_AUD_DEV_ROUTE_EARPIECE;
    printf("Operator asked for HEADSET\r\n");
    if (pjsua_get_snd_dev(&idMicro, &idOutput) == -1) {
        printf("Error pjsua_get_snd_dev\r\n");
    }
    idOutput = obj_PJSIP_Phonie.getIdHeadphone();
    if (pjsua_set_snd_dev(idMicro, idOutput) != PJ_SUCCESS) {
        printf("Error pjsua_set_snd_dev ID OUTPUT = %d\r\n", idOutput);
    }
    break;
case (int)EnumListeningDevice::SPEAKER_AND_HEADSET:
    printf("Operator asked for SPEAKER_AND_HEADSET\r\n");
    break;
default:
    printf("Error in request\r\n");
    break;
}

I am able to switch between my headset or my speaker but I can not find a way to use the two devices at the same time.我可以在耳机或扬声器之间切换,但找不到同时使用这两个设备的方法。

I have tried to look at pjmedia_snd_port_create_player function and tried this:我试图查看pjmedia_snd_port_create_player函数并尝试过这个:

    pjmedia_snd_port* headsetSoundPort;
    pjmedia_snd_port* speakerSoundPort;

    const char* driverNameHeadset = "WMME";
    const char* driverNameSpeaker = "WMME";

    const char* deviceNameHeadset = "Haut-parleurs (4- USB audio COD";
    const char* deviceNameSpeaker = "Haut-parleurs (3- USB audio COD";
    
    pjmedia_aud_dev_index deviceHeadsetIndex;
    pjmedia_aud_dev_index deviceSpeakerIndex;
      
    pjmedia_aud_dev_lookup(driverNameHeadset, deviceNameHeadset, &deviceHeadsetIndex);
    pjmedia_aud_dev_lookup(driverNameSpeaker, deviceNameSpeaker, &deviceSpeakerIndex);

    pjmedia_snd_port_create_player(pool1, deviceHeadsetIndex, 16000, 2, 160, 16, 0, &headsetSoundPort);

    pjmedia_snd_port_create_player(pool1, deviceHeadsetIndex, 16000, 2, 160, 16, 0, &speakerSoundPort);

But without success.但没有成功。 Any help would be appreciated.任何帮助,将不胜感激。 Feel free to ask questions.随意问的问题。

Do you have some logs when you try to change over to both?当您尝试更改为两者时,您是否有一些日志?

I am assuming that PJSIP only allows 1 primary sound device per call, as in 1 device that plays/receives audio only.我假设 PJSIP 每次呼叫只允许 1 个主要声音设备,就像在 1 个仅播放/接收音频的设备中一样。 I cannot confirm that without looking through the code etc.如果不查看代码等,我无法确认。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM