コード例 #1
0
        public void DoPublish()
        {
            var _publisherDelegate = new PublisherDelegate (this);
            _publisher = new OTPublisher(_publisherDelegate);

            OTError error;

            _session.Publish(_publisher, out error);

            if (error != null)
            {
                this.RaiseOnError(error.Description);
            }

            var pubView = _publisher.View;
            pubView.TranslatesAutoresizingMaskIntoConstraints = false;
            pubView.Frame = new RectangleF(0, 0, 100, 100);
            pubView.Layer.CornerRadius = 50;
            pubView.Layer.MasksToBounds = true;

            this.AddSubview (pubView);
            this.BringSubviewToFront (pubView);

            this.AddConstraints (new NSLayoutConstraint[] {
                NSLayoutConstraint.Create (pubView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1f, 0),
                NSLayoutConstraint.Create (pubView, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0),
                NSLayoutConstraint.Create (pubView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, pubView.Frame.Height),
                NSLayoutConstraint.Create (pubView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, pubView.Frame.Width)
            });
        }
コード例 #2
0
            public override void DidFailWithError(OTPublisher publisher, OTError error)
            {
                var msg = String.Format("PublisherDelegate:DidFailWithError: Error: {0}", error.Description);

                _this.RaiseOnError(msg);
                _this.CleanupPublisher();
            }
コード例 #3
0
        private void OnDidConnect(object sender, EventArgs e)
        {
            if (Session == null)
            {
                return;
            }

            ClearPublisher();

            PublisherKit = new OTPublisher(null, new OTPublisherSettings
            {
                Name             = "XamarinOpenTok",
                CameraFrameRate  = OTCameraCaptureFrameRate.OTCameraCaptureFrameRate15FPS,
                CameraResolution = OTCameraCaptureResolution.High,
                VideoTrack       = Permissions.HasFlag(OpenTokPermission.Camera),
                AudioTrack       = Permissions.HasFlag(OpenTokPermission.RecordAudio)
            })
            {
                PublishVideo         = IsVideoPublishingEnabled,
                PublishAudio         = IsAudioPublishingEnabled,
                AudioFallbackEnabled = PublisherVideoType == OpenTokPublisherVideoType.Camera,
                VideoType            = PublisherVideoType == OpenTokPublisherVideoType.Camera
                    ? OTPublisherKitVideoType.Camera
                    : OTPublisherKitVideoType.Screen
            };
            PublisherKit.StreamCreated += OnPublisherStreamCreated;
            Session.Publish(PublisherKit);
            RaisePublisherUpdated();
        }
コード例 #4
0
 public override void StreamCreated(OTPublisher publisher, OTStream stream)
 {
     if (_this._subscriber == null)
     {
         InvokeOnMainThread(() => _this.DoSubscribe(stream));
     }
 }
コード例 #5
0
 public override void StreamDestroyed(OTPublisher publisher, OTStream stream)
 {
     //InvokeOnMainThread (() => {
     _this.CleanupSubscriber();
     _this.CleanupPublisher();
     //});
 }
コード例 #6
0
        public void DoPublish()
        {
            var _publisherDelegate = new PublisherDelegate(this);

            _publisher = new OTPublisher(_publisherDelegate);

            OTError error;

            _session.Publish(_publisher, out error);

            if (error != null)
            {
                this.RaiseOnError(error.Description);
            }

            var pubView = _publisher.View;

            pubView.TranslatesAutoresizingMaskIntoConstraints = false;
            pubView.Frame = new RectangleF(0, 0, 100, 100);
            pubView.Layer.CornerRadius  = 50;
            pubView.Layer.MasksToBounds = true;

            this.AddSubview(pubView);
            this.BringSubviewToFront(pubView);

            this.AddConstraints(new NSLayoutConstraint[] {
                NSLayoutConstraint.Create(pubView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, this, NSLayoutAttribute.Bottom, 1f, 0),
                NSLayoutConstraint.Create(pubView, NSLayoutAttribute.Right, NSLayoutRelation.Equal, this, NSLayoutAttribute.Right, 1f, 0),
                NSLayoutConstraint.Create(pubView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, pubView.Frame.Height),
                NSLayoutConstraint.Create(pubView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, null, NSLayoutAttribute.NoAttribute, 1f, pubView.Frame.Width)
            });
        }
