This is my journey to bring a new life to my old Samsung S10 5G, which still functions perfectly fine. You can read the full blog here.
I know there're still works to do, especially the battery part, or my house will end up in fire. But that's another day story.
- Record from Camera and Microphone.
- Encode with H265 + AAC.
- Host an RTSP Server + Stream over RTP/TCP (not support UDP due to quality reasons).
- A/V sync using RTCP Sender Report.
- Use foreground service to keep the application alive.
- No busy-waiting in any threads.
- Try my best not to allocate dynamic memory.
I decide to use the NDK API because Java API has memory leak (link).
Hardware: An Android device with API level 28+.
Software: Android Studio with latest NDK (but I think the version doesn't really matter).
Simply import the repo as an Android Studio project and run.
In app/src/main/cpp/includes/utils/Configs.h
, the following configs are device-dependent:
VIDEO_WIDTH
VIDEO_HEIGHT
VIDEO_DEFAULT_FRAME_RATE
VIDEO_MIN_FRAME_RATE
CAMERA_ID
VIDEO_CODEC_PROFILE
VIDEO_CODEC_LEVEL
You should use Android APIs (just ask ChatGPT to generate the code) to find which config is hardware-acceleration supported.
Android: Start the app -> Click "Start".
PC or any other devices: Use VLC/ffmpeg -> open stream rtsp://<Android-ip>:8554/stream.
I highly recommend using Tailscale to create a VPN between your devices. After that, you can use the Tailscale's IP to connect.