Exemple #1
0
        static void StartManagedStreaming(IMutliStreamManager Streams, string[] args)
        {
            Console.WriteLine("If the stream lags try pausing and unpausing the player.");
            Streams.Begin();

            Console.ReadLine();
            Console.WriteLine("Terminating threads...");

            Streams.Stop();
            Streams.Dispose();
        }
Exemple #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("SysDVR-Client - 3.0 by exelix");
            Console.WriteLine("https://github.com/exelix11/SysDVR \r\n");
            if (args.Length < 1)
            {
                PrintGuide(false);
            }
            else if (args[0].Contains("help"))
            {
                PrintGuide(true);
                return;
            }

            bool IsUsbMode = true;
            IMutliStreamManager Streams = null;
            bool NoAudio = false, NoVideo = false;

            bool HasArg(string arg) => Array.IndexOf(args, arg) != -1;

            NoAudio = HasArg("--no-audio");
            NoVideo = HasArg("--no-video");

            if (NoVideo && NoAudio)
            {
                Console.WriteLine("Specify at least a video or audio target");
                return;
            }

            if (args.Length == 0 || args[0].ToLower() == "rtsp")
            {
                Streams = new RTSP.SysDvrRTSPServer(!NoVideo, !NoAudio, false);
            }
            else if (args[0].ToLower() == "bridge")
            {
                IsUsbMode = false;
                Streams   = new TCPBridgeManager(!NoVideo, !NoAudio, args[1]);
            }
            else
            {
                Streams = ParseLegacyArgs(args);
            }

            Console.WriteLine("Starting stream, press return to stop");
            if (IsUsbMode)
            {
                StartUsbStreaming(Streams, args);
            }
            else
            {
                StartManagedStreaming(Streams, args);
            }
        }
Exemple #3
0
        static void StartUsbStreaming(IMutliStreamManager Streams, string[] args)
        {
            bool     PrintStats  = false;
            LogLevel UsbLogLevel = LogLevel.Error;

            bool HasArg(string arg) => Array.IndexOf(args, arg) != -1;

            if (HasArg("--desync-fix"))
            {
                Console.WriteLine("Warning: the --desync-fix fix option has been deprecated and will be ignored");
            }

            PrintStats = HasArg("--print-stats");
            if (HasArg("--usb-warn"))
            {
                UsbLogLevel = LogLevel.Info;
            }
            if (HasArg("--usb-debug"))
            {
                UsbLogLevel = LogLevel.Debug;
            }

            if (Streams == null || !Streams.HasAStream)
            {
                Console.WriteLine("Specify at least a video or audio target");
                return;
            }

            var stream = GetDevice(UsbLogLevel);

            if (stream == null)
            {
                Console.WriteLine("Device not found, did you configure the drivers properly ?");
                return;
            }

            CancellationTokenSource StopThreads = new CancellationTokenSource();

            VideoStreamThread Video = null;

            if (Streams.Video != null)
            {
                Video = new VideoStreamThread(StopThreads.Token, Streams.Video, stream.OpenStreamDefault(), PrintStats);
            }

            AudioStreamThread Audio = null;

            if (Streams.Audio != null)
            {
                Audio = new AudioStreamThread(StopThreads.Token, Streams.Audio, stream.OpenStreamAlt(), PrintStats);
            }

            Video?.Start();
            Audio?.Start();

            //If streaming via RTSP use managed streaming, this part should be reworked in the future, maybe using "managed streams" only
            if (Streams is RTSP.SysDvrRTSPServer || Streams is TCPBridgeManager)
            {
                StartManagedStreaming(Streams, null);
            }
            else
            {
                Streams.Begin();
                Console.WriteLine("If the stream lags press Q to force a resync");
                ConsoleKey c;
                while ((c = Console.ReadKey().Key) != ConsoleKey.Enter)
                {
                    if (c == ConsoleKey.Q)
                    {
                        Console.WriteLine("Pausing streams for 3 seconds to flush buffer data");
                        Video?.Pause();
                        Audio?.Pause();
                        Thread.Sleep(3000);
                        Video?.Resume();
                        Audio?.Resume();
                    }
                }

                Console.WriteLine("Terminating threads...");
                Streams.Stop();
                Streams.Dispose();
            }

            StopThreads.Cancel();
            Video?.Join();
            Audio?.Join();

            Video?.Dispose();
            Audio?.Dispose();

            LibUsbCtx.Dispose();
        }
Exemple #4
0
        static void Main(string[] args)
        {
            Console.WriteLine("SysDVR-Client - 3.0 by exelix");
            Console.WriteLine("https://github.com/exelix11/SysDVR \r\n");
            if (args.Length < 1)
            {
                PrintGuide(false);
            }
            else if (args[0].Contains("help"))
            {
                PrintGuide(true);
                return;
            }

            bool IsUsbMode = true;
            IMutliStreamManager Streams = null;
            bool NoAudio = false, NoVideo = false;
            int  Port;

            bool HasArg(string arg) => Array.IndexOf(args, arg) != -1;

            string ArgValue(string arg)
            {
                int index = Array.IndexOf(args, arg);

                if (index == -1)
                {
                    return(null);
                }
                if (args.Length <= index + 1)
                {
                    return(null);
                }
                return(args[index + 1]);
            }

            int?ArgValueInt(string arg)
            {
                var a = ArgValue(arg);

                if (int.TryParse(a, out int res))
                {
                    return(res);
                }
                return(null);
            }

            NoAudio = HasArg("--no-audio");
            NoVideo = HasArg("--no-video");
            Port    = ArgValueInt("--port") ?? 6666;

            if (Port <= 1024)
            {
                Console.WriteLine("Warning: ports lower than 1024 are usually reserved and may require administrator privileges");
            }

            if (NoVideo && NoAudio)
            {
                Console.WriteLine("Specify at least a video or audio target");
                return;
            }

            if (args.Length == 0 || args[0].ToLower() == "rtsp")
            {
                Streams = new RTSP.SysDvrRTSPServer(!NoVideo, !NoAudio, false, Port);
            }
            else if (args[0].ToLower() == "bridge")
            {
                IsUsbMode = false;
                Streams   = new TCPBridgeManager(!NoVideo, !NoAudio, args[1], Port);
            }
            else
            {
                Streams = ParseLegacyArgs(args);
            }

            Console.WriteLine("Starting stream, press return to stop");
            if (IsUsbMode)
            {
                StartUsbStreaming(Streams, args);
            }
            else
            {
                StartManagedStreaming(Streams, args);
            }
        }