コード例 #7
0
        private void OnDidConnect(object sender, EventArgs e)
        {
            lock (_locker)
            {
                if (Session == null || PublisherKit != null)
                {
                    return;
                }

                OTError error;
                PublisherKit = new OTPublisher(null, new OTPublisherSettings
                {
                    Name             = "XamarinOpenTok",
                    CameraFrameRate  = OTCameraCaptureFrameRate.OTCameraCaptureFrameRate15FPS,
                    CameraResolution = OTCameraCaptureResolution.High,
                });

                PublisherKit.PublishVideo   = IsVideoPublishingEnabled;
                PublisherKit.PublishAudio   = IsAudioPublishingEnabled;
                PublisherKit.StreamCreated += OnPublisherStreamCreated;

                Session.Publish(PublisherKit, out error);
                PublisherUpdated?.Invoke(this, EventArgs.Empty);
            }
        }
コード例 #8
0
ファイル: VideoChatView.cs プロジェクト: Shtml7/Shared
            public override void StreamDestroyed(OTPublisher publisher, OTStream stream)
            {
                System.Diagnostics.Debug.WriteLine("PublisherDelegate:StreamDestroyed: " + stream.StreamId);

                _this.CleanupSubscriber();

                _this.CleanupPublisher();
            }
コード例 #9
0
        public override void StreamDestroyed(OTPublisher publisher, OTStream stream)
        {
            Debug.WriteLine("PublisherDelegate:StreamDestroyed: " + stream.StreamId);

            provider.CleanupSubscriber();

            provider.CleanupPublisher();
        }
コード例 #10
0
        private void DoPublish()
        {
            _publisher      = new OTPublisher(new PubDelegate(this));
            _publisher.Name = UIDevice.CurrentDevice.Name;

            _session.Publish(_publisher);

            View.AddSubview(_publisher.View);
            _publisher.View.Frame = new RectangleF(0, 0, widgetWidth, widgetHeight);
        }
コード例 #11
0
        public override void DidFailWithError(OTPublisher publisher, OTError error)
        {
            var msg = String.Format("PublisherDelegate:DidFailWithError: Error: {0}", error.Description);

            Debug.WriteLine(msg);

            provider.RaiseOnError(msg);

            provider.CleanupPublisher();
        }
コード例 #12
0
 /**
  * Cleans up the publisher and its view. At this point, the publisher should not
  * be attached to the session any more.
  */
 public void CleanupPublisher()
 {
     if (_publisher != null)
     {
         _publisher.View.RemoveFromSuperview();
         _publisher.Delegate = null;
         _publisher.Dispose();
         _publisher = null;
     }
 }
コード例 #13
0
        public override void EndSession()
        {
            lock (_sessionLocker)
            {
                try
                {
                    if (Session == null)
                    {
                        return;
                    }

                    foreach (var subscriberKit in _subscribers)
                    {
                        ClearSubscriber(subscriberKit);
                    }
                    _subscribers.Clear();
                    _subscriberStreamIds.Clear();

                    if (PublisherKit != null)
                    {
                        using (PublisherKit)
                        {
                            PublisherKit.PublishAudio   = false;
                            PublisherKit.PublishVideo   = false;
                            PublisherKit.StreamCreated -= OnPublisherStreamCreated;
                            Session.Unpublish(PublisherKit);
                        }
                        PublisherKit = null;
                    }

                    RaisePublisherUpdated()
                    .RaiseSubscriberUpdated();

                    if (Session != null)
                    {
                        using (Session)
                        {
                            Session.ConnectionDestroyed -= OnConnectionDestroyed;
                            Session.DidConnect          -= OnDidConnect;
                            Session.StreamCreated       -= OnStreamCreated;
                            Session.StreamDestroyed     -= OnStreamDestroyed;
                            Session.DidFailWithError    -= OnError;
                            Session.ReceivedSignalType  -= OnSignalReceived;
                            Session.Disconnect();
                        }
                        Session = null;
                    }
                }
                finally
                {
                    IsSessionStarted    = false;
                    IsPublishingStarted = false;
                }
            }
        }
