Inheritance: IDisposable
        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();

            // Register the IUnityContainer so that we can access services from the
            // HTTP server's module handlers.
            ServiceRegistry.RegisterContainer(Container);

            var serializer = new ConfigurationFileSerializer();

            var config      = serializer.Read();
            var sourceMgr   = new FacialDetectionSourceManager(config);
            var sessionMgr  = new RtspSessionManager();
            var rtspHandler = new RtspRequestHandler(sourceMgr, sessionMgr);

            var dispatcher = new DefaultRequestDispatcher();

            dispatcher.RegisterHandler("/stream", rtspHandler);

            var rtspServer = new RtspServer(config.RtspPort, dispatcher);
            var httpServer = new HttpServer(config.HttpPort);

            Container.RegisterInstance(config);
            Container.RegisterInstance(sessionMgr);
            Container.RegisterInstance(rtspServer);
            Container.RegisterInstance(httpServer);
            Container.RegisterInstance <IDetectionSourceManager>(sourceMgr);
            Container.RegisterType <IDataSourcesManager, DataSourcesManager>(new ContainerControlledLifetimeManager());
            Container.RegisterInstance <ISerenityService>(new SerenityService(), new ContainerControlledLifetimeManager());
        }
Ejemplo n.º 2
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.º 3
0
        public MediaRtspServer(int port)
        {
            IPAddress serverIp = SocketExtensions.GetFirstUnicastIPAddress(System.Net.Sockets.AddressFamily.InterNetwork);

            _server = new RtspServer(serverIp, 6601)
            {
                Logger = new RtspServerConsoleLogger(),
                //ClientSessionLogger = new Media.Rtsp.Server.RtspServerDebugLogger()
            };
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            RtspServer s = new RtspServer(8554);
            s.StartListen();

            // Wait for user to terminate programme
            Console.WriteLine("Press ENTER to exit");
            String dummy = Console.ReadLine();

            s.StopListen();
        }
Ejemplo n.º 5
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.º 6
0
        //rtsp://127.0.0.1:8554

        private void startServer(List <Tuple <RtspServer.StreamType, int, string> > streams)
        {
            int    port     = 8554;
            string username = "******";      // or use NUL if there is no username
            string password = "******";  // or use NUL if there is no password

            if (s == null)
            {
                s = new RtspServer(streams, port, null, null);
            }

            s.StartListen();
        }
Ejemplo n.º 7
0
 public void Dispose()
 {
     if (_rtspServer != null && _rtspServer.IsRunning)
     {
         _rtspServer.Stop();
         _rtspServer.Dispose();
     }
     _rtspServer = null;
     _media?.Dispose();
     _media = null;
     _writer?.Dispose();
     _writer = null;
 }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            _logger.Info("Starting");
            RtspServer monServeur = new RtspServer(8554);

            monServeur.StartListen();
            RTSPDispatcher.Instance.StartQueue();

            while (Console.ReadLine() != "q")
            {
            }

            monServeur.StopListen();
            RTSPDispatcher.Instance.StopQueue();
        }
Ejemplo n.º 9
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.º 10
0
        /// <summary>
        /// Starts the server.
        /// </summary>
        private void StartServer()
        {
            Utils.OutputMessage(false, MsgLevel.Info, string.Empty, "Try to start the server.");

            rtspServer = new RtspServer(serverPort, maxConnectionCount, maxSessionTimeout, fileCatalog);

            if (rtspServer == null)
            {
                return;
            }

            HookServerEvents();

            bool result = rtspServer.StartServer();

            if (result)
            {
                isServerRunning = true;
                UpdateServerStatus();

                Utils.OutputMessage(false, MsgLevel.Info, string.Empty, "Start the server successfully.");
            }
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
0
        private void mLaunchButton_Click(object sender, RoutedEventArgs e)
        {
            if (mLaunchButton.Content == "Stop")
            {
                if (s != null)
                {
                    s.StopListen();
                }

                s = null;

                if (mISession != null)
                {
                    mISession.closeSession();

                    mLaunchButton.Content = "Launch";
                }

                mISession = null;

                return;
            }


            string lxmldoc = "";

            mCaptureManager.getCollectionOfSinks(ref lxmldoc);

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(lxmldoc);

            var lSinkNode = doc.SelectSingleNode("SinkFactories/SinkFactory[@GUID='{3D64C48E-EDA4-4EE1-8436-58B64DD7CF13}']");

            if (lSinkNode == null)
            {
                return;
            }

            var lContainerNode = lSinkNode.SelectSingleNode("Value.ValueParts/ValuePart[1]");

            if (lContainerNode == null)
            {
                return;
            }

            var lReadMode = setContainerFormat(lContainerNode);

            var lSinkControl = mCaptureManager.createSinkControl();

            ISampleGrabberCallbackSinkFactory lSampleGrabberCallbackSinkFactory = null;

            lSinkControl.createSinkFactory(
                lReadMode,
                out lSampleGrabberCallbackSinkFactory);

            int lIndexCount = 120;

            var lVideoStreamSourceNode = createVideoStream(lSampleGrabberCallbackSinkFactory, lIndexCount++);

            var lAudioStreamSourceNode = createAudioStream(lSampleGrabberCallbackSinkFactory, lIndexCount++);


            List <object> lSourceMediaNodeList = new List <object>();

            List <Tuple <RtspServer.StreamType, int, string> > streams = new List <Tuple <RtspServer.StreamType, int, string> >();

            if (lVideoStreamSourceNode.Item1 != null)
            {
                lSourceMediaNodeList.Add(lVideoStreamSourceNode.Item1);

                streams.Add(Tuple.Create <RtspServer.StreamType, int, string>(lVideoStreamSourceNode.Item2, lVideoStreamSourceNode.Item3, lVideoStreamSourceNode.Item4));
            }

            if (lAudioStreamSourceNode.Item1 != null)
            {
                lSourceMediaNodeList.Add(lAudioStreamSourceNode.Item1);

                streams.Add(Tuple.Create <RtspServer.StreamType, int, string>(lAudioStreamSourceNode.Item2, lAudioStreamSourceNode.Item3, ""));
            }

            var lSessionControl = mCaptureManager.createSessionControl();

            if (lSessionControl == null)
            {
                return;
            }

            mISession = lSessionControl.createSession(
                lSourceMediaNodeList.ToArray());

            if (mISession == null)
            {
                return;
            }


            mISession.registerUpdateStateDelegate(UpdateStateDelegate);

            mISession.startSession(0, Guid.Empty);

            mLaunchButton.Content = "Stop";

            startServer(streams);
        }
Ejemplo n.º 13
0
        public StreamRtspServer()
        {
            _rtspServer = new RtspServer(IPAddress.Any, 554);

            //_writer = new FileWriter(@"d:\baseframe.txt");
        }