Ejemplo n.º 1
0
        private void btnServerCreate_Click(object sender, EventArgs e)
        {
            string ipAddress = GetLocalIPAddress();

            try
            {
                _server = new RtspServer(IPAddress.Parse(ipAddress), 554);

                #region  Create media source
                //MJPEGMedia source1 = new MJPEGMedia("myLocalStream", @"C:/VTT/Video/HIKARI.mp4");

                RtspSource source2 = new RtspSource("myStream", "rtsp://184.72.239.149/vod/mp4:BigBuckBunny_115k.mov");

                //RFC2435Media source3 = new RFC2435Media("streamPics", @"C:\VTT\ImagesTest\") { Loop = true };

                #endregion

                //Add media source to server
                //_server.TryAddMedia(source1);
                _server.TryAddMedia(source2);
                //_server.TryAddMedia(source3);
                _server.Start();

                txbServerStatus.Text = "Server on";

                txbConnMax.Text = _server.MaximumConnections.ToString();
            }
            catch (Exception ex)
            {
                txbServerStatus.Text = ex.Message;
            }
        }
Ejemplo n.º 2
0
        public void Start()
        {
            RtspSource rtspSrc = new RtspSource("Zeta", "rtsp://rtsp-v3-spbtv.msk.spbtv.com:554/spbtv_v3_1/332_110.sdp", RtspClient.ClientProtocolType.Tcp);

            _server.TryAddMedia(rtspSrc);
            _server.Start();
        }
Ejemplo n.º 3
0
 public void UpdateHeader(byte[] header)
 {
     _writer?.SavetoTxt(header);
     _media = new VideoRtspMedia(1920, 1080, "stream");
     _media.UpdateHeader(header);
     _rtspServer.TryAddMedia(_media);
     _rtspServer.Start();
     //_media.Stop();
     //_media.Start();
 }
Ejemplo n.º 4
0
        public void Initialize(string path, IRequestHandler handler)
        {
            using (var mutex = new Mutex(false, GlobalMutexId))
            {
                bool mutexAcquired = false;

                try
                {
                    // Because the tests can run on multiple threads we must synchronize
                    // to ensure that we don't start different test servers on the same port.
                    if ((mutexAcquired = mutex.WaitOne(5000, false)))
                    {
                        if (!Initialized)
                        {
                            ServerPort = NetworkUnil.FindAvailableTcpPort();

                            var dispatcher = new DefaultRequestDispatcher();
                            dispatcher.RegisterHandler(path, handler);

                            _path   = path;
                            _server = new RtspServer(ServerPort, dispatcher);
                            _server.Start();

                            // Wait until the serer port is not available.
                            while (NetworkUnil.IsTcpPortAvailable(ServerPort))
                            {
                                Thread.Sleep(1000);
                            }

                            Client = new RtspClient(ServerUriEndpoint);

                            Initialized = true;
                        }
                    }
                }
                catch (AbandonedMutexException)
                {
                    // do nothing
                }
                catch (Exception)
                {
                    // Do nothing since this is just a test, and if we fail here the tests
                    // are going to fail also.
                }
                finally
                {
                    if (mutexAcquired)
                    {
                        mutex.ReleaseMutex();
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            //Create the server optionally specifying the port to listen on
            using (RtspServer server = new RtspServer(IPAddress.Any, 554))
            {
                server.Logger = new RtspServerConsoleLogger();

                //Create a stream which will be exposed under the name Uri rtsp://localhost/live/RtspSourceTest
                //From the RtspSource rtsp://1.2.3.4/mpeg4/media.amp
                RtspSource source = new RtspSource("RtspSourceTest", "rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov");

                //If the stream had a username and password
                //source.Client.Credential = new System.Net.NetworkCredential("user", "password");

                //If you wanted to password protect the stream
                //source.RtspCredential = new System.Net.NetworkCredential("username", "password");

                //Add the stream to the server
                server.TryAddMedia(source);

                //server.TryAddRequestHandler(RtspMethod.OPTIONS,)

                //Start the server and underlying streams
                server.Start();

                Console.WriteLine("Waiting for source...");

                while (source.Ready == false)
                {
                    Thread.Sleep(10);
                }

                Console.WriteLine("Source Ready...");

                Console.ReadKey();
                server.Stop();
            }
        }
Ejemplo n.º 6
0
        public override bool Run()
        {
            LOG.Info("Starting facial detection agent");

            try
            {
                _rtspServer         = _bootstrapper.Container.Resolve <RtspServer>();
                _httpServer         = _bootstrapper.Container.Resolve <HttpServer>();
                _dataSourcesManager = _bootstrapper.Container.Resolve <IDataSourcesManager>();
                _sourcesManager     = _bootstrapper.Container.Resolve <IDetectionSourceManager>();

                _rtspServer.Start();
                _httpServer.Start();

                InitializeSources();
            }
            catch (Exception e)
            {
                LOG.Error($"Caught exception starting facial detection agent, msg={e.Message}");
                return(false);
            }

            return(true);
        }