コード例 #14
0
        public override void StreamCreated(OTPublisher publisher, OTStream stream)
        {
            Debug.WriteLine("PublisherDelegate:StreamCreated: " + stream.StreamId);

            // If Subscribe To Self is true: Our own publisher is now visible to
            // all participants in the OpenTok session. We will attempt to subscribe to
            // our own stream. Expect to see a slight delay in the subscriber video and
            // an echo of the audio coming from the device microphone.
            if (provider._subscriber == null && this.provider.SubscribeToSelf)
            {
                provider.DoSubscribe(stream);
            }
        }
コード例 #15
0
        private void ClearPublisher()
        {
            if (PublisherKit == null)
            {
                return;
            }

            using (PublisherKit)
            {
                PublisherKit.PublishAudio   = false;
                PublisherKit.PublishVideo   = false;
                PublisherKit.StreamCreated -= OnPublisherStreamCreated;
                Session.Unpublish(PublisherKit);
            }
            PublisherKit = null;
        }
コード例 #16
0
        private void SubscribeForPublisherEvents(OTPublisher publisher, bool subscribe = true)
        {
            if (publisher == null)
            {
                return;
            }

            if (subscribe)
            {
                publisher.StreamCreated += OnPublisherStreamCreated;
            }
            else
            {
                publisher.StreamCreated += OnPublisherStreamCreated;
            }
        }
コード例 #17
0
        private void SetPublisher()
        {
            if (Publisher != null || Session == null)
            {
                return;
            }
            Publisher = new OTPublisher(null, new OTPublisherSettings
            {
                Name             = "XamarinOpenTok",
                CameraFrameRate  = OTCameraCaptureFrameRate.OTCameraCaptureFrameRate15FPS,
                CameraResolution = OTCameraCaptureResolution.High,
            });

            Session.Publish(Publisher, out var error);
            ActivateStreamContainer(PublisherContianer, Publisher.View);
        }
コード例 #18
0
        /**
         * Sets up an instance of OTPublisher to use with this session. OTPubilsher
         * binds to the device camera and microphone, and will provide A/V streams
         * to the OpenTok session.
         */
        public void DoPublish()
        {
            _publisher = new OTPublisher(new PublisherDelegate(this), UIDevice.CurrentDevice.Name, OTCameraCaptureResolution.Medium, OTCameraCaptureFrameRate.OTCameraCaptureFrameRate30FPS);

            OTError error;

            _session.Publish(_publisher, out error);

            if (error != null)
            {
                this.RaiseOnError(error.Description);
            }

            _publisher.View.Frame = new RectangleF(0, 0, 100, 100);
            _publisher.View.Layer.CornerRadius  = 50;
            _publisher.View.Layer.MasksToBounds = true;

            this.PublisherView.AddSubview(_publisher.View);
        }
コード例 #19
0
        /**
         * Sets up an instance of OTPublisher to use with this session. OTPubilsher
         * binds to the device camera and microphone, and will provide A/V streams
         * to the OpenTok session.
         */
        private void DoPublish()
        {
            _publisher = new OTPublisher(new PublisherDelegate(this), UIDevice.CurrentDevice.Name);

            OTError error;

            _session.Publish(_publisher, out error);

            if (error != null)
            {
                this.RaiseOnError(error.Description);
            }

            // Show the Video in the View In Round Mode
            _publisher.View.Frame = new RectangleF(0, 0, 100, 100);
            _publisher.View.Layer.CornerRadius  = 50;
            _publisher.View.Layer.MasksToBounds = true;

            this.PublisherView.AddSubview(_publisher.View);
        }
コード例 #20
0
        private void Publish()
        {
            lock (_syncRoot)
            {
                if (_publisher != null || _session == null)
                {
                    return;
                }

                OTError error;
                _publisher = new OTPublisher(null, new OTPublisherSettings
                {
                    Name             = "XamarinOpenTok",
                    CameraFrameRate  = OTCameraCaptureFrameRate.OTCameraCaptureFrameRate15FPS,
                    CameraResolution = OTCameraCaptureResolution.High,
                });
                SubscribeForPublisherEvents(_publisher, true);
                _session.Publish(_publisher, out error);

                ActivateStreamContainer(_myStreamContainer, _publisher.View);
            }
        }
