// 2. // CreateAndRunWithVideoDigitizer void QuicktimeLiveImageStream::createAndRunWithVideoDigitizer(std::string fileName) { std::string::size_type idx = fileName.find(':'); if (idx == std::string::npos) { OSG_FATAL << "Error while parsing deviceID:deviceInputID.live path : " << fileName << std::endl; } // Better c++ code is to use istrstream std::string deviceIDStr = fileName.substr(0,idx); std::string deviceInputIDStr = fileName.substr(idx+1); m_videoDeviceID = static_cast<short>(atoi(deviceIDStr.c_str())); m_videoDeviceInputID = static_cast<short>(atoi(deviceInputIDStr.c_str())); // Get Video Digitizer Rectangle bounds from a Sequence Grabber proxy (using IDs) get_video_device_bounds_idstr(m_videoDeviceID, m_videoDeviceInputID, m_videoRectWidth, m_videoRectHeight, m_videoDeviceIDStr); // Create the Image createImage(); // Create the offscreen GWorld (using Image as target memory) createGWorld(); // Create the Sequence Grabber (using GWorld as target memory) createVideoDigitizer(); // Go _status = ImageStream::PLAYING; VideoDigitizerError error = VDSetPlayThruOnOff(m_vdig, vdPlayThruOn); if (error != noErr) { OSG_FATAL << "VDSetPlayThruOnOff : error" << std::endl; } // Ticker start(); }
// 1. // CreateAndRunWithSequenceGrabber void QuicktimeLiveImageStream::createAndRunWithSequenceGrabber(std::string fileName) { std::string::size_type idx = fileName.find(':'); if (idx == std::string::npos) { osg::notify(osg::FATAL) << "Error while parsing deviceID:deviceInputID.live path : " << fileName << std::endl; } // Better c++ code is to use istrstream std::string deviceIDStr = fileName.substr(0,idx); std::string deviceInputIDStr = fileName.substr(idx+1); m_videoDeviceID = static_cast<short>(atoi(deviceIDStr.c_str())); m_videoDeviceInputID = static_cast<short>(atoi(deviceInputIDStr.c_str())); // Get Video Digitizer Rectangle bounds from a Sequence Grabber proxy (using IDs) get_video_device_bounds_idstr(m_videoDeviceID, m_videoDeviceInputID, m_videoRectWidth, m_videoRectHeight, m_videoDeviceIDStr); // Sound m_soundDeviceID = 2; m_soundDeviceInputID = 0; //get_sound_device_idstr(m_soundDeviceID, m_soundDeviceInputID, m_soundDeviceIDStr); // Create the Image createImage(); // Create the offscreen GWorld (using Image as target memory) createGWorld(); // Create the Sequence Grabber (using GWorld as target memory) createSequenceGrabber(); // Create the Sequence Grabber Video Channel createSequenceGrabberVideoChannel(); if (g_s_use_sg_record) { // Create the Sequence Grabber DataProc setup for Record createSequenceGrabberDataProc(); } // Create the Sequence Grabber Audio Channel createSequenceGrabberAudioChannel(); // Start the engine Jack! // Callbacks createSequenceGrabberVideoBottlenecks(); ComponentResult result = noErr; result = SGPrepare( m_gSeqGrabber, TRUE, FALSE); if (result != noErr) osg::notify(osg::FATAL) << "SGPrepare : error" << std::endl; if (g_s_use_sg_record) { result = SGStartRecord(m_gSeqGrabber); if (result != noErr) osg::notify(osg::FATAL) << "SGStartRecord : error" << std::endl; } else { result = SGStartPreview(m_gSeqGrabber); if (result != noErr) osg::notify(osg::FATAL) << "SGStartPreview : error" << std::endl; } _status = ImageStream::PLAYING; // Ticker start(); }