Library that receives UDP packets wrapped into RTP and coded in H264, decodes the corresponding frames and plays the resulting stream in an Android SurfaceView
Clone or download
Latest commit 40be127 Mar 23, 2017

Android Streaming Client


What it does?

Android Streaming Client is a library to play real time video in an Android device.

How does it work

The current version of the code only supports RTP over UDP as the transport protocol and only decodes H264 encoded video.
Android Streaming Client uses efflux library to create an underlying RTP session and listen to packages.

It includes two different approaches to handle the package arrival:

  • Min-delay, which uses an RTP buffer that sends packets upstream for processing immediately. Each packet will be sent upstream only if it is the one being expected, hence this approach will work as long as the packages arrive in order. If a received packet is newer than the one being expected, it will be stored in order. Also, If stored packages are older than the configured threshold, they will be discarded.

  • Time-window, which uses an RTP buffer that keeps packets for a fixed amount of time and moves forward at a fixed rate. The received packets are pushed upstream in the same order and at a fixed rate. This approach uses two threads, one for storing the packets that arrive to the client and another to consume them with some wisdom.

How do I use it

  • Add the following dependency in your module's build.gradle file:
dependencies {

Version number may change.

  • Import the library in your main activity

   import com.c77.androidstreamingclient.lib.RtpMediaDecoder;
  • On onCreate method, create a Decoder and start it
   protected void onCreate(Bundle savedInstanceState) {

      // create an RtpMediaDecoder with the surface view where you want 
      // the video to be shown
      RtpMediaDecoder rtpMediaDecoder = new RtpMediaDecoder(surfaceView);   
      // start it
  • Remember to release the Decoder when onStop is called.
   protected void onStop() {
      // release decoder when application is stopped

Video Publishers


Android Streaming Client can play video streamed by an Android library called libstreaming. To give it a try, you can use the repositories used while developing Android Streaming Client library.

Follow this steps:

  • Clone libstreaming-examples fork:
   > git clone
  • Clone libstreaming inside libstreaming-examples's folder:
   > git clone
  • Create an empty Android Studio project.

  • Import libstreaming library in Android Studio as a module.

  • Import example4 project as a module in Android Studio and add the libstreaming dependency to its build.gradle file:

   dependencies {
      compile project(':libstreaming')
  • Clone this repository:
   > git clone
  • Import example as a module in Android Studio.

  • Check the IP address of the player device and change this line accordingly, so that the publisher knows where to stream the video to.

  • Run example4 in the publisher Android device.

  • Run the example module from Android Streaming Client in the player Android device.

If everything works, you will be streaming video from one device to another in real time.


  • Generate a raw h264 file:
   > ffmpeg –i sintel.mp4 –vcodec h264 –s 640*480 –an –f m4v sintel.h264
  • Streaming:
   > ffmpeg -re -i sintel.h264 -vcodec copy -f rtp rtp://
  • Notice:

    "" is android client's ip address.

    "5006" is android client's default port.

Other video publishers

Be sure to point your video publisher to the device's IP where you are playing video.


So far, Android Streaming Client was tested with video streamed from libstreaming library running in a separate Android device. It uses a custom version of libstreaming which is composed of the original libstreaming library plus a couple changes that fix particular issues encountered while working on the Android Streaming Client library.

Content of the project

This project contains an Android library which source code is located in the folder android_streaming_client and an Android application that uses the library located in the folder example. The efflux folder includes the efflux library source code.

Since Android Streaming Client was created using Android Studio, you will find several gradle files that include dependencies, versions, and other project configurations. The license_script folder includes a script to apply the license to every java file. You can also find the LICENSE and README files.


Android Streaming Client library documentation is located in doc, inside the android_streaming_client folder.


Ayelen Chavez

Julian Cerruti

Issues, bugs, feature requests

Github issue tracker


This project uses code from efflux library Copyright 2010 Bruno de Carvalho, licensed under the Apache License, Version 2.0. Efflux author gave us full approval to use his library.

Android Streaming Client is licensed under the Apache License, Version 2.0.