コード例 #1
0
        void StartStreaming()
        {
            string host    = TxtHost.Text;
            string port    = TxtPort.Text;
            var    channel = new Channel($"{host}:{port}", ChannelCredentials.Insecure);

            client = new GrpcStreamClient(new Rtspstream.Rtspstream.RtspstreamClient(channel));

            thread = new Thread(() =>
            {
                while (canStream)
                {
                    try
                    {
                        Console.WriteLine($"<=== Get streamData {CHANNEL}");
                        var streamData = client.GetStreaming(new AuthToken()
                        {
                            Token = $"ct-" + DateTime.Now
                        });
                        OnStreamReceived(streamData);
                        //Thread.Sleep(FRAME_SLEEP);
                    }
                    catch (TaskCanceledException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    catch (ObjectDisposedException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    catch (InvalidOperationException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                    catch (ThreadInterruptedException e)
                    {
                        Console.WriteLine(e.Message);
                    }
                }
            });

            thread.Start();

            Console.WriteLine($"=====> StartStreaming [V_INDEX : {CHANNEL}], [CurrentThread : {Thread.CurrentThread.ManagedThreadId}], [Thread : {thread.ManagedThreadId}]");
        }
コード例 #2
0
        static void Main(string[] args)
        {
            ////const string host = "127.0.0.1";
            const string host = "localhost";
            const int    Port = 1004;

            var channel = new Channel($"{host}:{Port}", ChannelCredentials.Insecure);
            var client  = new GrpcStreamClient(new Rtspstream.Rtspstream.RtspstreamClient(channel));

            //client.GetStreaming(new AuthToken() { Token = "streamingtoken_1" }).Wait();
            client.GetStreaming(new AuthToken()
            {
                Token = 1
            });

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }