Start() private method

private Start ( ) : void
return void
Example #1
0
        public bool Stop()
        {
            try
            {
                if (segmenterApplication != null && !segmenterApplication.HasExited)
                {
                    Log.Debug("HTTPLiveStreaming: killing segmenter");
                    segmenterApplication.Kill();
                }
            }
            catch (Exception ex)
            {
                Log.Error("HTTPLiveStreaming: failed to kill segmenter", ex);
            }

            // this really, really isn't the best way to do it but it's the easiest
            ThreadManager.Start("HTTPLiveCleanup", delegate()
            {
                try
                {
                    Thread.Sleep(5000);
                    Directory.Delete(TemporaryDirectory, true);
                }
                catch (Exception ex)
                {
                    Log.Warn("HTTPLiveStreaming: failed to delete temporary directory", ex);
                }
            });

            return(true);
        }
Example #2
0
        public void StartStream(StreamContext context, Reference <WebTranscodingInfo> infoRef)
        {
            // ignore when not needed
            if (!enabled || (context.Source.MediaType != WebStreamMediaType.Movie && context.Source.MediaType != WebStreamMediaType.TVEpisode))
            {
                return;
            }

            // do some cleanup
            foreach (string id in streams.Where(x => x.Value.Stale).Select(x => x.Value.Id).ToList())
            {
                streams.Remove(id);
            }

            // generate identifier
            string identifier = GetIdentifierFromMediaSource(context.Source);

            // start if non-existent
            if (!streams.ContainsKey(identifier))
            {
                StreamState state = new StreamState()
                {
                    Id              = identifier,
                    Context         = context,
                    TranscodingInfo = infoRef,
                    Canceled        = false,
                    Stale           = false
                };

                // get mediadescriptor and rough runtime
                Log.Debug("WatchSharing: synchronizing start watching event to service");
                if (context.Source.MediaType == WebStreamMediaType.TVEpisode)
                {
                    state.MediaDescriptor = MPEServices.MAS.GetTVEpisodeDetailedById(context.Source.Provider, context.Source.Id);
                    state.Runtime         = MPEServices.MAS.GetTVShowDetailedById(context.Source.Provider, ((WebTVEpisodeDetailed)state.MediaDescriptor).ShowId).Runtime * 60000;
                }
                else if (context.Source.MediaType == WebStreamMediaType.Movie)
                {
                    state.MediaDescriptor = MPEServices.MAS.GetMovieDetailedById(context.Source.Provider, context.Source.Id);
                    state.Runtime         = ((WebMovieDetailed)state.MediaDescriptor).Runtime * 60000;
                }

                // get exact runtime if available
                if (context.MediaInfo.Duration > 60)
                {
                    state.Runtime = (int)context.MediaInfo.Duration;
                }

                streams[identifier]    = state;
                state.BackgroundThread = ThreadManager.Start("WatchWorker", new ParameterizedThreadStart(this.BackgroundWorker), identifier);
            }
            else
            {
                // just update the progress which will be send next time
                Log.Info("WatchSharing: Picking up old stream");
                streams[identifier].Canceled = false;
                streams[identifier].Context  = context;
            }
        }
 public void Connect(string host, int port)
 {
     lastHost    = host;
     lastTcpPort = port;
     threadManager.Start();
     socket.Connect(lastHost, lastTcpPort);
     connectionMode = ConnectionModes.SOCKET;
 }
        protected override void OnStart(string[] args)
        {
            Database.SetInitializer <AmazonContext>(null);
            XmlConfigurator.Configure(new FileInfo(AppSettings.log4net_Config));
            _log.Fatal("Service STARTED! Self test SMTP message");

            _threadManager = new ThreadManager(_log, _time);
            _threadManager.Start();
        }
 public bool Setup()
 {
     data.Value.Failed = false;
     vlcIsStarted      = false;
     processThread     = ThreadManager.Start("VLCLogParsing", delegate()
     {
         ParseOutputStream(InputStream, data, position, false);
     });
     return(true);
 }
    void StartManagers()
    {
        ItemMgr.Start();
        //structureMgr.Start();
        //shapeMgr.Start();
        //textureAndMaterialMgr.Start();

        threadMgr.Start();
        worldMgr.Start();
        entityMgr.Start();
    }
