Package 

Class Medra


  • 
    public class Medra
    
                        

    Used to establish video and audio P2P communication between 2 participants. Usage: Establish connection:

     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");
        });
    Listen to communication requests:
        // 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);
            });
    
    Join conference:
        Medra medra = new Medra(gliaApiUrl);
        medra.joinConference(conferenceId, visitorAccessToken, context).subscribe(conference -> {
            System.out.println("Joined conference:" + conferenceId);
        });
    
    • 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • 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 channel
        options - Configuration options
      • 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 join
        visitorAccessToken - Visitor Access Token to make REST API calls