0

我正在尝试使用 C++ builder 在 Embarcadero 的 SIP 应用程序上接听电话,但我无法接听。我的情况如下:

我已经制作了一个 Asterisk 服务器,我已经创建了几个帐户来进行测试,并且我已经下载了适用于 Windows 和 Android 的 Zoiper 应用程序。在我设计的应用程序中,我可以调用那些在 Zoiper 中注册的帐户,虽然不是通过事件,但似乎监听器没有监听,我通过调用中的状态更改来完成它。

Java代码是这样的:

SipAudioCall.Listener listener = new SipAudioCall.Listener() {
    @Override
    public void onCallEstablished(SipAudioCall call) {
            call.startAudio();
            call.setSpeakerMode(true);
            call.toggleMute();
            Log.d("on call established", "on call established");
    }
    @Override
    public void onCallEnded(SipAudioCall call) {
        finish();
    }
};

在 Embarcadero C++ 构建器中,我认为它会是这样的(它不起作用)编译并执行,但事件永远不会发生:

//The Manifest counts as the necessary permissions for Android, Internet and Sip.

_di_JSipAudioCall_Listener audioCall_Listener;
_di_JSipSession_Listener sessionListener;
_di_JSipSession session;
_di_JSipManager;
_di_JSipAudioCall audioCall;
_di_JSipProfile profile;
_di_JString uri;
_di_JString uri_llamada;
void onCallEstablished2(SipAudioCall call); 

//The process of profile creation and instantiation of SipManager are programmed 
//and compiled and do not give any problem. 

audioCall_listener = TJSipAudioCall_Listener::JavaClass->init();
audioCall_listener->onCallEstablished = onCallEstablished2;
sessionListener = TJSipSession_Listener::JavaClass->init();
session = manager->createSipSession(profile,sessionListener);
audioCall = manager->makeAudioCall(uri,uri_llamada,audioCall_listener,15);

void onCallEstablished2(SipAudioCall call)
{
    audioCall->startAudio();
    audioCall->setSpeakerMode(true);
}

在 Embarcadero C++ builder 中制作的代码有效:

 //The Manifest counts as the necessary permissions for Android, Internet and Sip.

_di_JSipAudioCall_Listener audioCall_Listener;
_di_JSipSession_Listener sessionListener;
_di_JSipSession session;
_di_JSipManager;
_di_JSipAudioCall audioCall;
_di_JSipProfile profile;
_di_JString uri;
_di_JString uri_llamada;

 //The process of profile creation and instantiation of SipManager are programmed 
//and compiled and do not give any problem.

audioCall_listener = TJSipAudioCall_Listener::JavaClass->init();
audioCall_listener->onCallEstablished = onCallEstablished2;
sessionListener = TJSipSession_Listener::JavaClass->init();
session = manager->createSipSession(profile,sessionListener);
audioCall = manager->makeAudioCall(uri,uri_llamada,audioCall_listener,15);
Timer1->Enabled = true;

void __fastcall TMainForm::Timer1Timer(TObject *Sender)
{   
    if (audioCall->getState() == 8)
    {
        audioCall->startAudio();
        audioCall->setSpeakerMode(true);
    }
    if(audioCall->getState() == 0)
    {
        audioCall->endCall();
    }
}

至于接听电话的 Java 代码,我在这里找到了 No ringing event on incoming call 和这里 Android Sip incoming Call using Service with Broadcast Receiver的示例,但它们都是基于事件的,这似乎对我不起作用。我也尝试过从 BroadcastReceiver 扩展而来的 IncomingReceiver 类,并且在 Embarcadero 给我带来了问题。

在 Embarcadero 中使用 C++ builder 制作的类(不编译):

class IncomingReceiver: public JBroadcastReceiver{

public:
    __fastcall IncomingReceiver();
    _di_JSipAudioCall incomingCall;
    void onReceive(_di_JContext contexto, _di_JIntent intento);
    void accept();
    void showIncomingCallGui(_di_JIntent intento, _di_JContext contexto);
};

所以,我的问题是:

  • 为什么事件对我不起作用?

  • 我可以在没有事件的情况下接听电话吗?

  • 如果是这样,没有事件会是什么样子?

  • 如果我无法获得 IncomingReceiver 类怎么办?

4

1 回答 1

-1

我找到了一个页面(西班牙语): http: //lfgonzalez.visiblogs.com/cbuilder-10-2-tokyo-jni-broadcastreceiver-android/,其中解释了在 Embarcadero C++ Builder 中使用 BroadcastReceiver。也许有了这些信息,您可以让事件正常工作以接听电话。

于 2018-10-06T09:12:38.653 回答