コード例 #1
0
        /// <summary>
        /// Add a new media line of the given kind.
        ///
        /// This method creates a media line, which expresses an intent from the user to get a transceiver.
        /// The actual <see xref="WebRTC.Transceiver"/> object creation is delayed until a session
        /// negotiation is completed.
        ///
        /// Once the media line is created, the user can then assign its <see cref="MediaLine.Source"/> and
        /// <see cref="MediaLine.Receiver"/> properties to express their intent to send and/or receive some media
        /// through the transceiver that will be associated with that media line once a session is negotiated.
        /// This information is used in subsequent negotiations to derive a
        /// <see xref="Microsoft.MixedReality.WebRTC.Transceiver.Direction"/> to negotiate. Therefore users
        /// should avoid modifying the <see cref="Transceiver.DesiredDirection"/> property manually when using
        /// the Unity library, and instead modify the <see cref="MediaLine.Source"/> and
        /// <see cref="MediaLine.Receiver"/> properties.
        /// </summary>
        /// <param name="kind">The kind of media (audio or video) for the transceiver.</param>
        /// <returns>A newly created media line, which will be associated with a transceiver once the next session
        /// is negotiated.</returns>
        public MediaLine AddMediaLine(MediaKind kind)
        {
            var ml = new MediaLine(kind);

            _mediaLines.Add(ml);
            return(ml);
        }
コード例 #2
0
 /// <summary>
 /// Log an error when receiving an exception related to a media line and transceiver pairing.
 /// </summary>
 /// <param name="ex">The exception to log.</param>
 /// <param name="mediaLine">The media line associated with the exception.</param>
 /// <param name="transceiver">The transceiver associated with the exception.</param>
 private void LogErrorOnMediaLineException(Exception ex, MediaLine mediaLine, Transceiver transceiver)
 {
     // Dispatch to main thread to access Unity objects to get their names
     InvokeOnAppThread(() =>
     {
         string msg;
         if (ex is InvalidTransceiverMediaKindException)
         {
             msg = $"Peer connection \"{name}\" received {transceiver.MediaKind} transceiver #{transceiver.MlineIndex} \"{transceiver.Name}\", but local peer expected some {mediaLine.MediaKind} transceiver instead.";
             if (mediaLine.Source != null)
             {
                 msg += $" Sender \"{(mediaLine.Source as MonoBehaviour).name}\" will be ignored.";
             }
             if (mediaLine.Receiver != null)
             {
                 msg += $" Receiver \"{(mediaLine.Receiver as MonoBehaviour).name}\" will be ignored.";
             }
         }
         else
         {
             // Generic exception, log its message
             msg = ex.Message;
         }
         Debug.LogError(msg);
     });
 }
コード例 #3
0
        private void Peer_VideoTrackRemoved(Transceiver transceiver, RemoteVideoTrack track)
        {
            Debug.Assert(track.Transceiver == null); // already removed
            // Note: if the transceiver was created by SetRemoteDescription() 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.Video);
                mediaLine.OnUnpaired(track);
            }
        }
コード例 #4
0
        void IMediaTrackSourceInternal.OnRemoveFromMediaLine(MediaLine mediaLine)
        {
            bool removed = _mediaLines.Remove(mediaLine);

            Debug.Assert(removed);
        }
コード例 #5
0
 void IMediaTrackSourceInternal.OnAddedToMediaLine(MediaLine mediaLine)
 {
     Debug.Assert(!_mediaLines.Contains(mediaLine));
     _mediaLines.Add(mediaLine);
 }
コード例 #6
0
        /// <inheritdoc/>
        void IMediaReceiverInternal.OnRemoveFromMediaLine(MediaLine mediaLine)
        {
            bool removed = _mediaLines.Remove(mediaLine);

            Debug.Assert(removed);
        }
コード例 #7
0
 /// <inheritdoc/>
 void IMediaReceiverInternal.OnAddedToMediaLine(MediaLine mediaLine)
 {
     Debug.Assert(!_mediaLines.Contains(mediaLine));
     _mediaLines.Add(mediaLine);
 }
コード例 #8
0
 /// <summary>
 /// Internal callback invoked when the media receiver is de-assigned from a media line.
 /// </summary>
 /// <param name="mediaLine">The old media line this receiver was assigned to.</param>
 protected internal virtual void OnRemovedFromMediaLine(MediaLine mediaLine)
 {
     Debug.Assert(MediaLine == mediaLine);
     MediaLine = null;
 }
コード例 #9
0
 /// <summary>
 /// Internal callback invoked when the media receiver is assigned to a media line.
 /// </summary>
 /// <param name="mediaLine">The new media line this receiver is assigned to.</param>
 protected internal virtual void OnAddedToMediaLine(MediaLine mediaLine)
 {
     Debug.Assert(MediaLine == null);
     MediaLine = mediaLine;
 }
コード例 #10
0
        internal void OnRemovedFromMediaLine(MediaLine mediaLine)
        {
            bool removed = _mediaLines.Remove(mediaLine);

            Debug.Assert(removed);
        }
コード例 #11
0
 internal void OnAddedToMediaLine(MediaLine mediaLine)
 {
     Debug.Assert(!_mediaLines.Contains(mediaLine));
     _mediaLines.Add(mediaLine);
 }