用于我的 android 应用程序的 android NDK。我被困在起跑线上,它没有进一步编译。以下是我的代码。它在“str = (*env)->GetStringUTFChars(env, filename, NULL);”之后不编译 . 请检查我的 java 和 c 代码
的java代码:
public class MyffmpegActivity extends Activity {
private static native int logFileInfo(String filename);
static
{
Log.i("HEHA", "HOHA");
System.loadLibrary("mylib");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_myffmpeg);
String path=Environment.getExternalStorageDirectory().getPath();
path=path+"/test.mp4";
Log.i("Name Returned is ", ":"+path);
int x=logFileInfo(path);
}
C 代码
jint Java_com_example_myffmpegtest_MyffmpegActivity_logFileInfo(JNIEnv * env, jobject this, jstring filename)
{
av_register_all();
AVFormatContext *pFormatCtx;
const jbyte *str;
str = (*env)->GetStringUTFChars(env, filename, NULL);
if(av_open_input_file(&pFormatCtx, str, NULL, 0, NULL)!=0)
{
LOGE("Can't open file '%s'\n", str);
return 1;
}
else
{
LOGI("File was opened\n");
LOGI("File '%s', Codec %s",
pFormatCtx->filename,
pFormatCtx->iformat->name
);
}
return 0;}