Example #7
0
 public bool Setup()
 {
     // this might be better placed in the Start() method, but EncoderUnit.Start() depends on this
     data.Value.Supported = true;
     data.Value.Failed    = false;
     processThread        = ThreadManager.Start("FFMpegLogParsing", delegate()
     {
         ParseOutputStream(InputStream, data, startPosition, LogMessages, LogProgress);
     });
     return(true);
 }
Example #8
0
        static void Main(string[] args)
        {
            var threadManager = new ThreadManager(3);

            for (var i = 0; i < 10; i++)
            {
                var number = i;
                threadManager.AddTask(() => Print(number));
            }
            threadManager.Start();
            Console.ReadKey();
        }
Example #9
0
 protected override void Propose(Instance r)
 {
     ThreadManager.Start(() =>
     {
         var b = MineBlock(r);
         if (b != null)
         {
             ProcessBlock(r, b);
             Broadcast(r, MessageType.Propose, b);
         }
     });
 }
Example #10
0
        /// <summary>
        /// Запустить процесс компрессии/декомпрессии
        /// </summary>
        public void Run()
        {
            _status = Status.process;
            (new Thread(Read)).Start();
            (new Thread(Write)).Start();

            _threadManager.Start(Handle);
            if (_status == Status.process)
            {
                _status = Status.copmleted;
            }
            _queueReader.Stop();
        }
Example #11
0
        protected override void OnStart(string[] args)
        {
            Log.i("OnStart");


            // TODO: test
            ZhiRenHandler.init();
            //string time = String.Format("{0}-{1}-{2} {3}:{4}", 2017, 3, 22, 11, 06);
            //ZhiRenHandler.sendUserVerified("2",time);
            //ZhiRenHandler.GetSubCompany();

            manager.Start();
            Log.i("OnStart End");
        }
Example #12
0
 public void Connect(string host, int port)
 {
     lastHost    = host;
     lastTcpPort = port;
     threadManager.Start();
     if (useBlueBox)
     {
         connectionMode     = ConnectionModes.HTTP;
         bbClient.PollSpeed = ((sfs.Config == null) ? 750 : sfs.Config.BlueBoxPollingRate);
         bbClient.Connect(host, port);
     }
     else
     {
         socket.Connect(lastHost, lastTcpPort);
         connectionMode = ConnectionModes.SOCKET;
     }
 }
Example #13
0
 public bool Open()
 {
     try
     {
         Log.Debug("Opening MPExtended ServiceHost version {0} (build {1})", VersionUtil.GetVersionName(), VersionUtil.GetBuildVersion());
         wcf.Start(Installation.GetInstalledServices().Where(x => x.HostAsWCF).ToList());
         ThreadManager.Start("Zeroconf", delegate()
         {
             zeroconf.PublishServices(Installation.GetInstalledServices());
         });
         Log.Debug("Opened MPExtended ServiceHost");
         return(true);
     }
     catch (Exception ex)
     {
         Log.Error("Failed to open MPExtended ServiceHost", ex);
         return(false);
     }
 }
Example #14
0
        public bool Start()
        {
            // setup input
            if (inputMethod == InputMethod.NamedPipe)
            {
                ((NamedPipe)transcoderInputStream).WaitTillReady();
                Log.Info("VLCManagedEncoder: Copy stream of type {0} into transcoder input pipe", InputStream.ToString());
                StreamCopy.AsyncStreamCopy(InputStream, transcoderInputStream, "transinput");
            }

            // delay start of next unit till our output stream is ready
            Log.Info("VLCManagedEncoder: Waiting till output named pipe is ready");
            ((NamedPipe)DataOutputStream).WaitTillReady();

            // TODO: wait for state machine

            // setup data thread
            infoReader = ThreadManager.Start("VLCInfoThread", InfoThread, context.StartPosition);
            return(true);
        }