コード例 #21
0
        private void OnDidConnect(object sender, EventArgs e)
        {
            if (Session == null || PublisherKit != null)
            {
                return;
            }

            PublisherKit = new OTPublisher(null, new OTPublisherSettings
            {
                Name             = "XamarinOpenTok",
                CameraFrameRate  = OTCameraCaptureFrameRate.OTCameraCaptureFrameRate15FPS,
                CameraResolution = OTCameraCaptureResolution.High
            })
            {
                PublishVideo = IsVideoPublishingEnabled,
                PublishAudio = IsAudioPublishingEnabled
            };
            PublisherKit.StreamCreated += OnPublisherStreamCreated;

            Session.Publish(PublisherKit);
            RaisePublisherUpdated();
        }
コード例 #22
0
        public void DoPublish()
        {
            _publisherDelegate = new PublisherDelegate(this);
            _publisher         = new OTPublisher(_publisherDelegate);

            OTError error;

            _session.Publish(_publisher, out error);

            if (error != null)
            {
                this.RaiseOnError(error.Description);
            }

            // Show the Video in the View In Round Mode
            _publisher.View.Frame = new RectangleF(0, 0, 100, 100);
            _publisher.View.Layer.CornerRadius  = 50;
            _publisher.View.Layer.MasksToBounds = true;

            this.PublisherView.AddSubview(_publisher.View);

            // Schedule a periodic task to send a broadcast signal to all
            // peers on the session
            Task.Run(() => {
                while (true)
                {
                    InvokeOnMainThread(() => {
                        OTError signalerror;
                        _session.SignalWithType("BroadcastSignal",
                                                DateTime.Now.ToString(),
                                                null, // This is the connection of the peer you are sending the signal
                                                      // Leave it null and it will send to all members of the session.
                                                out signalerror);
                    });
                    Thread.Sleep(10000);
                }
            });
        }
コード例 #23
0
        public void DoPublish()
        {
            _publisherDelegate = new PublisherDelegate (this);
            _publisher = new OTPublisher(_publisherDelegate);

            OTError error;

            _session.Publish(_publisher, out error);

            if (error != null)
            {
                this.RaiseOnError(error.Description);
            }

            // Show the Video in the View In Round Mode
            _publisher.View.Frame = new RectangleF(0, 0, 100, 100);
            _publisher.View.Layer.CornerRadius = 50;
            _publisher.View.Layer.MasksToBounds = true;

            this.PublisherView.AddSubview (_publisher.View);

            // Schedule a periodic task to send a broadcast signal to all
            // peers on the session
            Task.Run (() => {
                while(true) {
                    InvokeOnMainThread( () => {
                        OTError signalerror;
                        _session.SignalWithType("BroadcastSignal",
                            DateTime.Now.ToString(),
                            null, // This is the connection of the peer you are sending the signal
                                  // Leave it null and it will send to all members of the session.
                            out signalerror);
                    });
                    Thread.Sleep(10000);
                }
            });
        }
コード例 #24
0
 private void CleanupPublisher()
 {
     if (_publisher != null)
     {
         _publisher.View.RemoveFromSuperview();
         _publisher.Delegate = null;
         _publisher.Dispose();
         _publisher = null;
         _publisherDelegate = null;
     }
 }
コード例 #25
0
        public void DoEndSession()
        {
            lock (syncLock)
            {
                if (Subscriber != null)
                {
                    if (Subscriber.SubscribeToAudio)
                    {
                        Subscriber.SubscribeToAudio = false;
                    }
                    if (Subscriber.SubscribeToVideo)
                    {
                        Subscriber.SubscribeToVideo = false;
                    }

                    Subscriber.DidConnectToStream -= OnSubscriberDidConnectToStream;
                    Subscriber.VideoDataReceived  -= OnSubscriberVideoDataReceived;
                    Subscriber.VideoEnabled       -= OnSubscriberVideoEnabled;

                    Subscriber.Dispose();
                    Subscriber = null;
                }

                if (Publisher != null)
                {
                    if (Publisher.PublishAudio)
                    {
                        Publisher.PublishAudio = false;
                    }
                    if (Publisher.PublishVideo)
                    {
                        Publisher.PublishVideo = false;
                    }
                    Publisher.Dispose();
                    Publisher = null;
                }

                if (Session != null)
                {
                    Session.ConnectionDestroyed -= OnConnectionDestroyed;
                    Session.DidConnect          -= OnDidConnect;
                    Session.StreamCreated       -= OnStreamCreated;
                    Session.StreamDestroyed     -= OnStreamDestroyed;

                    Session.Disconnect();
                    Session.Dispose();
                    Session = null;
                }

                PublisherContianer?.InvokeOnMainThread(() =>
                {
                    DeactivateStreamContainer(PublisherContianer);
                    PublisherContianer = null;
                });

                SubscriberContainer?.InvokeOnMainThread(() =>
                {
                    DeactivateStreamContainer(SubscriberContainer);
                    SubscriberContainer = null;
                });
            }
        }
