Example #1
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();
 }
Example #2
0
        /// <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>
        /// 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>
        protected virtual int NativeConnectionCallback(MMAL_CONNECTION_T *connection)
        {
            if (MMALCameraConfig.Debug)
            {
                MMALLog.Logger.LogDebug("Inside native connection callback");
            }

            var queue      = new MMALQueueImpl(connection->Queue);
            var bufferImpl = queue.GetBuffer();

            if (bufferImpl.CheckState())
            {
                if (MMALCameraConfig.Debug)
                {
                    bufferImpl.PrintProperties();
                }

                if (bufferImpl.Length > 0)
                {
                    this.CallbackHandler.InputCallback(bufferImpl);
                }

                this.InputPort.SendBuffer(bufferImpl);
            }
            else
            {
                queue      = new MMALQueueImpl(connection->Pool->Queue);
                bufferImpl = queue.GetBuffer();

                if (bufferImpl.CheckState())
                {
                    if (MMALCameraConfig.Debug)
                    {
                        bufferImpl.PrintProperties();
                    }

                    if (bufferImpl.Length > 0)
                    {
                        this.CallbackHandler.OutputCallback(bufferImpl);
                    }

                    this.OutputPort.SendBuffer(bufferImpl);
                }
                else
                {
                    MMALLog.Logger.LogInformation("Buffer could not be obtained by connection callback");
                }
            }

            return((int)connection->Flags);
        }
Example #4
0
        /// <summary>
        /// Creates a new instance of <see cref="MMALConnectionImpl"/>.
        /// </summary>
        /// <param name="ptr">The native connection pointer.</param>
        /// <param name="output">The upstream component's output port.</param>
        /// <param name="input">The downstream component's input port.</param>
        /// <param name="inputComponent">The upstream component.</param>
        /// <param name="outputComponent">The downstream component.</param>
        /// <param name="useCallback">Configure the connection to intercept native callbacks. Note: will adversely impact performance.</param>
        protected MMALConnectionImpl(MMAL_CONNECTION_T *ptr, OutputPortBase output, InputPortBase 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(this.ConnectionPool);
            }
        }
        /// <summary>
        /// Creates a new instance of <see cref="MMALConnectionImpl"/>.
        /// </summary>
        /// <param name="ptr">The native connection pointer.</param>
        /// <param name="output">The upstream component's output port.</param>
        /// <param name="input">The downstream component's input port.</param>
        /// <param name="inputComponent">The upstream component.</param>
        /// <param name="outputComponent">The downstream component.</param>
        /// <param name="useCallback">
        /// Configure the connection to intercept native callbacks. Note: will adversely impact performance. In addition, this will implicitly enable
        /// zero copy functionality on both the source and sink ports.
        /// </param>
        protected MMALConnectionImpl(MMAL_CONNECTION_T *ptr, IOutputPort output, IInputPort input, IDownstreamComponent inputComponent, IComponent outputComponent, bool useCallback)
        {
            this.Ptr                 = ptr;
            this.OutputPort          = output;
            this.InputPort           = input;
            this.DownstreamComponent = inputComponent;
            this.UpstreamComponent   = outputComponent;

            if (useCallback)
            {
                this.CallbackHandler = new DefaultConnectionCallbackHandler(this);
                this.ConfigureConnectionCallback(output, input);
            }

            this.Enable();

            if (useCallback)
            {
                this.OutputPort.SendAllBuffers(this.ConnectionPool);
            }
        }
Example #6
0
 public static extern unsafe MMALUtil.MMAL_STATUS_T mmal_connection_event_format_changed(MMAL_CONNECTION_T *connection, MMAL_BUFFER_HEADER_T *buffer);
Example #7
0
 public static extern unsafe MMALUtil.MMAL_STATUS_T mmal_connection_disable(MMAL_CONNECTION_T *connection);
Example #8
0
 public static extern unsafe void mmal_connection_acquire(MMAL_CONNECTION_T *connection);
Example #9
0
 public static unsafe extern MMALUtil.MMAL_STATUS_T mmal_connection_enable(MMAL_CONNECTION_T *connection);