1.这个例子是在ndk jni的实现文件中development/ndk/platforms/android-21/samples/native-codec去dump 图像buf数据。
//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中创建对应平台的文件夹,比如64位的就要创建一个arm64的文件夹,然后把生成的库推到app中
adb push libs/arm64-v8a/libnative-codec-jni.so data/app/com.example.nativecodec-1/lib/arm64/
4.kill掉应用进程,然后重启应用,进行测试。
5.如下链接中可以看到audio的raw数据dump方式
https://blog.csdn.net/ffmpeg4976/article/details/52212343