/// <summary> /// Enable processing on an output port /// </summary> /// <param name="managedCallback">A managed callback method we can do further processing on</param> internal override void EnablePort(Action <MMALBufferImpl, MMALPortBase> managedCallback) { if (!this.Enabled) { this.ManagedOutputCallback = managedCallback; this.NativeCallback = new MMALPort.MMAL_PORT_BH_CB_T(NativeOutputPortCallback); IntPtr ptrCallback = Marshal.GetFunctionPointerForDelegate(this.NativeCallback); MMALLog.Logger.Debug("Enabling port."); if (managedCallback == null) { MMALLog.Logger.Warn("Callback null"); MMALCheck(MMALPort.mmal_port_enable(this.Ptr, IntPtr.Zero), "Unable to enable port."); } else { MMALCheck(MMALPort.mmal_port_enable(this.Ptr, ptrCallback), "Unable to enable port."); } base.EnablePort(managedCallback); } if (!this.Enabled) { throw new PiCameraError("Unknown error occurred whilst enabling port"); } }
/// <summary> /// Enables processing on an input port. /// </summary> internal override void EnableInputPort() { if (!this.Enabled) { this.ManagedInputCallback = InputCallbackProvider.FindCallback(this); this.NativeCallback = new MMALPort.MMAL_PORT_BH_CB_T(this.NativeInputPortCallback); IntPtr ptrCallback = Marshal.GetFunctionPointerForDelegate(this.NativeCallback); MMALLog.Logger.Debug("Enabling input port."); if (this.ManagedInputCallback == null) { MMALLog.Logger.Warn("Callback null"); MMALCheck(MMALPort.mmal_port_enable(this.Ptr, IntPtr.Zero), "Unable to enable port."); } else { MMALCheck(MMALPort.mmal_port_enable(this.Ptr, ptrCallback), "Unable to enable port."); } this.InitialiseBufferPool(); } if (!this.Enabled) { throw new PiCameraError("Unknown error occurred whilst enabling port"); } }
/// <summary> /// Enables processing on an output port. /// </summary> /// <param name="sendBuffers">Indicates whether we want to send all the buffers in the port pool or simply create the pool.</param> internal override void EnableOutputPort(bool sendBuffers = true) { if (!this.Enabled) { this.ManagedOutputCallback = OutputCallbackProvider.FindCallback(this); this.NativeCallback = this.NativeOutputPortCallback; IntPtr ptrCallback = IntPtr.Zero; if (sendBuffers) { ptrCallback = Marshal.GetFunctionPointerForDelegate(this.NativeCallback); this.PtrCallback = ptrCallback; } else { ptrCallback = this.PtrCallback; } MMALLog.Logger.Debug("Enabling port."); if (this.ManagedOutputCallback == null) { MMALLog.Logger.Warn("Callback null"); MMALCheck(MMALPort.mmal_port_enable(this.Ptr, IntPtr.Zero), "Unable to enable port."); } else { MMALCheck(MMALPort.mmal_port_enable(this.Ptr, ptrCallback), "Unable to enable port."); } base.EnableOutputPort(sendBuffers); } if (!this.Enabled) { throw new PiCameraError("Unknown error occurred whilst enabling port"); } }
/// <summary> /// Enables processing on a port. /// </summary> internal override void EnableControlPort() { if (!this.Enabled) { this.ManagedControlCallback = OutputCallbackProvider.FindCallback(this); this.NativeCallback = new MMALPort.MMAL_PORT_BH_CB_T(this.NativeControlPortCallback); IntPtr ptrCallback = Marshal.GetFunctionPointerForDelegate(this.NativeCallback); MMALLog.Logger.Debug("Enabling control port."); if (this.ManagedControlCallback == null) { MMALLog.Logger.Debug("Callback null"); MMALCheck(MMALPort.mmal_port_enable(this.Ptr, IntPtr.Zero), "Unable to enable port."); } else { MMALCheck(MMALPort.mmal_port_enable(this.Ptr, ptrCallback), "Unable to enable port."); } } }