Skip to content
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

Resolution of WebCam #1

Open
chris-evans opened this issue May 27, 2015 · 0 comments
Open

Resolution of WebCam #1

chris-evans opened this issue May 27, 2015 · 0 comments

Comments

@chris-evans
Copy link

Hi Sam,

I have found this code sample / library really useful, but have been struggling to add one feature to the code base. I am trying to add support for detecting resolutions supported by the WebCam. I have some code previously that was leveraging DirectShowLib, but I much prefer the simplicity of this code base (I feel like I can understand it). Any ideas/thoughts would be greatly appreciated.

Code Sample:: so after getting the capture pin from the output filter... I am calling the below method I wrote. All looks good, but the data I get back from GetNumberOfCapabilities makes no sense. capabilitiesCount is random (but huge) and capabilitiesResultStructureSize is zero. Also, GetStreamCaps throws a memory error.
private void SelectWebcamResolution(IPin sourcePin)
{
var cfg = sourcePin as IAMStreamConfig;

int capsCount = 0;
int capsStructSize = 0;
var result = cfg.GetNumberOfCapabilities(out capsCount, out capsStructSize);

if (result == 0 && capabilitiesResultStructureSize > 0)
{
    var ptr = Marshal.AllocCoTaskMem(capabilitiesResultStructureSize);
    try
    {
        for (int i = 0; i != capabilitiesCount; ++i)
        {
            AMMediaType capabilityInfo = null;
            result = cfg.GetStreamCaps(0, out capabilityInfo, ptr); // this throws mem error
        }
    }
    finally
    { Marshal.Release(ptr); }
}

}

Thanks in advance,
Chris Evans

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant