Best android open-source packages and libraries.

Rtmp rtsp stream client java

Library to stream in rtmp and rtsp for Android. All code in Java
Updated 8 months ago

rtmp-rtsp-stream-client-java

Android Arsenal Release

Sponsored with 💖 &nbsp by
Stream Chat
Enterprise Grade APIs for Feeds & Chat. Try the Android Chat tutorial 💬

Library for stream in RTMP and RTSP. All code in Java.

If you need a player see this project:

https://github.com/pedroSG94/vlc-example-streamplayer

iOS version (under develop):

https://github.com/pedroSG94/rtmp-rtsp-stream-client-swift

Wiki

https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/wiki

Permissions:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!--Optional for play store-->
<uses-feature android:name="android.hardware.camera" android:required="false" />
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false" />

Compile

To use this library in your project with gradle add this to your build.gradle:

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.pedroSG94.rtmp-rtsp-stream-client-java:rtplibrary:2.2.6'
}

Features:

  • [x] Android min API 16.

Encoder:

  • [x] Support camera1 and camera2 API
  • [x] Encoder type buffer to buffer.
  • [x] Encoder type surface to buffer.
  • [x] Audio noise suppressor.
  • [x] Audio echo cancellation.
  • [x] Disable/Enable video and audio while streaming.
  • [x] Switch camera while streaming.
  • [x] Change video bitrate while streaming (API 19+).
  • [x] H264, H265 and AAC hardware/software encoding.
  • [x] Force video and audio Codec to use hardware/software encoding (Not recommended).
  • [X] Record MP4 file while streaming (API 18+).
  • [X] Set Image, Gif or Text to stream on real time.
  • [X] OpenGL real time filters. More info
  • [x] Stream from video and audio files like mp4, webm, mp3, etc (Limited by device decoders). More info
  • [x] Stream device screen (API 21+).

RTMP:

  • [X] Get upload bandwidth used.
  • [x] RTSP auth (adobe and llnw).
  • [x] H264, H265 (Using RTMP enhanced) and AAC support.
  • [x] RTMPS (under TLS)
  • [x] RTMPT and RTMPTS (tunneled and tunneled under TLS)
  • [x] AMF0
  • [ ] AMF3

RTSP:

  • [X] Get upload bandwidth used.
  • [x] RTMP auth (basic and digest).
  • [x] H264, H265 and AAC support.
  • [x] TCP/UDP.
  • [x] RTSPS.

Under develop:

Currently developing SRT

Other related projects:

https://github.com/pedroSG94/RTSP-Server

https://github.com/pedroSG94/AndroidReStreamer

https://github.com/pedroSG94/Stream-USB-test

3rd party projects:

Projects related with the library developed by other users. Contact with user owner if you have any problem or question.

https://github.com/FunnyDevs/rtmp-rtsp-stream-client-java-recordcontrollers

Real time filters:

NOTE:

In library version 2.0.9, the filters was refactored. Check the wiki link to migrate your implementation.

https://github.com/pedroSG94/rtmp-rtsp-stream-client-java/wiki/Real-time-filters

Use example:

This code is a basic example. I recommend you go to Activities in app module and see all examples.

RTMP:

//default

//create builder
RtmpCamera1 rtmpCamera1 = new RtmpCamera1(openGlView, connectCheckerRtmp);
//start stream
if (rtmpCamera1.prepareAudio() && rtmpCamera1.prepareVideo()) {
  rtmpCamera1.startStream("rtmp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtmpCamera1.stopStream();

//with params

//create builder
RtmpCamera1 rtmpCamera1 = new RtmpCamera1(openGlView, connectCheckerRtmp);
//start stream
if (rtmpCamera1.prepareAudio(int bitrate, int sampleRate, boolean isStereo, boolean echoCanceler,
      boolean noiseSuppressor) && rtmpCamera1.prepareVideo(int width, int height, int fps, int bitrate, int rotation)) {
  rtmpCamera1.startStream("rtmp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtmpCamera1.stopStream();

RTSP:

//default

//create builder
//by default TCP protocol.
RtspCamera1 rtspCamera1 = new RtspCamera1(openGlView, connectCheckerRtsp);
//start stream
if (rtspCamera1.prepareAudio() && rtspCamera1.prepareVideo()) {
  rtspCamera1.startStream("rtsp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtspCamera1.stopStream();

//with params

//create builder
RtspCamera1 rtspCamera1 = new RtspCamera1(openGlView, connectCheckerRtsp);
rtspCamera1.setProtocol(protocol);
//start stream
if (rtspCamera1.prepareAudio(int bitrate, int sampleRate, boolean isStereo, boolean echoCanceler,
      boolean noiseSuppressor) && rtspCamera1.prepareVideo(int width, int height, int fps, int bitrate, int rotation)) {
  rtspCamera1.startStream("rtsp://yourEndPoint");
} else {
 /**This device cant init encoders, this could be for 2 reasons: The encoder selected doesnt support any configuration setted or your device hasnt a H264 or AAC encoder (in this case you can see log error valid encoder not found)*/
}
//stop stream
rtspCamera1.stopStream();