1

I am trying to retrieve the frame from a Decklink input device for QT and pass this into a video sample queue for writing. The Line I am struggling with is how [this] is being passed as it says no suitable user defined conversion from type to const.

m_selectedDevice->OnVideoFrameArrival([this](CComPtr<IDeckLinkVideoInputFrame> frame) {
        if (Kraken_VideoRecorder().m_captureState == Kraken_VideoRecorder::CaptureState::Recording)
        {
            m_videoSampleQueue->VideoFrameArrived(frame);

            // Update UI with recording stream time
            //PostMessage(WM_UPDATE_STREAM_TIME_MESSAGE, 0, 0);
        }
    });


///This is defined as a QWidget
class DeckLinkInputPage : public QWidget
{
    Q_OBJECT

public:
//etc
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
JPonsford
  • 11
  • 1
  • Capturing in lambdas can be tricky. This might be rather a C++ issue than a Qt issue. However, this would be easier to answer if you could provide a little bit more background - e.g. a link to the resp. API functions or, at least, the declaration of these functions. Are you sure that `OnVideoFrameArrival()` takes a function (or functor) pointer? (If not, the parentheses (`()`) are missing at end of lambda.) – Scheff's Cat Apr 02 '20 at 08:54
  • Please attach a minimal working example, preferably without using external libraries, and in any case, always attach the compiler output. ( https://en.wikipedia.org/wiki/Minimal_working_example ) – NadavS Apr 02 '20 at 08:57
  • This is how OnVideoFrameArrival is defined: `void OnVideoFrameArrival(const VideoFrameArrivedCallback& callback) { m_videoFrameArrivedCallback = callback; }` – JPonsford Apr 02 '20 at 09:02
  • Its going to hard to create a minimal working example as the project relies on so many external libraries to compile. – JPonsford Apr 02 '20 at 09:03
  • Did you notice the `const` in `const VideoFrameArrivedCallback& callback`. This makes the functor object `const` and, hence, only `const` member functions may be used. As I already said, capturing in lambdas may be tricky. Have a look at [Lambda expressions](https://en.cppreference.com/w/cpp/language/lambda) to puzzle this out. (I must admit I do not yet get the ful context. Hence, only this foggy hint.) ;-) A dirty work-around might be a non-const cast at the right place to work-around your issue but I would consider this as last resort in desperation. – Scheff's Cat Apr 02 '20 at 09:06
  • Still stuck :/ I've put a section of my code on Github The error is on line 279 on ( DeckLinkInputPage.cpp) The error I'm getting is no suitable user defined conversion from type to const https://gist.github.com/jponsford95/568aeb21273c4caf691bed9a5bda2072?fbclid=IwAR3IsRAfXDtjme70373L3bwE78GOgmpmY0WvcQibObTWz4lSyGWq8VAr60g – JPonsford Apr 08 '20 at 15:36

0 Answers0