Esempio n. 1
0
        /// <inheritdoc/>
        protected internal override void OnPaired(MediaTrack track)
        {
            var remoteAudioTrack = (RemoteAudioTrack)track;

            Debug.Assert(Track == null);
            AudioTrack = remoteAudioTrack;
            AudioStreamStarted.Invoke(remoteAudioTrack);
        }
 /// <summary>
 /// Free-threaded callback invoked by the owning peer connection when a track is unpaired
 /// from this receiver.
 /// </summary>
 internal override void OnUnpaired(MediaTrack track)
 {
     Debug.Assert(track is RemoteAudioTrack);
     Debug.Assert(Track == track);
     _track = null;
     // Streaming will be stopped from the main Unity app thread, both to avoid locks on public
     // properties and so that listeners of the event can directly access Unity objects
     // from their handler function.
 }
Esempio n. 3
0
        /// <inheritdoc/>
        void IMediaReceiverInternal.OnPaired(MediaTrack track)
        {
            var remoteAudioTrack = (RemoteAudioTrack)track;

            Debug.Assert(Track == null);
            _track = remoteAudioTrack;
            // Streaming will be started from the main Unity app thread, both to avoid locks on public
            // properties and so that listeners of the event can directly access Unity objects
            // from their handler function.
        }
Esempio n. 4
0
        /// <summary>
        /// Callback on remote audio track added.
        ///
        /// For simplicity this grabs the first remote audio track found. However currently the user has no
        /// control over audio output, so this is only used for audio statistics.
        /// </summary>
        /// <param name="track">The audio track added.</param>
        /// <seealso cref="RemoteAudioTrack_FrameReady"/>
        private void OnRemoteAudioTrackAdded(RemoteAudioTrack track)
        {
            Logger.Log($"Added remote audio track {track.Name} of transceiver {track.Transceiver.Name}.");

            ThreadHelper.RunOnMainThread(() =>
            {
                var trvm = Transceivers.SingleOrDefault(tr => tr.Transceiver == track.Transceiver);
                Debug.Assert(trvm.Transceiver.RemoteAudioTrack == track);
                trvm.NotifyReceiverChanged(); // this is thread-aware
                // This raises property changed events in current thread, needs to be main one
                AudioTracks.Add(new AudioTrackViewModel(track));
            });
        }
Esempio n. 5
0
        /// <summary>
        /// Callback on remote audio track removed.
        /// </summary>
        /// <param name="track">The audio track removed.</param>
        private void OnRemoteAudioTrackRemoved(Transceiver transceiver, RemoteAudioTrack track)
        {
            Logger.Log($"Removed remote audio track {track.Name} from transceiver {transceiver.Name}.");

            var atvm = AudioTracks.Single(vm => vm.TrackImpl == track);

            AudioTracks.Remove(atvm);

            //IAudioTrack newPlaybackAudioTrack = null;
            //if (LocalAudioTracks.Count > 0)
            //{
            //    newPlaybackAudioTrack = LocalAudioTracks[0].Track;
            //}
            //SwitchMediaPlayerSource(newPlaybackAudioTrack, _playbackVideoTrack);
        }
Esempio n. 6
0
        private void Peer_AudioTrackRemoved(Transceiver transceiver, RemoteAudioTrack track)
        {
            Debug.Assert(track.Transceiver == null); // already removed
            // Note: if the transceiver was created by setting a remote description internally, but
            // the user did not add any MediaLine in the component, then the transceiver is ignored.
            // SetRemoteDescriptionAsync() already triggered a warning in this case, so be silent here.
            MediaLine mediaLine = _mediaLines.Find((MediaLine ml) => ml.Transceiver == transceiver);

            if (mediaLine != null)
            {
                Debug.Assert(mediaLine != null);
                Debug.Assert(mediaLine.MediaKind == MediaKind.Audio);
                mediaLine.OnUnpaired(track);
            }
        }
Esempio n. 7
0
        /// <summary>
        /// Free-threaded callback invoked by the owning peer connection when a track is unpaired
        /// from this receiver, which enqueues the <see cref="AudioSource.AudioStreamStopped"/>
        /// event to be fired from the main Unity app thread.
        /// </summary>
        internal override void OnUnpaired(MediaTrack track)
        {
            Debug.Assert(track is RemoteAudioTrack);

            // Enqueue invoking from the main Unity app thread, both to avoid locks on public
            // properties and so that listeners of the event can directly access Unity objects
            // from their handler function.
            _mainThreadWorkQueue.Enqueue(() =>
            {
                Debug.Assert(Track == track);
                Track       = null;
                IsStreaming = false;
                IsLive      = false;
                AudioStreamStopped.Invoke(this);
            });
        }
 private void OnAudioTrackRemoved2(Transceiver transceiver, RemoteAudioTrack track)
 {
     audioTrackRemovedEvent2_.Set();
 }
Esempio n. 9
0
 /// <inheritdoc/>
 protected internal override void OnUnpaired(MediaTrack track)
 {
     Debug.Assert(Track == track);
     AudioTrack = null;
     AudioStreamStopped.Invoke((RemoteAudioTrack)track);
 }
Esempio n. 10
0
 public void OnAudioTrackSubscribed(RemoteParticipant p0, RemoteAudioTrackPublication p1, RemoteAudioTrack p2)
 {
     RemoteAudioTrack = p2;
 }
Esempio n. 11
0
 public void OnAudioTrackUnsubscribed(RemoteParticipant p0, RemoteAudioTrackPublication p1, RemoteAudioTrack p2)
 {
     try
     {
         if (RemoteAudioTrack.Name == p1.TrackName)
         {
             RemoteAudioTrack = null;
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Esempio n. 12
0
 public void OnAudioTrackSubscribed(RemoteParticipant p0, RemoteAudioTrackPublication p1, RemoteAudioTrack p2)
 {
     try
     {
         RemoteAudioTrack = p1.RemoteAudioTrack;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
 public AudioTrackViewModel(RemoteAudioTrack track)
     : base(track, null)
 {
 }
Esempio n. 14
0
 public void OnClientAudioTrackRemoved(Transceiver transceiver, RemoteAudioTrack track)
 {
     this.clientAudioTrack.AudioFrameReady -= this.OnClientAudioReceived;
     this.clientAudioTrack = null;
 }
 public void OnAudioTrackSubscribed(RemoteParticipant p0, RemoteAudioTrackPublication p1, RemoteAudioTrack p2)
 {
     try
     {
         RemoteAudioTrack = p1.RemoteAudioTrack;
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
 private void OnAudioTrackAdded2(RemoteAudioTrack track)
 {
     audioTrackAddedEvent2_.Set();
 }
Esempio n. 17
0
 public void OnAudioTrackUnsubscribed(RemoteParticipant p0, RemoteAudioTrackPublication p1, RemoteAudioTrack p2)
 {
     if (RemoteAudioTrack.Name == p2.Name)
     {
         RemoteAudioTrack = null;
     }
 }
 public void OnAudioTrackUnsubscribed(RemoteParticipant p0, RemoteAudioTrackPublication p1, RemoteAudioTrack p2)
 {
     try
     {
         if (RemoteAudioTrack?.Name == p1.TrackName)
         {
             RemoteAudioTrack = null;
         }
     }
     catch (Exception e)
     {
         Methods.DisplayReportResultTrack(e);
     }
 }
Esempio n. 19
0
 public void OnClientAudioTrackAdded(RemoteAudioTrack track)
 {
     this.clientAudioTrack = track;
     this.clientAudioTrack.AudioFrameReady += this.OnClientAudioReceived;
 }