Skip to content

videosdk-live/videosdk-rtc-android-kotlin-sdk-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Video SDK for Android

Documentation Firebase Discord Register

At Video SDK, we’re building tools to help companies create world-class collaborative products with capabilities for live audio/video, cloud recordings, RTMP/HLS streaming, and interaction APIs.

πŸ₯³ Get 10,000 minutes free every month! Try it now!

⚑️From Clone to Launch - Get Started with the Example in 5 mins!

Kotlin

πŸ“š Table of Contents


πŸ“± Demo App

πŸ“± Download the sample Android app here: https://appdistribution.firebase.dev/i/99ae2c5db3a7e446

⚑ Quick Setup

  1. Sign up on VideoSDK to grab your API Key and Secret.
  2. Familiarize yourself with Token

πŸ›  Prerequisites

πŸ“¦ Running the Sample App

Step 1: Clone the Repository

Clone the repository to your local environment.

git clone https://github.com/videosdk-live/videosdk-rtc-android-kotlin-sdk-example.git

Step 2: Open and Sync the Project

Open the cloned project in Android Studio and perform a project sync.

Step 3: Modify local.properties

Generate a temporary token from your Video SDK Account and update the local.properties file:

auth_token = TEMPORARY-TOKEN

Step 4: Run the sample app

Run the Android app by pressing Shift+F10 or by clicking the β–Ά Run button in the Android Studio toolbar.

πŸ”₯ Meeting Features

Unlock a suite of powerful features to enhance your meetings:

Feature Documentation Description
πŸ“‹ Precall Setup Setup Precall Configure audio, video devices, and other settings before joining the meeting.
🀝 Join Meeting Join Meeting Allows participants to join a meeting.
πŸšͺ Leave Meeting Leave Meeting Allows participants to leave a meeting.
🎀 Toggle Mic Mic Control Toggle the microphone on or off during a meeting.
πŸ“· Toggle Camera Camera Control Turn the video camera on or off during a meeting.
πŸ–₯️ Screen Share Screen Share Share your screen with other participants during the call.
πŸ”Š Change Audio Device Switch Audio Device Select an input-output device for audio during a meeting.
πŸ”Œ Change Video Device Switch Video Device Select an output device for audio during a meeting.
βš™οΈ Optimize Audio Track Audio Track Optimization Enhance the quality and performance of media tracks.
βš™οΈ Optimize Video Track Video Track Optimization Enhance the quality and performance of media tracks.
πŸ’¬ Chat In-Meeting Chat Exchange messages with participants through a Publish-Subscribe mechanism.
πŸ“Έ Image Capture Image Capturer Capture images of other participant from their video stream, particularly useful for Video KYC and identity verification scenarios.
πŸ“ File Sharing File Sharing Share files with participants during the meeting.
πŸ–ΌοΈ Virtual Background Virtual Background Add a virtual background or blur effect to your video during the call.
πŸ“Ό Recording Recording Record the meeting for future reference.
πŸ“‘ RTMP Livestream RTMP Livestream Stream the meeting live to platforms like YouTube or Facebook.
πŸ“ Real-time Transcription Real-time Transcription Generate real-time transcriptions of the meeting.
πŸ”‡ Toggle Remote Media Remote Media Control Control the microphone or camera of remote participants.
🚫 Mute All Participants Mute All Mute all participants simultaneously during the call.
πŸ—‘οΈ Remove Participant Remove Participant Eject a participant from the meeting.

🧠 Key Concepts

Understand the core components of our SDK:

  • Meeting - A Meeting represents Real-time audio and video communication.

    Note: Don't confuse the terms Room and Meeting; both mean the same thing πŸ˜ƒ

  • Sessions - A particular duration you spend in a given meeting is referred as a session, you can have multiple sessions of a specific meetingId.

  • Participant - A participant refers to anyone attending the meeting session. The local participant represents yourself (You), while all other attendees are considered remote participants.

  • Stream - A stream refers to video or audio media content published by either the local participant or remote participants.

πŸ” Token Generation

The token is used to create and validate a meeting using API and also initialize a meeting.

πŸ› οΈ Development Environment:

  • You may use a temporary token for development. To create a temporary token, go to VideoSDK's dashboard .

🌐 Production Environment:

  • You must set up an authentication server to authorize users for production. To set up an authentication server, please take a look at our official example repositories. videosdk-rtc-api-server-examples

🧩 Project Overview

App Behaviour with Different Meeting Types

  • One-to-One meeting - The One-to-One meeting allows 2 participants to join a meeting in the app.

  • Group Meeting - The Group meeting allows any number of participants to join a meeting in the app.

πŸ—οΈ Project Structure

🧩 Project Overview

App Behaviour with Different Meeting Types

  • One-to-One meeting - The One-to-One meeting allows 2 participants to join a meeting in the app.

  • Group Meeting - The Group meeting allows any number of participants to join a meeting in the app.

