• This repository has been archived on 11/May/2023
  • Stars
    star
    309
  • Rank 135,306 (Top 3 %)
  • Language
    Kotlin
  • License
    Other
  • Created over 7 years ago
  • Updated about 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Open source library to create fast and beautiful video chats over WebRTC

VideoChatGuru simple webrtc for Android

environment status
Android Build Status

About

VideoChatGuru is an open-source solution written entirely in Kotlin, based on a WebRTC implementation. It’s not bound with any service, and you are free to choose whether you are going to use an established service provider or host your own. VideoChatGuru prioritises peer-to-peer connections, thanks to which we reduce delays to a minimum.

VideoChatGuru wraps the WebRTC API, providing a friendlier access to its features that you are going to need for implementing video chats. We also provide our Chat&Roll example implementation, so that you can see VideoChatGuru in action. Thanks to the fact that we used Firebase for signalling, it should be much easier to learn and understand how webRTC signalling works by observing it unfold live.

VideoChatGuru setup

  • Create layout for your Video Chat - you will need to provide two SurfaceViewRenderer views for remote and local video.

  • Create instance of WebRtcClient all params are optional and default ones should suffice most of use cases.

  • Attach views using webRtcClient.attachRemoteView(view) and webRtcClient.attachLocalView(view) respectiviely there are also methods which allows you to unbind those.

  • Initialize peer connection by calling webRtcClient.initializePeerConnection(...) method. Here you will need to provide list of Interactive Connectivity Establishment servers(read more below) and implementation for three listeners that are required to make everything work.

    • PeerConnectionListener.onIceCandidate and PeerConnectionListener.onIceCandidatesRemoved - those callbacks are called when WebRTC produces or removes ICE candidates, you are responsible to pass those to the other party through any other estabilished communication channel. Other party should handle those respectively by calling addRemoteIceCandidate or removeRemoteIceCandidate
    • WebRtcOfferingActionListener - callbacks launched for offering party - one which will initialize call using create offer. LocalSessionDescription object which is passed in onOfferRemoteDescription should be passed to the answering party and handled using handleRemoteOffer method.
    • WebRtcAnsweringPartyListener - callbacks launched for answering party - one which will call handleRemoteOffer method. LocalSessionDescription object which is passed in onSuccess should be passed to the offering party and handled using handleRemoteAnswer method.
  • At this point WebRtcClient setup is done and you should initialize handshake process on one of the clients using createOffer method handling all the callbacks as described earlier.

You can also reffer to the sample.

What this library won't do:

WebRTC is signaling agnostic meaning that it's your responsibility to provide communication channell that will allow to go through handshake phase. You are free to use your own solutions based on for example: FCM, WebSockets, Pooling, Firebase and any other that allows you to exchange messages beetwen clients in real time.

You can reffer to our sample for solution based on Firebase that allowed us to create and implement Chat Roullette logic. Firebase will also allow you to easily observe handshake process in real time.

Sample

Chat&Roll sample allows you to have a video chat with random stranger, project showcase use of VideoChatGuru WebRTC wrapper on Android. Signaling is done through Firebase. Your Firebase setup should provide at least one IceServer - for best results you should provide at least one Turn server to be able to make connection when peer to peer connection fails.

You can download Chat&Roll sample app from Google Play: https://play.google.com/store/apps/details?id=co.netguru.android.chatandroll

Development

To run sample project you need to prepare Firebase instance first.

Setting up Firebase

  1. Go to https://console.firebase.google.com/
  2. Create new project
  3. Add Firebase to your android app
    • To setup debug version insert package name co.netguru.android.chatandroll.debug
    • To setup release version insert package name co.netguru.android.chatandroll
  4. Download google-services.json
  5. Place it in App folder

Setting up Interactive Connectivity Establishment servers node.

You will need your STUN/TURN servers credentials here.

  1. Go to Database

  2. Add new child name it ice_servers

  3. Add new child to ice_servers named 0

  4. Add child to 0

  5. Insert ICE servers credentials

    • uri : "turn:ipAddress" or uri : "stun:ipAddress" in case of stun server

    optionally:

    • username: "your username"
    • password: "your password"
  6. You can add more ICE servers to be used by WebRTC

  7. This should be enough happy testing!

STUN/TURN servers

STUN (Session Traversal Utilities for NAT)

STUN server will allow two parties to expose what their public IP addres is. In most cases we are hidden behind routers in local networks with private IP's. It's used only in first phase of connection while estabilishing peer to peer communication. There are many free STUN servers available as they are used only during connection initialization phase.

TURN (Traversal Using Relay NAT)

TURN server is relay server which is used only when peer to peer connection cannot be estabilished, this can be caused for example by NAT restricions. When TURN server has to be used it might cause higher latency, as all the data has to go to the server and then to the other party, especially if the server is located far from both clients. TURN servers are obtainable mostly through paid services as lot of traffic is generated when TURN has to act as relay between clients, or you could host your own using Coturn.

If you want to learn more about how STUN and TURN works go on and watch : https://youtu.be/p2HzZkd2A40?t=1123

Public STUN/TURN servers

You can find many public STUN servers on the web, you might also want to try out:

  • http://numb.viagenie.ca/ Numb provides both STUN and TURN servers free of charge. Take in mind that using public servers might not be the best choice for production code.

Private STUN/TURN servers

External services

Many private services provides their STUN servers free of charge. You can also find free TURN servers with limited amount of bandwidth to use up.

Set up your own STUN/TURN server

There are various options available out there we've tested Coturn and setup is fairly easy, you can follow this guide https://github.com/coturn/coturn/wiki/CoturnConfig .

