mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 14:18:07 +00:00
add transfer_state_changed callback to JNI/java
info api wrapping in progress
This commit is contained in:
parent
da87ffc3e6
commit
53d4d1b7f8
14 changed files with 290 additions and 1 deletions
|
|
@ -241,5 +241,12 @@ public class TutorialBuddyStatus implements LinphoneCoreListener {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferState(LinphoneCore lc, LinphoneCall call,
|
||||
State new_call_state) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -163,5 +163,12 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa
|
|||
write("Sent message [" + msg.getText() + "] new state is " + state.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferState(LinphoneCore lc, LinphoneCall call,
|
||||
State new_call_state) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -167,5 +167,12 @@ public class TutorialHelloWorld implements LinphoneCoreListener {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferState(LinphoneCore lc, LinphoneCall call,
|
||||
State new_call_state) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,6 +198,13 @@ public class TutorialRegistration implements LinphoneCoreListener {
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void transferState(LinphoneCore lc, LinphoneCall call,
|
||||
State new_call_state) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -139,6 +139,7 @@ public:
|
|||
vTable.new_subscription_request = new_subscription_request;
|
||||
vTable.notify_presence_recv = notify_presence_recv;
|
||||
vTable.call_stats_updated = callStatsUpdated;
|
||||
vTable.transfer_state_changed = transferStateChanged;
|
||||
|
||||
listenerClass = (jclass)env->NewGlobalRef(env->GetObjectClass( alistener));
|
||||
|
||||
|
|
@ -160,6 +161,8 @@ public:
|
|||
callStateClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCall$State"));
|
||||
callStateFromIntId = env->GetStaticMethodID(callStateClass,"fromInt","(I)Lorg/linphone/core/LinphoneCall$State;");
|
||||
|
||||
transferStateId = env->GetMethodID(listenerClass,"transferState","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCall$State;)V");
|
||||
|
||||
/*callStatsUpdated(LinphoneCore lc, LinphoneCall call, LinphoneCallStats stats);*/
|
||||
callStatsUpdatedId = env->GetMethodID(listenerClass, "callStatsUpdated", "(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneCall;Lorg/linphone/core/LinphoneCallStats;)V");
|
||||
|
||||
|
|
@ -240,6 +243,7 @@ public:
|
|||
jmethodID messageReceivedId;
|
||||
jmethodID dtmfReceivedId;
|
||||
jmethodID callStatsUpdatedId;
|
||||
jmethodID transferStateId;
|
||||
|
||||
jclass globalStateClass;
|
||||
jmethodID globalStateId;
|
||||
|
|
@ -499,7 +503,22 @@ public:
|
|||
env->CallVoidMethod(callobj, lcData->callSetVideoStatsId, statsobj);
|
||||
env->CallVoidMethod(lcData->listener, lcData->callStatsUpdatedId, lcData->core, callobj, statsobj);
|
||||
}
|
||||
|
||||
static void transferStateChanged(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState remote_call_state){
|
||||
JNIEnv *env = 0;
|
||||
jint result = jvm->AttachCurrentThread(&env,NULL);
|
||||
jobject jcall;
|
||||
if (result != 0) {
|
||||
ms_error("cannot attach VM\n");
|
||||
return;
|
||||
}
|
||||
LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc);
|
||||
env->CallVoidMethod(lcData->listener
|
||||
,lcData->transferStateId
|
||||
,lcData->core
|
||||
,(jcall=lcData->getCall(env,call))
|
||||
,env->CallStaticObjectMethod(lcData->callStateClass,lcData->callStateFromIntId,(jint)remote_call_state)
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_newLinphoneCore(JNIEnv* env
|
||||
|
|
@ -545,6 +564,19 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_delete(JNIEnv* env
|
|||
delete lcData;
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_linphone_core_LinphoneCoreImpl
|
||||
* Method: createInfoMessage
|
||||
* Signature: (J)J
|
||||
*/
|
||||
JNIEXPORT jlong JNICALL Java_org_linphone_core_LinphoneCoreImpl_createInfoMessage(JNIEnv *, jobject jobj, jlong lcptr){
|
||||
return (jlong) linphone_core_create_info_message((LinphoneCore*)lcptr);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_sendInfoMessage(JNIEnv *env, jobject jobj, jlong lcptr, jlong infoptr, jlong addrptr){
|
||||
return linphone_core_send_info_message((LinphoneCore*)lcptr,(LinphoneInfoMessage*)infoptr,(LinphoneAddress*)addrptr);
|
||||
}
|
||||
|
||||
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPrimaryContact(JNIEnv* env, jobject thiz, jlong lc, jstring jdisplayname, jstring jusername) {
|
||||
const char* displayname = env->GetStringUTFChars(jdisplayname, NULL);
|
||||
const char* username = env->GetStringUTFChars(jusername, NULL);
|
||||
|
|
@ -1694,6 +1726,17 @@ extern "C" jint Java_org_linphone_core_LinphoneCallImpl_getState( JNIEnv* env
|
|||
,jlong ptr) {
|
||||
return (jint)linphone_call_get_state((LinphoneCall*)ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: org_linphone_core_LinphoneCallImpl
|
||||
* Method: getTransferState
|
||||
* Signature: (J)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCallImpl_getTransferState(JNIEnv *, jobject jobj, jlong callptr){
|
||||
LinphoneCall *call=(LinphoneCall*)callptr;
|
||||
return linphone_call_get_transfer_state(call);
|
||||
}
|
||||
|
||||
extern "C" void Java_org_linphone_core_LinphoneCallImpl_enableEchoCancellation( JNIEnv* env
|
||||
,jobject thiz
|
||||
,jlong ptr
|
||||
|
|
|
|||
|
|
@ -292,4 +292,10 @@ public interface LinphoneCall {
|
|||
* Stop call recording.
|
||||
*/
|
||||
void stopRecording();
|
||||
|
||||
/**
|
||||
* If a call transfer has been initiated for this call, returns the call state of the new call performed at the remote end as a result of the transfer request.
|
||||
* @return the call state of the new call performed by the referee to the refer target.
|
||||
*/
|
||||
State getTransferState();
|
||||
}
|
||||
|
|
|
|||
46
java/common/org/linphone/core/LinphoneContent.java
Normal file
46
java/common/org/linphone/core/LinphoneContent.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package org.linphone.core;
|
||||
|
||||
/**
|
||||
* LinphoneContent interface describes a SIP message content (body).
|
||||
* It can be used together with the LinphoneInfoMessage, in order to add content attachment to the INFO message.
|
||||
* @author smorlat
|
||||
*
|
||||
*/
|
||||
public interface LinphoneContent {
|
||||
/**
|
||||
* Get the type of the content, for example "application"
|
||||
* @return the type
|
||||
*/
|
||||
String getType();
|
||||
/**
|
||||
* Get the subtype of the content, for example "html"
|
||||
* @return the subtype
|
||||
*/
|
||||
String getSubtype();
|
||||
/**
|
||||
* Get the data as a string.
|
||||
* @return the data
|
||||
*/
|
||||
String getDataAsString();
|
||||
/**
|
||||
* Get the data size.
|
||||
* @return the data size.
|
||||
*/
|
||||
int getSize();
|
||||
|
||||
/**
|
||||
* Set the content type, for example "application"
|
||||
* @param type the content's primary type
|
||||
*/
|
||||
void setType(String type);
|
||||
/**
|
||||
* Set the subtype, for example "text"
|
||||
* @param subtype the subtype
|
||||
*/
|
||||
void setSubtype(String subtype);
|
||||
/**
|
||||
* Set the data, supplied as String.
|
||||
* @param data the data
|
||||
*/
|
||||
void setStringData(String data);
|
||||
}
|
||||
|
|
@ -1259,5 +1259,19 @@ public interface LinphoneCore {
|
|||
* the external ip address is not available return null.
|
||||
*/
|
||||
public String getUpnpExternalIpaddress();
|
||||
|
||||
/**
|
||||
* Create an empty INFO message.
|
||||
* It can later be sent using {@link LinphoneCore.sendInfoMessage() }.
|
||||
* @return the new info message.
|
||||
*/
|
||||
public LinphoneInfoMessage createInfoMessage();
|
||||
|
||||
/**
|
||||
* Send an INFO message to specified destination.
|
||||
* @param info the info message
|
||||
* @param dest the destination sip address.
|
||||
*/
|
||||
public void sendInfoMessage(LinphoneInfoMessage info, LinphoneAddress dest);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,6 +117,13 @@ public interface LinphoneCoreListener {
|
|||
*/
|
||||
void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event);
|
||||
|
||||
/**
|
||||
* Notifies progress of a call transfer.
|
||||
* @param lc the LinphoneCore
|
||||
* @param call the call through which the transfer was sent.
|
||||
* @param new_call_state the state of the call resulting of the transfer, at the other party.
|
||||
**/
|
||||
void transferState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State new_call_state);
|
||||
|
||||
/**< @Deprecated Notifies the application that it should show up
|
||||
* @return */
|
||||
|
|
|
|||
36
java/common/org/linphone/core/LinphoneInfoMessage.java
Normal file
36
java/common/org/linphone/core/LinphoneInfoMessage.java
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
package org.linphone.core;
|
||||
|
||||
/**
|
||||
* The LinphoneInfoMessage represents an informational message (INFO) to be transmitted or received by the LinphoneCore.
|
||||
* @author smorlat
|
||||
*
|
||||
*/
|
||||
public interface LinphoneInfoMessage {
|
||||
/**
|
||||
* Assign a content to the info message. This is optional.
|
||||
* @param content
|
||||
*/
|
||||
void setContent(LinphoneContent content);
|
||||
/**
|
||||
* Get the actual content of the info message. It may be null.
|
||||
* @return a LinphoneContent object or null
|
||||
*/
|
||||
LinphoneContent getContent();
|
||||
/**
|
||||
* Add a specific header to the info message
|
||||
* @param name the header's name
|
||||
* @param value the header's value
|
||||
*/
|
||||
void addHeader(String name, String value);
|
||||
/**
|
||||
* Retrieve a header's value based on its name.
|
||||
* @param name the header's name
|
||||
* @return the header's value
|
||||
*/
|
||||
String getHeader(String name);
|
||||
/**
|
||||
* Get the origin of the info message as a string URI.
|
||||
* @return origin of the message.
|
||||
*/
|
||||
String getFrom();
|
||||
}
|
||||
|
|
@ -207,4 +207,9 @@ class LinphoneCallImpl implements LinphoneCall {
|
|||
public void stopRecording() {
|
||||
stopRecording(nativePtr);
|
||||
}
|
||||
private native int getTransferState(long nativePtr);
|
||||
@Override
|
||||
public State getTransferState() {
|
||||
return State.fromInt(getTransferState(nativePtr));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
46
java/impl/org/linphone/core/LinphoneContentImpl.java
Normal file
46
java/impl/org/linphone/core/LinphoneContentImpl.java
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package org.linphone.core;
|
||||
|
||||
public class LinphoneContentImpl implements LinphoneContent {
|
||||
private String mType, mSubtype, mData;
|
||||
public LinphoneContentImpl(String type, String subtype, String data){
|
||||
mType=type;
|
||||
mSubtype=subtype;
|
||||
mData=data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return mType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubtype() {
|
||||
return mSubtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDataAsString() {
|
||||
return mData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return mData.length();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setType(String type) {
|
||||
mType=type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSubtype(String subtype) {
|
||||
mSubtype=subtype;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStringData(String data) {
|
||||
mData=data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -948,4 +948,15 @@ class LinphoneCoreImpl implements LinphoneCore {
|
|||
public int getVideoDscp() {
|
||||
return getVideoDscp(nativePtr);
|
||||
}
|
||||
|
||||
private native long createInfoMessage(long nativeptr);
|
||||
@Override
|
||||
public LinphoneInfoMessage createInfoMessage() {
|
||||
return new LinphoneInfoMessageImpl(createInfoMessage(nativePtr));
|
||||
}
|
||||
private native int sendInfoMessage(long corePtr, long infoptr, long destptr);
|
||||
@Override
|
||||
public void sendInfoMessage(LinphoneInfoMessage info, LinphoneAddress dest) {
|
||||
sendInfoMessage(nativePtr,((LinphoneInfoMessageImpl)info).nativePtr, ((LinphoneAddressImpl)dest).nativePtr);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
java/impl/org/linphone/core/LinphoneInfoMessageImpl.java
Normal file
47
java/impl/org/linphone/core/LinphoneInfoMessageImpl.java
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package org.linphone.core;
|
||||
|
||||
public class LinphoneInfoMessageImpl implements LinphoneInfoMessage {
|
||||
protected long nativePtr;
|
||||
private LinphoneContent mContent;
|
||||
|
||||
private native Object getContent(long nativeptr);
|
||||
public LinphoneInfoMessageImpl(long ptr){
|
||||
nativePtr=ptr;
|
||||
mContent=(LinphoneContent)getContent(nativePtr);
|
||||
}
|
||||
|
||||
private native void setContent(long nativePtr, String type, String subtype, String data);
|
||||
@Override
|
||||
public void setContent(LinphoneContent content) {
|
||||
mContent=content;
|
||||
setContent(nativePtr,mContent.getType(),mContent.getSubtype(),mContent.getDataAsString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public LinphoneContent getContent() {
|
||||
return mContent;
|
||||
}
|
||||
|
||||
private native void addHeader(long nativePtr, String name, String value);
|
||||
@Override
|
||||
public void addHeader(String name, String value) {
|
||||
addHeader(nativePtr,name,value);
|
||||
}
|
||||
|
||||
private native String getHeader(long nativePtr, String name);
|
||||
@Override
|
||||
public String getHeader(String name) {
|
||||
return getHeader(nativePtr,name);
|
||||
}
|
||||
|
||||
private native String getFrom(long nativePtr);
|
||||
@Override
|
||||
public String getFrom() {
|
||||
return getFrom(nativePtr);
|
||||
}
|
||||
|
||||
private native void delete(long nativePtr);
|
||||
protected void finalize(){
|
||||
delete(nativePtr);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue