#Android Streaming Client
##Introduction
###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.
##How do I use it
- Add the following dependency in your module's build.gradle file:
dependencies {
compile('com.creativa77:android_streaming_client:1.0.+')
}
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
@Override
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
rtpMediaDecoder.start();
...
}
- Remember to release the Decoder when onStop is called.
@Override
protected void onStop() {
...
// release decoder when application is stopped
rtpMediaDecoder.release();
...
}
##Video Publishers
###Libstreaming
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 https://github.com/ashyonline/libstreaming-examples
- Clone libstreaming inside libstreaming-examples's folder:
> git clone https://github.com/ashyonline/libstreaming
- Create an empty Android Studio project.
- 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 [email protected]:creativa77/AndroidStreamingClient.git
- Import example as a module in Android Studio.
- 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.
##FFmpeg
- 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://192.168.0.112:5006
-
Notice:
"192.168.0.112" 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.
###Disclamer
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.
##Documentation
Android Streaming Client library documentation is located in doc, inside the android_streaming_client folder.
##Authors
Ayelen Chavez [email protected]
Julian Cerruti [email protected]
##Issues, bugs, feature requests
##Licensing
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.