| @@ -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, | CameraDevice* CameraDevice::openDevice (int index, | ||||
| int minWidth, int minHeight, | int minWidth, int minHeight, | ||||
| int maxWidth, int maxHeight) | |||||
| int maxWidth, int maxHeight, | |||||
| bool highQuality) | |||||
| { | { | ||||
| ScopedPointer<CameraDevice> d (new CameraDevice (getAvailableDevices() [index], index, | ScopedPointer<CameraDevice> d (new CameraDevice (getAvailableDevices() [index], index, | ||||
| minWidth, minHeight, maxWidth, maxHeight)); | |||||
| minWidth, minHeight, maxWidth, maxHeight, | |||||
| highQuality)); | |||||
| if (d->pimpl->openedOk()) | if (d->pimpl->openedOk()) | ||||
| return d.release(); | return d.release(); | ||||
| @@ -58,10 +58,15 @@ public: | |||||
| The size constraints allow the method to choose between different resolutions if | 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) | the camera supports this. If the resolution cam't be specified (e.g. on the Mac) | ||||
| then these will be ignored. | 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, | static CameraDevice* openDevice (int deviceIndex, | ||||
| int minWidth = 128, int minHeight = 64, | 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 */ | /** Returns the name of this device */ | ||||
| @@ -147,7 +152,7 @@ private: | |||||
| friend struct ViewerComponent; | friend struct ViewerComponent; | ||||
| CameraDevice (const String& name, int index, | 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) | JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (CameraDevice) | ||||
| }; | }; | ||||
| @@ -30,7 +30,8 @@ extern Image juce_createImageFromCIImage (CIImage*, int w, int h); | |||||
| struct CameraDevice::Pimpl | 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), | : input (nil), | ||||
| audioDevice (nil), | audioDevice (nil), | ||||
| audioInput (nil), | audioInput (nil), | ||||
| @@ -66,8 +67,9 @@ struct CameraDevice::Pimpl | |||||
| if (err == nil) | if (err == nil) | ||||
| { | { | ||||
| resetFile(); | resetFile(); | ||||
| imageOutput = useHighQuality ? [[QTCaptureDecompressedVideoOutput alloc] init] : | |||||
| [[QTCaptureVideoPreviewOutput alloc] init]; | |||||
| imageOutput = [[QTCaptureDecompressedVideoOutput alloc] init]; | |||||
| [imageOutput setDelegate: callbackDelegate]; | [imageOutput setDelegate: callbackDelegate]; | ||||
| if (err == nil) | if (err == nil) | ||||
| @@ -263,7 +265,7 @@ struct CameraDevice::Pimpl | |||||
| QTCaptureDeviceInput* audioInput; | QTCaptureDeviceInput* audioInput; | ||||
| QTCaptureSession* session; | QTCaptureSession* session; | ||||
| QTCaptureMovieFileOutput* fileOutput; | QTCaptureMovieFileOutput* fileOutput; | ||||
| QTCaptureDecompressedVideoOutput* imageOutput; | |||||
| QTCaptureOutput* imageOutput; | |||||
| NSObject* callbackDelegate; | NSObject* callbackDelegate; | ||||
| String openingError; | String openingError; | ||||
| int64 firstPresentationTime, averageTimeOffset; | int64 firstPresentationTime, averageTimeOffset; | ||||
| @@ -49,7 +49,7 @@ struct CameraDevice::Pimpl : public ChangeBroadcaster | |||||
| { | { | ||||
| Pimpl (const String&, int index, | Pimpl (const String&, int index, | ||||
| int minWidth, int minHeight, | int minWidth, int minHeight, | ||||
| int maxWidth, int maxHeight) | |||||
| int maxWidth, int maxHeight, bool /*highQuality*/) | |||||
| : isRecording (false), | : isRecording (false), | ||||
| openedSuccessfully (false), | openedSuccessfully (false), | ||||
| imageNeedsFlipping (false), | imageNeedsFlipping (false), | ||||
| @@ -597,10 +597,10 @@ private: | |||||
| if (wc->isRegistered()) | if (wc->isRegistered()) | ||||
| { | { | ||||
| DWORD exstyle = 0; | DWORD exstyle = 0; | ||||
| DWORD type = WS_CHILD; | |||||
| DWORD windowType = WS_CHILD; | |||||
| hwnd = CreateWindowEx (exstyle, wc->getWindowClassName(), | 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); | (HINSTANCE) Process::getCurrentModuleInstanceHandle(), 0); | ||||
| if (hwnd != 0) | if (hwnd != 0) | ||||