Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
#189 - Add user provided name to MMALPortConfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
techyian committed Oct 15, 2020
1 parent 13ad659 commit 3f15dfb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/MMALSharp/Ports/IMMALPortConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,10 @@ public interface IMMALPortConfig
/// Indicates whether motion vector data should be stored to a separate output stream. Only applies to Video recording.
/// </summary>
bool StoreMotionVectors { get; }

/// <summary>
/// User provided name for port. Helps with debugging.
/// </summary>
string UserPortName { get; }
}
}
10 changes: 9 additions & 1 deletion src/MMALSharp/Ports/MMALPortConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ public class MMALPortConfig : IMMALPortConfig
/// </summary>
public bool StoreMotionVectors { get; }

/// <summary>
/// User provided name for port. Helps with debugging.
/// </summary>
public string UserPortName { get; set; }

/// <summary>
/// Create a new instance of <see cref="MMALPortConfig"/>.
/// </summary>
Expand All @@ -102,6 +107,7 @@ public class MMALPortConfig : IMMALPortConfig
/// <param name="bufferNum">Requested number of buffer headers.</param>
/// <param name="bufferSize">Requested size of buffer headers.</param>
/// <param name="crop">The Region of Interest requested.</param>
/// <param name="userPortName">User provided name for port. Helps with debugging..</param>
public MMALPortConfig(
MMALEncoding encodingType,
MMALEncoding pixelFormat,
Expand All @@ -116,7 +122,8 @@ public MMALPortConfig(
bool zeroCopy = false,
int bufferNum = 0,
int bufferSize = 0,
Rectangle? crop = null)
Rectangle? crop = null,
string userPortName = "")
{
this.EncodingType = encodingType;
this.PixelFormat = pixelFormat;
Expand All @@ -132,6 +139,7 @@ public MMALPortConfig(
this.BufferSize = bufferSize;
this.Crop = crop;
this.StoreMotionVectors = storeMotionVectors;
this.UserPortName = userPortName;
}
}
}
10 changes: 8 additions & 2 deletions src/MMALSharp/Ports/PortBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,15 @@ public abstract unsafe class PortBase<TCallback> : MMALObject, IPort
public MMAL_PORT_T* Ptr { get; }

/// <summary>
/// Native name of port.
/// Returns the Native name and user provided name of port (if set).
/// </summary>
public string Name => Marshal.PtrToStringAnsi((IntPtr)this.Ptr->Name);
public string Name
{
get
{
return $"{Marshal.PtrToStringAnsi((IntPtr)this.Ptr->Name)} {this.PortConfig?.UserPortName}";
}
}

/// <summary>
/// Indicates whether this port is enabled.
Expand Down

0 comments on commit 3f15dfb

Please sign in to comment.