Ejemplo n.º 1
0
        /// <inheritdoc />
        public override void Render(MediaBlock mediaBlock, TimeSpan clockPosition)
        {
            var block = BeginRenderingCycle(mediaBlock);

            if (block == null)
            {
                return;
            }

            VideoDispatcher?.Invoke(() =>
            {
                try
                {
                    // Prepare and write frame data
                    if (PrepareVideoFrameBuffer(block))
                    {
                        WriteVideoFrameBuffer(block, clockPosition);
                    }
                }
                catch (Exception ex)
                {
                    this.LogError(Aspects.VideoRenderer, $"{nameof(VideoRenderer)}.{nameof(Render)} bitmap failed.", ex);
                }
                finally
                {
                    FinishRenderingCycle(block, clockPosition);
                }
            }, DispatcherPriority.Normal);
        }
Ejemplo n.º 2
0
        /// <inheritdoc />
        public void Render(MediaBlock mediaBlock, TimeSpan clockPosition)
        {
            if (mediaBlock is VideoBlock == false)
            {
                return;
            }

            var block = (VideoBlock)mediaBlock;

            if (IsRenderingInProgress.Value)
            {
                if (MediaCore?.State.IsPlaying ?? false)
                {
                    this.LogDebug(Aspects.VideoRenderer, $"{nameof(VideoRenderer)} frame skipped at {mediaBlock.StartTime}");
                }

                return;
            }

            // Flag the start of a rendering cycle
            IsRenderingInProgress.Value = true;

            // Send the packets to the CC renderer
            MediaElement?.CaptionsView?.SendPackets(block, MediaCore);

            if (!IsRenderTime)
            {
                return;
            }
            else
            {
                RenderStopwatch.Restart();
            }

            VideoDispatcher?.BeginInvoke(() =>
            {
                try
                {
                    // Prepare and write frame data
                    if (PrepareVideoFrameBuffer(block))
                    {
                        WriteVideoFrameBuffer(block, clockPosition);
                    }
                }
                catch (Exception ex)
                {
                    this.LogError(Aspects.VideoRenderer, $"{nameof(VideoRenderer)}.{nameof(Render)} bitmap failed.", ex);
                }
                finally
                {
                    // Update the layout including pixel ratio and video rotation
                    ControlDispatcher?.InvokeAsync(() =>
                                                   UpdateLayout(block, clockPosition), DispatcherPriority.Render);

                    IsRenderingInProgress.Value = false;
                }
            }, DispatcherPriority.Send);
        }
Ejemplo n.º 3
0
        private void UpdateTargetImage(DispatcherPriority priority, bool syncrhonous)
        {
            var task = VideoDispatcher?.InvokeAsync(() => Graphics.Render(MediaElement.VideoView), priority);

            if (syncrhonous)
            {
                task?.Wait();
            }
        }