From 9f5011a2663340e522c0846bfbc85c806cbcd3e8 Mon Sep 17 00:00:00 2001 From: techyian Date: Sun, 19 Jan 2020 11:30:50 +0000 Subject: [PATCH] #47. Port configuration to accept IMMALPortConfig. --- .../Callbacks/PortCallbackHandler.cs | 2 + .../EncoderComponents/MMALImageEncoder.cs | 2 +- .../EncoderComponents/MMALVideoEncoder.cs | 25 ++++-- .../Components/IDownstreamComponent.cs | 12 +-- .../Components/MMALDownstreamComponent.cs | 12 +-- .../Components/MMALSplitterComponent.cs | 16 +++- src/MMALSharp/Ports/IMMALPortConfig.cs | 80 +++++++++++++++++++ src/MMALSharp/Ports/IPort.cs | 2 +- src/MMALSharp/Ports/Inputs/IInputPort.cs | 2 +- src/MMALSharp/Ports/Inputs/InputPort.cs | 8 +- src/MMALSharp/Ports/MMALPortConfig.cs | 30 +++---- src/MMALSharp/Ports/Outputs/FastStillPort.cs | 2 +- src/MMALSharp/Ports/Outputs/IOutputPort.cs | 2 +- src/MMALSharp/Ports/Outputs/OutputPort.cs | 2 +- .../Ports/Outputs/SplitterVideoPort.cs | 2 +- src/MMALSharp/Ports/Outputs/StillPort.cs | 2 +- src/MMALSharp/Ports/Outputs/VideoPort.cs | 2 +- src/MMALSharp/Ports/PortBase.cs | 9 ++- 18 files changed, 160 insertions(+), 52 deletions(-) create mode 100644 src/MMALSharp/Ports/IMMALPortConfig.cs diff --git a/src/MMALSharp/Callbacks/PortCallbackHandler.cs b/src/MMALSharp/Callbacks/PortCallbackHandler.cs index 001ca559..157a559a 100644 --- a/src/MMALSharp/Callbacks/PortCallbackHandler.cs +++ b/src/MMALSharp/Callbacks/PortCallbackHandler.cs @@ -76,6 +76,8 @@ public virtual void Callback(IBuffer buffer) var eos = buffer.AssertProperty(MMALBufferProperties.MMAL_BUFFER_HEADER_FLAG_FRAME_END) || buffer.AssertProperty(MMALBufferProperties.MMAL_BUFFER_HEADER_FLAG_EOS); + MMALLog.Logger.LogDebug("Attempting to process data."); + this.CaptureHandler?.Process(data, eos); if (eos) diff --git a/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs b/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs index 8520141b..632cec81 100644 --- a/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs +++ b/src/MMALSharp/Components/EncoderComponents/MMALImageEncoder.cs @@ -89,7 +89,7 @@ public MMALImageEncoder(bool rawBayer = false, bool useExif = true, bool continu } /// - public override IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config, IOutputCaptureHandler handler) + public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler) { base.ConfigureOutputPort(outputPort, config, handler); diff --git a/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs b/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs index 64122665..1d041328 100644 --- a/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs +++ b/src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs @@ -62,24 +62,29 @@ public MMALVideoEncoder() } /// - public override IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config, IOutputCaptureHandler handler) + public override IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler) { this.Quality = config.Quality; + + var bufferSize = 0; + var framerate = 0; if (config.EncodingType == MMALEncoding.H264) { - config.BufferSize = Math.Max(this.Outputs[outputPort].Ptr->BufferSizeRecommended, this.Outputs[outputPort].Ptr->BufferSizeMin); + bufferSize = Math.Max(this.Outputs[outputPort].Ptr->BufferSizeRecommended, this.Outputs[outputPort].Ptr->BufferSizeMin); } else { // Follow raspivid logic. - config.BufferSize = Math.Max(this.Outputs[outputPort].Ptr->BufferSizeRecommended, 256 << 10); + bufferSize = Math.Max(this.Outputs[outputPort].Ptr->BufferSizeRecommended, 256 << 10); } + + var bitrate = this.GetValidBitrate(outputPort, config); // Force framerate to be 0 in case it was provided by user. - config.Framerate = 0; - - this.ConfigureBitrate(outputPort, config); + config = new MMALPortConfig(config.EncodingType, config.PixelFormat, config.Width, config.Height, framerate, + config.Quality, bitrate, config.ZeroCopy, config.Timeout, config.BufferNum, bufferSize, config.Crop, + config.StoreMotionVectors); base.ConfigureOutputPort(outputPort, config, handler); @@ -103,8 +108,10 @@ public override IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPor return this; } - private void ConfigureBitrate(int outputPort, MMALPortConfig config) + private int GetValidBitrate(int outputPort, IMMALPortConfig config) { + var bitrate = config.Bitrate; + if (this.Outputs[outputPort].EncodingType == MMALEncoding.H264) { List levelList = null; @@ -134,9 +141,11 @@ private void ConfigureBitrate(int outputPort, MMALPortConfig config) if (this.Outputs[outputPort].Bitrate > MaxBitrateMJPEG) { MMALLog.Logger.LogWarning("Bitrate too high: Reducing to 25MBit/s"); - config.Bitrate = MaxBitrateMJPEG; + bitrate = MaxBitrateMJPEG; } } + + return bitrate; } private void ConfigureRateControl(int outputPort) diff --git a/src/MMALSharp/Components/IDownstreamComponent.cs b/src/MMALSharp/Components/IDownstreamComponent.cs index 4f66b534..3cb16deb 100644 --- a/src/MMALSharp/Components/IDownstreamComponent.cs +++ b/src/MMALSharp/Components/IDownstreamComponent.cs @@ -28,7 +28,7 @@ public interface IDownstreamComponent : IComponent /// The port to copy from. /// The capture handler to use with this port. /// This component. - IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IPort copyPort, IInputCaptureHandler handler); + IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IPort copyPort, IInputCaptureHandler handler); /// /// Call to configure changes on a downstream component input port. @@ -38,7 +38,7 @@ public interface IDownstreamComponent : IComponent /// pipeline and you are feeding data to it directly from a . If this port is connected to by another component then leave this parameter null. /// /// This . - IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCaptureHandler handler); + IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IInputCaptureHandler handler); /// /// Configures the input port. In addition, it will create a new instance of the port @@ -50,7 +50,7 @@ public interface IDownstreamComponent : IComponent /// pipeline and you are feeding data to it directly from a . If this port is connected to by another component then leave this parameter null. /// /// This component. - IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCaptureHandler handler) + IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IInputCaptureHandler handler) where TPort : IInputPort; /// @@ -59,7 +59,7 @@ IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCapt /// The port configuration object. /// The output port capture handler. /// This component. - IDownstreamComponent ConfigureOutputPort(MMALPortConfig config, IOutputCaptureHandler handler); + IDownstreamComponent ConfigureOutputPort(IMMALPortConfig config, IOutputCaptureHandler handler); /// /// Configures the output port. @@ -68,7 +68,7 @@ IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCapt /// The port configuration object. /// The capture handler to use with this port. /// This component. - IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config, IOutputCaptureHandler handler); + IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler); /// /// Configures the output port. In addition, it will create a new instance of the port @@ -79,7 +79,7 @@ IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCapt /// The port configuration object. /// The capture handler to use with this port. /// This component. - IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config, IOutputCaptureHandler handler) + IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler) where TPort : IOutputPort; } } diff --git a/src/MMALSharp/Components/MMALDownstreamComponent.cs b/src/MMALSharp/Components/MMALDownstreamComponent.cs index 68bbfa16..59f0b728 100644 --- a/src/MMALSharp/Components/MMALDownstreamComponent.cs +++ b/src/MMALSharp/Components/MMALDownstreamComponent.cs @@ -45,7 +45,7 @@ protected MMALDownstreamComponent(string name) /// pipeline and you are feeding data to it directly from a . If this port is connected to by another component then leave this parameter null. /// /// This . - public virtual IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCaptureHandler handler) + public virtual IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IInputCaptureHandler handler) { return this.ConfigureInputPort(config, null, handler); } @@ -60,7 +60,7 @@ public virtual IDownstreamComponent ConfigureInputPort(MMALPortConfig config, II /// pipeline and you are feeding data to it directly from a . If this port is connected to by another component then leave this parameter null. /// /// This . - public virtual unsafe IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) + public virtual unsafe IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) { this.Inputs[0].Configure(config, copyPort, handler); @@ -79,7 +79,7 @@ public virtual unsafe IDownstreamComponent ConfigureInputPort(MMALPortConfig con /// User provided port configuration object. /// The input port capture handler. /// This . - public virtual unsafe IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCaptureHandler handler) + public virtual unsafe IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IInputCaptureHandler handler) where TPort : IInputPort { this.Inputs[0] = (IInputPort)Activator.CreateInstance(typeof(TPort), (IntPtr)(&(*this.Ptr->Input[0])), this, Guid.NewGuid()); @@ -93,7 +93,7 @@ public virtual unsafe IDownstreamComponent ConfigureInputPort(MMALPortCon /// User provided port configuration object. /// The output port capture handler. /// This . - public virtual IDownstreamComponent ConfigureOutputPort(MMALPortConfig config, IOutputCaptureHandler handler) + public virtual IDownstreamComponent ConfigureOutputPort(IMMALPortConfig config, IOutputCaptureHandler handler) { return this.ConfigureOutputPort(0, config, handler); } @@ -105,7 +105,7 @@ public virtual IDownstreamComponent ConfigureOutputPort(MMALPortConfig config, I /// User provided port configuration object. /// The output port capture handler. /// This . - public virtual IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config, IOutputCaptureHandler handler) + public virtual IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler) { if (this.ProcessingPorts.ContainsKey(outputPort)) { @@ -127,7 +127,7 @@ public virtual IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPort /// User provided port configuration object. /// The output port capture handler. /// This . - public virtual unsafe IDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config, IOutputCaptureHandler handler) + public virtual unsafe IDownstreamComponent ConfigureOutputPort(int outputPort, IMMALPortConfig config, IOutputCaptureHandler handler) where TPort : IOutputPort { this.Outputs[outputPort] = (IOutputPort)Activator.CreateInstance(typeof(TPort), (IntPtr)(&(*this.Ptr->Output[outputPort])), this, Guid.NewGuid()); diff --git a/src/MMALSharp/Components/MMALSplitterComponent.cs b/src/MMALSharp/Components/MMALSplitterComponent.cs index 975278a1..7e7232af 100644 --- a/src/MMALSharp/Components/MMALSplitterComponent.cs +++ b/src/MMALSharp/Components/MMALSplitterComponent.cs @@ -34,9 +34,13 @@ public unsafe MMALSplitterComponent() } /// - public override IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) + public override IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) { - config.BufferNum = Math.Max(this.Inputs[0].BufferNumRecommended, 3); + 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, copyPort, handler); @@ -44,9 +48,13 @@ public override IDownstreamComponent ConfigureInputPort(MMALPortConfig config, I } /// - public override IDownstreamComponent ConfigureInputPort(MMALPortConfig config, IInputCaptureHandler handler) + public override IDownstreamComponent ConfigureInputPort(IMMALPortConfig config, IInputCaptureHandler handler) { - config.BufferNum = Math.Max(this.Inputs[0].BufferNumRecommended, 3); + 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); diff --git a/src/MMALSharp/Ports/IMMALPortConfig.cs b/src/MMALSharp/Ports/IMMALPortConfig.cs new file mode 100644 index 00000000..133e5e79 --- /dev/null +++ b/src/MMALSharp/Ports/IMMALPortConfig.cs @@ -0,0 +1,80 @@ +using MMALSharp.Config; +using MMALSharp.Native; +using System; +using System.Drawing; + +namespace MMALSharp.Ports +{ + public interface IMMALPortConfig + { + /// + /// The encoding type this output port will send data in. + /// + MMALEncoding EncodingType { get; } + + /// + /// The pixel format this output port will send data in. + /// + MMALEncoding PixelFormat { get; } + + /// + /// User provided width of output frame. + /// + int Width { get; } + + /// + /// User provided height of output frame. + /// + int Height { get; } + + /// + /// The framerate of the outputted data. + /// + int Framerate { get; } + + /// + /// The quality of our outputted data. + /// + int Quality { get; } + + /// + /// The bitrate we are sending data at. + /// + int Bitrate { get; } + + /// + /// Instruct MMAL to not copy buffers to ARM memory (useful for large buffers and handling raw data). + /// + bool ZeroCopy { get; } + + /// + /// Time that processing shall stop. Relevant for video recording. + /// + DateTime? Timeout { get; } + + /// + /// Requested number of buffer headers. + /// + int BufferNum { get; } + + /// + /// Requested size of buffer headers. + /// + int BufferSize { get; } + + /// + /// The Region of Interest requested. + /// + Rectangle? Crop { get; } + + /// + /// Video split configuration object. + /// + Split Split { get; } + + /// + /// Indicates whether motion vector data should be stored to a separate output stream. Only applies to Video recording. + /// + bool StoreMotionVectors { get; } + } +} diff --git a/src/MMALSharp/Ports/IPort.cs b/src/MMALSharp/Ports/IPort.cs index 675a28f4..a02f7ebc 100644 --- a/src/MMALSharp/Ports/IPort.cs +++ b/src/MMALSharp/Ports/IPort.cs @@ -60,7 +60,7 @@ public interface IPort : IMMALObject /// /// The config for this port. /// - MMALPortConfig PortConfig { get; } + IMMALPortConfig PortConfig { get; } /// /// Native name of port. diff --git a/src/MMALSharp/Ports/Inputs/IInputPort.cs b/src/MMALSharp/Ports/Inputs/IInputPort.cs index ac54e2f5..ed3dd98e 100644 --- a/src/MMALSharp/Ports/Inputs/IInputPort.cs +++ b/src/MMALSharp/Ports/Inputs/IInputPort.cs @@ -28,7 +28,7 @@ public interface IInputPort : IPort /// The port configuration object. /// The port to copy from. /// The capture handler to assign to this port. - void Configure(MMALPortConfig config, IPort copyPort, IInputCaptureHandler handler); + void Configure(IMMALPortConfig config, IPort copyPort, IInputCaptureHandler handler); /// /// Enables processing on an input port. diff --git a/src/MMALSharp/Ports/Inputs/InputPort.cs b/src/MMALSharp/Ports/Inputs/InputPort.cs index 34f7a653..819ac71f 100644 --- a/src/MMALSharp/Ports/Inputs/InputPort.cs +++ b/src/MMALSharp/Ports/Inputs/InputPort.cs @@ -61,7 +61,7 @@ public void ConnectTo(IOutputPort outputPort, IConnection connection) /// The port configuration object. /// The port to copy from. /// The capture handler to assign to this port. - public virtual void Configure(MMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) + public virtual void Configure(IMMALPortConfig config, IPort copyPort, IInputCaptureHandler handler) { copyPort?.ShallowCopy(this); @@ -184,7 +184,11 @@ public virtual void ReleaseBuffer(IBuffer bufferImpl) // Populate the new input buffer with user provided image data. var result = this.CallbackHandler.CallbackWithResult(newBuffer); - newBuffer.ReadIntoBuffer(result.BufferFeed, result.DataLength, result.EOF); + + if (result.Success) + { + newBuffer.ReadIntoBuffer(result.BufferFeed, result.DataLength, result.EOF); + } this.SendBuffer(newBuffer); diff --git a/src/MMALSharp/Ports/MMALPortConfig.cs b/src/MMALSharp/Ports/MMALPortConfig.cs index 2621f52c..9527b538 100644 --- a/src/MMALSharp/Ports/MMALPortConfig.cs +++ b/src/MMALSharp/Ports/MMALPortConfig.cs @@ -13,77 +13,77 @@ namespace MMALSharp.Ports /// /// Port configuration class. /// - public class MMALPortConfig + public class MMALPortConfig : IMMALPortConfig { /// /// The encoding type this output port will send data in. /// - public MMALEncoding EncodingType { get; set; } + public MMALEncoding EncodingType { get; } /// /// The pixel format this output port will send data in. /// - public MMALEncoding PixelFormat { get; set; } + public MMALEncoding PixelFormat { get; } /// /// User provided width of output frame. /// - public int Width { get; set; } + public int Width { get; } /// /// User provided height of output frame. /// - public int Height { get; set; } + public int Height { get; } /// /// The framerate of the outputted data. /// - public int Framerate { get; set; } + public int Framerate { get; } /// /// The quality of our outputted data. /// - public int Quality { get; set; } + public int Quality { get; } /// /// The bitrate we are sending data at. /// - public int Bitrate { get; set; } + public int Bitrate { get; } /// /// Instruct MMAL to not copy buffers to ARM memory (useful for large buffers and handling raw data). /// - public bool ZeroCopy { get; set; } + public bool ZeroCopy { get; } /// /// Time that processing shall stop. Relevant for video recording. /// - public DateTime? Timeout { get; set; } + public DateTime? Timeout { get; } /// /// Requested number of buffer headers. /// - public int BufferNum { get; set; } + public int BufferNum { get; } /// /// Requested size of buffer headers. /// - public int BufferSize { get; set; } + public int BufferSize { get; } /// /// The Region of Interest requested. /// - public Rectangle? Crop { get; set; } + public Rectangle? Crop { get; } /// /// Video split configuration object. /// - public Split Split { get; set; } + public Split Split { get; } /// /// Indicates whether motion vector data should be stored to a separate output stream. Only applies to Video recording. /// - public bool StoreMotionVectors { get; set; } + public bool StoreMotionVectors { get; } /// /// Create a new instance of with parameters useful for image capture. diff --git a/src/MMALSharp/Ports/Outputs/FastStillPort.cs b/src/MMALSharp/Ports/Outputs/FastStillPort.cs index 269dc0ff..ee95687c 100644 --- a/src/MMALSharp/Ports/Outputs/FastStillPort.cs +++ b/src/MMALSharp/Ports/Outputs/FastStillPort.cs @@ -60,7 +60,7 @@ public FastStillPort(IPort copyFrom) } /// - public override void Configure(MMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) + public override void Configure(IMMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) { base.Configure(config, copyFrom, handler); diff --git a/src/MMALSharp/Ports/Outputs/IOutputPort.cs b/src/MMALSharp/Ports/Outputs/IOutputPort.cs index 4e214310..547e99d1 100644 --- a/src/MMALSharp/Ports/Outputs/IOutputPort.cs +++ b/src/MMALSharp/Ports/Outputs/IOutputPort.cs @@ -21,7 +21,7 @@ public interface IOutputPort : IPort /// The port configuration object. /// The port to copy from. /// The capture handler to assign to this port. - void Configure(MMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler); + void Configure(IMMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler); /// /// Connects two components together by their input and output ports. diff --git a/src/MMALSharp/Ports/Outputs/OutputPort.cs b/src/MMALSharp/Ports/Outputs/OutputPort.cs index 901f2870..6eb28a48 100644 --- a/src/MMALSharp/Ports/Outputs/OutputPort.cs +++ b/src/MMALSharp/Ports/Outputs/OutputPort.cs @@ -50,7 +50,7 @@ public OutputPort(IntPtr ptr, IComponent comp, Guid guid) /// The port configuration object. /// The port to copy from. /// The capture handler to assign to this port. - public virtual void Configure(MMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) + public virtual void Configure(IMMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) { if (config != null) { diff --git a/src/MMALSharp/Ports/Outputs/SplitterVideoPort.cs b/src/MMALSharp/Ports/Outputs/SplitterVideoPort.cs index 47820670..e8c1110a 100644 --- a/src/MMALSharp/Ports/Outputs/SplitterVideoPort.cs +++ b/src/MMALSharp/Ports/Outputs/SplitterVideoPort.cs @@ -40,7 +40,7 @@ public SplitterVideoPort(IPort copyFrom) } /// - public override void Configure(MMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) + public override void Configure(IMMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) { // The splitter component should not have its resolution set on the output port so override method accordingly. if (config != null) diff --git a/src/MMALSharp/Ports/Outputs/StillPort.cs b/src/MMALSharp/Ports/Outputs/StillPort.cs index ad1b78d0..55c97fa4 100644 --- a/src/MMALSharp/Ports/Outputs/StillPort.cs +++ b/src/MMALSharp/Ports/Outputs/StillPort.cs @@ -58,7 +58,7 @@ public StillPort(IPort copyFrom) } /// - public override void Configure(MMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) + public override void Configure(IMMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) { base.Configure(config, copyFrom, handler); diff --git a/src/MMALSharp/Ports/Outputs/VideoPort.cs b/src/MMALSharp/Ports/Outputs/VideoPort.cs index 46caa8bd..d7f072c2 100644 --- a/src/MMALSharp/Ports/Outputs/VideoPort.cs +++ b/src/MMALSharp/Ports/Outputs/VideoPort.cs @@ -60,7 +60,7 @@ public VideoPort(IPort copyFrom) } /// - public override void Configure(MMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) + public override void Configure(IMMALPortConfig config, IInputPort copyFrom, IOutputCaptureHandler handler) { base.Configure(config, copyFrom, handler); diff --git a/src/MMALSharp/Ports/PortBase.cs b/src/MMALSharp/Ports/PortBase.cs index f608fe2b..1879afc8 100644 --- a/src/MMALSharp/Ports/PortBase.cs +++ b/src/MMALSharp/Ports/PortBase.cs @@ -66,7 +66,7 @@ public abstract unsafe class PortBase : MMALObject, IPort /// /// The config for this port. /// - public MMALPortConfig PortConfig { get; internal set; } + public IMMALPortConfig PortConfig { get; internal set; } /// /// Indicates whether ZeroCopy mode should be enabled on this port. When enabled, data is not copied to the ARM processor and is handled directly by the GPU. Useful when @@ -372,10 +372,15 @@ public void SendBuffer(IBuffer buffer) { if (MMALCameraConfig.Debug) { - MMALLog.Logger.LogDebug("Sending buffer"); + MMALLog.Logger.LogDebug("Sending buffer start."); } MMALCheck(MMALPort.mmal_port_send_buffer(this.Ptr, buffer.Ptr), "Unable to send buffer header."); + + if (MMALCameraConfig.Debug) + { + MMALLog.Logger.LogDebug("Sending buffer complete."); + } } }