Browse Source

Add low quality mode for juce CameraDevice

tags/2021-05-28
hogliux 9 years ago
parent
commit
c21716499c
5 changed files with 22 additions and 12 deletions
  1. +7
    -4
      modules/juce_video/capture/juce_CameraDevice.cpp
  2. +7
    -2
      modules/juce_video/capture/juce_CameraDevice.h
  3. +5
    -3
      modules/juce_video/native/juce_mac_CameraDevice.mm
  4. +1
    -1
      modules/juce_video/native/juce_win32_CameraDevice.cpp
  5. +2
    -2
      modules/juce_video/native/juce_win32_DirectShowComponent.cpp

+ 7
- 4
modules/juce_video/capture/juce_CameraDevice.cpp View File

@@ -22,8 +22,9 @@
==============================================================================
*/
CameraDevice::CameraDevice (const String& nm, int index, int minWidth, int minHeight, int maxWidth, int maxHeight)
: name (nm), pimpl (new Pimpl (name, index, minWidth, minHeight, maxWidth, maxHeight))
CameraDevice::CameraDevice (const String& nm, int index, int minWidth, int minHeight, int maxWidth, int maxHeight,
bool highQuality)
: name (nm), pimpl (new Pimpl (name, index, minWidth, minHeight, maxWidth, maxHeight, highQuality))
{
}
@@ -77,10 +78,12 @@ StringArray CameraDevice::getAvailableDevices()
CameraDevice* CameraDevice::openDevice (int index,
int minWidth, int minHeight,
int maxWidth, int maxHeight)
int maxWidth, int maxHeight,
bool highQuality)
{
ScopedPointer<CameraDevice> d (new CameraDevice (getAvailableDevices() [index], index,
minWidth, minHeight, maxWidth, maxHeight));
minWidth, minHeight, maxWidth, maxHeight,
highQuality));
if (d->pimpl->openedOk())
return d.release();


+ 7
- 2
modules/juce_video/capture/juce_CameraDevice.h View File

@@ -58,10 +58,15 @@ public:
The size constraints allow the method to choose between different resolutions if
the camera supports this. If the resolution cam't be specified (e.g. on the Mac)
then these will be ignored.
On Mac, if highQuality is false, then the camera will be opened in preview mode
which will allow the OS to drop frames if the computer cannot keep up in processing
the frames.
*/
static CameraDevice* openDevice (int deviceIndex,
int minWidth = 128, int minHeight = 64,
int maxWidth = 1024, int maxHeight = 768);
int maxWidth = 1024, int maxHeight = 768,
bool highQuality = true);
//==============================================================================
/** Returns the name of this device */
@@ -147,7 +152,7 @@ private:
friend struct ViewerComponent;
CameraDevice (const String& name, int index,
int minWidth, int minHeight, int maxWidth, int maxHeight);
int minWidth, int minHeight, int maxWidth, int maxHeight, bool highQuality);
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CameraDevice)
};


+ 5
- 3
modules/juce_video/native/juce_mac_CameraDevice.mm View File

@@ -30,7 +30,8 @@ extern Image juce_createImageFromCIImage (CIImage*, int w, int h);
struct CameraDevice::Pimpl
{
Pimpl (const String&, const int index, int /*minWidth*/, int /*minHeight*/, int /*maxWidth*/, int /*maxHeight*/)
Pimpl (const String&, const int index, int /*minWidth*/, int /*minHeight*/, int /*maxWidth*/, int /*maxHeight*/,
bool useHighQuality)
: input (nil),
audioDevice (nil),
audioInput (nil),
@@ -66,8 +67,9 @@ struct CameraDevice::Pimpl
if (err == nil)
{
resetFile();
imageOutput = useHighQuality ? [[QTCaptureDecompressedVideoOutput alloc] init] :
[[QTCaptureVideoPreviewOutput alloc] init];
imageOutput = [[QTCaptureDecompressedVideoOutput alloc] init];
[imageOutput setDelegate: callbackDelegate];
if (err == nil)
@@ -263,7 +265,7 @@ struct CameraDevice::Pimpl
QTCaptureDeviceInput* audioInput;
QTCaptureSession* session;
QTCaptureMovieFileOutput* fileOutput;
QTCaptureDecompressedVideoOutput* imageOutput;
QTCaptureOutput* imageOutput;
NSObject* callbackDelegate;
String openingError;
int64 firstPresentationTime, averageTimeOffset;


+ 1
- 1
modules/juce_video/native/juce_win32_CameraDevice.cpp View File

@@ -49,7 +49,7 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster
{
Pimpl (const String&, int index,
int minWidth, int minHeight,
int maxWidth, int maxHeight)
int maxWidth, int maxHeight, bool /*highQuality*/)
: isRecording (false),
openedSuccessfully (false),
imageNeedsFlipping (false),


+ 2
- 2
modules/juce_video/native/juce_win32_DirectShowComponent.cpp View File

@@ -597,10 +597,10 @@ private:
if (wc->isRegistered())
{
DWORD exstyle = 0;
DWORD type = WS_CHILD;
DWORD windowType = WS_CHILD;
hwnd = CreateWindowEx (exstyle, wc->getWindowClassName(),
L"", type, 0, 0, 0, 0, parentToAddTo, 0,
L"", windowType, 0, 0, 0, 0, parentToAddTo, 0,
(HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0);
if (hwnd != 0)


Loading…
Cancel
Save