Пример #1
0
        private void Conn_OnAddStream(MediaStreamEvent __param0)
        {
            var stream = __param0.Stream;

            var videotracks = stream.GetVideoTracks();
            //var media = Media.CreateMedia();

            //var apd = media.GetAudioPlayoutDevices();
            //if (apd.Count > 0)
            //{
            //    media.SelectAudioPlayoutDevice(apd[0]);
            //}

            var source = LocalMedia.CreateMediaSource(videotracks.FirstOrDefault(), stream.Id);

            RemoteMediaPlayer.SetMediaStreamSource(source);

            RemoteMediaPlayer.Play();
        }
Пример #2
0
        public async Task CreateReceiver(MediaStream mediaStream, long fromUid)
        {
            var conn = new RTCPeerConnection(RtcConfig);

            CurrentRoom.Recvs.Add(fromUid, conn);
            CurrentRoom.Recvs[fromUid].AddStream(mediaStream);
            CurrentRoom.Recvs[fromUid].OnIceCandidate += async(p) =>
            {
                var Candidate = p.Candidate;
                var m         = new SendCadidatModel();
                m.candidate = new CandidateModel
                {
                    candidate     = Candidate.Candidate,
                    sdpMlineindex = Candidate.SdpMLineIndex,
                    sdpMid        = Candidate.SdpMid,
                };
                m.uid     = Uid;
                m.fromUid = fromUid;
                Candidates.Add(m);
                await SendCandidate(m);
            };
            CurrentRoom.Recvs[fromUid].OnAddStream += (p) =>
            {
                var stream = p.Stream;

                var videotracks = stream.GetVideoTracks();


                var source = LocalMedia.CreateMediaSource(videotracks.FirstOrDefault(), stream.Id);

                RemoteMediaPlayer.SetMediaStreamSource(source);

                RemoteMediaPlayer.Play();
            };

            await CreatOffer(Uid, fromUid);
        }