Beispiel #1
0
        public virtual void OnRender(TargetBase targetBase)
        {
            lock (lockObject)
            {
                if (isVideoStopped)
                {
                    return;
                }

                if (mediaEngineEx != null)
                {
                    long pts;
                    if (mediaEngineEx.OnVideoStreamTick(out pts))
                    {
                        var backBuffer = OutputVideoTexture ?? targetBase.BackBuffer;

                        if (backBuffer != null)
                        {
                            var desc   = backBuffer.Description;
                            var region = new Rectangle(0, 0, desc.Width, desc.Height);

                            mediaEngineEx.TransferVideoFrame(backBuffer, null, region, (ColorBGRA)BackgroundColor);
                        }
                    }
                }
            }
        }
Beispiel #2
0
        public virtual void OnRender()
        {
            lock (lockObject)
            {
                if (isVideoStopped)
                {
                    return;
                }

                if (mediaEngineEx != null)
                {
                    long pts;
                    if (mediaEngineEx.OnVideoStreamTick(out pts))
                    {
                        if (OutputVideoTexture != null)
                        {
                            var desc   = OutputVideoTexture.Description;
                            var region = new Rectangle(0, 0, desc.Width, desc.Height);

                            try
                            {
                                // Blit the frame to the supplied rendertarget
                                mediaEngineEx.TransferVideoFrame(OutputVideoTexture, null, region, (ColorBGRA)BackgroundColor);
                            }
                            catch (Exception)
                            {
                                // This exception can be worked around by using DirectX 9 only (see configuration)
                                Debug.WriteLine("Exception during TransferVideoFrame");
                            }
                        }
                    }
                }
            }
        }
Beispiel #3
0
        public virtual void OnRender()
        {
            lock (lockObject)
            {
                if (isVideoStopped)
                {
                    return;
                }

                if (mediaEngineEx != null)
                {
                    long pts;
                    if (mediaEngineEx.OnVideoStreamTick(out pts))
                    {
                        if (OutputVideoTexture != null)
                        {
                            var desc        = OutputVideoTexture.Description;
                            var dxgiSurface = OutputVideoTexture.QueryInterface <SharpDX.DXGI.Surface>();
                            var region      = new SharpDX.Mathematics.Interop.RawRectangle(0, 0, desc.Width, desc.Height);

                            try
                            {
                                // Blit the frame to the supplied rendertarget
                                mediaEngineEx.TransferVideoFrame(dxgiSurface, null, region, null);
                            }
                            catch (Exception)
                            {
                                // This exception can be worked around by using DirectX 9 only (see configuration)
                                Debug.WriteLine("Exception during TransferVideoFrame");
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
0
 private async Task FrameLoopAsync(CancellationToken token)
 {
     try
     {
         while (!token.IsCancellationRequested)
         {
             if (engine.OnVideoStreamTick(out long time) && time >= 0)
             {
                 engine.GetNativeVideoSize(out int width, out int height);
                 engine.TransferVideoFrame(TargetSurface, null, new RawRectangle(0, 0, width, height), null);
                 UpdateOutputSurface();
                 SetCurrentTime(new TimeSpan(time));
             }
             await Task.Delay(frameTime, token);
         }
     }
     catch (Exception)
     {
         Pause();
         throw;
     }
 }