Giter Club home page Giter Club logo

elastos.net.webrtc.android.sdk's Introduction

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

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:

$ 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.

$ cd YOUR-PATH/Elastos.NET.Carrier.Native.SDK

Enter the 'build' folder.

$ cd build

Create a new folder with the target platform name, then change directory.

$ 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_64

Replace 'YOUR-ANDROID-NDK-HOME' with the path to the extracted NDK folder.

Run the command with the correct options described above:

$ 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.

$ make

Install the program:
Note: If "make install" fails due to missing permissions, use "sudo make install" instead.

$ 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:

$ 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:

$ 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

Usage

In your project with gradle management, add following statements in module's build.gradle to import Carrier SDK:

dependencies {
    implementation 'org.elastos.carrier:webrtc:1.0.0'
}

While in project with maven management, add the following statements as it's dependency:

<dependency>
  <groupId>org.elastos.carrier</groupId>
  <artifactId>webrtc</artifactId>
  <version>1.0.0</version>
  <type>pom</type>
</dependency>

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

elastos.net.webrtc.android.sdk's People

Contributors

0xli avatar cpedia avatar jiiq avatar lixianghuan-go avatar stiartsly avatar xhuanlee avatar xiaokunmeng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.