public RTSPVideoWindow(int Port, string StreamName, string RecordingPath, int BufferSizeMs = 200) { DataContext = this; this.Port = Port; this.StreamName = StreamName; this.BufferSizeMs = BufferSizeMs; this.RecordingPath = RecordingPath; foreach (NetworkInterface currentNetworkInterface in NetworkInterface.GetAllNetworkInterfaces()) { Console.WriteLine(currentNetworkInterface.Description); if (currentNetworkInterface.Description == "Realtek USB GbE Family Controller") { networkInterface = currentNetworkInterface; } } IPv4InterfaceStatistics interfaceStatistic = networkInterface.GetIPv4Statistics(); lastBytesRecv = interfaceStatistic.BytesReceived; DispatcherTimer dispatcherTimer = new DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(GetNetworkInBackground); dispatcherTimer.Interval = new TimeSpan(0, 0, 1); dispatcherTimer.Start(); PipelineElements pipeline = CreatePipeline(); // Clean up running pipeline runningPipeline = pipeline; pendingPipeline = new PipelineElements(); Closing += OnCloseEvent; InitializeComponent(); }
private PipelineElements CreatePipeline() { PipelineElements pipe = new PipelineElements(); pendingPipeline = pipe; pipe.pipeline = new Pipeline(); pipe.RTSP = (Bin)ElementFactory.Make("rtspsrc"); pipe.Depay = ElementFactory.Make("rtpvrawdepay"); pipe.VideoSink = ElementFactory.Make("d3dvideosink"); Window window = GetWindow(this); WindowInteropHelper wih = new WindowInteropHelper(this); wih.EnsureHandle(); // Generate Window Handle if current HWND is NULL (always occurs because background window) pipe.overlay = new VideoOverlayAdapter(pipe.VideoSink.Handle); pipe.overlay.WindowHandle = wih.Handle; pipe.pipeline["message-forward"] = true; pipe.RTSP["location"] = "rtsp://" + StreamName; pipe.RTSP["latency"] = BufferSizeMs; pipe.pipeline.Add(pipe.RTSP, pipe.Depay, pipe.VideoSink); pipe.RTSP.PadAdded += RTSPPadAdded; pipe.RTSP.Link(pipe.Depay); pipe.Depay.Link(pipe.VideoSink); pipe.pipeline.SetState(State.Null); return(pipe); }
/// <summary> /// Adds elements to the end of the pipeline. /// </summary> /// <param name="pipelineElements"> /// One or more elements to add to the end of the pipeline. /// </param> public void AddStage(params IPipelineElement[] pipelineElements) { foreach (IPipelineElement pipelineElement in pipelineElements) { PipelineElements.Add(pipelineElement); } }