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

Commit d7106f9

Browse files
committed
Some XMLDoc work. Getting ready for 0.5 release.
1 parent 5a96edf commit d7106f9

13 files changed

Lines changed: 125 additions & 89 deletions

File tree

src/MMALSharp/Components/EncoderComponents/MMALVideoDecoder.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// Licensed under the MIT License. Please see LICENSE.txt for License info.
44
// </copyright>
55

6-
using System;
7-
using MMALSharp.Common.Utility;
86
using MMALSharp.Handlers;
97
using MMALSharp.Native;
108
using MMALSharp.Ports;
@@ -17,14 +15,10 @@ namespace MMALSharp.Components
1715
/// </summary>
1816
public class MMALVideoDecoder : MMALEncoderBase
1917
{
20-
private int _width;
21-
private int _height;
22-
2318
/// <summary>
2419
/// Creates a new instance of <see cref="MMALVideoDecoder"/>.
2520
/// </summary>
2621
/// <param name="handler">The capture handler.</param>
27-
/// <param name="timeout">Optional timeout value.</param>
2822
public MMALVideoDecoder(ICaptureHandler handler)
2923
: base(MMALParameters.MMAL_COMPONENT_DEFAULT_VIDEO_DECODER, handler)
3024
{
@@ -34,12 +28,16 @@ public MMALVideoDecoder(ICaptureHandler handler)
3428
public override MMALDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config)
3529
{
3630
base.ConfigureOutputPort(outputPort, config);
37-
((VideoPort)this.Outputs[outputPort]).Timeout = config.Timeout;
3831

32+
if (this.Outputs[outputPort].GetType() == typeof(VideoPort) || this.Outputs[outputPort].GetType().IsSubclassOf(typeof(VideoPort)))
33+
{
34+
((VideoPort)this.Outputs[outputPort]).Timeout = config.Timeout;
35+
}
36+
3937
return this;
4038
}
4139

42-
/// <inheritdoc />>
40+
/// <inheritdoc />
4341
internal override void InitialiseOutputPort(int outputPort)
4442
{
4543
this.Outputs[outputPort] = new VideoPort(this.Outputs[outputPort]);

src/MMALSharp/Components/EncoderComponents/MMALVideoEncoder.cs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -65,26 +65,19 @@ public unsafe class MMALVideoEncoder : MMALEncoderBase
6565
/// and this can be applied on the next run to the newly created file.
6666
/// </summary>
6767
public bool PrepareSplit { get; set; }
68-
69-
/// <summary>
70-
/// A <see cref="DateTime"/> to signify when processing should terminate on this component.
71-
/// </summary>
72-
public DateTime? Timeout { get; }
7368

7469
/// <summary>
7570
/// Creates a new instance of <see cref="MMALVideoEncoder"/>.
7671
/// </summary>
7772
/// <param name="handler">The capture handler.</param>
78-
/// <param name="timeout">The optional termination time.</param>
7973
/// <param name="split">Configure this component to split into multiple files.</param>
80-
public MMALVideoEncoder(ICaptureHandler handler, DateTime? timeout = null, Split split = null)
74+
public MMALVideoEncoder(ICaptureHandler handler, Split split = null)
8175
: base(MMALParameters.MMAL_COMPONENT_DEFAULT_VIDEO_ENCODER, handler)
8276
{
8377
this.Split = split;
84-
this.Timeout = timeout;
8578
}
8679

87-
/// <inheritdoc />>
80+
/// <inheritdoc />
8881
public override MMALDownstreamComponent ConfigureOutputPort(int outputPort, MMALPortConfig config)
8982
{
9083
base.ConfigureOutputPort(outputPort, config);
@@ -94,12 +87,13 @@ public override MMALDownstreamComponent ConfigureOutputPort(int outputPort, MMAL
9487
{
9588
this.Outputs[outputPort].VideoColorSpace = MMALCameraConfig.VideoColorSpace;
9689
}
97-
90+
9891
if (this.Outputs[outputPort].GetType() == typeof(VideoPort) || this.Outputs[outputPort].GetType().IsSubclassOf(typeof(VideoPort)))
9992
{
100-
((VideoPort)this.Outputs[outputPort]).Timeout = this.Timeout;
93+
((VideoPort)this.Outputs[outputPort]).Timeout = config.Timeout;
10194
}
102-
95+
96+
this.Outputs[outputPort].Ptr->BufferNum = Math.Max(this.Outputs[outputPort].Ptr->BufferNumRecommended, 3);
10397
this.Outputs[outputPort].Ptr->BufferSize = 512 * 1024;
10498
this.Quality = config.Quality;
10599

@@ -122,7 +116,7 @@ public override MMALDownstreamComponent ConfigureOutputPort(int outputPort, MMAL
122116
this.ConfigureBitrate(outputPort);
123117

124118
this.RegisterOutputCallback(new VideoOutputCallbackHandler(this.Outputs[outputPort]));
125-
119+
126120
return this;
127121
}
128122

@@ -182,6 +176,7 @@ internal void ConfigureBitrate(int outputPort)
182176
this.Outputs[outputPort].Bitrate = MaxBitrateMJPEG;
183177
}
184178
}
179+
185180
this.Outputs[outputPort].Ptr->Format->Bitrate = this.Outputs[outputPort].Bitrate;
186181
this.Outputs[outputPort].Ptr->Format->Es->Video.FrameRate = new MMAL_RATIONAL_T(0, 1);
187182
this.Outputs[outputPort].Commit();

src/MMALSharp/Components/MMALCameraComponent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ private void InitialiseVideo()
305305

306306
this.VideoPort.BufferNum = Math.Max(
307307
this.VideoPort.BufferNumRecommended,
308-
this.VideoPort.BufferNumMin);
308+
3);
309309

310310
this.VideoPort.BufferSize = Math.Max(
311311
this.VideoPort.BufferSizeRecommended,
@@ -381,7 +381,7 @@ private void InitialiseStill()
381381

382382
this.StillPort.BufferNum = Math.Max(
383383
this.StillPort.BufferNumRecommended,
384-
this.StillPort.BufferNumMin);
384+
3);
385385

386386
this.StillPort.BufferSize = Math.Max(
387387
this.StillPort.BufferSizeRecommended,

src/MMALSharp/Components/MMALDownstreamComponent.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,7 @@ public virtual unsafe MMALDownstreamComponent ConfigureInputPort(MMALPortConfig
131131
{
132132
this.Inputs[0].NativeEncodingSubformat = config.PixelFormat.EncodingVal;
133133
}
134-
135-
this.Inputs[0].BufferNum = Math.Max(this.Inputs[0].Ptr->BufferNumMin, this.Inputs[0].Ptr->BufferNumRecommended);
136-
this.Inputs[0].BufferSize = Math.Max(this.Inputs[0].Ptr->BufferSizeMin, this.Inputs[0].Ptr->BufferSizeRecommended);
137-
134+
138135
if (config.Width > 0 && config.Height > 0)
139136
{
140137
this.Inputs[0].Resolution = new Resolution(config.Width, config.Height);
@@ -170,6 +167,9 @@ public virtual unsafe MMALDownstreamComponent ConfigureInputPort(MMALPortConfig
170167
this.Inputs[0].SetParameter(MMALParametersCommon.MMAL_PARAMETER_ZERO_COPY, true);
171168
}
172169

170+
this.Inputs[0].BufferNum = Math.Max(this.Inputs[0].Ptr->BufferNumMin, this.Inputs[0].Ptr->BufferNumRecommended);
171+
this.Inputs[0].BufferSize = Math.Max(this.Inputs[0].Ptr->BufferSizeMin, this.Inputs[0].Ptr->BufferSizeRecommended);
172+
173173
return this;
174174
}
175175

@@ -271,7 +271,7 @@ public virtual unsafe MMALDownstreamComponent ConfigureOutputPort(int outputPort
271271
this.Outputs[outputPort].Crop = new Rectangle(0, 0, this.Outputs[outputPort].Resolution.Width, this.Outputs[outputPort].Resolution.Height);
272272
}
273273
}
274-
274+
275275
// It is important to re-commit changes to width and height.
276276
this.Outputs[outputPort].Commit();
277277

src/MMALSharp/Components/MMALSplitterComponent.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
// Licensed under the MIT License. Please see LICENSE.txt for License info.
44
// </copyright>
55

6+
using System;
67
using MMALSharp.Handlers;
78
using MMALSharp.Native;
9+
using MMALSharp.Ports;
810

911
namespace MMALSharp.Components
1012
{
@@ -23,5 +25,25 @@ public MMALSplitterComponent(params ICaptureHandler[] handler)
2325
: base(MMALParameters.MMAL_COMPONENT_DEFAULT_VIDEO_SPLITTER, handler)
2426
{
2527
}
28+
29+
/// <inheritdoc />
30+
public override unsafe MMALDownstreamComponent ConfigureInputPort(MMALEncoding encodingType, MMALEncoding pixelFormat, PortBase copyPort, bool zeroCopy = false)
31+
{
32+
base.ConfigureInputPort(encodingType, pixelFormat, copyPort, zeroCopy);
33+
34+
this.Inputs[0].Ptr->BufferNum = Math.Max(this.Inputs[0].Ptr->BufferNumRecommended, 3);
35+
36+
return this;
37+
}
38+
39+
/// <inheritdoc />
40+
public override unsafe MMALDownstreamComponent ConfigureInputPort(MMALPortConfig config)
41+
{
42+
base.ConfigureInputPort(config);
43+
44+
this.Inputs[0].Ptr->BufferNum = Math.Max(this.Inputs[0].Ptr->BufferNumRecommended, 3);
45+
46+
return this;
47+
}
2648
}
2749
}

src/MMALSharp/MMALCamera.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public async Task TakeVideo(ICaptureHandler handler, CancellationToken cancellat
9191
split = null;
9292
}
9393

94-
using (var vidEncoder = new MMALVideoEncoder(handler, null, split))
94+
using (var vidEncoder = new MMALVideoEncoder(handler, split))
9595
using (var renderer = new MMALVideoRenderer())
9696
{
9797
this.ConfigureCameraSettings();

src/MMALSharp/MMALStandalone.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
namespace MMALSharp
88
{
9+
/// <summary>
10+
/// Used for Standalone use of MMALSharp without camera.
11+
/// </summary>
912
public class MMALStandalone
1013
{
1114
/// <summary>

src/MMALSharp/Ports/Controls/ControlPort.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace MMALSharp.Ports.Controls
1818
/// </summary>
1919
public unsafe class ControlPort : ControlPortBase
2020
{
21+
/// <inheritdoc />
2122
public override Resolution Resolution
2223
{
2324
get => new Resolution(0, 0);

src/MMALSharp/Ports/GenericPort.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace MMALSharp.Ports
1515
/// </summary>
1616
public unsafe class GenericPort : PortBase
1717
{
18+
/// <inheritdoc />
1819
public override Resolution Resolution
1920
{
2021
get => new Resolution(this.Ptr->Format->Es->Video.Width, this.Ptr->Format->Es->Video.Height);

src/MMALSharp/Ports/MMALPortConfig.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
1-
using System;
1+
// <copyright file="MMALPortConfig.cs" company="Techyian">
2+
// Copyright (c) Ian Auty. All rights reserved.
3+
// Licensed under the MIT License. Please see LICENSE.txt for License info.
4+
// </copyright>
5+
6+
using System;
27
using MMALSharp.Native;
38

49
namespace MMALSharp.Ports
510
{
11+
/// <summary>
12+
/// Port configuration class.
13+
/// </summary>
614
public class MMALPortConfig
715
{
816
/// <summary>
@@ -71,13 +79,15 @@ public MMALPortConfig(MMALEncoding encodingType, MMALEncoding pixelFormat, int q
7179
/// <param name="framerate">The output framerate.</param>
7280
/// <param name="quality">The output quality.</param>
7381
/// <param name="bitrate">The output bitrate.</param>
82+
/// <param name="timeout">Video record timeout.</param>
7483
public MMALPortConfig(MMALEncoding encodingType, MMALEncoding pixelFormat, int framerate, int quality, int bitrate, DateTime? timeout)
7584
{
7685
this.EncodingType = encodingType;
7786
this.PixelFormat = pixelFormat;
7887
this.Framerate = framerate;
7988
this.Quality = quality;
8089
this.Bitrate = bitrate;
90+
this.Timeout = timeout;
8191
}
8292

8393
/// <summary>

0 commit comments

Comments
 (0)