1.這個例子是在ndk jni的實現(xiàn)文件中development/ndk/platforms/android-21/samples/native-codec去dump 圖像buf數(shù)據。
//dump buf
LOGV("zhou Edward lannister begin to dump inputbuffer");
FILE *fp=NULL;
if((fp = fopen("/data/data/com.example.nativecodec/hirestmp1.txt", "wb"))==NULL){
LOGV("zhou Edward lannister can not open the txt data/data/temp1 file,open fail errno = %d reason = %s \n",errno, strerror(errno));
}else {
LOGV("zhou Edward lannister begin to write buffer");
fwrite(buf, sizeof(uint8_t),1,fp);
}
LOGV("zhou Edward lannister begin to close fp");
fclose(fp);
//dump buf
2.保證app具有讀寫存儲的權限,必要可去setting中打開相應app的權限;
3.ndk-build之后將生成的對應的庫推到對應的app的對應庫中,沒有直接編譯進apk的話,就要去/data/app/com.example.nativecodec-1/lib中創(chuàng)建對應平臺的文件夾,比如64位的就要創(chuàng)建一個arm64的文件夾,然后把生成的庫推到app中
adb push libs/arm64-v8a/libnative-codec-jni.so data/app/com.example.nativecodec-1/lib/arm64/
4.kill掉應用進程,然后重啟應用,進行測試。
5.如下鏈接中可以看到audio的raw數(shù)據dump方式
https://blog.csdn.net/ffmpeg4976/article/details/52212343