static int v4m_stop(MSFilter *f, void *arg){ V4lState *s=(V4lState*)f->data; if (s->seqgrab!=NULL){ SGStop(s->seqgrab); v4m_close(s); } return 0; }
///////////////////////////////////////////////////////// // startTransfer // ///////////////////////////////////////////////////////// int pix_videoDarwin :: stopTransfer() { OSErr err = noErr; //might need SGPause or SGStop here err = SGStop(m_sg); if (err != noErr)error("SGStop failed with error %d",err); return 1; }
//-------------------------------------------------------------------- bool ofVideoGrabber::qtCloseSeqGrabber(){ if (gSeqGrabber != NULL){ SGStop (gSeqGrabber); CloseComponent (gSeqGrabber); gSeqGrabber = NULL; bSgInited = false; return true; } return false; }
void DoCloseSG(ComponentInstance seqGrab, SGChannel sgChannel, SGDataUPP dataProc) { if(seqGrab) { SGStop(seqGrab); SGSetDataProc(seqGrab, NULL ,NULL); if (dataProc) { DisposeSGDataUPP(dataProc); } SGDisposeChannel(seqGrab, sgChannel); CloseComponent(seqGrab); } }
// ###################################################################### QuickTimeGrabber::Impl::~Impl() { const std::string summary = this->getSummary(); if (summary.size() > 0) LINFO("%s", summary.c_str()); if (itsSeqGrab.it != 0) SGStop(itsSeqGrab.it); // clean up the bits if (itsDrawSeq) CDSequenceEnd(itsDrawSeq); DisposeGWorld(itsGWorld); }
// ###################################################################### GenericFrame QuickTimeGrabber::Impl::readFrame() { if (!itsStreamStarted) this->startStream(); while (1) { itsGotFrame = false; itsErrorMsg = ""; if (noErr != SGIdle(itsSeqGrab.it)) LFATAL("SGIdle() failed"); if (itsErrorMsg.length() > 0) { // some error specific to SGIdle occurred - any errors // returned from the data proc will also show up here and we // don't want to write over them // in QT 4 you would always encounter a cDepthErr error // after a user drags the window, this failure condition has // been greatly relaxed in QT 5 it may still occur but // should only apply to vDigs that really control the screen // you don't always know where these errors originate from, // some may come from the VDig... LFATAL("QuickTimeGrabber error during SGIdle (%s)", itsErrorMsg.c_str()); // ...to fix this we simply call SGStop and SGStartRecord // again calling stop allows the SG to release and // re-prepare for grabbing hopefully fixing any problems, // this is obviously a very relaxed approach SGStop(itsSeqGrab.it); SGStartRecord(itsSeqGrab.it); } if (itsGotFrame) return GenericFrame(itsCurrentImage); usleep(20000); } }
static GstStateChangeReturn gst_osx_video_src_change_state (GstElement * element, GstStateChange transition) { GstStateChangeReturn result; GstOSXVideoSrc *self; ComponentResult err; result = GST_STATE_CHANGE_SUCCESS; self = GST_OSX_VIDEO_SRC (element); // ###: prepare_capture in READY->PAUSED? switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_PLAYING: { ImageDescriptionHandle imageDesc; Rect sourceRect; MatrixRecord scaleMatrix; if (!prepare_capture (self)) return GST_STATE_CHANGE_FAILURE; // ###: should we start recording /after/ making the decompressionsequence? // CocoaSequenceGrabber does it beforehand, so we do too, but it feels // wrong. err = SGStartRecord (self->seq_grab); if (err != noErr) { /* since we prepare here, we should also unprepare */ SGRelease (self->seq_grab); GST_ERROR_OBJECT (self, "SGStartRecord returned %d", (int) err); return GST_STATE_CHANGE_FAILURE; } imageDesc = (ImageDescriptionHandle) NewHandle (0); err = SGGetChannelSampleDescription (self->video_chan, (Handle) imageDesc); if (err != noErr) { SGStop (self->seq_grab); SGRelease (self->seq_grab); DisposeHandle ((Handle) imageDesc); GST_ERROR_OBJECT (self, "SGGetChannelSampleDescription returned %d", (int) err); return GST_STATE_CHANGE_FAILURE; } GST_DEBUG_OBJECT (self, "actual capture resolution is %dx%d", (int) (**imageDesc).width, (int) (**imageDesc).height); SetRect (&sourceRect, 0, 0, (**imageDesc).width, (**imageDesc).height); RectMatrix (&scaleMatrix, &sourceRect, &self->rect); err = DecompressSequenceBegin (&self->dec_seq, imageDesc, self->world, NULL, NULL, &scaleMatrix, srcCopy, NULL, 0, codecNormalQuality, bestSpeedCodec); if (err != noErr) { SGStop (self->seq_grab); SGRelease (self->seq_grab); DisposeHandle ((Handle) imageDesc); GST_ERROR_OBJECT (self, "DecompressSequenceBegin returned %d", (int) err); return GST_STATE_CHANGE_FAILURE; } DisposeHandle ((Handle) imageDesc); break; } default: break; } result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); if (result == GST_STATE_CHANGE_FAILURE) return result; switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: SGStop (self->seq_grab); err = CDSequenceEnd (self->dec_seq); if (err != noErr) GST_WARNING_OBJECT (self, "CDSequenceEnd returned %d", (int) err); self->dec_seq = 0; SGRelease (self->seq_grab); break; default: break; } return result; }