%module(directors=“1”) SSPlayer
%{
#include “IStreamCallback.h”
%}

%include “typemaps.i”
%include “stdint.i”
%include “std_string.i”
%include “carrays.i”
//%array_class(jbyte, ByteArray);

%feature(“director”) IStreamCallback; // 允许 Java 继承 C++ 接口

%include “arrays_java.i”
%clear signed char*;
%apply char * { signed char * };
%apply int8_t * { signed char * };
%apply (int8_t* BUFFER, size_t LENGTH) { (int8_t* data, int len) };

%typemap(jni) int8_t* “jobject”
%typemap(jtype) int8_t* “java.nio.ByteBuffer”
%typemap(jstype) int8_t* “java.nio.ByteBuffer”
%typemap(in) int8_t* {
$1 = (int8_t*) JCALL1(GetDirectBufferAddress, jenv, $input);
if (!$1) SWIG_JavaThrowException(jenv, SWIG_JavaNullPointerException, “null ByteBuffer”);
}

%typemap(out) int8_t* {
$result = JCALL1(NewByteArray, jenv, arg1->length);
JCALL4(SetByteArrayRegion, jenv, KaTeX parse error: Expected 'EOF', got '}' at position 47: …*)arg1->data); }̲ %typemap(javai…javainput"
%typemap(javaout) int8_t* { return $jnicall; }

%typemap(directorin, descriptor=“Ljava/nio/ByteBuffer;”) int8_t* {
$input = JCALL1(NewDirectByteBuffer, jenv, $1);
}

%typemap(directorout) int8_t* {
// C++到Java的转换逻辑
jbyteArray jarr = jenv->NewByteArray($1_length);
jenv->SetByteArrayRegion(jarr, 0, $1_length, (jbyte*)$1);
$result = jenv->NewDirectByteBuffer(
jenv->GetByteArrayElements(jarr, NULL),
$1_length
);
}

%include “IStreamCallback.h”

Logo

开源鸿蒙跨平台开发社区汇聚开发者与厂商,共建“一次开发,多端部署”的开源生态,致力于降低跨端开发门槛,推动万物智联创新。

更多推荐