/// <summary> /// Represents the native callback method for a connection between two ports. /// </summary> /// <param name="connection">The native pointer to a MMAL_CONNECTION_T struct.</param> /// <returns>The value of all flags set against this connection.</returns> internal virtual int NativeConnectionCallback(MMAL_CONNECTION_T *connection) { lock (MMALConnectionImpl.ConnectionLock) { if (MMALCameraConfig.Debug) { MMALLog.Logger.Debug("Inside native connection callback"); } var queue = new MMALQueueImpl(connection->Queue); var bufferImpl = queue.GetBuffer(); if (bufferImpl != null) { if (MMALCameraConfig.Debug) { bufferImpl.PrintProperties(); } if (bufferImpl.Length > 0) { ConnectionCallbackProvider.FindCallback(this).InputCallback(bufferImpl); } this.InputPort.SendBuffer(bufferImpl); } else { queue = new MMALQueueImpl(connection->Pool->Queue); bufferImpl = queue.GetBuffer(); if (bufferImpl != null) { if (MMALCameraConfig.Debug) { bufferImpl.PrintProperties(); } if (bufferImpl.Length > 0) { ConnectionCallbackProvider.FindCallback(this).OutputCallback(bufferImpl); } this.OutputPort.SendBuffer(bufferImpl); } else { MMALLog.Logger.Debug("Buffer could not be obtained by connection callback"); } } } return((int)connection->Flags); }
/// <summary> /// If it exists, removes a <see cref="IConnectionCallbackHandler"/> on the port specified. /// </summary> /// <param name="port">The port with a created connection.</param> public void RemoveConnectionCallback(PortBase port) => ConnectionCallbackProvider.RemoveCallback(port.ConnectedReference);
/// <summary> /// Registers a <see cref="IConnectionCallbackHandler"/>. /// </summary> /// <param name="handler">The output handler.</param> public void RegisterConnectionCallback(IConnectionCallbackHandler handler) => ConnectionCallbackProvider.RegisterCallback(handler);