@@ -112,7 +112,8 @@ public async Task TakeVideo(MMALPortImpl connPort, DateTime? timeout = null, Spl
112112
113113 try
114114 {
115- Console . WriteLine ( $ "Preparing to take video. Resolution: { MMALCameraConfig . VideoResolution . Width } x { MMALCameraConfig . VideoResolution . Height } . Encoder: { encoder . EncodingType . EncodingName } . Pixel Format: { encoder . PixelFormat . EncodingName } .") ;
115+ Console . WriteLine ( $ "Preparing to take video. Resolution: { MMALCameraConfig . VideoResolution . Width } x { MMALCameraConfig . VideoResolution . Height } . " +
116+ $ "Encoder: { encoder . EncodingType . EncodingName } . Pixel Format: { encoder . PixelFormat . EncodingName } .") ;
116117
117118 ( ( MMALVideoPort ) encoder . Outputs . ElementAt ( 0 ) ) . Timeout = timeout ;
118119 ( ( MMALVideoEncoder ) encoder ) . Split = split ;
@@ -138,19 +139,16 @@ public async Task TakeRawPicture(ICaptureHandler handler)
138139 {
139140 throw new PiCameraError ( "A connection was found to the Camera still port. No encoder should be connected to the Camera's still port for raw capture." ) ;
140141 }
141- if ( handler == null )
142- {
143- throw new PiCameraError ( "No handler specified" ) ;
144- }
145142
146- this . Camera . Handler = handler ;
143+ this . Camera . Handler = handler ?? throw new PiCameraError ( "No handler specified" ) ;
147144
148145 this . CheckPreviewComponentStatus ( ) ;
149146
150147 //Enable the image encoder output port.
151148 try
152149 {
153- Console . WriteLine ( $ "Preparing to take picture - Resolution: { MMALCameraConfig . StillResolution . Width } x { MMALCameraConfig . StillResolution . Height } ") ;
150+ Console . WriteLine ( $ "Preparing to take raw picture - Resolution: { MMALCameraConfig . StillResolution . Width } x { MMALCameraConfig . StillResolution . Height } . " +
151+ $ "Encoder: { MMALCameraConfig . StillEncoding . EncodingName } . Pixel Format: { MMALCameraConfig . StillSubFormat . EncodingName } .") ;
154152
155153 await BeginProcessing ( this . Camera , null , this . Camera . StillPort , MMALCameraComponent . MMALCameraStillPort ) ;
156154 }
@@ -209,7 +207,8 @@ public async Task TakePicture(MMALPortImpl connPort, bool rawBayer = false, bool
209207 //Enable the image encoder output port.
210208 try
211209 {
212- Console . WriteLine ( $ "Preparing to take picture. Resolution: { MMALCameraConfig . StillResolution . Width } x { MMALCameraConfig . StillResolution . Height } . Encoder: { encoder . EncodingType . EncodingName } . Pixel Format: { encoder . PixelFormat . EncodingName } .") ;
210+ Console . WriteLine ( $ "Preparing to take picture. Resolution: { MMALCameraConfig . StillResolution . Width } x { MMALCameraConfig . StillResolution . Height } . " +
211+ $ "Encoder: { encoder . EncodingType . EncodingName } . Pixel Format: { encoder . PixelFormat . EncodingName } .") ;
213212
214213 await BeginProcessing ( encoder , encoder . Connection , this . Camera . StillPort , 0 ) ;
215214 }
@@ -228,8 +227,13 @@ public async Task TakePicture(MMALPortImpl connPort, bool rawBayer = false, bool
228227 /// <param name="useExif">Specify whether to include EXIF tags in the capture</param>
229228 /// <param name="exifTags">Custom EXIF tags to use in the capture</param>
230229 /// <returns>The awaitable Task</returns>
231- public async Task TakePictureTimeout ( MMALPortImpl connPort , DateTime timeout , bool rawBayer = false , bool useExif = true , params ExifTag [ ] exifTags )
232- {
230+ public async Task TakePictureTimeout ( MMALPortImpl connPort , DateTime timeout , bool rawBayer = false , bool useExif = true , bool burstMode = false , params ExifTag [ ] exifTags )
231+ {
232+ if ( burstMode )
233+ {
234+ this . Camera . StillPort . SetParameter ( MMALParametersCamera . MMAL_PARAMETER_CAMERA_BURST_CAPTURE , true ) ;
235+ }
236+
233237 while ( DateTime . Now . CompareTo ( timeout ) < 0 )
234238 {
235239 await TakePicture ( connPort , rawBayer , useExif , exifTags ) ;
@@ -305,19 +309,16 @@ private async Task BeginProcessing(MMALComponentBase component, MMALConnectionIm
305309 component . CleanPortPools ( ) ;
306310 }
307311
312+
313+
308314 /// <summary>
309315 /// Helper method to create a new preview component
310316 /// </summary>
311317 /// <param name="renderer">The renderer type</param>
312- /// <returns>The static Camera instance</returns>
318+ /// <returns>The camera instance</returns>
313319 public MMALCamera CreatePreviewComponent ( MMALRendererBase renderer )
314320 {
315- if ( this . Preview != null )
316- {
317- this . Preview ? . Connection . Disable ( ) ;
318- this . Preview ? . Connection . Destroy ( ) ;
319- this . Preview . Dispose ( ) ;
320- }
321+ this . DestroyPreviewComponent ( ) ;
321322
322323 this . Preview = renderer ;
323324 this . Preview . CreateConnection ( this . Camera . PreviewPort ) ;
@@ -327,7 +328,7 @@ public MMALCamera CreatePreviewComponent(MMALRendererBase renderer)
327328 /// <summary>
328329 /// Helper method to create a splitter component
329330 /// </summary>
330- /// <returns>The static Camera instance</returns>
331+ /// <returns>The camera instance</returns>
331332 public MMALCamera CreateSplitterComponent ( )
332333 {
333334 this . Splitter = new MMALSplitterComponent ( ) ;
@@ -339,7 +340,7 @@ public MMALCamera CreateSplitterComponent()
339340 /// </summary>
340341 /// <param name="encoder">The encoder component to attach to the output port</param>
341342 /// <param name="outputPort">The output port to attach to</param>
342- /// <returns>The static Camera instance</returns>
343+ /// <returns>The camera instance</returns>
343344 public MMALCamera AddEncoder ( MMALEncoderBase encoder , MMALPortImpl outputPort )
344345 {
345346 if ( MMALCameraConfig . Debug )
@@ -359,7 +360,7 @@ public MMALCamera AddEncoder(MMALEncoderBase encoder, MMALPortImpl outputPort)
359360 /// Remove an encoder component from an output port
360361 /// </summary>
361362 /// <param name="outputPort">The output port we are removing an encoder component from</param>
362- /// <returns>The static Camera instance</returns>
363+ /// <returns>The camera instance</returns>
363364 public MMALCamera RemoveEncoder ( MMALPortImpl outputPort )
364365 {
365366 var enc = this . Encoders . Where ( c => c . Connection != null && c . Connection . OutputPort == outputPort ) . FirstOrDefault ( ) ;
@@ -399,26 +400,76 @@ public void EnableCamera()
399400 }
400401
401402 /// <summary>
402- /// Configures the camera component. This method applies configuration settings and initialises the components required
403- /// for capturing images.
403+ /// Reconfigures the Camera's still port.
404404 /// </summary>
405- /// <returns>The static Camera instance</returns>
406- public MMALCamera ConfigureCamera ( )
405+ /// <returns>The camera instance</returns>
406+ public MMALCamera ConfigureStill ( )
407407 {
408- if ( MMALCameraConfig . Debug )
409- {
410- Console . WriteLine ( "Configuring camera parameters." ) ;
411- }
412-
413408 this . DisableCamera ( ) ;
414409
415- this . Camera . SetCameraParameters ( ) ;
410+ this . Encoders . Where ( c => c . Connection != null && c . Connection . OutputPort == this . Camera . StillPort ) . ToList ( ) . ForEach ( c => c . Connection . Disable ( ) ) ;
411+
412+ this . Camera . InitialiseStill ( ) ;
413+
414+ this . Encoders . Where ( c => c . Connection != null && c . Connection . OutputPort == this . Camera . StillPort ) . ToList ( ) . ForEach ( c => c . Connection . Enable ( ) ) ;
416415
417416 this . EnableCamera ( ) ;
418-
417+
418+ return this ;
419+ }
420+
421+ /// <summary>
422+ /// Reconfigures the Camera's video port.
423+ /// </summary>
424+ /// <returns>The camera instance</returns>
425+ public MMALCamera ConfigureVideo ( )
426+ {
427+ this . DisableCamera ( ) ;
428+
429+ this . Encoders . Where ( c => c . Connection != null && c . Connection . OutputPort == this . Camera . VideoPort ) . ToList ( ) . ForEach ( c => c . Connection . Disable ( ) ) ;
430+
431+ this . Camera . InitialiseVideo ( ) ;
432+
433+ this . Encoders . Where ( c => c . Connection != null && c . Connection . OutputPort == this . Camera . VideoPort ) . ToList ( ) . ForEach ( c => c . Connection . Enable ( ) ) ;
434+
435+ this . EnableCamera ( ) ;
436+
437+ return this ;
438+ }
439+
440+ /// <summary>
441+ /// Reconfigures the Camera's preview port.
442+ /// </summary>
443+ /// <returns>The camera instance</returns>
444+ public MMALCamera ConfigurePreview ( )
445+ {
446+ this . DisableCamera ( ) ;
447+
448+ this . Preview ? . Connection ? . Disable ( ) ;
449+ this . Camera . InitialisePreview ( ) ;
450+ this . Preview ? . Connection ? . Enable ( ) ;
451+
452+ this . EnableCamera ( ) ;
453+
419454 return this ;
420455 }
421-
456+
457+
458+ private void DestroyPreviewComponent ( )
459+ {
460+ if ( this . Preview != null )
461+ {
462+ this . Preview ? . Connection . Disable ( ) ;
463+ this . Preview ? . Connection . Destroy ( ) ;
464+ this . Preview . Dispose ( ) ;
465+ }
466+ }
467+
468+ private void DestroyEncoders ( )
469+ {
470+ this . Encoders . ForEach ( c => c . Dispose ( ) ) ;
471+ }
472+
422473 /// <summary>
423474 /// Helper method to check the Renderer component status. If a Renderer has not been initialized, a warning will
424475 /// be shown to the user. If a Renderer has been created but a connection has not been initialized, this will be
0 commit comments