_peerViewA.SetVideoTexture(_activeCamera);
_peerViewA.audioSource.clip= _activeMicrophone;
_peerViewA.audioSource.Play();
_videoManager.SetActiveCameraAndMicrophone(_activeCamera, _peerViewA.audioSource);
public void SetActiveCameraAndMicrophone(WebCamTexture activeWebCamTexture, AudioSource activeMicrophone)
{
// 기존의 비디오 트랙과 오디오 트랙을 제거합니다.
var senders = _peerConnection.GetSenders();
foreach (var sender in senders)
{
_peerConnection.RemoveTrack(sender);
}
// 비디오 트랙을 추가합니다.
var videoTrack = new VideoStreamTrack(activeWebCamTexture);
_peerConnection.AddTrack(videoTrack);
Debug.Log("Sender video track was set");
// 마이크 트랙을 추가합니다.
var audioTrack = new AudioStreamTrack(activeMicrophone);
audioTrack.Loopback = true;
_peerConnection.AddTrack(audioTrack,sendStream);
if (activeMicrophone.clip == null)
{
Debug.Log("not activeMicrophone");
}
else
{
Debug.Log("good activeMicrophone");
}
Debug.Log("Sender audio track was set");
}
private void OnTrack(RTCTrackEvent trackEvent)
{
// 비디오 트랙을 처리하는 부분
if (trackEvent.Track is VideoStreamTrack videoStreamTrack)
{
videoStreamTrack.OnVideoReceived += OnVideoReceived;
}
// 오디오 트랙을 처리하는 부분
else if (trackEvent.Track is AudioStreamTrack audioStreamTrack)
{
OutputAudioSource.SetTrack(audioStreamTrack);
if(OutputAudioSource.clip==null)
{
Debug.Log("OutputAudioSource.clip is null");
}
OutputAudioSource.loop = true; // 필요 시 루프 설정
OutputAudioSource.Play();
Debug.Log("Audio track connected.");
Debug.Log("event register");
}
else
{
Debug.LogError($"Unhandled track of type: {trackEvent.Track.GetType()}. Only video and audio tracks are handled.");
}
}
If I don’t _peerViewA.audiosource.Play() in the code, the sound won’t be sent to the other party. However, if I write _peerViewA.audiosource.Play(), I can hear the voice I said, even though it’s sent to the other party. Is there a way for me to send a voice to the other party without being heard?