简体   繁体   English

使用Embarcadero C ++ Builder中的Android Sip堆栈进行来电

[英]Incomings Call with Android Sip stack in Embarcadero C++ builder

I'm trying to receive calls on my SIP application at Embarcadero with C++ builder and I'm not able to get it. 我正在尝试使用C ++生成器在Embarcadero的SIP应用程序上接听电话,但无法获取。 My situation is as follows: 我的情况如下:

I've made an Asterisk server, I've created several accounts to be able to do the tests and I've downloaded the Zoiper application for both Windows and Android. 我已经制作了一个Asterisk服务器,创建了多个帐户来进行测试,并且下载了适用于Windows和Android的Zoiper应用程序。 In my designed application, I'm able to make calls to those accounts registered in Zoiper, although not through events, it seems that the listener does not listen, and I've done it through the status changes in the call. 在我设计的应用程序中,我可以对在Zoiper中注册的那些帐户进行调用,尽管不是通过事件进行的,但似乎监听器没有监听,并且已经通过调用中的状态更改来实现了。

The Java code is like this: 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();
    }
};

In Embarcadero C++ builder I think it would be like this (it doesn't work) Compiles and executes but the event never occurs: 在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;
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);
}

The code made in Embarcadero C++ builder that works: 在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;

 //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();
    }
}

As for the Java code for receiving calls, I have found examples here No ringing event on incoming calls and here Android Sip incoming Call using Service with Broadcast Receiver , but they are all event based, which doesn't seem to work for me. 至于用于接收呼叫的Java代码,我在这里找到了示例, 在传入呼叫上没有响铃事件,在这里找到了使用带有Broadcast Receiver的Service进行Android Sip传入呼叫的示例,但是它们都是基于事件的,这似乎不适用于我。 I have also tried to do the IncomingReceiver class, which extends from BroadcastReceiver and at the Embarcadero gives me problems. 我还尝试做IncomingReceiver类,它是从BroadcastReceiver扩展而来的,在Embarcadero上给我带来了问题。

Class made in Embarcadero with C++ builder (not compiles): 使用C ++构建器在Embarcadero中制作的类(不编译):

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);
};

So, my questions are: 因此,我的问题是:

  • Why don't events work for me? 为什么事件对我不起作用?

  • Can I receive calls without events? 我可以接听没有事件的电话吗?

  • If so, what would it be like without events? 如果是这样,没有事件会是什么样?

  • What do I do if I can't get the IncomingReceiver class? 如果无法获得IncomingReceiver类,该怎么办?

I found a page (in spanish): http://lfgonzalez.visiblogs.com/cbuilder-10-2-tokyo-jni-broadcastreceiver-android/ in which it is explained the use of BroadcastReceiver in Embarcadero C++ Builder. 我找到了一个页面(西班牙语): http : //lfgonzalez.visiblogs.com/cbuilder-10-2-tokyo-jni-broadcastreceiver-android/ ,其中解释了在Embarcadero C ++ Builder中使用BroadcastReceiver的方法。 Maybe with this information you can get the events working in order to receive calls. 也许有了这些信息,您就可以使事件正常进行以接听电话。

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

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