void pix_videoDarwin :: DoVideoSettings() { Rect newActiveVideoRect; Rect curBounds, curVideoRect, newVideoRect; ComponentResult err; // Get our current state - do i need this??? err = SGGetChannelBounds (m_vc, &curBounds); err = SGGetVideoRect (m_vc, &curVideoRect); // Pause err = SGPause (m_sg, true); // Do the dialog thang err = SGSettingsDialog( m_sg, m_vc, 0, nil, 0, nil, 0); // What happened? err = SGGetVideoRect (m_vc, &newVideoRect); err = SGGetSrcVideoBounds (m_vc, &newActiveVideoRect); /* //Attempt to save SG settings to disk UserData uD = NULL; //NewUserData(uD); SGGetSettings(m_sg,&uD,0); //short uDCount; //uDCount = CountUserDataType(*uD,sgClipType); //post("UserDataType count %d",uDCount); Handle myHandle = NewHandle(0); int length; PutUserDataIntoHandle(uD,myHandle); length = GetHandleSize(myHandle); int myFile; myFile = open("/Users/lincoln/Documents/temp",O_CREAT | O_RDWR, 0600); write(myFile,myHandle,length); close(myFile); */ err = SGPause (m_sg, false); }
//-------------------------------------------------------------------- void ofQuickTimeGrabber::videoSettings(void){ //--------------------------------- #ifdef OF_VIDEO_CAPTURE_QUICKTIME //--------------------------------- Rect curBounds, curVideoRect; ComponentResult err; // Get our current state err = SGGetChannelBounds (gVideoChannel, &curBounds); if (err != noErr){ ofLogError("ofQuickTimeGrabber") << "videoSettings(): couldn't get get channel bounds: ComponentResult " << err; return; } err = SGGetVideoRect (gVideoChannel, &curVideoRect); if (err != noErr){ ofLogError("ofQuickTimeGrabber") << "videoSettings(): couldn't get video rect: ComponentResult " << err; return; } // Pause err = SGPause (gSeqGrabber, true); if (err != noErr){ ofLogError("ofQuickTimeGrabber") << "videoSettings(): couldn't set pause: ComponentResult " << err; return; } #ifdef TARGET_OSX //load any saved camera settings from file loadSettings(); static SGModalFilterUPP gSeqGrabberModalFilterUPP = NewSGModalFilterUPP(SeqGrabberModalFilterUPP); ComponentResult result = SGSettingsDialog(gSeqGrabber, gVideoChannel, 0, nil, 0, gSeqGrabberModalFilterUPP, nil); if (result != noErr){ ofLogError("ofQuickTimeGrabber") << "videoSettings(): settings dialog error: ComponentResult " << err; return; } //save any changed settings to file saveSettings(); #else SGSettingsDialog(gSeqGrabber, gVideoChannel, 0, nil, seqGrabSettingsPreviewOnly, NULL, 0); #endif SGSetChannelBounds(gVideoChannel, &videoRect); SGPause (gSeqGrabber, false); //--------------------------------- #endif //--------------------------------- }
//--------------------------------------------------------------------- bool ofVideoGrabber::loadSettings(){ if (bGrabberInited != true || deviceName.length() == 0) return false; ComponentResult err; UserData mySGVideoSettings = NULL; // get the settings using the key "ofVideoSettings-the name of the device" string pref = "ofVideoSettings-"+deviceName; CFStringRef cameraString = CFStringCreateWithCString(kCFAllocatorDefault,pref.c_str(),kCFStringEncodingMacRoman); GetSettingsPreference(cameraString, &mySGVideoSettings); if (mySGVideoSettings){ Rect curBounds, curVideoRect; //we need to make sure the dimensions don't get effected //by our preferences // Get our current state err = SGGetChannelBounds (gVideoChannel, &curBounds); if (err != noErr){ ofLog(OF_LOG_ERROR, "Error in SGGetChannelBounds"); } err = SGGetVideoRect (gVideoChannel, &curVideoRect); if (err != noErr){ ofLog(OF_LOG_ERROR, "Error in SGGetVideoRect"); } // use the saved settings preference to configure the SGChannel err = SGSetChannelSettings(gSeqGrabber, gVideoChannel, mySGVideoSettings, 0); if ( err != noErr ) { ofLog(OF_LOG_ERROR, "Error applying stored settings %i", err); return false; } DisposeUserData(mySGVideoSettings); // Pause err = SGPause (gSeqGrabber, true); if (err != noErr){ ofLog(OF_LOG_ERROR, "Error in SGPause"); } SGSetChannelBounds(gVideoChannel, &videoRect); SGPause (gSeqGrabber, false); }else{ ofLog(OF_LOG_WARNING, "No camera settings to load"); return false; } return true; }
//-------------------------------------------------------------------- void ofVideoGrabber::videoSettings(void){ //--------------------------------- #ifdef OF_VIDEO_CAPTURE_QUICKTIME //--------------------------------- Rect curBounds, curVideoRect; ComponentResult err; // Get our current state err = SGGetChannelBounds (gVideoChannel, &curBounds); if (err != noErr){ ofLog(OF_LOG_ERROR, "Error in SGGetChannelBounds"); return; } err = SGGetVideoRect (gVideoChannel, &curVideoRect); if (err != noErr){ ofLog(OF_LOG_ERROR, "Error in SGGetVideoRect"); return; } // Pause err = SGPause (gSeqGrabber, true); if (err != noErr){ ofLog(OF_LOG_ERROR, "Error in SGPause"); return; } #ifdef TARGET_OSX //load any saved camera settings from file loadSettings(); static SGModalFilterUPP gSeqGrabberModalFilterUPP = NewSGModalFilterUPP(SeqGrabberModalFilterUPP); ComponentResult result = SGSettingsDialog(gSeqGrabber, gVideoChannel, 0, nil, seqGrabSettingsPreviewOnly, gSeqGrabberModalFilterUPP, nil); if (result != noErr){ ofLog(OF_LOG_ERROR, "error in dialogue"); return; } //save any changed settings to file saveSettings(); #else SGSettingsDialog(gSeqGrabber, gVideoChannel, 0, nil, seqGrabSettingsPreviewOnly, NULL, 0); #endif SGSetChannelBounds(gVideoChannel, &videoRect); SGPause (gSeqGrabber, false); //--------------------------------- #endif //--------------------------------- //--------------------------------- #ifdef OF_VIDEO_CAPTURE_DIRECTSHOW //--------------------------------- if (bGrabberInited == true) VI.showSettingsWindow(device); //--------------------------------- #endif //--------------------------------- //--------------------------------- #ifdef OF_VIDEO_CAPTURE_UNICAP //-------------------------------- ucGrabber.queryUC_imageProperties(); //--------------------------------- #endif //--------------------------------- //--------------------------------- #ifdef OF_VIDEO_CAPTURE_V4L //-------------------------------- queryV4L_imageProperties(); //--------------------------------- #endif //--------------------------------- }