Skip to main content
Version: 2.12

Android SDK Samples

The Andriod SDK has many ready-to-use samples under the webrtc_android_sample_app module that can be used for different scenarios and use cases.

  • The webrtc_android_sample_app module has three packages.

1. Minimal

This component has the simple publishcActivity which is the simplest Webrtc publish sample.

2. Basic

This component has several samples like publish activity, play activity, screen capture activity, conference activity, data channel only activity, peer activity, and settings.

3. Advanced

This component has samples for advanced cases like conference activity with speaker indicator, MP3 publish activity, MP4 publish activity, MP4 publish with surface activity, multi-track play activity, publish activity with you are speaking, and USB camera activity.

Let's explore how to get the Android SDK and experience the samples.

Getting the Android SDK

The WebRTC Android SDK is free to download. You can download/clone it from Android SDK Github repository.

  • After you have downloaded/cloned the Android SDK, open it with the Android Studio.

  • The samples are located under

webrtc-android-sample-app > java > io.antmedia.webrtc_android_sample_app

To compile and build the SDK, we need to connect the Android studio to an Android mobile device. It can be a virtual device/emulator or a physical device. For this demonstration, I'm using a physical Android device.

Run the WebRTC Android SDK

Now that we have the Android SDK, we will connect a mobile device to the Android studio and then run the SDK.

Connecting the Android Device with Android Studio

  • Connect your Android device to your system and switch to the developer mode.
  • Go to developer options and enable USB debugging.
  • In the Android Studio application, you will see your mobile device name which shows that it is connected.

connected-device-01

Run the SDK

  • Click on run to build the SDK.

run-sdk-02

  • Once the build is successful, the webrtc Android sample app will be launched on your Android device.

launching-app-03

  • On your mobile device, you can see all the samples under the Ant Media WebRTC Sample App.

samples-04-new

WebRTC Android SDK Samples

The samples are divided into three categories, Minimal, Basic, and Advanced. We will discuss some of these samples here. Feel free to explore all the samples as you may require.

Settings

Under settings, you need to pass your Ant Media Server websocket URL and the Room Name (in case of a conference).

  • All the stream samples that you publish/play will be carried from this Ant Media Server only.

settings-06

Publish Activity

This sample can be used to publish WebRTC streams and it also has a data channel function embedded in this sample.

publish-sample-07

To verify whether the stream is published successfully or not, open the web panel of your Ant Media Server (e.g., http://server_ip:5080) and view the stream there.

Play Activity

This sample is to play WebRTC stream and like the publish activity, it also has the data channel function embedded.

play-sample-08

Conference Activity

The conference activity sample can be used for video conference calls.

It can also be used to join in Play Only mode as well and has enable/disable audio and video.

conference-sample-09

Screen Share Activity

This sample activity demonstrates how to share screens with the WebRTC Android sample app.

screen-share-010

It has three variations, Screen, Front camera, and Rear camera.

screen-variations-011

Data Channel Only Activity

The data channel is another channel in WebRTC other than video and audio. In the data channel, you can send any kind of information to the other clients. Data channels can be utilized in various use cases including chat, control messages, or file sharing.

data-channel-012

Stats Activity

This sample page includes Webrtc publish and shows the various audio and video stats of the published stream when Show Stats is called.

stats-013

Conference with Speaking Indicator Activity

This is also a conference sample and it indicates when a speaker is speaking.

speaker-014

Publish with Are You Speaking Activity

This is also an example of a publishing activity that flashes Are you Speaking in case the speaker is speaking but the microphone is muted.

Peer Activity

The includes a sample for peer-to-peer cases. In peer-to-peer, the Ant Media Server is only a signaling server to establish the connection. Video and Audio are not relayed through the Ant Media Server.

peer-015

info

There are many more samples included with the Android SDK like USB Camera, mp3, mp4, mp4 with Surface, and Multi Track activity, etc. which you can check according to your use.