diff --git a/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs b/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs
index 632cec81..7ca13513 100644
--- a/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs
+++ b/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs
@@ -89,9 +89,9 @@ public MMALImageEncoder(bool rawBayer = false, bool useExif = true, bool continu
}
///
- public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler)
+ public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler, IInputPort copyFrom = null)
{
- base.ConfigureOutputPort(outputPort, config, handler);
+ base.ConfigureOutputPort(outputPort, config, handler, copyFrom);
if (this.RawBayer)
{
diff --git a/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs b/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs
index 1d041328..457ed967 100644
--- a/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs
+++ b/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs
@@ -62,7 +62,7 @@ public MMALVideoEncoder()
}
///
- public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler)
+ public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler, IInputPort copyFrom = null)
{
this.Quality = config.Quality;
@@ -86,7 +86,7 @@ public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPo
config.Quality, bitrate, config.ZeroCopy, config.Timeout, config.BufferNum, bufferSize, config.Crop,
config.StoreMotionVectors);
- base.ConfigureOutputPort(outputPort, config, handler);
+ base.ConfigureOutputPort(outputPort, config, handler, copyFrom);
if (this.Outputs[outputPort].EncodingType == MMALEncoding.H264)
{
diff --git a/src/MMALSharp/Components/IDownstreamComponent.cs b/src/MMALSharp/Components/IDownstreamComponent.cs
index 3cb16deb..552388da 100644
--- a/src/MMALSharp/Components/IDownstreamComponent.cs
+++ b/src/MMALSharp/Components/IDownstreamComponent.cs
@@ -67,8 +67,9 @@ IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IInputCap
/// The output port number.
/// The port configuration object.
/// The capture handler to use with this port.
+ /// Optional port to copy format from.
/// This component.
- IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler);
+ IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler, IInputPort copyFrom = null);
///
/// Configures the output port. In addition, it will create a new instance of the port
diff --git a/src/MMALSharp/Components/MMALDownstreamComponent.cs b/src/MMALSharp/Components/MMALDownstreamComponent.cs
index 59f0b728..e8d667a3 100644
--- a/src/MMALSharp/Components/MMALDownstreamComponent.cs
+++ b/src/MMALSharp/Components/MMALDownstreamComponent.cs
@@ -104,8 +104,9 @@ public virtual IDownstreamComponent ConfigureOutputPort(IMMALPortConfig config,
/// The output port number to configure.
/// User provided port configuration object.
/// The output port capture handler.
+ /// Optional port to copy format from.
/// This .
- public virtual IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler)
+ public virtual IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler, IInputPort copyFrom = null)
{
if (this.ProcessingPorts.ContainsKey(outputPort))
{
@@ -114,7 +115,14 @@ public virtual IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPor
this.ProcessingPorts.Add(outputPort, this.Outputs[outputPort]);
- this.Outputs[outputPort].Configure(config, this.Inputs[0], handler);
+ if (copyFrom != null)
+ {
+ this.Outputs[outputPort].Configure(config, copyFrom, handler);
+ }
+ else
+ {
+ this.Outputs[outputPort].Configure(config, this.Inputs[0], handler);
+ }
return this;
}
diff --git a/src/MMALSharp/Components/MMALRawcamComponent.cs b/src/MMALSharp/Components/MMALRawcamComponent.cs
index 5ece4175..1ee84839 100644
--- a/src/MMALSharp/Components/MMALRawcamComponent.cs
+++ b/src/MMALSharp/Components/MMALRawcamComponent.cs
@@ -36,8 +36,7 @@ public class MMALRawcamComponent : MMALDownstreamHandlerComponent
public unsafe MMALRawcamComponent()
: base(MMAL_COMPONENT_RAWCAM)
{
- // Default to use still image port behaviour.
- this.Inputs.Add(new InputPort((IntPtr)(&(*this.Ptr->Input[0])), this, Guid.NewGuid()));
+ // Default to use still image port behaviour.
this.Outputs.Add(new StillPort((IntPtr)(&(*this.Ptr->Output[0])), this, Guid.NewGuid()));
}
@@ -47,20 +46,19 @@ public unsafe MMALRawcamComponent()
/// The user defined output port type.
public unsafe MMALRawcamComponent(Type outputPortType)
: base(MMAL_COMPONENT_RAWCAM)
- {
- this.Inputs.Add(new InputPort((IntPtr)(&(*this.Ptr->Input[0])), this, Guid.NewGuid()));
+ {
this.Outputs.Add((IOutputPort)Activator.CreateInstance(outputPortType, (IntPtr)(&(*this.Ptr->Output[0])), this, Guid.NewGuid()));
}
-
+
///
- public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler)
- {
+ public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler, IInputPort copyFrom = null)
+ {
if (config is MMALRawcamPortConfig)
{
var rawcamConfig = config as MMALRawcamPortConfig;
this.ConfigureCameraInterface(rawcamConfig.CameraInterface);
- this.ConfigureCameraClockingMode(rawcamConfig.ClockingMode);
+ // this.ConfigureCameraClockingMode(rawcamConfig.ClockingMode);
this.ConfigureCameraRxConfig(rawcamConfig.RxConfig);
this.ConfigureTimingRegisters(rawcamConfig.TimingConfig);
}
@@ -68,8 +66,8 @@ public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPo
{
MMALLog.Logger.LogWarning($"Rawcam component should be given port configuration of type {nameof(MMALRawcamPortConfig)}. Defaults will be used.");
}
-
- return base.ConfigureOutputPort(outputPort, config, handler);
+
+ return base.ConfigureOutputPort(outputPort, config, handler, copyFrom);
}
private unsafe void ConfigureCameraInterface(MMAL_CAMERA_INTERFACE_T cameraInterface)
@@ -83,7 +81,7 @@ private unsafe void ConfigureCameraInterface(MMAL_CAMERA_INTERFACE_T cameraInter
try
{
MMALCheck(
- MMALPort.mmal_port_parameter_set(this.Inputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
+ MMALPort.mmal_port_parameter_set(this.Outputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
"Unable to set camera interface type.");
}
finally
@@ -103,7 +101,7 @@ private unsafe void ConfigureCameraClockingMode(MMAL_CAMERA_CLOCKING_MODE_T cloc
try
{
MMALCheck(
- MMALPort.mmal_port_parameter_set(this.Inputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
+ MMALPort.mmal_port_parameter_set(this.Outputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
"Unable to set camera clocking mode.");
}
finally
@@ -124,7 +122,7 @@ private unsafe void ConfigureCameraRxConfig(MMALRawcamRxConfig rxConfig)
try
{
MMALCheck(
- MMALPort.mmal_port_parameter_set(this.Inputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
+ MMALPort.mmal_port_parameter_set(this.Outputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
"Unable to set camera peripheral config.");
}
finally
@@ -146,7 +144,7 @@ private unsafe void ConfigureTimingRegisters(MMALRawcamTimingConfig timingConfig
try
{
MMALCheck(
- MMALPort.mmal_port_parameter_set(this.Inputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
+ MMALPort.mmal_port_parameter_set(this.Outputs[0].Ptr, (MMAL_PARAMETER_HEADER_T*)ptr),
"Unable to set camera timing registers.");
}
finally
diff --git a/src/MMALSharp/Components/MMALSplitterComponent.cs b/src/MMALSharp/Components/MMALSplitterComponent.cs
index 7e7232af..2d823336 100644
--- a/src/MMALSharp/Components/MMALSplitterComponent.cs
+++ b/src/MMALSharp/Components/MMALSplitterComponent.cs
@@ -46,19 +46,5 @@ public override IDownstreamComponent ConfigureInputPort(IMMALPortConfig config,
return this;
}
-
- ///
- 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;
- }
}
}
diff --git a/src/MMALSharp/Ports/MMALRawcamPortConfig.cs b/src/MMALSharp/Ports/MMALRawcamPortConfig.cs
index ac9ea75f..2711c02d 100644
--- a/src/MMALSharp/Ports/MMALRawcamPortConfig.cs
+++ b/src/MMALSharp/Ports/MMALRawcamPortConfig.cs
@@ -39,17 +39,16 @@ public class MMALRawcamPortConfig : MMALPortConfig
/// The encoding type. Set this to specify the output format. Colour format should be
/// RGB565, RGB888, ABGR8888, YUV420 packed planar, YUV422 packed
/// planar, or one of the flavours of YUYV.
- /// The pixel format.
- /// The output bitrate.
+ /// The pixel format.
/// Video record timeout.
/// The physical camera interface type.
/// Camera peripheral clocking mode.
/// The receiver peripheral configuration for unpacking/packing DPCM, and decoding or encoding Bayer images.
/// Camera peripheral timing registers.
- public MMALRawcamPortConfig(MMALEncoding encodingType, MMALEncoding pixelFormat, int bitrate, DateTime? timeout,
+ public MMALRawcamPortConfig(MMALEncoding encodingType, MMALEncoding pixelFormat, DateTime? timeout,
MMAL_CAMERA_INTERFACE_T cameraInterface, MMAL_CAMERA_CLOCKING_MODE_T clockingMode, MMALRawcamRxConfig rxConfig,
MMALRawcamTimingConfig timingConfig)
- : base(encodingType, pixelFormat, 0, bitrate, timeout, null, false)
+ : base(encodingType, pixelFormat, 0, 0, 0, 0, 0, true, timeout)
{
this.CameraInterface = cameraInterface;
this.ClockingMode = clockingMode;