35 #include "qedit_wrapper.h"
37 extern "C" const CLSID CLSID_SampleGrabber;
39 comutils::Ptr<ISampleGrabber> grabber;
42 SampleGrabberWrapper::SampleGrabberWrapper()
47 printf(
"directx_camera_server::open_and_find_parameters(): Before "
48 "CoCreateInstance SampleGrabber\n");
51 CoCreateInstance(CLSID_SampleGrabber,
nullptr, CLSCTX_INPROC_SERVER,
52 IID_IBaseFilter, AttachPtr(sampleGrabber_));
53 if (!sampleGrabber_) {
54 throw std::runtime_error(
"Could not create Sample Grabber filter - "
55 "possibly missing DirectShow/DirectX 8.1+?");
58 sampleGrabber_->QueryInterface(IID_ISampleGrabber,
59 AttachPtr(impl_->grabber));
64 AM_MEDIA_TYPE mt = {0};
65 mt.majortype = MEDIATYPE_Video;
66 mt.subtype = MEDIASUBTYPE_RGB24;
67 impl_->grabber->SetMediaType(&mt);
69 impl_->grabber->SetCallback(callback_.get(),
73 impl_->grabber->SetOneShot(FALSE);
77 impl_->grabber->SetBufferSamples(FALSE);
80 SampleGrabberWrapper::~SampleGrabberWrapper() {
shutdown(); }
83 BOOST_ASSERT(impl_ && impl_->grabber);
84 auto hr = impl_->grabber->GetConnectedMediaType(&mt);
86 throw std::runtime_error(
"Could not get connected media type - is "
87 "there nothing connected on the input pin of "
94 BOOST_ASSERT(impl_ && impl_->grabber);
95 impl_->grabber->SetCallback(
nullptr, 0 );
98 callback_->shutdown();
void shutdown()
Gets the callback to finish up all its samples.
void getConnectedMediaType(AM_MEDIA_TYPE &mt)
Forwards call on to SampleGrabber.