LRA
LRA

Reputation: 1

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. 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. 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.

The Java code is like this:

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:

//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:

 //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. I have also tried to do the IncomingReceiver class, which extends from BroadcastReceiver and at the Embarcadero gives me problems.

Class made in Embarcadero with C++ builder (not compiles):

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:

Upvotes: 0

Views: 253

Answers (1)

AMR
AMR

Reputation: 1

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. Maybe with this information you can get the events working in order to receive calls.

Upvotes: -1

Related Questions