Ejemplo n.º 1
0
        public void StopConference(Action <string> callback)
        {
            // Detach signalling from the conference.
            Signalling.Detach((error) =>
            {
                // Stop echo canceller.
                if (EnableSoftwareEchoCancellation)
                {
                    OpusEchoCanceller.Stop();
                    OpusEchoCanceller = null;
                }

                Conference.OnLinkInit -= LogLinkInit;
                Conference.OnLinkUp   -= LogLinkUp;
                Conference.OnLinkDown -= LogLinkDown;
                Conference             = null;

                VideoStream.OnLinkInit -= AddRemoteVideoControl;
                VideoStream.OnLinkDown -= RemoveRemoteVideoControl;
                VideoStream             = null;

                AudioStream = null;

                callback(error);
            });
        }
        // TODO: will move to dispose
        /// <summary>
        /// Stops the conference.
        /// </summary>
        /// <returns>The conference.</returns>
        private void StopConference()
        {
            try
            {
#if __ANDROID__
                // Stop echo canceller.
                OpusEchoCanceller.Stop();
                OpusEchoCanceller = null;
#endif
                conference.OnLinkInit -= LogLinkInit;
                conference.OnLinkUp   -= LogLinkUp;
                conference.OnLinkDown -= LogLinkDown;

                conference.OnLinkOfferAnswer -= OnLinkSendOfferAnswer;
                conference.OnLinkCandidate   -= OnLinkSendCandidate;
                conference = null;

                videoStream.OnLinkInit -= AddRemoteVideoControl;
                videoStream.OnLinkDown -= RemoveRemoteVideoControl;
                videoStream             = null;

                audioStream = null;
            }
            catch (Exception ex)
            {
                FM.Log.Debug(ex.ToString());
            }
        }
