Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
19cb807c
Commit
19cb807c
authored
Mar 17, 2015
by
Sylvain Berfini
🐮
Browse files
Finished implementation of file_transfer_send callback in JNI layer
parent
2bc09231
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
5 deletions
+32
-5
coreapi/linphonecore_jni.cc
coreapi/linphonecore_jni.cc
+32
-5
No files found.
coreapi/linphonecore_jni.cc
View file @
19cb807c
...
...
@@ -85,6 +85,7 @@ static jobject handler_obj=NULL;
static
jobject
create_java_linphone_content
(
JNIEnv
*
env
,
const
LinphoneContent
*
content
);
static
jobject
create_java_linphone_buffer
(
JNIEnv
*
env
,
const
LinphoneBuffer
*
buffer
);
static
LinphoneBuffer
*
create_c_linphone_buffer_from_java_linphone_buffer
(
JNIEnv
*
env
,
jobject
jbuffer
);
#ifdef ANDROID
void
linphone_android_log_handler
(
int
prio
,
char
*
str
)
{
...
...
@@ -3282,9 +3283,10 @@ static void file_transfer_recv(LinphoneChatMessage *msg, const LinphoneContent*
static
LinphoneBuffer
*
file_transfer_send
(
LinphoneChatMessage
*
msg
,
const
LinphoneContent
*
content
,
size_t
offset
,
size_t
size
)
{
JNIEnv
*
env
=
0
;
jint
result
=
jvm
->
AttachCurrentThread
(
&
env
,
NULL
);
LinphoneBuffer
*
buffer
=
NULL
;
if
(
result
!=
0
)
{
ms_error
(
"cannot attach VM
\n
"
);
return
NULL
;
return
buffer
;
}
jobject
listener
=
(
jobject
)
msg
->
cb_ud
;
...
...
@@ -3294,8 +3296,7 @@ static LinphoneBuffer* file_transfer_send(LinphoneChatMessage *msg, const Linph
jobject
jbuffer
=
create_java_linphone_buffer
(
env
,
NULL
);
env
->
CallVoidMethod
(
listener
,
method
,
jmessage
,
content
?
create_java_linphone_content
(
env
,
content
)
:
NULL
,
offset
,
size
,
jbuffer
);
//TODO
LinphoneBuffer
*
buffer
=
linphone_buffer_new
();
buffer
=
create_c_linphone_buffer_from_java_linphone_buffer
(
env
,
jbuffer
);
return
buffer
;
}
...
...
@@ -4551,10 +4552,9 @@ static jobject create_java_linphone_content(JNIEnv *env, const LinphoneContent *
return
jobj
;
}
static
jobject
create_java_linphone_buffer
(
JNIEnv
*
env
,
const
LinphoneBuffer
*
buffer
){
static
jobject
create_java_linphone_buffer
(
JNIEnv
*
env
,
const
LinphoneBuffer
*
buffer
)
{
jclass
bufferClass
;
jmethodID
ctor
;
jstring
jtype
,
jsubtype
,
jencoding
,
jname
;
jbyteArray
jdata
=
NULL
;
jint
jsize
=
0
;
...
...
@@ -4572,6 +4572,33 @@ static jobject create_java_linphone_buffer(JNIEnv *env, const LinphoneBuffer *bu
return
jobj
;
}
static
LinphoneBuffer
*
create_c_linphone_buffer_from_java_linphone_buffer
(
JNIEnv
*
env
,
jobject
jbuffer
)
{
jclass
bufferClass
;
jmethodID
getSizeMethod
,
getDataMethod
;
LinphoneBuffer
*
buffer
;
jint
jsize
;
jobject
jdata
;
jbyteArray
jcontent
;
uint8_t
*
content
;
bufferClass
=
(
jclass
)
env
->
NewGlobalRef
(
env
->
FindClass
(
"org/linphone/core/LinphoneBufferImpl"
));
getSizeMethod
=
env
->
GetMethodID
(
bufferClass
,
"getSize"
,
"()I"
);
getDataMethod
=
env
->
GetMethodID
(
bufferClass
,
"getContent"
,
"()[B"
);
jsize
=
env
->
CallIntMethod
(
jbuffer
,
getSizeMethod
);
ms_error
(
"Fetched %i bytes"
,
jsize
);
jdata
=
env
->
CallObjectMethod
(
jbuffer
,
getDataMethod
);
jcontent
=
reinterpret_cast
<
jbyteArray
>
(
jdata
);
content
=
(
uint8_t
*
)
env
->
GetByteArrayElements
(
jcontent
,
NULL
);
buffer
=
linphone_buffer_new_from_data
(
content
,
(
size_t
)
jsize
);
env
->
ReleaseByteArrayElements
(
jcontent
,
(
jbyte
*
)
content
,
JNI_ABORT
);
env
->
DeleteGlobalRef
(
bufferClass
);
return
buffer
;
}
/*
* Class: org_linphone_core_LinphoneInfoMessageImpl
* Method: getContent
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment