|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_PRIV_HPP
|
|
|
#define OPENCV_GAPI_STREAMING_GSTREAMER_GSTREAMERSOURCE_PRIV_HPP
|
|
|
|
|
|
#include "gstreamerptr.hpp"
|
|
|
#include "gstreamer_pipeline_facade.hpp"
|
|
|
#include <opencv2/gapi/streaming/gstreamer/gstreamersource.hpp>
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
#include <gst/gst.h>
|
|
|
#include <gst/video/video-frame.h>
|
|
|
#endif
|
|
|
|
|
|
namespace cv {
|
|
|
namespace gapi {
|
|
|
namespace wip {
|
|
|
namespace gst {
|
|
|
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
|
|
|
class GStreamerSource::Priv
|
|
|
{
|
|
|
public:
|
|
|
Priv(const std::string& pipeline, const GStreamerSource::OutputType outputType);
|
|
|
|
|
|
Priv(std::shared_ptr<GStreamerPipelineFacade> pipeline, const std::string& appsinkName,
|
|
|
const GStreamerSource::OutputType outputType);
|
|
|
|
|
|
bool pull(cv::gapi::wip::Data& data);
|
|
|
|
|
|
|
|
|
GMetaArg descr_of() noexcept;
|
|
|
|
|
|
virtual ~Priv();
|
|
|
|
|
|
protected:
|
|
|
|
|
|
std::shared_ptr<GStreamerPipelineFacade> m_pipeline;
|
|
|
|
|
|
|
|
|
GStreamerPtr<GstElement> m_appsink;
|
|
|
GStreamerPtr<GstSample> m_sample;
|
|
|
GstBuffer* m_buffer = nullptr;
|
|
|
GstVideoInfo m_videoInfo;
|
|
|
|
|
|
GStreamerSource::OutputType m_outputType = GStreamerSource::OutputType::MAT;
|
|
|
|
|
|
GMatDesc m_matMeta;
|
|
|
GFrameDesc m_mediaFrameMeta;
|
|
|
|
|
|
bool m_isMetaPrepared = false;
|
|
|
bool m_isPipelinePlaying = false;
|
|
|
|
|
|
int64_t m_frameId = 0L;
|
|
|
size_t m_type = 0;
|
|
|
|
|
|
protected:
|
|
|
void configureAppsink();
|
|
|
void prepareVideoMeta();
|
|
|
|
|
|
int64_t computeTimestamp();
|
|
|
|
|
|
bool pullBuffer();
|
|
|
bool retrieveFrame(cv::Mat& data);
|
|
|
bool retrieveFrame(cv::MediaFrame& data);
|
|
|
};
|
|
|
|
|
|
#else
|
|
|
|
|
|
class GStreamerSource::Priv
|
|
|
{
|
|
|
public:
|
|
|
Priv(const std::string& pipeline, const GStreamerSource::OutputType outputType);
|
|
|
Priv(std::shared_ptr<GStreamerPipelineFacade> pipeline, const std::string& appsinkName,
|
|
|
const GStreamerSource::OutputType outputType);
|
|
|
bool pull(cv::gapi::wip::Data& data);
|
|
|
GMetaArg descr_of() const noexcept;
|
|
|
virtual ~Priv();
|
|
|
};
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|