Example #15
0
        public bool Setup()
        {
            siteRoot = WCFUtil.GetCurrentRoot() + "StreamingService/stream/CustomTranscoderData?identifier=" + identifier + "&action=segment&parameters=";

            TemporaryDirectory = Path.Combine(Path.GetTempPath(), "MPExtended.Services.StreamingService.HTTPLiveStreaming-" + new Random().Next());
            Directory.CreateDirectory(TemporaryDirectory);
            Log.Debug("HTTPLiveStreaming: created temporary directory {0}", TemporaryDirectory);

            string arguments = String.Format("- {0} segment playlist.m3u8 {2} {3}", SEGMENT_LENGTH, TemporaryDirectory, siteRoot, SEGMENT_BUFFER);
            string segmenter = @"..\..\..\..\Libraries\Streaming\segmenter\segmenter.exe";

            ProcessStartInfo start = new ProcessStartInfo(segmenter, arguments);

            start.UseShellExecute        = false;
            start.RedirectStandardInput  = true;
            start.RedirectStandardOutput = false;
            start.RedirectStandardError  = true;
            start.WindowStyle            = DebugOutput ? ProcessWindowStyle.Normal : ProcessWindowStyle.Hidden;
            start.CreateNoWindow         = !DebugOutput;
            start.WorkingDirectory       = TemporaryDirectory;

            Log.Info("HTTPLiveStreaming: segmenter arguments: {0}", arguments);

            try
            {
                segmenterApplication           = new Process();
                segmenterApplication.StartInfo = start;
                segmenterApplication.Start();
                ThreadManager.Start("HTTPLiveSegmenter", MonitorThread);
            }
            catch (Exception ex)
            {
                Log.Error("HTTPLiveStreaming: failed to start segmenter", ex);
                return(false);
            }

            return(true);
        }
Example #16
0
        private void Build(List <Vector2> points)
        {
            _lastCreatedObject = null;

            Vector2[] temp = new Vector2[points.Count];
            points.CopyTo(temp);
            _points = new List <Vector2>(temp);

            if (_points.Count < MINIMUM_ALLOWED_VERTICES)
            {
                InvalidShapeCreated();
                return;
            }

            if (_useThread)
            {
                StartCoroutine(ThreadManager.Start(StartConstruction, MeshConstructionComplete, 0));
            }
            else
            {
                StartConstruction(-1);
            }
        }
Example #17
0
 public Streaming(StreamingService serviceInstance)
 {
     sharing = new WatchSharing();
     service = serviceInstance;
     ThreadManager.Start("StreamTimeout", TimeoutStreamsWorker);
 }
Example #18
0
 public static void Main()
 {
     var TM = new ThreadManager();
     TM.Enqueue(WebController.HandleClients(TM));
     TM.Start(1);
 }
Example #19
0
        public void EndStream(MediaSource source, bool force = false)
        {
            // generate identifier
            string identifier = GetIdentifierFromMediaSource(source);

            // ignore if not registered
            if (!enabled || !streams.ContainsKey(identifier))
            {
                return;
            }

            if (streams[identifier].TranscodingInfo != null && streams[identifier].TranscodingInfo.Value != null)
            {
                int progress = CalculateWatchPosition(identifier);
                if (progress >= 95)
                {
                    Log.Debug("WatchSharing: seeing {0}% as finished for {1}", progress, identifier);

                    // send the finished event in a background thread
                    ThreadManager.Start("FinishWatching", delegate()
                    {
                        if (streams[identifier].Context.Source.MediaType == WebStreamMediaType.TVEpisode)
                        {
                            service.FinishEpisode((WebTVEpisodeDetailed)streams[identifier].MediaDescriptor);
                        }
                        else if (streams[identifier].Context.Source.MediaType == WebStreamMediaType.Movie)
                        {
                            service.FinishMovie((WebMovieDetailed)streams[identifier].MediaDescriptor);
                        }

                        // kill it
                        streams[identifier].BackgroundThread.Abort();
                        ThreadManager.Remove(streams[identifier].BackgroundThread);
                        streams.Remove(identifier);
                        Log.Debug("WatchSharing: finished handling {0}", identifier);
                    });
                    return;
                }
            }

            // cancel it
            if (!force)
            {
                Log.Debug("WatchSharing: canceling stream {0}", identifier);
                streams[identifier].Canceled = true;
            }
            else
            {
                // definitely cancel it
                Log.Debug("WatchSharing: killing stream {0} because of forced EndStream", identifier);
                lock (service)
                {
                    if (streams[identifier].Context.Source.MediaType == WebStreamMediaType.TVEpisode)
                    {
                        service.CancelWatchingEpisode((WebTVEpisodeDetailed)streams[identifier].MediaDescriptor);
                    }
                    else if (streams[identifier].Context.Source.MediaType == WebStreamMediaType.Movie)
                    {
                        service.CancelWatchingMovie((WebMovieDetailed)streams[identifier].MediaDescriptor);
                    }
                }
            }
        }
Example #20
0
 public static void threadManagerStart()
 {
     threadManager1.Start(8);
     //threadManager2.Start(8);
 }
Example #21
0
 public void Start()
 {
     _threadManager.Start();
     Logger.Debug("Started");
 }