Browse Source

Improved win32 camera resolution selection.

tags/2021-05-28
Julian Storer 15 years ago
parent
commit
20ab8e6e96
4 changed files with 40 additions and 16 deletions
  1. +19
    -7
      juce_amalgamated.cpp
  2. +1
    -1
      juce_amalgamated.h
  3. +1
    -1
      src/core/juce_StandardHeader.h
  4. +19
    -7
      src/native/windows/juce_win32_CameraDevice.cpp

+ 19
- 7
juce_amalgamated.cpp View File

@@ -227911,16 +227911,16 @@ private:
const int minWidth, const int minHeight,
const int maxWidth, const int maxHeight)
{
int count = 0, size = 0;
int count = 0, size = 0, bestArea = 0, bestIndex = -1;
streamConfig->GetNumberOfCapabilities (&count, &size);

if (size == sizeof (VIDEO_STREAM_CONFIG_CAPS))
{
AM_MEDIA_TYPE* config;
VIDEO_STREAM_CONFIG_CAPS scc;

for (int i = 0; i < count; ++i)
{
VIDEO_STREAM_CONFIG_CAPS scc;
AM_MEDIA_TYPE* config;

HRESULT hr = streamConfig->GetStreamCaps (i, &config, (BYTE*) &scc);

if (SUCCEEDED (hr))
@@ -227930,14 +227930,26 @@ private:
&& scc.InputSize.cx <= maxWidth
&& scc.InputSize.cy <= maxHeight)
{
hr = streamConfig->SetFormat (config);
deleteMediaType (config);
return SUCCEEDED (hr);
int area = scc.InputSize.cx * scc.InputSize.cy;
if (area > bestArea)
{
bestIndex = i;
bestArea = area;
}
}

deleteMediaType (config);
}
}

if (bestIndex >= 0)
{
HRESULT hr = streamConfig->GetStreamCaps (bestIndex, &config, (BYTE*) &scc);

hr = streamConfig->SetFormat (config);
deleteMediaType (config);
return SUCCEEDED (hr);
}
}

return false;


+ 1
- 1
juce_amalgamated.h View File

@@ -43,7 +43,7 @@

#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 51
#define JUCE_BUILDNUMBER 0
#define JUCE_BUILDNUMBER 2

#define JUCE_VERSION ((JUCE_MAJOR_VERSION << 16) + (JUCE_MINOR_VERSION << 8) + JUCE_BUILDNUMBER)



+ 1
- 1
src/core/juce_StandardHeader.h View File

@@ -33,7 +33,7 @@
*/
#define JUCE_MAJOR_VERSION 1
#define JUCE_MINOR_VERSION 51
#define JUCE_BUILDNUMBER 0
#define JUCE_BUILDNUMBER 2
/** Current Juce version number.


+ 19
- 7
src/native/windows/juce_win32_CameraDevice.cpp View File

@@ -507,16 +507,16 @@ private:
const int minWidth, const int minHeight,
const int maxWidth, const int maxHeight)
{
int count = 0, size = 0;
int count = 0, size = 0, bestArea = 0, bestIndex = -1;
streamConfig->GetNumberOfCapabilities (&count, &size);
if (size == sizeof (VIDEO_STREAM_CONFIG_CAPS))
{
AM_MEDIA_TYPE* config;
VIDEO_STREAM_CONFIG_CAPS scc;
for (int i = 0; i < count; ++i)
{
VIDEO_STREAM_CONFIG_CAPS scc;
AM_MEDIA_TYPE* config;
HRESULT hr = streamConfig->GetStreamCaps (i, &config, (BYTE*) &scc);
if (SUCCEEDED (hr))
@@ -526,14 +526,26 @@ private:
&& scc.InputSize.cx <= maxWidth
&& scc.InputSize.cy <= maxHeight)
{
hr = streamConfig->SetFormat (config);
deleteMediaType (config);
return SUCCEEDED (hr);
int area = scc.InputSize.cx * scc.InputSize.cy;
if (area > bestArea)
{
bestIndex = i;
bestArea = area;
}
}
deleteMediaType (config);
}
}
if (bestIndex >= 0)
{
HRESULT hr = streamConfig->GetStreamCaps (bestIndex, &config, (BYTE*) &scc);
hr = streamConfig->SetFormat (config);
deleteMediaType (config);
return SUCCEEDED (hr);
}
}
return false;


Loading…
Cancel
Save