Sample integrations

Contribution

You're more than welcome to contribute or report an issue in case of any problems, questions or improvement proposals.

How to contribute

Download

To use this library in your project, place the following code in your top hierarchy build.gradle file:

allprojects {
    repositories {
        maven {  url 'https://dl.bintray.com/netguru/maven/' }
    }
}

Just add the following dependency in your app's build.gradle:

dependencies {
      compile 'co.netguru.videochatguru:videochatguru:0.1.2@aar'
}

Copyright Β© 2017 Netguru.

More Repositories

1

ResponseDetective

Sherlock Holmes of the networking layer. πŸ•΅οΈβ€β™‚οΈ
Swift
1,956
star
2

sticky-parallax-header

A simple React Native library, enabling the creation of fully customized header for your iOS and Android apps.
TypeScript
1,811
star
3

CarLensCollectionViewLayout

An easy-to-use Collection View Layout for card-like animation.
Swift
548
star
4

Kissme

Kissme: Kotlin Secure Storage Multiplatform
Kotlin
411
star
5

BlueSwift

Swift framework for easy connection with Bluetooth peripherals.
Swift
169
star
6

ngrvalidator

Validation has never been as easy as now!
Objective-C
165
star
7

compose-multiplatform-charts

Charts library for Kotlin multiplatform applications
Kotlin
136
star
8

CarLens-iOS

CarLens - Recognize and Collect Cars
Swift
130
star
9

AnimatedCardInput

Easy to use iOS library with components for input of Credit Card data.
Swift
38
star
10

ar-localizer-view-android

Kotlin
33
star
11

CarLens-Android

CarLens - Recognize and Collect Cars
Kotlin
24
star
12

mobile-security-checklist

Netguru mobile security checklist
Python
23
star
13

rnd-retail-multiplatform-public

Kotlin
22
star
14

baby-monitor-client-android

Internal Baby Monitor android project
Kotlin
20
star
15

heroes-api

TypeScript
18
star
16

baby-monitor-client-ios

Swift
17
star
17

netguru

netguru gem - collection of solutions we use to develop and deploy our projects.
Ruby
16
star
18

awesome-list

Ruby
15
star
19

xcconfigs

Collection of common Xcode configuration files. πŸ› οΈ
14
star
20

CreateML-Research

The easy ways to start your journey with CreateML.
Swift
14
star
21

mobile-security-review

Security review guidelines for mobile projects
13
star
22

react-native-ar-localizer

Java
12
star
23

nodejs-recruitment-task

Repository for Node.js department's recruitment process.
JavaScript
11
star
24

productivity

Productivity tips for Netguru
Dockerfile
10
star
25

ng-ios-network-module

iOS Networking Module
Swift
9
star
26

commentable-rs

Rust
9
star
27

highway

Build system on top of Fastlane.
Ruby
9
star
28

coolcal-android

Kotlin
9
star
29

flutter-recruitment-task

Dart
8
star
30

design-process

CSS
7
star
31

opoca

Library for speeding up building machine learning proof of concepts.
Python
7
star
32

atstats-android

atStats native android app
Kotlin
5
star
33

graphql-starter-pack

Graphql training by Netguru.
Ruby
4
star
34

kivy-games

Python
4
star
35

SimpleRegEx

Wrapper for RegEx, made so the RegEx code will be understable
Python
4
star
36

smarthome

Kotlin
4
star
37

netguru-grdb

Swift
4
star
38

react-native-modal-dropdown

JavaScript
4
star
39

sections-decorator-android

Kotlin
4
star
40

bitrise-step-slack

A next-gen Slack webhook step for Bitrise
Ruby
3
star
41

frontend-recruitment-task

3
star
42

picguard-swift

Image analysis framework for Swift
Swift
3
star
43

hubguru-ios-public

Swift
3
star
44

ios-framework-template

Swift
3
star
45

qa-selenium-java-framework

Java
2
star
46

ar-localizer-view-iOS

Swift
2
star
47

capistrano-docker

Ruby
2
star
48

ngrcrop-ios

ngrcrop-ios: UI component for editing selected photos.
Objective-C
2
star
49

rack_password

Small rack middleware to block your site from unwanted vistors.
Ruby
2
star
50

awesome-frontend-architecture

Collection of awesome frontend architecture resources
2
star
51

iOS-Good-Practices

Swift
2
star
52

inicjatywyotwarte-be

A website that tries to collect all important and relevant initiatives that could help in the times of COVID-19. https://www.inicjatywyotwarte.pl
Ruby
2
star
53

terraform-module-hcloud

Hetzner Cloud module for terraform
HCL
2
star
54

inicjatywyotwarte-fe

A website that tries to collect all important and relevant initiatives that could help in the times of COVID-19.
JavaScript
2
star
55

sync-aws-extend-switch-roles

Sync AWS Extend Switch Roles
1
star
56

ios-bitrise-client-public

Swift
1
star
57

bitrise-step-ng-jira-step

Shell
1
star
58

codestories-react-native-hooks

JavaScript
1
star
59

devise-2fa

Devise with 2FA support based on Twilio
Ruby
1
star
60

twilio-2fa-bot

Simple Twilio messages scrapper for shared phone numbers
JavaScript
1
star
61

danger-flutter-coverage

Ruby
1
star
62

meetguru

JavaScript
1
star
63

django-modular-user

Python
1
star
64

bitrise-step-danger-android

Shell
1
star
65

dc-docker-task

This repo stores docker recruitment tasks for devops-college
Dockerfile
1
star