java层
private ByteBuffer _recBuffer;
try{
_recBuffer = ByteBuffer.allocateDirect(204800); // Max 10 ms @ 48
} catch(Exception e) {
Log.d("UVCCamera","can not get _capBuffer");
}
native 层
jclass cls = env->GetObjectClass(thiz);
if(cls == NULL){
LOGE("cls == NULL");
} else {
}
jfieldID fidRecBuffer = env->GetFieldID( cls, "_recBuffer", "Ljava/nio/ByteBuffer;");
if(fidRecBuffer == NULL){
LOGE("fidRecBuffer == NULL");
} else {
}
jobject javaRecBufferLocal = env->GetObjectField(thiz, fidRecBuffer);
if(javaPlayBufferLocal == NULL){
LOGE("javaPlayBufferLocal == NULL");
} else {
}
_javaRecBuffer = env->NewGlobalRef(javaRecBufferLocal);
if(_javaRecBuffer == NULL){
LOGE("_javaRecBuffer == NULL");
} else {
_javaDirectRecBuffer =env->GetDirectBufferAddress(_javaRecBuffer);
}
void* _javaDirectRecBuffer; // Direct buffer pointer to rec buffer
jobject _javaRecBuffer;
可以对_javaDirectRecBuffer进行操作,再java 层会同时更新数据
网友评论