-
public class MedraUsed to establish video and audio P2P communication between 2 participants. Usage: Establish connection:
Listen to communication requests:Medra medra = new Medra(gliaApiUrl); Options options = new Options(); options.context = context; options.namespace = namespace; options.webRTC = new Options.WebRTCOptions(); options.webRTC.iceServers = iceServers; ObservableconnectionObservable = medra.connect(channel, options); connectionObservable.subscribe(connection -> { System.out.println("Connected to remote Medra participant"); });Join conference:// connectionObservable emits new connection every time remote participant reconnects. // Therefore use `switchMap` to replace previous `communicationRequest`. connectionObservable .switchMap(connection -> connection.communicationRequest()) .subscribe(request -> { Runnable onAccept = () -> { AcceptOptions.Builder builder = CommunicationRequest.AcceptOptions.builder(); if (request.isVideoRequested()) { builder.withVideo(CameraSource.build(activity, videoRequestCode)); } if (request.isAudioRequested()) { builder.withAudio(MicrophoneSource.build(activity, audioRequestCode)); } AcceptOptions acceptOptions = builder.build(); request.accept(acceptOptions).subscribe(streams -> { System.out.println("Received communication streams"); }, exception -> { System.out.println("Error when accepting communication request"); }); }; Runnable onDecline = () -> { request.decline(); }; showRequestedMediaDialog(request, onAccept, onDecline); });Medra medra = new Medra(gliaApiUrl); medra.joinConference(conferenceId, visitorAccessToken, context).subscribe(conference -> { System.out.println("Joined conference:" + conferenceId); });
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enumMedra.CommunicationType
-
Constructor Summary
Constructors Constructor Description Medra(String baseUrl, Context context, Observable<AppLifecycle.AppState> appLifeState)
-
Method Summary
Modifier and Type Method Description Observable<Connection>connect(EventEmitter channel, Options options)Connects to remote Medra participant Ported from Medra.js Android version uses integer for local connection ID instead of double to avoidsum precision problems. Observable<Connection>connect(EventEmitter channel)Single<Conference>joinConference(String conferenceId, String visitorAccessToken)Joins the specified conferenceCompared to Connection conference is not P2P and allows to have more then 2 participants. -
-
Constructor Detail
-
Medra
Medra(String baseUrl, Context context, Observable<AppLifecycle.AppState> appLifeState)
- Parameters:
baseUrl- - Glia API URLcontext- - Application context
-
-
Method Detail
-
connect
Observable<Connection> connect(EventEmitter channel, Options options)
Connects to remote Medra participant Ported from Medra.js Android version uses integer for local connection ID instead of double to avoidsum precision problems.
- Parameters:
channel- Signaling channeloptions- Configuration options
-
connect
Observable<Connection> connect(EventEmitter channel)
-
joinConference
Single<Conference> joinConference(String conferenceId, String visitorAccessToken)
Joins the specified conferenceCompared to Connection conference is not P2P and allows to have more then 2 participants.
- Parameters:
conferenceId- ID of the conference to joinvisitorAccessToken- Visitor Access Token to make REST API calls
-
-
-
-