示例#1
0
        private void EncodeThreadInit(int _camNumber, string _encodePipeName, string _sessionPath, int _count, ConcurrentQueue <byte[]> _encodeQueue)
        {
            int    camNumber      = _camNumber;
            string pipeName       = _encodePipeName;
            string sessionPath    = _sessionPath;
            int    count          = _count;
            int    nFramesWritten = 0;
            ConcurrentQueue <byte[]> encodeQueue = _encodeQueue;

            NamedPipeServerStream pipe = new NamedPipeServerStream(pipeName: pipeName, direction: PipeDirection.Out, maxNumberOfServerInstances: 1,
                                                                   transmissionMode: PipeTransmissionMode.Byte, options: PipeOptions.Asynchronous, inBufferSize: 7057600, outBufferSize: 7057600);

            string    videoFileName = sessionPath + @"\" + DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss") + ".mp4";
            FFProcess ffProcess     = new FFProcess(pipeName: pipeName, videoFileName: videoFileName);

            ffProcess.OpenWithStartInfo();
            pipe.WaitForConnection();
            Console.WriteLine("Pipe connected to ffProcess for camera {0} on thread {1}", camNumber.ToString(), Thread.CurrentThread.ManagedThreadId.ToString());

            bool goEncode = true;
            bool isDequeueSuccess;

            while (goEncode)
            {
                isDequeueSuccess = encodeQueue.TryDequeue(out byte[] result);
                if (isDequeueSuccess)
                {
                    pipe.Write(buffer: result, offset: 0, count: count);
                    nFramesWritten++;

                    if (nFramesWritten % 1000 == 0)
                    {
                        Console.WriteLine("nFramesWritten for cam number {0}:   {1}", camNumber.ToString(), nFramesWritten.ToString());
                    }
                }
                else
                {
                    Thread.Sleep(10);
                    if (encodeQueue.Count == 0)
                    {
                        goEncode = false;
                    }
                }
            }

            pipe.FlushAsync();
            pipe.WaitForPipeDrain();
            pipe.Close();
            ffProcess.process.WaitForExit();
            ffProcess.process.Close();
            Console.WriteLine("EncodeThread for camera {0}: Pipe flushed, drained, and closed. FFProcess exited and closed.", camNumber.ToString());

            if (camNumber == 0)
            {
                GC.Collect();
                Console.WriteLine("Garbage collected on camera 1 EncodeThread. Now exiting.");
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            FFProcess       process  = new FFProcess(FFProcess.DX11_DEFAULT_NAME, true);
            DiscordPresence presence = new DiscordPresence(DISCORD_CLIENT_ID);

            bool shutdown = false;

            new Thread(x => {
                while (!shutdown)
                {
                    if (Console.ReadKey(true).Key == ConsoleKey.Escape)
                    {
                        shutdown = true;
                        Console.WriteLine("Stopping application...");
                    }
                }
            }).Start();

            Console.WriteLine("Press ESC to stop");
            do
            {
                while (Scanner.Instance.IsScanning)
                {
                    Thread.Sleep(1000);
                    Console.WriteLine("Scanning...");
                }
                CurrentPlayer currentPlayer = Reader.GetCurrentPlayer().CurrentPlayer;
                ActorItem     player        = null /*ActorItem.CurrentUser*/;
                if (player == null)
                {
                    ActorResult aResult = Reader.GetActors();
                    KeyValuePair <uint, ActorItem> playerKeyValue = aResult.CurrentPCs.ToList().Find(x => x.Value.Name == currentPlayer.Name);
                    ActorItem playerItem = playerKeyValue.Value;

                    player = playerItem;
                }

                if (player != null)
                {
                    presence.playerName = player.Name;
                    presence.lvl        = player.Level.ToString();
                    presence.job        = player.Job.ToString();

                    uint    mapID = player.MapTerritory;
                    MapItem zone  = ZoneLookup.GetZoneInfo(mapID);
                    presence.place = zone.Name.English;

                    presence.UpdatePresence();
                }
                Thread.Sleep(5000);
            } while (!shutdown);

            presence.Deinitialize();
        }
示例#3
0
        private void BtnTimeSync_Click(object sender, EventArgs e)
        {
            if (isCaptureFlag)
            {
                net._shouldStop              = true;
                isCaptureFlag                = false;
                (sender as Button).Text      = "网络同步";
                (sender as Button).BackColor = Color.FromArgb(255, 110, 128);
            }
            else
            {
                TimeSync();


                net       = new NetworkClass();
                net.Play += Net_Play;

                try
                {
                    List <Process> ffxivProcess = FFProcess.FindFFXIVProcess();
                    if (ffxivProcess.Count == 1)
                    {
                        Task.Run((Action)(() => this.net.Run((uint)FFProcess.FindFFXIVProcess().First <Process>().Id)));
                        this.isCaptureFlag           = true;
                        (sender as Button).Text      = "停止同步";
                        (sender as Button).BackColor = Color.Aquamarine;
                    }
                    else if (ffxivProcess.Count >= 2)
                    {
                        uint      id        = 0;
                        PidSelect pidSelect = new PidSelect();
                        pidSelect.GetPid += (PidSelect.PidSelector)(x => id = (uint)x);
                        int num = (int)pidSelect.ShowDialog();
                        Task.Run((Action)(() => this.net.Run(id)));
                        this.isCaptureFlag           = true;
                        (sender as Button).Text      = "停止同步";
                        (sender as Button).BackColor = Color.Aquamarine;
                    }
                    else
                    {
                        MessageBox.Show(new Form()
                        {
                            TopMost = true
                        }, "你开游戏了吗?", "喵喵喵?", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    }
                }
                catch (Exception exception)
                {
                }
            }
        }