Ejemplo n.º 1
0
        public VideoTestPatternSource(IVideoEncoder encoder = null)
        {
            if (encoder != null)
            {
                _videoEncoder  = encoder;
                _formatManager = new MediaFormatManager <VideoFormat>(SupportedFormats);
            }

            var assem          = typeof(VideoTestPatternSource).GetTypeInfo().Assembly;
            var testPatternStm = assem.GetManifestResourceStream(TEST_PATTERN_RESOURCE_PATH);

            if (testPatternStm == null)
            {
                OnVideoSourceError?.Invoke(
                    $"Test pattern embedded resource could not be found, {TEST_PATTERN_RESOURCE_PATH}.");
            }
            else
            {
                _testI420Buffer = new byte[TEST_PATTERN_WIDTH * TEST_PATTERN_HEIGHT * 3 / 2];
                testPatternStm.Read(_testI420Buffer, 0, _testI420Buffer.Length);
                testPatternStm.Close();
                _sendTestPatternTimer = new Timer(GenerateTestPattern, null, Timeout.Infinite, Timeout.Infinite);
                _frameSpacing         = 1000 / DEFAULT_FRAMES_PER_SECOND;
            }
        }
        private async void VideoCaptureDevice_Failed(MediaCapture sender, MediaCaptureFailedEventArgs errorEventArgs)
        {
            if (!_videoCaptureDeviceFailed)
            {
                _videoCaptureDeviceFailed = true;

                //logger.LogWarning($"Video capture device failed. {errorEventArgs.Message}.");
                OnVideoSourceError?.Invoke(errorEventArgs.Message);

                await CloseVideoCaptureDevice().ConfigureAwait(false);
            }
        }
Ejemplo n.º 3
0
        public VideoTestPatternSource()
        {
            EmbeddedFileProvider efp = new EmbeddedFileProvider(Assembly.GetExecutingAssembly());
            var testPatternFileInfo  = efp.GetFileInfo(TEST_PATTERN_RESOURCE_PATH);

            if (testPatternFileInfo == null)
            {
                OnVideoSourceError?.Invoke($"Test pattern embedded resource could not be found, {TEST_PATTERN_RESOURCE_PATH}.");
            }
            else
            {
                _testPattern          = new Bitmap(testPatternFileInfo.CreateReadStream());
                _sendTestPatternTimer = new Timer(GenerateTestPattern, null, Timeout.Infinite, Timeout.Infinite);
                _frameSpacing         = 1000 / DEFAULT_FRAMES_PER_SECOND;
            }
        }
Ejemplo n.º 4
0
        public void SetEmbeddedTestPatternPath(string path)
        {
            EmbeddedFileProvider efp = new EmbeddedFileProvider(Assembly.GetExecutingAssembly());
            var testPattenFileInfo   = efp.GetFileInfo(path);

            if (testPattenFileInfo == null)
            {
                OnVideoSourceError?.Invoke($"Video test pattern source could not locate embedded path {path}.");
            }
            else
            {
                logger.LogDebug($"Test pattern loaded from embedded resource {path}.");

                lock (_sendTestPatternTimer)
                {
                    _testPattern?.Dispose();
                    _testPattern = new Bitmap(testPattenFileInfo.CreateReadStream());
                }
            }
        }
        public VideoTestPatternSource()
        {
            var assem          = typeof(VideoTestPatternSource).GetTypeInfo().Assembly;
            var testPatternStm = assem.GetManifestResourceStream(TEST_PATTERN_RESOURCE_PATH);

            if (testPatternStm == null)
            {
                OnVideoSourceError?.Invoke($"Test pattern embedded resource could not be found, {TEST_PATTERN_RESOURCE_PATH}.");
            }
            else
            {
                //Bitmap testPattern = new Bitmap(testPatternStm);
                //LoadI420Buffer(testPattern);
                //testPattern.Dispose();
                _testI420Buffer = new byte[TEST_PATTERN_WIDTH * TEST_PATTERN_HEIGHT * 3 / 2];
                testPatternStm.Read(_testI420Buffer, 0, _testI420Buffer.Length);
                testPatternStm.Close();
                _sendTestPatternTimer = new Timer(GenerateTestPattern, null, Timeout.Infinite, Timeout.Infinite);
                _frameSpacing         = 1000 / DEFAULT_FRAMES_PER_SECOND;
            }
        }