Simple Streaming at scale.
Uiza is the complete toolkit for building a powerful video streaming application with unlimited scalability. We design Uiza so simple that you only need a few lines of codes to start streaming, but sophisticated enough for you to build complex products on top of it.
Read CHANGELOG here.
Step 1. Add the JitPack
repository to your build.gradle
file
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.uizaio:uiza-android-broadcast-sdk:1.x.x'
}
Get latest release number HERE.
Turn on Java 8 support
If not enabled already, you need to turn on Java 8 support in all build.gradle
files depending on ExoPlayer, by adding the following to the android
section:
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
. If you want show log, install any Tree
instances you want in the onCreate
of your Application
class
if (BuildConfig.DEBUG) {
Timber.plant(new Timber.DebugTree());
}
. To set icon in notificationbar. In onCreate
of your Application
class:
UZBroadCast.init(R.mipmap.ic_launcher);
It's very easy, plz follow these steps below to implement:
XML:
<com.uiza.sdkbroadcast.view.UZBroadCastView
android:id="@+id/uz_broadcast"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:runInBackground="true" # support camera2 only
app:startCamera="FRONT"
app:useCamera2="true" />
In class UZBroadCastActivity
:
public class UZBroadCastActivity extends AppCompatActivity implements UZBroadCastListener {
// ...
}
In onCreate()
:
getWindow().setFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON, WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
uzBroadCast = (UZBroadCastView) findViewById(R.id.uz_broadcast);
uzBroadCast.setUZBroadcastListener(this);
In onResume()
:
@Override
protected void onResume() {
uzBroadCast.onResume();
super.onResume();
}
Start a Stream: see VideoAttributes
and AudioAttributes
uzBroadCast.setVideoAttributes(VideoAttributes videoAttrs);
uzBroadCast.setAudioAttributes(AudioAttributes audioAttrs);
if (uzBroadCast.prepareBroadCast()) {
uzBroadCast.startBroadCast("broadCastUrl");
}
or
if (uzBroadCast.prepareBroadCast(AudioAttributes audioAttrs, VideoAttributes videoAttrs, boolean isLandscape)) {
uzBroadCast.startBroadCast("broadCastUrl");
}
Stop streaming (It auto saves mp4 file in your gallery if you start a broadcast with option save local file)
uzBroadCast.stopBroadCast();
Switch camera:
uzBroadCast.switchCamera();
In case runInBackground = false
But you want to allows streaming again after back from background:
uzBroadCast.setBackgroundAllowedDuration(YOUR_ALLOW_TIME); // default time is 2 minutes
This sample help you know how to use all Uiza SDK for livestream, please refer to THIS
UZBroadcast is supported watermarks.
with text
uzBroadCast.setTextWatermark("UIZA", 22, Color.RED, Translate.CENTER);
With image
uzBroadCast.setImageWatermark(R.drawable.logo, new PointF(20f, 15f), Translate.CENTER);
// or
// uzBroadCast.setImageWatermark(bitmap, new PointF(20f, 15f), Translate.CENTER);
With Gif
uzBroadCast.setGifWatermark(R.raw.banana, new PointF(20f, 15f), Translate.CENTER);
// or
// uzBroadCast.setGifWatermark(inputstream, new PointF(20f, 15f), Translate.CENTER);
With Video
uzBroadCast.setVideoWatermarkByResource(R.raw.big_bunny_240p, Translate.CENTER);
// or
// uzBroadCast.setVideoWatermarkByUri(uri, Translate.CENTER);
Clear watermark
uzBroadCast.clearWatermark();
uzBroadCast.takePhoto(photoCallback)
See example in class UZDisplayActivity
:
- Android min API 21.
- Support camera1 and camera2 API
- Encoder type buffer to buffer.
- Encoder type surface to buffer.
- RTMP/RTMPS auth.
- Audio noise suppressor.
- Audio echo cancellation.
- Disable/Enable video and audio while streaming.
- Switch camera while streaming.
- Change video bitrate while streaming.
- Get upload bandwidth used.
- Record MP4 file while streaming.
- H264 and AAC hardware encoding.
- Force H264 and AAC Codec hardware/software encoding (Not recommended).
- Stream device display.
- OpenGL real time filters and watermarks. More info
Uiza Checkstyle configuration is based on the Google coding conventions from Google Java Style that can be found at here.
Your code must be followed the rules that defined in our uiza_style.xml
rules
You can setting the rules after import project to Android Studio follow below steps:
- File > Settings > Editor > Code Style
- Right on the
Scheme
, select the setting icon > Import Scheme > Intellij IDEA code style XML - Select the
uiza_style.xml
file path - Click Apply > OK, then ready to go
For apply check style, install CheckStyle-IDEA plugin, then
- File > Settings > Other Settings > Checkstyle
- In Configuration file, select the
+
icon - Check
Use local checkstyle file
& select path touiza_check.xml
file - Select OK & you're ready to go
To run checkstyle for project
- Right click on project
- Select Analyze > Inspect Code
Support all devices which have Android 5.0 (API level 21) above. For a given use case, we aim to support UizaSDK on all Android devices that satisfy the minimum version requirement.
Note: Some Android emulators do not properly implement components of Android’s media stack, and as a result do not support UizaSDK. This is an issue with the emulator, not with UizaSDK. Android’s official emulator (“Virtual Devices” in Android Studio) supports UizaSDK provided the system image has an API level of at least 23. System images with earlier API levels do not support UizaSDK. The level of support provided by third party emulators varies. Issues running UizaSDK on third party emulators should be reported to the developer of the emulator rather than to the UizaSDK team. Where possible, we recommend testing media applications on physical devices rather than emulators.
If you've found an error in this sample, please file an issue
Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please feel free to contact me anytime: developer@uiza.io for more details.
Address: 33 Ubi Avenue 3 #08- 13, Vertex Tower B, Singapore 408868 Email: developer@uiza.io Website: uiza.io
UizaSDK is released under the BSD license. See LICENSE for details.