From e628b22e546ff8b76a4d93455c005510ae804121 Mon Sep 17 00:00:00 2001 From: Jason Date: Wed, 29 Jun 2016 10:02:24 -0500 Subject: [PATCH] Fixed bug where grouping capabilities for video devices was causing video capabilities with different frame rates to be ignored. --- Sources/Video.DirectShow/VideoCapabilities.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Sources/Video.DirectShow/VideoCapabilities.cs b/Sources/Video.DirectShow/VideoCapabilities.cs index a7c8dd41..d94ee9f2 100644 --- a/Sources/Video.DirectShow/VideoCapabilities.cs +++ b/Sources/Video.DirectShow/VideoCapabilities.cs @@ -77,24 +77,25 @@ static internal VideoCapabilities[] FromStreamConfig( IAMStreamConfig videoStrea throw new NotSupportedException( "Unable to retrieve video device capabilities. This video device requires a larger VideoStreamConfigCaps structure." ); // group capabilities with similar parameters - Dictionary videocapsList = new Dictionary( ); + Dictionary videocapsList = new Dictionary(); - for ( int i = 0; i < count; i++ ) + for (int i = 0; i < count; i++) { try { - VideoCapabilities vc = new VideoCapabilities( videoStreamConfig, i ); + VideoCapabilities vc = new VideoCapabilities(videoStreamConfig, i); - uint key = ( ( (uint) vc.FrameSize.Height ) << 32 ) | - ( ( (uint) vc.FrameSize.Width ) << 16 ); + ulong key = (((uint)vc.AverageFrameRate) << 48) | + (((uint)vc.FrameSize.Height) << 32) | + (((uint)vc.FrameSize.Width) << 16); - if ( !videocapsList.ContainsKey( key ) ) + if (!videocapsList.ContainsKey(key)) { - videocapsList.Add( key, vc ); + videocapsList.Add(key, vc); } else { - if ( vc.BitCount > videocapsList[key].BitCount ) + if (vc.BitCount > videocapsList[key].BitCount) { videocapsList[key] = vc; } @@ -105,6 +106,7 @@ static internal VideoCapabilities[] FromStreamConfig( IAMStreamConfig videoStrea } } + VideoCapabilities[] videocaps = new VideoCapabilities[videocapsList.Count]; videocapsList.Values.CopyTo( videocaps, 0 );