private async void DoAutoStartActions(WebRTC.PeerConnection nativePeer) { // If a headset is active then do not capture local streams. if (XRDevice.isPresent) { return; } if (AutoStartCapture) { //nativePeer.LocalAudioFrameReady += LocalAudioFrameReady; // TODO - Currently AddLocalAudioTrackAsync() both open the capture device AND add an audio track } if (AutoAddTrack) { // Force again PreferredAudioCodec right before starting the local capture, // so that modifications to the property done after OnPeerInitialized() are // accounted for. nativePeer.PreferredAudioCodec = PreferredAudioCodec; //FrameQueue.Clear(); await nativePeer.AddLocalAudioTrackAsync(); AudioStreamStarted.Invoke(); } }
/// <summary> /// Internal free-threaded helper callback on track added, which enqueues the /// <see cref="VideoSource.VideoStreamStarted"/> event to be fired from the main /// Unity thread. /// </summary> private void TrackAdded(WebRTC.PeerConnection.TrackKind trackKind) { if (trackKind == WebRTC.PeerConnection.TrackKind.Audio) { // Enqueue invoking the unity event from the main Unity thread, so that listeners // can directly access Unity objects from their handler function. _mainThreadWorkQueue.Enqueue(() => AudioStreamStarted.Invoke()); } }
protected async void OnEnable() { if (AutoAddTrack) { var nativePeer = PeerConnection?.Peer; if ((nativePeer != null) && nativePeer.Initialized) { await nativePeer.AddLocalAudioTrackAsync(); AudioStreamStarted.Invoke(); } } }
private void OnPeerInitialized() { var nativePeer = PeerConnection.Peer; nativePeer.PreferredAudioCodec = PreferredAudioCodec; if (AutoStartCapture) { //nativePeer.I420LocalVideoFrameReady += I420LocalVideoFrameReady; // TODO - Currently AddLocalVideoTrackAsync() both open the capture device AND add a video track } if (AutoAddTrack) { nativePeer.AddLocalAudioTrackAsync(); AudioStreamStarted.Invoke(); } }