Skip to content

Instantly share code, notes, and snippets.

@ShwetaChauhan18
Last active April 13, 2020 08:40
Show Gist options
  • Select an option

  • Save ShwetaChauhan18/55c486d900c59a4f883ae3bc22d3f5c0 to your computer and use it in GitHub Desktop.

Select an option

Save ShwetaChauhan18/55c486d900c59a4f883ae3bc22d3f5c0 to your computer and use it in GitHub Desktop.
private fun startStreamingVideo() {
//creating local mediastream
val mediaStream = factory?.createLocalMediaStream("ARDAMS")
mediaStream?.apply {
addTrack(localAudioTrack)
addTrack(localVideoTrack)
localPeerConnection?.addStream(this)
}
val sdpMediaConstraints = MediaConstraints()
sdpMediaConstraints.apply {
mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveAudio", "true"))
mandatory.add(MediaConstraints.KeyValuePair("OfferToReceiveVideo", "true"))
}
localPeerConnection?.createOffer(object : SimpleSdpObserver() {
override fun onCreateSuccess(sessionDescription: SessionDescription) {
Log.d(TAG, "onCreateSuccess: ")
localPeerConnection?.setLocalDescription(SimpleSdpObserver(), sessionDescription)
remotePeerConnection?.setRemoteDescription(SimpleSdpObserver(), sessionDescription)
remotePeerConnection?.createAnswer(object : SimpleSdpObserver() {
override fun onCreateSuccess(sessionDescription: SessionDescription) {
localPeerConnection?.setRemoteDescription(SimpleSdpObserver(), sessionDescription)
remotePeerConnection?.setLocalDescription(SimpleSdpObserver(), sessionDescription)
}
}, sdpMediaConstraints)
}
}, sdpMediaConstraints)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment