Class StreamPeerConnectionFactory

  • All Implemented Interfaces:

    
    public final class StreamPeerConnectionFactory
    
                        

    Builds a factory that provides PeerConnections when requested.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private final EglBase eglBase
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final EglBase getEglBase() Represents the EGL rendering context.
      final Unit setAudioSampleCallback(Function1<JavaAudioDeviceModule.AudioSamples, Unit> callback) Set to get callbacks when audio input from microphone is received.
      final Unit setAudioRecordDataCallback(Function4<Integer, Integer, Integer, ByteBuffer, Unit> callback) Set to get callbacks when audio input from microphone is received.
      final StreamPeerConnection makePeerConnection(CoroutineScope coroutineScope, PeerConnection.RTCConfiguration configuration, StreamPeerType type, MediaConstraints mediaConstraints, Function1<MediaStream, Unit> onStreamAdded, Function2<StreamPeerConnection, StreamPeerType, Unit> onNegotiationNeeded, Function2<IceCandidate, StreamPeerType, Unit> onIceCandidateRequest, Integer maxPublishingBitrate) Builds a StreamPeerConnection that wraps the WebRTC PeerConnection and exposes several helpful handlers.
      final VideoTrack makeVideoTrack(VideoSource source, String trackId) Builds a VideoTrack from the factory that can be used for regular video share (camera) or screen sharing.
      final AudioSource makeAudioSource(MediaConstraints constraints) Builds an AudioSource from the factory that can be used for audio sharing.
      final AudioTrack makeAudioTrack(AudioSource source, String trackId) Builds an AudioTrack from the factory that can be used for regular video share (camera) or screen sharing.
      • Methods inherited from class java.lang.Object

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

      • StreamPeerConnectionFactory

        StreamPeerConnectionFactory(Context context, Integer audioUsage)
        Parameters:
        context - Used to build the underlying native components for the factory.
        audioUsage - signal to the system how the audio tracks are used.
    • Method Detail

      • getEglBase

         final EglBase getEglBase()

        Represents the EGL rendering context.

      • setAudioSampleCallback

         final Unit setAudioSampleCallback(Function1<JavaAudioDeviceModule.AudioSamples, Unit> callback)

        Set to get callbacks when audio input from microphone is received. This can be example used to detect whether a person is speaking while muted.

      • makePeerConnection

         final StreamPeerConnection makePeerConnection(CoroutineScope coroutineScope, PeerConnection.RTCConfiguration configuration, StreamPeerType type, MediaConstraints mediaConstraints, Function1<MediaStream, Unit> onStreamAdded, Function2<StreamPeerConnection, StreamPeerType, Unit> onNegotiationNeeded, Function2<IceCandidate, StreamPeerType, Unit> onIceCandidateRequest, Integer maxPublishingBitrate)

        Builds a StreamPeerConnection that wraps the WebRTC PeerConnection and exposes several helpful handlers.

        Parameters:
        coroutineScope - Scope used for asynchronous operations.
        configuration - The PeerConnection.RTCConfiguration used to set up the connection.
        type - The type of connection, either a subscriber of a publisher.
        mediaConstraints - Constraints used for audio and video tracks in the connection.
        onStreamAdded - Handler when a new MediaStream gets added.
        onNegotiationNeeded - Handler when there's a new negotiation.
        onIceCandidateRequest - Handler whenever we receive IceCandidates.
        Returns:

        StreamPeerConnection That's fully set up and can be observed and used to send and receive tracks.

      • makeVideoTrack

         final VideoTrack makeVideoTrack(VideoSource source, String trackId)

        Builds a VideoTrack from the factory that can be used for regular video share (camera) or screen sharing.

        Parameters:
        source - The VideoSource used for the track.
        trackId - The unique ID for this track.
        Returns:

        VideoTrack That represents a video feed.

      • makeAudioSource

         final AudioSource makeAudioSource(MediaConstraints constraints)

        Builds an AudioSource from the factory that can be used for audio sharing.

        Parameters:
        constraints - The constraints used to change the way the audio behaves.
        Returns:

        AudioSource that can be used to build tracks.

      • makeAudioTrack

         final AudioTrack makeAudioTrack(AudioSource source, String trackId)

        Builds an AudioTrack from the factory that can be used for regular video share (camera) or screen sharing.

        Parameters:
        source - The AudioSource used for the track.
        trackId - The unique ID for this track.
        Returns:

        AudioTrack That represents an audio feed.