天天看點

【一起來玩NDK】篇一:不好意思,學會NDK真的無所不能

廣告時間

寶沃汽車-智能系統部

正在招聘Android開發工程師,感興趣的可以發送履歷到 [email protected],期待跟你成為同僚!

前言

作為Android工程師,Java和Kotlin是我們經常使用的開發語言

但在涉及到一些需要高性能,或與底層相關,或與安全相關的功能,就不得不使用C/C++來實作,Java語言也提供了相關接口(JNI)來調用native相關的代碼

Android平台又在此基礎上提供了native相關的開發套件NDK(native develop kit)讓我們更加便利的實作Android平台與native代碼之間的互動

作為開端,本篇文章将簡單介紹我們使用NDK可以做哪些事情,實作哪些功能

下面,正文開始!

使用NDK可以做什麼?

NDK開發并不難,因為NDK隻是開發工具,但前提是掌握了C/C++相關的語言基礎,JNI相關的調用API,以及Cmake相關的編譯知識,本系列也會在此基礎上進行的展開分析

安全相關

将部分代碼放在C語言中去實作,可以增加逆向分析的難度,對程式來說也更安全。針對這一塊目前沒有發現比較好的開源庫,後面我會自己去做一些代碼示例,或者做成開源庫的形式

處理音頻(Audio)

  1. audio-echo: https://github.com/android/ndk-samples/blob/main/audio-echo/README.md
  2. oboe: https://github.com/android/ndk-samples/blob/main/hello-oboe/README.md
  3. opensl es: https://github.com/android/ndk-samples/blob/main/native-audio/README.md
  4. MIDI: https://github.com/android/ndk-samples/blob/main/native-midi/README.md

處理視訊(Video)

  1. codec: https://github.com/android/ndk-samples/blob/main/native-codec/README.md
  2. openMAX: https://github.com/android/ndk-samples/blob/main/native-media/README.md
  3. ffmpeg: https://github.com/FFmpeg/FFmpeg

處理圖檔(Picture)

  1. plasma effect : https://github.com/android/ndk-samples/blob/main/bitmap-plasma/README.md
  2. webp: https://github.com/android/ndk-samples/blob/main/webp/README.md
  3. image-p3: https://github.com/android/ndk-samples/blob/main/display-p3/README.md

神經網絡(Neural Network)

  1. NNAPI: https://github.com/android/ndk-samples/blob/main/nn-samples/README.md

OpenGL(Render with OpenGL)

  1. render tea port: https://github.com/android/ndk-samples/blob/main/teapots/README.md
  2. render san angles: https://github.com/android/ndk-samples/blob/main/san-angeles/README.md
  3. sensor graph: https://github.com/android/ndk-samples/blob/main/sensor-graph/README.md
  4. GLES2.0: https://github.com/android/ndk-samples/blob/main/hello-gl2/README.md
  5. GLES3.0 : https://github.com/android/ndk-samples/blob/main/gles3jni/README.md

遊戲開發(3D Game)

https://github.com/android/ndk-samples/blob/main/endless-tunnel/README.md

後記

在下面的文章中,我将逐項分析相關源碼,并拓展實作相關功能,感興趣的小夥伴可以關注一波!

我是釋然,我們下篇文章再見!