πŸ—οΈ Project Structure

  • We have created 3 package screens and widgets in the following folder structure:
    • OneToOneCall - It includes all classes/files related to OneToOne meetings.
    • GroupCall - It includes all classes/files related to the Group meetings.
    • Common - It includes all the classes/files that are used in both meeting type.

1. Pre-Call Setup on Join Screen

  • DeviceAdapter.kt : This is a custom RecyclerView.Adapter used to display a list of audio devices. It takes a list of devices and a click listener to handle item clicks. Each item shows the device name and an icon.

  • bottom_sheet.xml : This layout defines the structure of the bottom sheet dialog, which contains a RecyclerView that displays the list of items. The RecyclerView fills the available space and references list_items_bottom_sheet for its individual list items.

  • list_items_bottom_sheet.xml : This layout defines how each item in the bottom sheet looks. It contains a LinearLayout with an ImageView for the device icon, a TextView for the device label, and another ImageView for a checkmark icon. The checkmark is used to indicate the currently selected device.

2. Create or Join Meeting

  • NetworkUtils.kt - This class is used to call the API to generate a token, create and validate the meeting.

  • CreateOrJoinActivity.kt and activity_create_or_join.xml : This Activity allows users to either create or join a meeting. It manages microphone and webcam permissions and handles UI interactions like enabling/disabling audio and video. It also switches between the CreateMeetingFragment and JoinMeetingFragment, depending on user actions.

  • CreateOrJoinFragment.kt and fragment_createorjoin.xml : This fragment provides two buttons for users to either create or join a meeting. On button clicks, it transitions to the respective fragments (CreateMeetingFragment or JoinMeetingFragment) within CreateOrJoinActivity.

  • CreateMeetingFragment.kt and fragment_create_meeting.xml : This fragment enables users to create a new meeting by selecting a meeting type (e.g., One-to-One or Group Call) and entering their name. Upon submission, it makes a network request to create a meeting and navigates to the relevant meeting activity.

  • JoinMeetingFragment.kt and fragment_join_meeting.xml : This fragment allows users to join an existing meeting by entering a valid meeting ID and their name. It validates input and, on success, navigates to the appropriate meeting activity based on the selected meeting type.

3. Switch AudioDevice

  • AudioDeviceListAdapter.kt : This is a custom ArrayAdapter that displays a list of audio devices in a dialog. It uses a ListItem model to represent each audio device. The layout for each list item is defined in audio_device_list_layout.xml.

  • ListItem.kt : This class represents an individual list item (audio device) with properties such as the device name, icon, and a description, and a boolean indicating whether the item is selected.

  • audio_device_list_layout.xml : This layout defines the appearance of each audio device in the list.

4. Chat

  • MessageAdapter.kt ; This is a custom RecyclerView.Adapter for displaying chat messages in a meeting.

  • item_message_list.xml : This layout defines the structure of each chat message in the list. It displays the sender's name, the message, and the message timestamp.

5. ParticipantList

  • ParticipantListAdapter.kt : This adapter displays the list of meeting participants in a RecyclerView. It includes the local user and updates in real-time as participants join or leave the meeting.

  • layout_participants_list_view.xml : This layout defines the structure for the participant's list view. It includes a RecyclerView that lists each participant using the item_participant_list_layout.

  • item_participant_list_layout.xml : This layout defines the appearance of each participant in the list. It displays the participant’s name, microphone, and camera status.

  • OneToOneCallActivity.kt : OneToOneCallActivity.java handles one-on-one video call, providing features like microphone and camera control, screen sharing, and participant management. It supports real-time chat and meeting event listeners for tasks like recording and screen sharing. The activity also displays session elapsed time and handles permissions for audio, video, and screen sharing.
  • GroupCallActivity.kt : The GroupCallActivity class manages the main UI and logic for initiating and maintaining a group video call. It serves as the primary activity where users can join a video call session, toggle mic and camera. It also manages the video grid where all participants are displayed using ParticipantViewFragment and ParticipantViewAdapter.
  • ParticipantViewFragment.kt : Displays an individual participant's video feed and controls within a fragment, updating the UI based on participant state changes.
  • ParticipantViewAdapter.kt : Binds participant data to a RecyclerView, dynamically updating the video grid as participants join, leave, or change state.
  • ParticipantChangeListener.kt : Listens for participant-related events (join, leave, state changes) and triggers UI updates.
  • ParticipantState.kt : Represents the current state of a participant, such as mute and video status, for UI display and logic handling.

πŸ“– Examples

πŸ“ Documentation

Explore more and start building with our Documentation

🀝 Join Our Community

  • Discord: Engage with the Video SDK community, ask questions, and share insights.
  • X: Stay updated with the latest news, updates, and tips from Video SDK.