コード例 #26
0
        public void EndSession()
        {
            lock (_syncRoot)
            {
                try
                {
                    _sessionTerminationIsInProgress = true;
                    if (_subscriber != null)
                    {
                        if (_subscriber.SubscribeToAudio)
                        {
                            _subscriber.SubscribeToAudio = false;
                        }
                        if (_subscriber.SubscribeToVideo)
                        {
                            _subscriber.SubscribeToVideo = false;
                        }
                        SubscribeForSubscriberEvents(_subscriber, false);
                        _subscriber.Dispose();
                        _subscriber = null;
                    }
                    if (_publisher != null)
                    {
                        if (_publisher.PublishAudio)
                        {
                            _publisher.PublishAudio = false;
                        }
                        if (_publisher.PublishVideo)
                        {
                            _publisher.PublishVideo = false;
                        }
                        SubscribeForPublisherEvents(_publisher, false);
                        _publisher.Dispose();
                        _publisher = null;
                    }

                    if (_session != null)
                    {
                        SubscribeForSessionEvents(_session, false);
                        _session.Disconnect();
                        _session.Dispose();
                        _session = null;
                    }

                    _myStreamContainer.InvokeOnMainThread(() =>
                    {
                        DeactivateStreamContainer(_myStreamContainer);
                        _myStreamContainer = null;

                        DeactivateStreamContainer(_otherStreamContainer);
                        _otherStreamContainer = null;
                    });

                    _apiKey    = null;
                    _sessionId = null;
                    _userToken = null;

                    IsVideoPublishingEnabled   = false;
                    IsAudioPublishingEnabled   = false;
                    IsVideoSubscriptionEnabled = false;
                    IsAudioSubscriptionEnabled = false;
                    IsSubscriberVideoEnabled   = false;

                    _subscriberConnected = false;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
                finally
                {
                    _sessionTerminationIsInProgress = false;
                    OnSessionEnded();
                }
            }
        }
 public override void DidStopStreaming(OTPublisher publisher)
 {
 }
        private void DoPublish()
        {
            _publisher = new OTPublisher(new PubDelegate(this));
            _publisher.Name = UIDevice.CurrentDevice.Name;

            _session.Publish(_publisher);

            View.AddSubview(_publisher.View);
            _publisher.View.Frame = new RectangleF(0, 0, widgetWidth, widgetHeight);
        }
 public override void DidFail(OTPublisher publisher, OTError error)
 {
     Debug.WriteLine("Publisher DidFail {0}", error);
     _this.ShowAlert("There was an error publishing");
 }
コード例 #30
0
 public override void StreamDestroyed(OTPublisher publisher, OTStream stream)
 {
     //InvokeOnMainThread (() => {
         _this.CleanupSubscriber();
         _this.CleanupPublisher();
     //});
 }
コード例 #31
0
 public override void DidFail(OTPublisher publisher, OTError error)
 {
     Debug.WriteLine("Publisher DidFail {0}", error);
     _this.ShowAlert("There was an error publishing");
 }
コード例 #32
0
 public override void DidChangeCameraPosition(OTPublisher publisher, MonoTouch.AVFoundation.AVCaptureDevicePosition cameraPosition)
 {
 }
コード例 #33
0
            public override void DidFailWithError(OTPublisher publisher, OTError error)
            {
                var msg = String.Format("PublisherDelegate:DidFailWithError: Error: {0}", error.Description);

                _this.RaiseOnError(msg);
                _this.CleanupPublisher();
            }
コード例 #34
0
 public override void DidStopStreaming(OTPublisher publisher)
 {
 }
コード例 #35
0
 public override void StreamCreated(OTPublisher publisher, OTStream stream)
 {
     if(_this._subscriber == null)
     {
         //InvokeOnMainThread (() => _this.DoSubscribe (stream));
         _this.DoSubscribe (stream);
     }
 }
 public override void DidChangeCameraPosition(OTPublisher publisher, MonoTouch.AVFoundation.AVCaptureDevicePosition cameraPosition)
 {
 }