MCPcopy Index your code
hub / github.com/ant-media/LibRtmp-Client-for-Android

github.com/ant-media/LibRtmp-Client-for-Android @v3.1.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v3.1.0 ↗ · + Follow
287 symbols 772 edges 23 files 31 documented · 11%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Librtmp Client for Android

It is probably the smallest(~60KB) rtmp client for android. It calls librtmp functions over JNI interface. With all cpu architectures(arm, arm7, arm8, x86, x86-64, mips) its size is getting about 300KB

It compiles librtmp library without ssl.

In version 0.2, it supports FLV muxing and sending stream via RTMP. FLV muxing is based on this repo https://github.com/rainfly123/flvmuxer

To read streams, you can call below functions of RtmpClient from Java

For live streams add " live=1" at the end of the url when calling the open function

  • public native int open(String url, boolean isPublishMode);
  • public native int read(byte[] data, int offset, int size);
  • public native int write(byte[] data);
  • public native int seek(int seekTime);
  • public native int pause(int pause);
  • public native int close();
  • public native int isConnected();: Call this function to query the connection status. Returns 1 if connected, returns 0 if not connected

Don't forget calling the close function after you are done. If you don't, there will be memory leakage

To publish streams, you can call below functions of RtmpMuxer from Java
  • public native int open(String url, int width, int height); : First, call this function with the url you plan to publish. Width and height are the width and height of the video. These two parameters are not mandatory. They are optional. They put width and height values into the metadata tag.
  • public native int writeVideo(byte[] data, int offset, int length, int timestamp);: Write h264 nal units with this function
  • public native int writeAudio(byte[] data, int offset, int length, int timestamp);: Write aac frames with this function
  • public native int close();: Call this function to close the publishing.
  • public native int isConnected();: Call this function to query the connection status. Returns 1 if connected, returns 0 if not connected

To save flv file locally as well, you can use below functions * public native void file_open(String filename); : call this function with full file path * public native void write_flv_header(boolean is_have_audio, boolean is_have_video);: After opening file call this function * public native void file_close();: Call this function to close the file.

if any local file is opened, library will write the audio and video frames to local file as well.

Install

  • Add dependency to your build gradle
dependencies {
    ...
    compile 'net.butterflytv.utils:rtmp-client:3.1.0'
    ...
}
  • That's all. You can use RtmpClient class

Ant Media

Core symbols most depended-on inside this repo

RTMP_Log
called by 291
rtmp-client/src/main/cpp/librtmp/log.c
AMF_EncodeString
called by 33
rtmp-client/src/main/cpp/librtmp/amf.c
AMF_EncodeNumber
called by 28
rtmp-client/src/main/cpp/librtmp/amf.c
RTMP_LogHex
called by 27
rtmp-client/src/main/cpp/librtmp/log.c
RTMP_SendPacket
called by 24
rtmp-client/src/main/cpp/librtmp/rtmp.c
ReadN
called by 19
rtmp-client/src/main/cpp/librtmp/rtmp.c
RTMP_Close
called by 18
rtmp-client/src/main/cpp/librtmp/rtmp.c
AMF_EncodeInt32
called by 17
rtmp-client/src/main/cpp/librtmp/amf.c

Shape

Function 214
Class 41
Method 31
Enum 1

Languages

C72%
C++16%
Java13%

Modules by API surface

rtmp-client/src/main/cpp/librtmp/rtmp.c110 symbols
rtmp-client/src/main/cpp/librtmp/amf.c44 symbols
rtmp-client/src/main/java/net/butterflytv/rtmp_client/RtmpClient.java18 symbols
rtmp-client/src/main/cpp/librtmp/handshake.h16 symbols
rtmp-client/src/main/cpp/flvmuxer/xiecc_rtmp.c13 symbols
rtmp-client/src/main/cpp/librtmp/hashswf.c12 symbols
rtmp-client/src/main/java/net/butterflytv/rtmp_client/RTMPMuxer.java10 symbols
rtmp-client/src/main/cpp/librtmp/log.c10 symbols
rtmp-client/src/main/cpp/librtmp/rtmp.h9 symbols
rtmp-client/src/main/cpp/librtmp/dh.h9 symbols
rtmp-client/src/main/cpp/librtmp-jni.c9 symbols
test/src/androidTest/java/net/butterflytv/rtmp_client/test/ApplicationTest.java6 symbols

For agents

$ claude mcp add LibRtmp-Client-for-Android \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact