mirror of
https://github.com/element-hq/element-android
synced 2024-11-28 13:38:49 +03:00
Send sdp to remote party when answer is received.
This commit is contained in:
parent
37c926d178
commit
54b154f85f
3 changed files with 48 additions and 15 deletions
|
@ -17,10 +17,13 @@
|
|||
package im.vector.riotx.features.call
|
||||
|
||||
import android.app.KeyguardManager
|
||||
import android.content.ComponentName
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.ServiceConnection
|
||||
import android.os.Build
|
||||
import android.os.Bundle
|
||||
import android.os.IBinder
|
||||
import android.os.Parcelable
|
||||
import android.view.View
|
||||
import android.view.Window
|
||||
|
@ -35,6 +38,7 @@ import im.vector.riotx.core.platform.VectorBaseActivity
|
|||
import im.vector.riotx.core.utils.PERMISSIONS_FOR_VIDEO_IP_CALL
|
||||
import im.vector.riotx.core.utils.allGranted
|
||||
import im.vector.riotx.core.utils.checkPermissions
|
||||
import im.vector.riotx.features.call.service.CallHeadsUpService
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.subjects.PublishSubject
|
||||
import kotlinx.android.parcel.Parcelize
|
||||
|
@ -88,6 +92,19 @@ class VectorCallActivity : VectorBaseActivity(), WebRtcPeerConnectionManager.Lis
|
|||
|
||||
private val iceCandidateSource: PublishSubject<IceCandidate> = PublishSubject.create()
|
||||
|
||||
|
||||
|
||||
var callHeadsUpService: CallHeadsUpService? = null
|
||||
private val serviceConnection = object : ServiceConnection {
|
||||
override fun onServiceDisconnected(name: ComponentName?) {
|
||||
finish()
|
||||
}
|
||||
|
||||
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
||||
callHeadsUpService = (service as? CallHeadsUpService.CallHeadsUpServiceBinder)?.getService()
|
||||
}
|
||||
}
|
||||
|
||||
override fun doBeforeSetContentView() {
|
||||
// Set window styles for fullscreen-window size. Needs to be done before adding content.
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE)
|
||||
|
@ -113,6 +130,8 @@ class VectorCallActivity : VectorBaseActivity(), WebRtcPeerConnectionManager.Lis
|
|||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
|
||||
bindService(Intent(this, CallHeadsUpService::class.java), serviceConnection, 0)
|
||||
|
||||
if (intent.hasExtra(MvRx.KEY_ARG)) {
|
||||
callArgs = intent.getParcelableExtra(MvRx.KEY_ARG)!!
|
||||
} else {
|
||||
|
@ -340,8 +359,8 @@ class VectorCallActivity : VectorBaseActivity(), WebRtcPeerConnectionManager.Lis
|
|||
private fun handleViewEvents(event: VectorCallViewEvents?) {
|
||||
when (event) {
|
||||
is VectorCallViewEvents.CallAnswered -> {
|
||||
val sdp = SessionDescription(SessionDescription.Type.ANSWER, event.content.answer.sdp)
|
||||
peerConnectionManager.answerReceived("", sdp)
|
||||
//val sdp = SessionDescription(SessionDescription.Type.ANSWER, event.content.answer.sdp)
|
||||
//peerConnectionManager.answerReceived("", sdp)
|
||||
// peerConnection?.setRemoteDescription(object : SdpObserverAdapter() {}, sdp)
|
||||
}
|
||||
is VectorCallViewEvents.CallHangup -> {
|
||||
|
|
|
@ -103,8 +103,8 @@ class VectorCallViewModel @AssistedInject constructor(
|
|||
}
|
||||
|
||||
override fun initialState(viewModelContext: ViewModelContext): VectorCallViewState? {
|
||||
val args: CallArgs = viewModelContext.args()
|
||||
return VectorCallViewState(roomId = args.roomId)
|
||||
//val args: CallArgs = viewModelContext.args()
|
||||
return VectorCallViewState()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,9 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||
|
||||
private var peerConnection: PeerConnection? = null
|
||||
|
||||
private var localViewRenderer: SurfaceViewRenderer? = null
|
||||
private var remoteViewRenderer: SurfaceViewRenderer? = null
|
||||
|
||||
private var remoteVideoTrack: VideoTrack? = null
|
||||
private var localVideoTrack: VideoTrack? = null
|
||||
|
||||
|
@ -185,7 +188,6 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||
|
||||
localVideoTrack = peerConnectionFactory?.createVideoTrack("ARDAMSv0", videoSource)?.also {
|
||||
Timber.v("## VOIP Local video track created")
|
||||
listener?.addLocalVideoTrack(it)
|
||||
// localSurfaceRenderer?.get()?.let { surface ->
|
||||
// // it.addSink(surface)
|
||||
// // }
|
||||
|
@ -226,15 +228,6 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun answerReceived(callId: String, answerSdp: SessionDescription) {
|
||||
this.callId = callId
|
||||
|
||||
executor.execute {
|
||||
Timber.v("## answerReceived $callId")
|
||||
peerConnection?.setRemoteDescription(object : SdpObserverAdapter() {}, answerSdp)
|
||||
}
|
||||
}
|
||||
|
||||
private fun startCall() {
|
||||
createPeerConnectionFactory()
|
||||
createPeerConnection(object : PeerConnectionObserverAdapter() {
|
||||
|
@ -246,8 +239,16 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||
override fun onAddStream(mediaStream: MediaStream?) {
|
||||
Timber.v("## VOIP onAddStream remote $mediaStream")
|
||||
mediaStream?.videoTracks?.firstOrNull()?.let {
|
||||
listener?.addRemoteVideoTrack(it)
|
||||
remoteVideoTrack = it
|
||||
remoteSurfaceRenderer?.get()?.let { surface ->
|
||||
it.setEnabled(true)
|
||||
it.addSink(surface)
|
||||
}
|
||||
mediaStream.videoTracks?.firstOrNull()?.let { videoTrack ->
|
||||
remoteVideoTrack = videoTrack
|
||||
remoteVideoTrack?.setEnabled(true)
|
||||
remoteVideoTrack?.addSink(remoteViewRenderer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -318,9 +319,14 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||
}
|
||||
|
||||
fun attachViewRenderers(localViewRenderer: SurfaceViewRenderer, remoteViewRenderer: SurfaceViewRenderer) {
|
||||
this.localViewRenderer = localViewRenderer
|
||||
this.remoteViewRenderer = remoteViewRenderer
|
||||
audioSource = peerConnectionFactory?.createAudioSource(DEFAULT_AUDIO_CONSTRAINTS)
|
||||
audioTrack = peerConnectionFactory?.createAudioTrack(AUDIO_TRACK_ID, audioSource)
|
||||
|
||||
localViewRenderer.setMirror(true)
|
||||
localVideoTrack?.addSink(localViewRenderer)
|
||||
|
||||
localMediaStream = peerConnectionFactory?.createLocalMediaStream("ARDAMS") // magic value?
|
||||
|
||||
if (isVideoCall == true) {
|
||||
|
@ -429,6 +435,7 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||
this.isVideoCall = callInviteContent.isVideo()
|
||||
|
||||
startHeadsUpService(signalingRoomId, participantUserId, true, callInviteContent.isVideo())
|
||||
context.startActivity(VectorCallActivity.newIntent(context, signalingRoomId, participantUserId, false, callInviteContent.isVideo()))
|
||||
|
||||
startCall()
|
||||
}
|
||||
|
@ -448,6 +455,13 @@ class WebRtcPeerConnectionManager @Inject constructor(
|
|||
}
|
||||
|
||||
override fun onCallAnswerReceived(callAnswerContent: CallAnswerContent) {
|
||||
this.callId = callAnswerContent.callId
|
||||
|
||||
executor.execute {
|
||||
Timber.v("## answerReceived $callId")
|
||||
val sdp = SessionDescription(SessionDescription.Type.ANSWER, callAnswerContent.answer.sdp)
|
||||
peerConnection?.setRemoteDescription(object : SdpObserverAdapter() {}, sdp)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCallHangupReceived(callHangupContent: CallHangupContent) {
|
||||
|
|
Loading…
Reference in a new issue