Esempio n. 1
0
        private void FindComponents(MMALDownstreamComponent downstream, List <MMALDownstreamComponent> list)
        {
            if (downstream.Outputs.Count == 0)
            {
                return;
            }

            if (downstream.Outputs.Count == 1 && downstream.Outputs[0].ConnectedReference == null)
            {
                list.Add(downstream);
                return;
            }

            if (downstream.GetType().BaseType == typeof(MMALDownstreamHandlerComponent))
            {
                list.Add((MMALDownstreamHandlerComponent)downstream);
            }

            foreach (var output in downstream.Outputs)
            {
                if (output.ConnectedReference != null)
                {
                    this.FindComponents(output.ConnectedReference.DownstreamComponent, list);
                }
            }
        }
Esempio n. 2
0
        /// <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]);
        }
Esempio n. 3
0
        public MMALPortBase ConnectTo(MMALDownstreamComponent destinationComponent, int inputPort = 0)
        {
            if (MMALCamera.Instance.Connections.Any(c => c.UpstreamComponent == this.ComponentReference &&
                                                    c.DownstreamComponent == destinationComponent))
            {
                MMALLog.Logger.Warn("A connection has already been established between these components");
                return(destinationComponent.Inputs[inputPort]);
            }

            var connection = MMALConnectionImpl.CreateConnection(this, destinationComponent.Inputs[inputPort], destinationComponent);

            MMALCamera.Instance.Connections.Add(connection);

            return(destinationComponent.Inputs[inputPort]);
        }
Esempio n. 4
0
        /// <summary>
        /// Facility to create a connection between two port objects
        /// </summary>
        /// <param name="output">The output port of the connection</param>
        /// <param name="input">The input port of the connection</param>
        /// <returns></returns>
        internal static MMALConnectionImpl CreateConnection(MMALPortBase output, MMALPortBase input, MMALDownstreamComponent inputComponent)
        {
            IntPtr ptr = IntPtr.Zero;

            MMALCheck(MMALConnection.mmal_connection_create(&ptr, output.Ptr, input.Ptr, MMALConnection.MMAL_CONNECTION_FLAG_TUNNELLING | MMALConnection.MMAL_CONNECTION_FLAG_ALLOCATION_ON_INPUT), "Unable to create connection");

            return(new MMALConnectionImpl((MMAL_CONNECTION_T *)ptr, output, input, inputComponent, output.ComponentReference));
        }
Esempio n. 5
0
 protected MMALConnectionImpl(MMAL_CONNECTION_T *ptr, MMALPortBase output, MMALPortBase input, MMALDownstreamComponent inputComponent, MMALComponentBase outputComponent)
 {
     this.Ptr                 = ptr;
     this.OutputPort          = output;
     this.InputPort           = input;
     this.DownstreamComponent = inputComponent;
     this.UpstreamComponent   = outputComponent;
     this.Enable();
 }
Esempio n. 6
0
        protected MMALConnectionImpl(MMAL_CONNECTION_T *ptr, MMALPortBase output, MMALPortBase input, MMALDownstreamComponent inputComponent, MMALComponentBase outputComponent, bool useCallback)
        {
            this.Ptr                 = ptr;
            this.OutputPort          = output;
            this.InputPort           = input;
            this.DownstreamComponent = inputComponent;
            this.UpstreamComponent   = outputComponent;


            if (useCallback)
            {
                this.ConfigureConnectionCallback(output, input);
            }

            this.Enable();

            if (useCallback)
            {
                this.OutputPort.SendAllBuffers();
            }
        }
Esempio n. 7
0
 /// <inheritdoc />
 public override InputPortBase ConnectTo(MMALDownstreamComponent destinationComponent, int inputPort, Func <PortBase> callback)
 {
     this.ConnectTo(destinationComponent, inputPort);
     callback();
     return(destinationComponent.Inputs[inputPort]);
 }