Example #1
0
        public void ShowVideo(Media.MediaUri uri, Media.VideoEncoderConfiguration encoder, Media.AudioEncoderConfiguration audio)
        {
            try
            {
                _videoWindow = new VideoContainer();
                DeviceEnvironment environment    = ContextController.GetDeviceEnvironment();
                int messageTimeout               = environment.Timeouts.Message;
                Media.TransportProtocol protocol = GetTransportProtocol();
                VideoUtils.AdjustVideo(
                    _videoWindow,
                    environment.Credentials.UserName,
                    environment.Credentials.Password,
                    messageTimeout,
                    protocol,
                    Media.StreamType.RTPUnicast,
                    uri,
                    encoder);
                _videoWindow.KEEPALIVE = true;
                _videoWindow.DebugPage = true;
                _videoWindow.OpenWindow(audio != null);

                Invoke(new Action(() => { btnGetStreams.Text = "Stop Video"; }));
            }
            catch
            {
                _videoWindow.DebugPage = false;
                _videoWindow           = null;
                throw;
            }
        }
Example #2
0
 public void ShowVideo(Onvif.MediaUri uri, Onvif.VideoEncoderConfiguration encoder)
 {
     try
     {
         _videoWindow = new VideoContainer();
         DeviceEnvironment environment = ContextController.GetDeviceEnvironment();
         int messageTimeout            = environment.Timeouts.Message;
         VideoUtils.AdjustVideo(
             _videoWindow,
             environment.Credentials.UserName,
             environment.Credentials.Password,
             messageTimeout,
             Onvif.TransportProtocol.UDP,
             Onvif.StreamType.RTPUnicast,
             uri,
             encoder);
         _videoWindow.KEEPALIVE = true;
         _videoWindow.OpenWindow(false);
         Invoke(new Action(() => { btnVideo.Text = "Stop Video"; }));
     }
     catch
     {
         _videoWindow = null;
         throw;
     }
 }
Example #3
0
            public static void VW(object param)
            {
                VideoStreamForm vsf = (VideoStreamForm)param;

                try
                {
                    lock (vsf.eventConsumer)
                    {
                        vsf.streamUri = vsf.getStreamUri(vsf.streamSetup, vsf.profile.token);
                    }
                }
                catch (Exception ex)
                {
                    vsf.exception = ex;
                }

                if (vsf.exception == null)
                {
                    IVideoForm videoForm = new VideoContainer();
                    videoForm.NICIndex = vsf.NICIndex;
                    VideoUtils.AdjustVideo(
                        videoForm, vsf.username, vsf.password, vsf.messageTimeout, vsf.streamSetup.Transport.Protocol,
                        vsf.streamSetup.Stream, vsf.streamUri, vsf.profile.VideoEncoderConfiguration);
                    bool VideoIsOpened = false;
                    try
                    {
                        VideoIsOpened       = true;
                        videoForm.EventSink = vsf;
                        videoForm.OpenWindow(false);

                        ((AutoResetEvent)vsf.eventOpened).Set();
                        vsf.signalCloseWindow.WaitOne();

                        videoForm.CloseWindow();
                        VideoIsOpened = false;
                    }
                    catch (Exception ex)
                    {
                        vsf.exception = ex;
                    }
                    finally
                    {
                        if (VideoIsOpened)
                        {
                            videoForm.CloseWindow();
                        }
                        videoForm = null;
                    }
                }
                ((ManualResetEvent)vsf.eventWorkEnded).Set();
                ((AutoResetEvent)vsf.signalCloseWindow).Set();
            }