diff --git a/modules/juce_video/capture/juce_CameraDevice.cpp b/modules/juce_video/capture/juce_CameraDevice.cpp index e879bba223..85bd7f9347 100644 --- a/modules/juce_video/capture/juce_CameraDevice.cpp +++ b/modules/juce_video/capture/juce_CameraDevice.cpp @@ -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 d (new CameraDevice (getAvailableDevices() [index], index, - minWidth, minHeight, maxWidth, maxHeight)); + minWidth, minHeight, maxWidth, maxHeight, + highQuality)); if (d->pimpl->openedOk()) return d.release(); diff --git a/modules/juce_video/capture/juce_CameraDevice.h b/modules/juce_video/capture/juce_CameraDevice.h index ec76b24d05..5f560e1d52 100644 --- a/modules/juce_video/capture/juce_CameraDevice.h +++ b/modules/juce_video/capture/juce_CameraDevice.h @@ -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) }; diff --git a/modules/juce_video/native/juce_mac_CameraDevice.mm b/modules/juce_video/native/juce_mac_CameraDevice.mm index d237b69acc..1b310c99a1 100644 --- a/modules/juce_video/native/juce_mac_CameraDevice.mm +++ b/modules/juce_video/native/juce_mac_CameraDevice.mm @@ -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; diff --git a/modules/juce_video/native/juce_win32_CameraDevice.cpp b/modules/juce_video/native/juce_win32_CameraDevice.cpp index 83d16e6241..4880e6c03a 100644 --- a/modules/juce_video/native/juce_win32_CameraDevice.cpp +++ b/modules/juce_video/native/juce_win32_CameraDevice.cpp @@ -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), diff --git a/modules/juce_video/native/juce_win32_DirectShowComponent.cpp b/modules/juce_video/native/juce_win32_DirectShowComponent.cpp index 003a2ecbbf..8ad6e3e637 100644 --- a/modules/juce_video/native/juce_win32_DirectShowComponent.cpp +++ b/modules/juce_video/native/juce_win32_DirectShowComponent.cpp @@ -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)