コード例 #1
0
        /// <inheritdoc />
        internal override void EnableOutputPort(bool sendBuffers = true)
        {
            if (!this.Enabled)
            {
                this.ManagedOutputCallback = OutputCallbackProvider.FindCallback(this);

                this.NativeCallback = this.NativeOutputPortCallback;

                IntPtr ptrCallback = Marshal.GetFunctionPointerForDelegate(this.NativeCallback);
                this.PtrCallback = ptrCallback;

                if (this.ManagedOutputCallback == null)
                {
                    MMALLog.Logger.Warn("Callback null");

                    this.EnablePort(IntPtr.Zero);
                }
                else
                {
                    this.EnablePort(ptrCallback);
                }

                if (this.ManagedOutputCallback != null)
                {
                    this.SendAllBuffers(sendBuffers);
                }
            }

            if (!this.Enabled)
            {
                throw new PiCameraError("Unknown error occurred whilst enabling port");
            }
        }
コード例 #2
0
        /// <summary>
        /// Register a new <see cref="IOutputCallbackHandler"/>.
        /// </summary>
        /// <param name="handler">The callback handler.</param>
        public static void RegisterCallback(IOutputCallbackHandler handler)
        {
            if (handler?.WorkingPort == null)
            {
                throw new NullReferenceException("Callback handler not configured correctly.");
            }

            if (WorkingHandlers.ContainsKey(handler.WorkingPort))
            {
                WorkingHandlers[handler.WorkingPort] = handler;
            }
            else
            {
                WorkingHandlers.Add(handler.WorkingPort, handler);
            }
        }
コード例 #3
0
 /// <summary>
 /// Registers a <see cref="IOutputCallbackHandler"/>.
 /// </summary>
 /// <param name="handler">The output handler.</param>
 public void RegisterOutputCallback(IOutputCallbackHandler handler) => OutputCallbackProvider.RegisterCallback(handler);