apivideo / api.video-rtmpdroid

librtmp wrapper for Android. Made with ♥ by api.video

Home Page:https://api.video

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

badge   badge   badge

api.video Android live stream library

api.video is the video infrastructure for product builders. Lightning fast video APIs for integrating, scaling, and managing on-demand & low latency live streaming features in your app.

Table of contents

Project description

When it comes to Real-Time Messaging Protocol (RTMP), the most popular implementation is the C library: librtmp. However, if you are streaming from Android and want to use librtmp, you need to go through the following painful steps:

  • compile librtmp for all Android architectures to generate multiple shared libraries
  • write a code that links the librtmp C functions to the Java classes/methods using Java Native Interface (JNI)
  • write Java classes/methods

rtmpdroid has been built to address this pain: you can directly use librtmp in your Android application like any other Java/Kotlin library.

rtmpdroid also comes with a minimalist Action Message Format (AMF) encoder that is included in librtmp.

Getting started

Installation

Gradle

In build.gradle, add the following code:

dependencies {
    implementation 'video.api:rtmpdroid:1.2.0'
}

Code sample

RTMP

val rtmp = Rtmp()
rtmp.connect("rtmp://broadcast.api.video/s/YOUR_STREAM_KEY")
rtmp.connectStream()

while (true) {
    val flvBuffer = getNewFlvFrame() // flvBuffer is a direct ByteBuffer 
    rtmp.write(flvBuffer)
}

AMF

val amfEncoder = AmfEncoder()

amfEncoder.add("myParam", 3.0)
val ecmaArray = EcmaArray()
ecmaArray.add("myOtherParam", "value")
amfEncoder.add(ecmaArray)

val amfBuffer = amfEncoder.encode()

Permissions

<manifest>
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

Packed version

The default version of rtmpdroid comes with the following shared libraries:

  • librtmp.so
  • libssl.so
  • libcrypto.so
  • librtmpdroid.so

However, your application might already use libssl and libcrypto. In this case, you can use the packed version of rtmpdroid. It only contains only librtmpdroid.so and the other libraries are contains in this library. To use the packed version, add a -packed suffix to the rtmpdroid version in your build.gradle:

dependencies {
    implementation 'video.api:rtmpdroid:1.2.0-packed'
}

Documentation

FAQ

If you have any questions, ask us in https://community.api.video or use Issues.

About

librtmp wrapper for Android. Made with ♥ by api.video

https://api.video

License:MIT License


Languages

Language:Kotlin 58.3%Language:C++ 34.3%Language:CMake 6.6%Language:C 0.8%