/// <inheritdoc /> public override IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IInputCaptureHandler handler) { var bufferNum = Math.Max(this.Inputs[0].BufferNumRecommended, 3); config = new MMALPortConfig(config.EncodingType, config.PixelFormat, config.Width, config.Height, config.Framerate, config.Quality, config.Bitrate, config.ZeroCopy, config.Timeout, bufferNum, config.BufferSize, config.Crop, config.StoreMotionVectors); base.ConfigureInputPort(config, handler); return(this); }
/// <summary> /// Call to configure changes on a downstream component input port. /// </summary> /// <typeparam name="TPort">Input port type.</typeparam> /// <param name="config">User provided port configuration object.</param> /// <param name="handler">The input port capture handler.</param> /// <returns>This <see cref="MMALDownstreamComponent"/>.</returns> public virtual unsafe IDownstreamComponent ConfigureInputPort <TPort>(MMALPortConfig config, IInputCaptureHandler handler) where TPort : IInputPort { this.Inputs[0] = (IInputPort)Activator.CreateInstance(typeof(TPort), (IntPtr)(&(*this.Ptr->Input[0])), this, Guid.NewGuid()); return(this.ConfigureInputPort(config, null, handler)); }
/// <summary> /// Configures a specific input port on a downstream component. This method will perform a shallow copy of the output /// port it is to be connected to. /// </summary> /// <param name="config">User provided port configuration object.</param> /// <param name="copyPort">The output port we are copying format data from.</param> /// <param name="handler">The input port capture handler. This will be non-null if this port's component is the 1st component in the /// pipeline and you are feeding data to it directly from a <see cref="IInputCaptureHandler"/>. If this port is connected to by another component then leave this parameter null. /// </param> /// <returns>This <see cref="MMALDownstreamComponent"/>.</returns> public virtual unsafe IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) { this.Inputs[0].Configure(config, copyPort, handler); if (this.Outputs.Count > 0 && this.Outputs[0].Ptr->Format->Type == MMALFormat.MMAL_ES_TYPE_T.MMAL_ES_TYPE_UNKNOWN) { throw new PiCameraError("Unable to determine settings for output port."); } return(this); }
/// <summary> /// Call to configure changes on a downstream component input port. /// </summary> /// <param name="config">User provided port configuration object.</param> /// <param name="handler">The input port capture handler. This will be non-null if this port's component is the 1st component in the /// pipeline and you are feeding data to it directly from a <see cref="IInputCaptureHandler"/>. If this port is connected to by another component then leave this parameter null. /// </param> /// <returns>This <see cref="MMALDownstreamComponent"/>.</returns> public virtual IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCaptureHandler handler) { return(this.ConfigureInputPort(config, null, handler)); }
/// <summary> /// Call to configure an input port. /// </summary> /// <param name="config">The port configuration object.</param> /// <param name="copyPort">The port to copy from.</param> /// <param name="handler">The capture handler to assign to this port.</param> public virtual void Configure(IMMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) { copyPort?.ShallowCopy(this); if (config != null) { this.PortConfig = config; if (config.EncodingType != null) { this.NativeEncodingType = config.EncodingType.EncodingVal; } if (config.PixelFormat != null) { this.NativeEncodingSubformat = config.PixelFormat.EncodingVal; } if (config.Width > 0 && config.Height > 0) { if (config.Crop.HasValue) { this.Crop = config.Crop.Value; } else { this.Crop = new Rectangle(0, 0, config.Width, config.Height); } this.Resolution = new Resolution(config.Width, config.Height); } else { // Use config or don't set depending on port type. this.Resolution = new Resolution(0, 0); // Certain resolution overrides set to global config Video/Still resolutions so check here if the width and height are greater than 0. if (this.Resolution.Width > 0 && this.Resolution.Height > 0) { this.Crop = new Rectangle(0, 0, this.Resolution.Width, this.Resolution.Height); } } if (config.Framerate > 0) { this.FrameRate = config.Framerate; } if (config.Bitrate > 0) { this.Bitrate = config.Bitrate; } this.EncodingType = config.EncodingType; if (config.ZeroCopy) { this.ZeroCopy = true; this.SetParameter(MMALParametersCommon.MMAL_PARAMETER_ZERO_COPY, true); } this.BufferNum = Math.Max(this.BufferNumMin, config.BufferNum > 0 ? config.BufferNum : this.BufferNumRecommended); this.BufferSize = Math.Max(this.BufferSizeMin, config.BufferSize > 0 ? config.BufferSize : this.BufferSizeRecommended); this.Commit(); this.CallbackHandler = new DefaultInputPortCallbackHandler(this, handler); } }
/// <inheritdoc /> public override IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCaptureHandler handler) { config.BufferNum = Math.Max(this.Inputs[0].BufferNumRecommended, 3); base.ConfigureInputPort(config, handler); return(this); }