Ejemplo n.º 1
0
        private uint VideoFormatCallback(ref IntPtr opaque, ref uint chroma, ref uint width, ref uint height,
                                         ref uint pitches, ref uint lines)
        {
            Debug.WriteLine(String.Format("Initialize Video Content : {0}x{1}", width, height));

            var videoFormatChangingArgs = new VideoFormatChangingEventArgs(width, height, ChromaType.RV32);

            if (VideoFormatChanging != null)
            {
                VideoFormatChanging(this, videoFormatChangingArgs);
            }

            if (_context == null || videoFormatChangingArgs.Width != _context.Width || videoFormatChangingArgs.Height != _context.Height)
            {
                if (DisplayThreadDispatcher == null)
                {
                    throw new NullReferenceException(String.Format("Image = {0}, Image.SeparateThreadDispatcher = {1}, ThreadSeparatedImage.CommonDispatcher = {2}", Image, Image.SeparateThreadDispatcher, ThreadSeparatedImage.CommonDispatcher));
                }
                DisplayThreadDispatcher.Invoke(DispatcherPriority.Normal,
                                               new Action(() =>
                {
                    if (_context != null)
                    {
                        _context.Dispose();
                    }
                    _context    = new VideoDisplayContext(videoFormatChangingArgs.Width, videoFormatChangingArgs.Height, videoFormatChangingArgs.ChromaType);
                    VideoSource = null;
                }));
            }

            _context.IsAspectRatioChecked = false;
            chroma  = (uint)_context.ChromaType;
            width   = (uint)_context.Width;
            height  = (uint)_context.Height;
            pitches = (uint)_context.Stride;
            lines   = (uint)_context.Height;
            return((uint)_context.Size);
        }
Ejemplo n.º 2
0
        private uint VideoFormatCallback(void **opaque, byte *chroma, uint *width, uint *height, uint *pitches,
                                         uint *lines)
        {
            Debug.WriteLine($"Initialize Video Content : {*width}x{*height}");

            var videoFormatChangingArgs = new VideoFormatChangingEventArgs(*width, *height, ChromaType.RV32);

            VideoFormatChanging?.Invoke(this, videoFormatChangingArgs);

            if (_context == null || videoFormatChangingArgs.Width != _context.Width ||
                videoFormatChangingArgs.Height != _context.Height)
            {
                if (DisplayThreadDispatcher == null)
                {
                    throw new NullReferenceException(
                              $"Image = {Image}, Image.SeparateThreadDispatcher = {Image.SeparateThreadDispatcher}, ThreadSeparatedImage.CommonDispatcher = {ThreadSeparatedImage.CommonDispatcher}");
                }
                DisplayThreadDispatcher.Invoke(DispatcherPriority.Normal,
                                               new Action(() =>
                {
                    if (_context != null)
                    {
                        _context.Dispose();
                    }
                    _context = new VideoDisplayContext(videoFormatChangingArgs.Width,
                                                       videoFormatChangingArgs.Height, videoFormatChangingArgs.ChromaType);
                    VideoSource = null;
                }));
            }

            _context.IsAspectRatioChecked = false;
            *(uint *)chroma = (uint)_context.ChromaType;
            *width   = (uint)_context.Width;
            *height  = (uint)_context.Height;
            *pitches = (uint)_context.Stride;
            *lines   = (uint)_context.Height;
            return((uint)_context.Size);
        }