Skip to content
[WIP]Camera and Microphone streaming library via RTMP for Android.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Oct 27, 2018
app
gradle/wrapper Update Android Studio 3.4 May 4, 2019
haishinkit
.gitignore
HaishinKit.iml
HaishinKit.kt.iml Update Android Studio 3.2 Oct 27, 2018
HaishinStudio.iml Migration .java -> .kt Dec 10, 2017
LICENSE.md
README.md Migration .java -> .kt Dec 10, 2017
build.gradle
gradle.properties Migration .java -> .kt Dec 10, 2017
gradlew
gradlew.bat
local.properties
settings.gradle

README.md

HaishinKit.kt

GitHub license

Coming soon... Camera and Microphone streaming library via RTMP for Android.

Features

RTMP

  • Authentication
  • Publish (H264/AAC)
  • Playback
  • AMF0
  • AMF3
  • SharedObject
  • RTMPS
    • Native (RTMP over SSL/TSL)
    • Tunneled (RTMPT over SSL/TSL)

Others

  • Hardware acceleration for H264 video encoding/AAC audio encoding

License

New BSD

Donation

Bitcoin

1CWA9muX36QKBdJiRQJGpu2HvchfEpJbWr

Android manifest

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

Prerequisites

ActivityCompat.requestPermissions(this,arrayOf(
    Manifest.permission.CAMERA,
    Manifest.permission.RECORD_AUDIO
), 1)

RTMP Usage

Real Time Messaging Protocol (RTMP).

class MainActivity : AppCompatActivity(), IEventListener {

    private var connection: RTMPConnection? = null
    private var stream: RTMPStream? = null

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        ActivityCompat.requestPermissions(this,
                arrayOf(Manifest.permission.CAMERA,
                        Manifest.permission.RECORD_AUDIO),
                1)

        setContentView(R.layout.activity_main)

        connection = RTMPConnection()
        stream = RTMPStream(connection!!)
        stream?.attachCamera(Camera(android.hardware.Camera.open()))
        stream?.attachAudio(Audio())
        connection?.addEventListener("rtmpStatus", this)

        val button = findViewById(R.id.button) as Button
        button.setOnClickListener {
            connection?.connect("rtmp://192.168.11.15/live")
        }
    }

    override fun onStart() {
        super.onStart()
        val view1 = findViewById(R.id.camera) as CameraView
        view1.attachStream(stream!!)
    }

    override fun handleEvent(event: Event) {
        val data = EventUtils.toMap(event)
        val code = data["code"].toString()
        if (code == RTMPConnection.Codes.CONNECT_SUCCESS.rawValue) {
            Log.w(javaClass.name, "PUBLISH")
            stream!!.publish("live")
        }
    }
}

Related Project

You can’t perform that action at this time.