At Video SDK, we’re building tools to help companies create world-class collaborative products with capabilities of live audio/videos, compose cloud recordings/rtmp/hls and interaction APIs
📱 Download the sample Android app here: https://appdistribution.firebase.dev/i/99ae2c5db3a7e446
- Real-time video and audio conferencing
- Enable/disable camera
- Mute/unmute mic
- Switch between front and back camera
- Change audio device
- Screen share
- Chat
- Raise hand
- Recording
- External call detection
-
Sign up on VideoSDK and visit API Keys section to get your API key and Secret key.
-
Get familiarized with Authentication and Token.
- Development environment requirements:
- Java Development Kit
- Android Studio 3.0 or later
- A physical or virtual mobile device running Android 5.0 or later
- Valid Video SDK Account
Clone the repository to your local environment.
git clone https://github.com/videosdk-live/videosdk-rtc-android-java-sdk-example.git
Generate temporary token from Video SDK Account.
auth_token = "TEMPORARY-TOKEN";
Run the android app with Shift+F10 or the ▶ Run from toolbar.
-
Meeting
- A Meeting represents Real time audio and video communication.Note : Don't confuse with Room and Meeting keyword, both are same thing 😃
-
Sessions
- A particular duration you spend in a given meeting is a referred as session, you can have multiple session of a particular meetingId. -
Participant
- Participant represents someone who is attending the meeting's session,local partcipant
represents self (You), for this self, other participants areremote participants
. -
Stream
- Stream means video or audio media content that is either published bylocal participant
orremote participants
.
Add all the following permissions to AndroidManifest.xml file.
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<!-- Needed to communicate with already-paired Bluetooth devices. (Legacy up to Android 11) -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<!-- Needed to communicate with already-paired Bluetooth devices. (Android 12 upwards)-->
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
Token is used to create and validate a meeting using API and also initialise a meeting.
🛠️ Development Environment
:
- For development, you can use temporary token. Visit VideoSDK dashboard to generate temporary token.
🌐 Production Environment
:
- For production, you have to set up an authentication server to authorize users. Follow our official example repositories to setup authentication server, videosdk-rtc-api-server-examples
create meeting
- Please refer this documentation to create meeting.validate meeting
- Please refer this documentation to validate the meetingId.
- For meeting initialization, you have to first initialize the
VideoSDK
. You can initialize theVideoSDK
usinginitialize()
method.
VideoSDK.initialize(Context context)
- After successfully initialization, you can configure
VideoSDK
by passing token inconfig
method
VideoSDK.config(String token)
- After VideoSDK initialization and configuration, you can initialize the meeting using
initMeeting()
method.initMeeting()
will generate a newMeeting
class and the initiated meeting will be returned.
Meeting meeting = VideoSDK.initMeeting(
Context context,
String meetingId,
String name,
boolean micEnabled,
boolean webcamEnabled,
String participantId)
// unmute mic
meeting.unmuteMic();
// mute mic
meeting.muteMic();
- The
meeting.getMics()
function allows a participant to list all of the attached microphones (e.g., Bluetooth and Earphone).
// get connected mics
Set<AppRTCAudioManager.AudioDevice> mics = meeting.getMics();
- Local participant can change the audio device using
changeMic(AppRTCAudioManager.AudioDevice device)
method ofmeeting
class.
// change mic
meeting.changeMic(AppRTCAudioManager.AudioDevice device);
Please consult our documentation Change Audio Device for more infromation.
// enable webcam
meeting.enableWebcam();
// disable webcam
meeting.disableWebcam();
// switch webcam
meeting.changeWebcam();
The chat feature allows participants to send and receive messages about specific topics to which they have subscribed.
// publish
meeting.pubSub.publish(String topic,String message, PubSubPublishOptions pubSubPublishoptions);
// pubSubPublishoptions is an object of PubSubPublishOptions, which provides an option, such as persist, which persists message history for upcoming participants.
//subscribe
List<PubSubMessage> pubSubMessageList = meeting.pubSub.subscribe(String topic, PubSubMessageListener pubSubMessageListener)
//unsubscribe
meeting.pubSub.unsubscribe(topic, PubSubMessageListener pubSubMessageListener);
// receiving messages
// PubSubMessageListener will be invoked with onMessageReceived(PubSubMessage message)
PubSubMessageListener pubSubMessageListener = new PubSubMessageListener() {
@Override
public void onMessageReceived(PubSubMessage message) {
Log.d("#message", "onMessageReceived: " + message.getMessage());
}
};
// Only one participant will leave/exit the meeting; the rest of the participants will remain.
meeting.leave();
// The meeting will come to an end for each and every participant. So, use this function in accordance with your requirements.
meeting.end();
By implementing MeetingEventListener
, VideoSDK sends callbacks to the client app whenever there is a change or update in the meeting after a user joins.
MeetingEventListener meetingEventListener = new MeetingEventListener() {
@Override
public void onMeetingJoined() {
// This event will be emitted when a localParticipant(you) successfully joined the meeting.
}
@Override
public void onMeetingLeft() {
// This event will be emitted when a localParticipant(you) left the meeting.
}
@Override
public void onParticipantJoined(Participant participant) {
// This event will be emitted when a new participant joined the meeting.
// [participant]: new participant who joined the meeting
}
@Override
public void onParticipantLeft(Participant participant) {
// This event will be emitted when a joined participant left the meeting.
// [participant]: participant who left the meeting
}
@Override
public void onPresenterChanged(String participantId) {
// This event will be emitted when any participant starts or stops screen sharing.
// [participantId]: Id of participant who shares the screen.
}
@Override
public void onSpeakerChanged(String participantId) {
// This event will be emitted when a active speaker changed.
// [participantId] : Id of active speaker
}
@Override
public void onRecordingStarted() {
// This event will be emitted when recording of the meeting is started.
}
@Override
public void onRecordingStopped() {
// This event will be emitted when recording of the meeting is stopped.
}
@Override
public void onExternalCallStarted() {
// This event will be emitted when local particpant receive incoming call.
}
@Override
public void onMeetingStateChanged(String state) {
// This event will be emitted when state of meeting changes.
}
};
By implementing ParticipantEventListener
, VideoSDK sends callbacks to the client app whenever a participant's video, audio, or screen share stream is enabled or disabled.
ParticipantEventListener participantEventListener = new ParticipantEventListener() {
@Override
public void onStreamEnabled(Stream stream) {
// This event will be triggered whenever a participant's video, audio or screen share stream is enabled.
}
@Override
public void onStreamDisabled(Stream stream) {
// This event will be triggered whenever a participant's video, audio or screen share stream is disabled.
}
};
If you want to learn more about, read the complete documentation of Android VideoSDK
Note :
- master branch: Better UI with One-to-One and Group call experience.
- v1-code-sample branch: Simple UI with Group call experience.
-
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 2 or more participants to join a meeting in the app.
We have 3 packages :
OneToOneCall
- OneToOneCall package includes all classes/files related to OneToOne meeting.GroupCall
- GroupCall package includes all classes/files related to Group meeting.Common
- Common package inclues all the classes/files that are used in both meeting type.
1. Create or Join Meeting
-
NetworkUtils.java
- This class is used to call the api to generate token,create and validate the meeting. -
CreateOrJoinActivity.java
andactivity_create_or_join.xml
- This activity is used to ask permissions to the partcipant,and to initiate webcam and mic status.
CreateOrJoinFragment
,CreateMeetingFragment
,JoinMeetingFragment
will be bound to this activity.
-
CreateOrJoinFragment.java
andfragment_createorjoin.xml
- This fragment will includeCreate Meeting Button
- This button will navigate toCreateMeetingFragment
.Join Meeting Button
- This button will navigate toJoinMeetingFragment
.
-
CreateMeetingFragment.java
andfragment_create_meeting.xml
- This fragement will includeDropdown to select meeting type
- This dropdown will give choice for meeting type.EditText for ParticipantName
- This edit text will contain name of the participant.Create Meeting Button
- This button will call api for create a new meeting and navigate toOneToOneCallActivity
orGroupCallActivity
according to user choice.
-
JoinMeetingFragment.java
andfragment_join_meeting.xml
- This fragement will includeDropdown to select meeting type
- This dropdown will give choice for meeting type.EditText for ParticipantName
- This edit text will contain name of the participant.EditText for MeetingId
- This edit text will contain the meeting Id that you want to join.Join Meeting Button
- This button will call api for join meeting with meetingId that you provided and navigate toOneToOneCallActivity
orGroupCallActivity
according to user choice.
2. ParticipantList
ParticipantListAdapter.java
,layout_participants_list_view.xml
anditem_participant_list_layout.xml
files used to show ParticipantList.
3. Dialogs
- MoreOptions:
MoreOptionsListAdapter.java
class,ListItem.java
class andmore_options_list_layout.xml
files used to showMoreOptions
dialog.
- AudioDeviceList:
AudioDeviceListAdapter.java
class,ListItem.java
class andaudio_device_list_layout.xml
files used to showAudioDeviceList
dialog.
- LeaveOrEndDialog:
LeaveOptionListAdapter.java
class,ListItem.java
class andleave_options_list_layout.xml
files used to showLeaveOrEndDialog
.
OneToOneCallActivity.java
activity is main activity for One-to-One meeting.
GroupCallActivity.java
activity is main activity for Group meeting.ParticipantViewFragment.java
,ParticipantViewAdapter.java
,ParticipantChangeListener.java
andParticipantState.java
is used to show participants in Grid.
- videosdk-rtc-prebuilt-examples
- videosdk-rtc-javascript-sdk-example
- videosdk-rtc-react-sdk-examplee
- videosdk-rtc-react-native-sdk-example
- videosdk-rtc-flutter-sdk-example
- videosdk-rtc-android-java-sdk-example
- videosdk-rtc-android-kotlin-sdk-example
- videosdk-rtc-ios-sdk-example
- videosdk-hls-react-sdk-example
- videosdk-hls-react-native-sdk-example
- videosdk-hls-flutter-sdk-example
- videosdk-hls-android-java-example
- videosdk-hls-android-kotlin-example
Read the documentation to start using Video SDK.