Ejemplo n.º 3
0
        private void StopConference()
        {
            // Detach signalling from the conference.
            Signalling.Detach((error) =>
            {
                if (error != null)
                {
                    Alert(error);
                }
            });

                        #if __ANDROID__
            // Stop echo canceller.
            OpusEchoCanceller.Stop();
            OpusEchoCanceller = null;
                        #endif

            Conference.OnLinkInit -= LogLinkInit;
            Conference.OnLinkUp   -= LogLinkUp;
            Conference.OnLinkDown -= LogLinkDown;
            Conference             = null;

            VideoStream.OnLinkInit -= AddRemoteVideoControl;
            VideoStream.OnLinkDown -= RemoveRemoteVideoControl;
            VideoStream             = null;

            AudioStream = null;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates the local audio and video devices, from Icelink demo
        /// </summary>
        /// <param name="callType"></param>
        /// <param name="callback"></param>
        public void StartConference(string callType, Action <string> callback)
        {
            // Create a WebRTC audio stream description (requires a
            // reference to the local audio feed).
            AudioStream = new AudioStream(LocalMedia.LocalMediaStream);

            // Create a WebRTC video stream description (requires a
            // reference to the local video feed). Whenever a P2P link
            // initializes using this description, position and display
            // the remote video control on-screen by passing it to the
            // layout manager created above. Whenever a P2P link goes
            // down, remove it.
            VideoStream             = new VideoStream(LocalMedia.LocalMediaStream);
            VideoStream.OnLinkInit += AddRemoteVideoControl;
            VideoStream.OnLinkDown += RemoveRemoteVideoControl;

            // Create a conference using our stream descriptions.

            Conference = new FM.IceLink.Conference(StunServerAddress, new Stream[] { AudioStream, VideoStream });
            Conference.CandidateMode = CandidateMode.Early;
            // Use our pre-generated DTLS certificate.
            Conference.DtlsCertificate = Certificate;

            // Supply TURN relay credentials in case we are behind a
            // highly restrictive firewall. These credentials will be
            // verified by the TURN server.
            Conference.RelayUsername = "******";
            Conference.RelayPassword = "******";

            // Add a few event handlers to the conference so we can see
            // when a new P2P link is created or changes state.
            Conference.OnLinkInit += LogLinkInit;
            Conference.OnLinkUp   += LogLinkUp;
            Conference.OnLinkDown += LogLinkDown;


            // Start echo canceller.
            if (EnableSoftwareEchoCancellation)
            {
                OpusEchoCanceller = new OpusEchoCanceller(OpusClockRate, OpusChannels, true);
                OpusEchoCanceller.Start();
            }

            if (callType == "outgoing")
            {
                // Outgoing call
                Signalling.Call(Conference, Jid, callback);
            }
            else if (callType == "incoming")
            {
                // Incoming call
                Signalling.Answer(Conference, Jid, Sdp, callback);
            }
        }
Ejemplo n.º 5
0
        private void StartConference()
        {
            ConferenceStarted = true;

            // Create a WebRTC audio stream description (requires a
            // reference to the local audio feed).
            AudioStream = new AudioStream(LocalMedia.LocalMediaStream);

            // Create a WebRTC video stream description (requires a
            // reference to the local video feed). Whenever a P2P link
            // initializes using this description, position and display
            // the remote video control on-screen by passing it to the
            // layout manager created above. Whenever a P2P link goes
            // down, remove it.
            VideoStream             = new VideoStream(LocalMedia.LocalMediaStream);
            VideoStream.OnLinkInit += AddRemoteVideoControl;
            VideoStream.OnLinkDown += RemoveRemoteVideoControl;

            // Create a conference using our stream descriptions.
            Conference = new FM.IceLink.Conference(IceLinkServerAddress, new Stream[] { AudioStream, VideoStream });

            // Use our pre-generated DTLS certificate.
            Conference.DtlsCertificate = Certificate;

            // Supply TURN relay credentials in case we are behind a
            // highly restrictive firewall. These credentials will be
            // verified by the TURN server.
            Conference.RelayUsername = "******";
            Conference.RelayPassword = "******";

            // Add a few event handlers to the conference so we can see
            // when a new P2P link is created or changes state.
            Conference.OnLinkInit += LogLinkInit;
            Conference.OnLinkUp   += LogLinkUp;
            Conference.OnLinkDown += LogLinkDown;

                        #if __ANDROID__
            // Start echo canceller.
            OpusEchoCanceller = new OpusEchoCanceller(OpusClockRate, OpusChannels);
            OpusEchoCanceller.Start();
                        #endif

            Signalling.Attach(Conference, SessionId, (error) =>
            {
                if (error != null)
                {
                    Alert(error);
                }
            });
        }
        public ConferenceWrapper(string sessionId,
                                 LocalMedia localMedia)
        {
            this.LocalMedia = localMedia;
            InitAudioAndVideoStreams();

            // Create a conference using our stream descriptions.
            conference = new FM.IceLink.Conference(this.IceServers, new Stream[] { audioStream, videoStream });

            // Use our pre-generated DTLS certificate.
            conference.DtlsCertificate = Certificate;

            // Supply TURN relay credentials in case we are behind a
            // highly restrictive firewall. These credentials will be
            // verified by the TURN server.
            conference.RelayUsername = "******";
            conference.RelayPassword = "******";
            conference.ServerPort    = 3478;

            // Add a few event handlers to the conference so we can see
            // when a new P2P link is created or changes state.
            conference.OnLinkInit += LogLinkInit;
            conference.OnLinkUp   += LogLinkUp;
            conference.OnLinkDown += LogLinkDown;

            conference.OnLinkOfferAnswer += OnLinkSendOfferAnswer;
            conference.OnLinkCandidate   += OnLinkSendCandidate;
            conference.Timeout            = ConferenceTimeout;

#if __ANDROID__
            // Start echo canceller.
            OpusEchoCanceller = new OpusEchoCanceller(OpusClockRate, OpusChannels);
            OpusEchoCanceller.Start();
#endif

            this.sessionId = sessionId;
        }
Ejemplo n.º 7
0
        public void GetUserMedia(Context context, ViewGroup videoContainer)
        {
            DefaultProviders.AndroidContext = context;

            UserMedia.GetMedia(new GetMediaArgs(true, true)
            {
                DefaultVideoPreviewScale = LayoutScale.Contain,
                DefaultVideoScale        = LayoutScale.Contain,
                VideoWidth     = 640,
                VideoHeight    = 480,
                VideoFrameRate = 15,
                OnSuccess      = (result) =>
                {
                    _localMedia                    = result.LocalStream;
                    _layoutManager                 = new AndroidLayoutManager(videoContainer);
                    _senderLocalVideoControl       = (View)result.LocalVideoControl;
                    var localVideoStream           = new VideoStream(result.LocalStream);
                    _conference                    = new Conference(STUN_TURN_URL, new Stream[] { new AudioStream(result.LocalStream), localVideoStream });
                    _conference.RelayUsername      = "******";
                    _conference.RelayPassword      = "******";
                    _conference.DtlsCertificate    = Certificate.GenerateCertificate();
                    _conference.OnLinkCandidate   += Conference_OnLinkCandidate;
                    _conference.OnLinkOfferAnswer += Conference_OnLinkOfferAnswer;

                    localVideoStream.OnLinkInit += LocalVideoStream_OnLinkInit;
                    localVideoStream.OnLinkDown += LocalVideoStream_OnLinkDown;
                    _layoutManager.SetLocalVideoControl(_senderLocalVideoControl);
                    _opusEchoCanceller = new OpusEchoCanceller(4800, 2);
                    _opusEchoCanceller.Start();
                },
                OnFailure = (error) =>
                {
                    Console.WriteLine(error);
                }
            });
        }