Beispiel #1
0
        static void Test1()
        {
            var videoInfo = new SmVideoInfo()
            {
                PixelType       = SmPixelTypes.Bgr24,
                Width           = 1920,
                Height          = 1080,
                Stride          = 1920 * 3,
                Fps_numerator   = 25,
                Fps_denominator = 1
            };
            var smm = new SharedMemManager(videoInfo, 2, "SHAREDMEMTEST");

            smm.Initialize(-1);
        }
Beispiel #2
0
        static void Test2()
        {
            var videoInfo = new SmVideoInfo()
            {
                PixelType       = SmPixelTypes.Bgr24,
                Width           = 1920,
                Height          = 1080,
                Stride          = 1920 * 3,
                Fps_numerator   = 25,
                Fps_denominator = 1
            };
            var smm = new SharedMemManager(videoInfo, 2, "SHAREDMEMTEST");

            smm.Initialize(500);

            StartFfmpeg();

            var bitmapGenerator = new TestPictureGenerator(videoInfo.Width, videoInfo.Height);

            int i = 0;

            for (; ;)
            {
                bitmapGenerator.GenerateNext();

                bitmapGenerator.GetBitmap(
                    (ptr, width, height, stride) =>
                {
                    for (; ;)
                    {
                        bool b = smm.TryAddFrame(ptr, width, height, stride);
                        if (b == true)
                        {
                            break;
                        }

                        // I put this here hoping that this plays nicely with HyperTreading
                        // -> https://stackoverflow.com/questions/48959457/c-call-c-sharp-clr-function-spinwaitinternal
                        Thread.SpinWait(10);
                    }
                });
                Console.WriteLine($"Put frame #{i}");
                ++i;
            }
        }