Exemplo n.º 1
0
        RenderTexture TryReceiveFrame()
        {
            PrepareInternalObjects();

            // Do nothing if the recv object is not ready.
            if (_recv == null)
            {
                return(null);
            }

            // Try getting a video frame.
            var frameOrNull = RecvHelper.TryCaptureVideoFrame(_recv);

            if (frameOrNull == null)
            {
                return(null);
            }
            var frame = (Interop.VideoFrame)frameOrNull;

            // Pixel format conversion
            var rt = _converter.Decode
                         (frame.Width, frame.Height,
                         Util.CheckAlpha(frame.FourCC), frame.Data);

            // Free the frame up.
            _recv.FreeVideoFrame(frame);

            return(rt);
        }
Exemplo n.º 2
0
 void PrepareInternalObjects()
 {
     if (_recv == null)
     {
         _recv = RecvHelper.TryCreateRecv(_ndiName);
     }
     if (_converter == null)
     {
         _converter = new FormatConverter(_resources);
     }
     if (_override == null)
     {
         _override = new MaterialPropertyBlock();
     }
 }