Sub Service_Create
audioStream2.Initialize("AudioStream", 22050, False, 16, audioStream2.VOLUME_MUSIC)
audioStream.Initialize("AudioStream", 22050, False, 16,audioStream.VOLUME_VOICE_CALL)
SetEchoCanceler
End Sub
Sub SetEchoCanceler
Dim echo As JavaObject
echo.InitializeStatic("android/media/audiofx/AcousticEchoCanceler".Replace("/", "."))
If echo.RunMethod("isAvailable", Null) = True Then
Dim r As Reflector
r.Target = streamer
Dim AudioRecord As JavaObject = r.GetField("audioRecord")
echo.RunMethod("create", Array(AudioRecord.RunMethod("getAudioSessionId", Null)))
Log("echo set")
Else
Log("Echo not available")
End If
End Sub
Private Sub socket1_Connected (Successful As Boolean)
If Successful Then
StartAStream(socket1.InputStream, socket1.OutputStream)
End If
End Sub
Private Sub socket2_Connected (Successful As Boolean)
If Successful Then
StartAStream2(socket2.InputStream, socket2.OutputStream)
End If
End Sub
Private Sub StartAStream (In As InputStream, out As OutputStream)
Log("StartAStream")
astream.InitializePrefix(In, True, out, "astream")
SetSpeaker(True)
SetMute(True)
End Sub
Private Sub StartAStream2 (In As InputStream, out As OutputStream)
Log("StartAStream2")
astream2.InitializePrefix(In, True, out, "astream2")
SetSpeaker(True)
SetMute(True)
End Sub
Sub astream_NewData (Buffer() As Byte)
Dim mm11 As MyMessage
mm11.Initialize
mm11=ser.ConvertBytesToObject(Buffer)
Dim bb11() As Byte
bb11=mm11.Voice
Select mm11.Code
Case 1 'SetIp
Starter.CALL_MYIP=mm11.Sen
SendIp(Starter.CALL_MYIP,mm11.rec)
Case 2 'Voice
If Speaker Then
audioStream.Write(bb11)
Else
audioStream2.Write(bb11)
End If
' Case 3
' If IsPaused(Chat1) Then
' EndCall
' Else
' CallSub(Calls,"CallChatCancel")
' End If
End Select
End Sub
Sub astream2_NewData (Buffer() As Byte)
Dim mm11 As MyMessage
mm11.Initialize
mm11=ser.ConvertBytesToObject(Buffer)
Dim bb11() As Byte
bb11=mm11.Voice
Select mm11.Code
Case 1 'SetIp
Starter.CALL_MYIP=mm11.Sen
SendIp(Starter.CALL_MYIP,mm11.rec)
Case 2 'Voice
If Speaker Then
audioStream.Write(bb11)
Else
audioStream2.Write(bb11)
End If
' Case 3
' If IsPaused(Chat1) Then
' EndCall
' Else
' CallSub(Calls,"CallChatCancel")
' End If
End Select
End Sub
Sub AudioStream_RecordBuffer (Data() As Byte)
Select Starter.CALL_STATE
Case "IN"
Dim mm11 As MyMessage
mm11.Initialize
mm11.Code=2
mm11.Sen=Starter.CALL_MYIP
mm11.Rec=Starter.CALL_IP
mm11.Voice=Data
Dim bb11() As Byte
bb11=ser.ConvertObjectToBytes(mm11)
astream2.Write(bb11)
' CallSub3(FirebaseMessaging,"sendVoice",Starter.CALL_ID,mm11)
Case "OUT"
Dim mm12 As MyMessage
mm12.Initialize
mm12.Code=2
mm12.Sen=Starter.CALL_MYIP
mm12.Rec=Starter.CALL_IP
mm12.Voice=Data
Dim bb12() As Byte
bb12=ser.ConvertObjectToBytes(mm12)
astream.Write(bb12)
' CallSub3(FirebaseMessaging,"sendVoice",Starter.CALL_ID,mm12)
End Select
End Sub
Sub SetSpeaker(status As Boolean)
Speaker=status
If status Then
audioStream2.StopPlaying
audioStream.StartPlaying
Else
audioStream.StopPlaying
audioStream2.StartPlaying
End If
End Sub