Interface WebRtcBridge
Internal service-provider interface a port implements to carry the
com.codename1.webrtc API onto its native WebRTC stack: Google's
org.webrtc on Android, the WebRTC framework on iOS, the browser's
RTCPeerConnection in the JavaScript port, and a loopback in the
simulator.
Application code never touches this interface; the public classes reach it
through com.codename1.ui.Display#getWebRtcBridge(), and a port that
returns null there is a port without WebRTC -- WebRtc.isSupported()
says so and nothing else needs a platform if.
Everything is ids, primitives and strings
As with com.codename1.call.spi.CallBridge, no method takes or returns a
framework type, so a port reached through ParparVM never constructs a
Java object from native code. Peer connections and tracks are integer
handles the port allocates; structured values cross as strings.
Every request answers exactly once
An operation that can fail takes a requestId from the caller and answers
it by calling exactly one of WebRtc.deliverDescription,
WebRtc.deliverTracks or WebRtc.deliverResult. A request that never
answers leaves an AsyncResource that never settles, which is worse than
one that fails. Unsolicited events -- a gathered candidate, a state
change, a remote track -- carry the peer handle instead. Every entry point
may be called from any thread; they marshal to the EDT themselves.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddIceCandidate(int peer, String sdpMid, int sdpMLineIndex, String candidate) Adds a candidate the other side gathered.voidaddTrack(int peer, int track) Sends a local track over a peer connection.voidclosePeerConnection(int peer) Closes a peer connection and frees its handle.voidcreateDescription(int peer, int requestId, boolean answer) Creates an offer, or withansweran answer to the remote description already set.intcreatePeerConnection(String iceServers, boolean relayOnly) Creates a peer connection and answers its handle, or a negative number when it cannot be created.createVideoView(int track, boolean mirror) A native view drawing a video track: acom.codename1.ui.PeerComponent, or anycom.codename1.ui.Componenton a port that draws it itself.voidopenUserMedia(int requestId, boolean audio, boolean video, boolean frontCamera) Starts the local camera and/or microphone.voidreleaseTrack(int track) Stops a local track and frees its handle.voidreleaseVideoView(Object view) Detaches a view from its track, before the view is discarded.voidsetDescription(int peer, int requestId, boolean remote, String type, String sdp) Sets a description as the local one, or withremoteas the remote one.voidsetSpeakerphone(boolean on) Routes call audio to the loudspeaker or back to the earpiece.voidsetTrackEnabled(int track, boolean enabled) Mutes or unmutes a track, local or remote.voidswitchCamera(int track) Switches a local video track between the front and back cameras.
-
Method Details
-
createPeerConnection
Creates a peer connection and answers its handle, or a negative number when it cannot be created.
Parameters
-
iceServers: one server per line, each line tab-separated asurls(comma-separated),username,credential -
relayOnly: whether only relayed (TURN) candidates may be used, which keeps the device's own addresses from the other side
-
-
openUserMedia
void openUserMedia(int requestId, boolean audio, boolean video, boolean frontCamera) Starts the local camera and/or microphone. Answers withWebRtc.deliverTracks: the handles of the audio track and the video track, 0 for one not asked for. -
addTrack
void addTrack(int peer, int track) Sends a local track over a peer connection. -
createDescription
void createDescription(int peer, int requestId, boolean answer) Creates an offer, or withansweran answer to the remote description already set. Answers withWebRtc.deliverDescription. -
setDescription
-
addIceCandidate
-
closePeerConnection
void closePeerConnection(int peer) Closes a peer connection and frees its handle. -
setTrackEnabled
void setTrackEnabled(int track, boolean enabled) Mutes or unmutes a track, local or remote. -
switchCamera
void switchCamera(int track) Switches a local video track between the front and back cameras. -
setSpeakerphone
void setSpeakerphone(boolean on) Routes call audio to the loudspeaker or back to the earpiece. -
releaseTrack
void releaseTrack(int track) Stops a local track and frees its handle. -
createVideoView
A native view drawing a video track: acom.codename1.ui.PeerComponent, or anycom.codename1.ui.Componenton a port that draws it itself. Null when the track cannot be drawn. -
releaseVideoView
Detaches a view from its track, before the view is discarded.
-