Skip to content

Fixed bug where grouping capabilities for video devices was causing v… #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Sources/Video.DirectShow/VideoCapabilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint, VideoCapabilities> videocapsList = new Dictionary<uint, VideoCapabilities>( );
Dictionary<ulong, VideoCapabilities> videocapsList = new Dictionary<ulong, VideoCapabilities>();

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;
}
Expand All @@ -105,6 +106,7 @@ static internal VideoCapabilities[] FromStreamConfig( IAMStreamConfig videoStrea
}
}


VideoCapabilities[] videocaps = new VideoCapabilities[videocapsList.Count];
videocapsList.Values.CopyTo( videocaps, 0 );

Expand Down