/// <summary> /// Remove a callback handler for a given connection. /// </summary> /// <param name="connection">The connection we are removing the callback handler for.</param> public static void RemoveCallback(MMALConnectionImpl connection) { if (WorkingHandlers.ContainsKey(connection)) { WorkingHandlers.Remove(connection); } }
/// <summary> /// Finds and returns a <see cref="IConnectionCallbackHandler"/> for a given connection. If no handler is registered, a /// <see cref="DefaultConnectionCallbackHandler"/> will be returned. /// </summary> /// <param name="connection">The connection for which we are retrieving the callback handler.</param> /// <returns>A <see cref="IConnectionCallbackHandler"/> for a given connection. If no handler is registered, a /// <see cref="DefaultConnectionCallbackHandler"/> will be returned.</returns> public static IConnectionCallbackHandler FindCallback(MMALConnectionImpl connection) { if (WorkingHandlers.ContainsKey(connection)) { return(WorkingHandlers[connection]); } return(new DefaultConnectionCallbackHandler(connection)); }
/// <inheritdoc /> public override InputPortBase ConnectTo(MMALDownstreamComponent destinationComponent, int inputPort = 0, bool useCallback = false) { if (this.ConnectedReference != null) { MMALLog.Logger.Warn("A connection has already been established on this port"); return(destinationComponent.Inputs[inputPort]); } var connection = MMALConnectionImpl.CreateConnection(this, destinationComponent.Inputs[inputPort], destinationComponent, useCallback); this.ConnectedReference = connection; destinationComponent.Inputs[inputPort].ConnectedReference = connection; return(destinationComponent.Inputs[inputPort]); }
/// <summary> /// Connects two components together by their input and output ports. /// </summary> /// <param name="destinationComponent">The component we want to connect to.</param> /// <param name="inputPort">The input port of the component we want to connect to.</param> /// <param name="useCallback">Flag to use connection callback (adversely affects performance).</param> /// <returns>The connection instance between the source output and destination input ports.</returns> public virtual IConnection ConnectTo(IDownstreamComponent destinationComponent, int inputPort = 0, bool useCallback = false) { if (this.ConnectedReference != null) { MMALLog.Logger.LogWarning($"{this.Name}: A connection has already been established on this port"); return(this.ConnectedReference); } var connection = MMALConnectionImpl.CreateConnection(this, destinationComponent.Inputs[inputPort], destinationComponent, useCallback); this.ConnectedReference = connection; destinationComponent.Inputs[inputPort].ConnectTo(this, connection); return(connection); }
/// <summary> /// Creates a new instance of <see cref="ConnectionCallbackHandlerBase"/>. /// </summary> /// <param name="connection">The connection.</param> protected ConnectionCallbackHandlerBase(MMALConnectionImpl connection) { this.WorkingConnection = connection; }
/// <summary> /// Create a new instance of <see cref="DefaultConnectionCallbackHandler"/>. /// </summary> /// <param name="connection">The connection object.</param> public DefaultConnectionCallbackHandler(MMALConnectionImpl connection) : base(connection) { }