[英]Incomings Call with Android Sip stack in Embarcadero C++ builder
我正在尝试使用C ++生成器在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 ++ 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);
}
在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();
}
}
至于用于接收呼叫的Java代码,我在这里找到了示例, 在传入呼叫上没有响铃事件,在这里找到了使用带有Broadcast Receiver的Service进行Android Sip传入呼叫的示例,但是它们都是基于事件的,这似乎不适用于我。 我还尝试做IncomingReceiver类,它是从BroadcastReceiver扩展而来的,在Embarcadero上给我带来了问题。
使用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);
};
因此,我的问题是:
为什么事件对我不起作用?
我可以接听没有事件的电话吗?
如果是这样,没有事件会是什么样?
如果无法获得IncomingReceiver类,该怎么办?
我找到了一个页面(西班牙语): http : //lfgonzalez.visiblogs.com/cbuilder-10-2-tokyo-jni-broadcastreceiver-android/ ,其中解释了在Embarcadero C ++ Builder中使用BroadcastReceiver的方法。 也许有了这些信息,您就可以使事件正常进行以接听电话。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.