|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "gstreamerenv.hpp"
|
|
|
#include "gstreamerptr.hpp"
|
|
|
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
#include <gst/gst.h>
|
|
|
#endif
|
|
|
|
|
|
namespace cv {
|
|
|
namespace gapi {
|
|
|
namespace wip {
|
|
|
namespace gst {
|
|
|
|
|
|
#ifdef HAVE_GSTREAMER
|
|
|
|
|
|
const GStreamerEnv& GStreamerEnv::init()
|
|
|
{
|
|
|
static GStreamerEnv gInit;
|
|
|
return gInit;
|
|
|
}
|
|
|
|
|
|
GStreamerEnv::GStreamerEnv()
|
|
|
{
|
|
|
if (!gst_is_initialized())
|
|
|
{
|
|
|
GError* error = NULL;
|
|
|
gst_init_check(NULL, NULL, &error);
|
|
|
|
|
|
GStreamerPtr<GError> err(error);
|
|
|
|
|
|
if (err)
|
|
|
{
|
|
|
cv::util::throw_error(
|
|
|
std::runtime_error(std::string("GStreamer initializaton error! Details: ") +
|
|
|
err->message));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guint major, minor, micro, nano;
|
|
|
gst_version(&major, &minor, µ, &nano);
|
|
|
if (GST_VERSION_MAJOR != major)
|
|
|
{
|
|
|
cv::util::throw_error(
|
|
|
std::runtime_error(std::string("Incompatible GStreamer version: compiled with ") +
|
|
|
std::to_string(GST_VERSION_MAJOR) + '.' +
|
|
|
std::to_string(GST_VERSION_MINOR) + '.' +
|
|
|
std::to_string(GST_VERSION_MICRO) + '.' +
|
|
|
std::to_string(GST_VERSION_NANO) +
|
|
|
", but runtime has " +
|
|
|
std::to_string(major) + '.' + std::to_string(minor) + '.' +
|
|
|
std::to_string(micro) + '.' + std::to_string(nano) + '.'));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
GStreamerEnv::~GStreamerEnv()
|
|
|
{
|
|
|
gst_deinit();
|
|
|
}
|
|
|
|
|
|
#else
|
|
|
|
|
|
const GStreamerEnv& GStreamerEnv::init()
|
|
|
{
|
|
|
GAPI_Error("Built without GStreamer support!");
|
|
|
}
|
|
|
|
|
|
GStreamerEnv::GStreamerEnv()
|
|
|
{
|
|
|
GAPI_Error("Built without GStreamer support!");
|
|
|
}
|
|
|
|
|
|
GStreamerEnv::~GStreamerEnv()
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|