https://github.com/elastos/elastos.net.webrtc.android.sdk
https://github.com/elastos/elastos.net.webrtc.android.sdk
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/elastos/elastos.net.webrtc.android.sdk
- Owner: elastos
- License: apache-2.0
- Created: 2020-09-11T09:19:00.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-12-31T09:14:50.000Z (over 4 years ago)
- Last Synced: 2023-08-06T18:53:10.227Z (almost 2 years ago)
- Language: Java
- Size: 8.6 MB
- Stars: 3
- Watchers: 26
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Elastos WebRTC Android SDK
===========================## Introduction
Elastos WebRTC Android SDK is a java api set for webrtc connection using elastos carrier network.
With the Elastos Android WebRTC SDK, it is possible to build voip applications for mobile phones, tablets, wearables, TVs and car media systems that run on the Android Operating System (OS) while utilizing the functionalities of the Elastos Carrier and WebRTC protocol.The Elastos Carrier is a decentralized and encrypted peer-to-peer (P2P) communication framework that routes network traffic between virtual machines and Decentralized Applications (DApps).
With WebRTC, you can add real-time communication capabilities to your application that works on top of an open standard. It supports video, voice, and generic data to be sent between peers, allowing developers to build powerful voice- and video-communication solutions.
Elastos WebRTC Android SDK combines Elastos Carrier and WebRTC, it use Elastos Carrier network as signaling services and STUN/TURN server.
If you want to know the architecture and how to use the api in your real project, please refer to:
[Elastos WebRTC Android SDK architecture](./ARCHITECTURE.md)## Build from source
***************
### 0. Source code folders structure.```
./Elastos.NET.WebRTC.Android.SDK
|--app
|--Api source code of the SDK
|--carrier
|--A modified version of the source code of Elastos.NET.Carrier.Android.SDK
|--demo
|--AppRTCMobile
|--A demo app using api in the ../app directory
|--ElastosWebrtcCall
|--Another demo app using api in the ../app directory
```To run and test the demo app directly, you can download the apk files from the URLs, and then run the following command to install.
[Download AppRTCMobile.apk]()
[Download ElastosWebrtcCall.apk]()```
adb install -r ~/Download/AppRTCMobile.apk
adb install -r ~/Download/ElastosWebrtcCall.apk
```### 1. (Optional) Carrier's Cross-compilation for Android Platform on Ubuntu / Debian / Linux or MacOS host
***************
As we added some api to Carrier's android SDK for fetching STUN/TURN servers from carrier network, for now, the changes haven't yet been merged to the release of Elastos.NET.Carrier.Android.SDK,
so the Elastos WebRTC Android SDK refers Carrier's android SDK as a implementation project with source code, the native libraries of carrier has been put into carrier/native-dist folder.If you want to rebuild the native libraries, please follow the instruction as below.
```
./Elastos.NET.WebRTC.Android.SDK
|--carrier
|--A modified version of the source code of Elastos.NET.Carrier.Android.SDK
|native-dist
|--include
|--ela_carrier.h
|--ela_session.h
|--ela_turnserver.h
|--lib
|--armeabi-v7a
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
|--arm64-v8a
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
|--x86
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
|--x86_64
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
|--...
```With CMake, Elastos Carrier can be cross-compiled to run on Android as a target platform, while compilation is carried out on a(n) Ubuntu / Debian / Linux or MacOS host.
**Prerequisite**: Android NDK 'android-ndk-r16b' or higher must be downloaded onto the host.
Android NDKs (such as 'Linux 64-bit (x86)' or 'Mac' ) can be downloaded from https://developer.android.com/ndk/downloads/ .
Please make sure to extract the downloaded NDK.Open a new terminal window.
Download the **Elastos.NET.Carrier.Native.SDK** (not the Elastos.NET.Carrier.Android.SDK) repository using Git:
```shell
$ git clone https://github.com/elastos/Elastos.NET.Carrier.Native.SDK
```Navigate to the previously downloaded folder that contains the source code of the Carrier project.
```shell
$ cd YOUR-PATH/Elastos.NET.Carrier.Native.SDK
```Enter the 'build' folder.
```shell
$ cd build
```Create a new folder with the target platform name, then change directory.
```shell
$ mkdir android
$ cd android
```To generate the required Makefile in the current directory, please make sure to first replace 'YOUR-TARGET-ARCHITECTURE'
and 'YOUR-ANDROID-NDK-HOME' with the correct option and path.-DANDROID_ABI accepts the following target architecture options:
* armeabi-v7a
* arm64-v8a
* x86
* x86_64Replace 'YOUR-ANDROID-NDK-HOME' with the path to the extracted NDK folder.
Run the command with the correct options described above:
```shell
$ cmake -DANDROID_ABI=YOUR-TARGET-ARCHITECTURE -DANDROID_NDK_HOME=YOUR-ANDROID-NDK-HOME -DCMAKE_TOOLCHAIN_FILE=../../cmake/AndroidToolchain.cmake ../..```
Build the program:
Note: If "make" fails due to missing permissions, use "sudo make" instead.
```shell
$ make
```Install the program:
Note: If "make install" fails due to missing permissions, use "sudo make install" instead.
```shell
$ make install
```Create distribution package:
Note: If "make dist" fails due to missing permissions, use "sudo make dist" instead.
```
$ make dist
```Note: To build for multiple target architectures separately, repeat the steps starting from:
Run the command with the correct options described above:
```shell
$ cmake -DANDROID_ABI=YOUR-TARGET-ARCHITECTURE -DANDROID_NDK_HOME=YOUR-ANDROID-NDK-HOME -DCMAKE_TOOLCHAIN_FILE=../../cmake/AndroidToolchain.cmake ../..```
For each architecture, the distribution package will contain the following files:
```
libcrystal.so
libelacarrier.so
libelasession.so
```These shared native libraries will have to be later imported into the Android project based on their
target architectures.Currently, the target CPU architectures **armv7l**, **arm64**, **x86**, **x86-64** are supported.
### 2. Import Android project
**Prerequisite**: Android Studio must be installed (Download from https://developer.android.com/studio/ ).
Android NDK must be installed within Android Studio (File >> Settings >>Appearance and Behavior >> System Settings >> Android SDK -> SDK Tools (Tab) -> NDK (active))Option 1: Start Android Studio and select "Check out project from Version Control", then select Git and add the URL
https://github.com/elastos/Elastos.NET.WebRTC.Android.SDK , click clone.Option 2: Download the Elastos.NET.WebRTC.Android.SDK with Git:
```shell
$ git clone https://github.com/elastos/Elastos.NET.WebRTC.Android.SDK
```
then start Android Studio and import the project with the option 'Open an existing Android Studio project'.Select 'Create project from existing sources', click next, click finish.
Wait for all the import processes to finish.
### 3. Import Shared Native Libraries
In the Project View on the left side, navigate to the directory **"carrier/native-dist/lib"** .
Under the native-dist folder, create a new folder with the name of the target architecture such as armeabi-v7a, arm64-v8a,
x86, x86-64 or all of them, depending on which are relevant for your needs.From Step 1 (Cross-compilation for Android Platform) in this documentation, copy the created native libraries ( .so files )
into the target directories.Your project should have following directory structure:
```
carrier/native-dist
|--include
|--ela_carrier.h
|--ela_session.h
|--ela_turnserver.h
|--lib
|--armeabi-v7a
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
|--arm64-v8a
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
|--x86
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
|--x86_64
|--libcrystal.so
|--libelacarrier.so
|--libelasession.so
```The files under the subdirectory **"app/native-dist/include"** are public header files and are already exported from Carrier native.
### 4. Build Elastos WebRTC Android SDK
In Android Studio, click 'Make Project', then 'Build Project'.
### 5. Output
After building with success, the output distribution package named **org.elastos.carrier-debug(release).aar**, carrying the JAR package and JNI shared libraries to different CPU architectures, will be put under the directory:
```
./app/build/outputs/aar
```
## UsageIn your project with gradle management, add following statements in module's build.gradle to import Carrier SDK:
```markdown
dependencies {
implementation 'org.elastos.carrier:webrtc:1.0.0'
}
```While in project with maven management, add the following statements as it's dependency:
```markdownorg.elastos.carrier
webrtc
1.0.0
pom```
## Basic Tests
All basic tests are located under the directory **"app/src/androidTest"**. These tests can be run in Android Studio.
Before running the tests, uncomment the **"service"** configuration in AndroidMinifest.xml.## Build Docs
Open **Tools** tab in Android Studio and click the **Generate JavaDoc...** item to generate the Java API document.
## Contribution
We welcome contributions to the Elastos WebRTC Android SDK Project.
## Acknowledgments
A sincere thank you to all teams and projects that we rely on directly or indirectly.
## License
This project is licensed under the terms of the [GPLv3 license](./LICENSE)