Hi,
i am trying to implement a gstreamermm plugin for a H264 hardware encoder using gstreamermm.
i am extending Gst::PushSrc for this.
listening to Query Events using
this->get_src_pad()->set_query_function(sigc::mem_fun(*this, &FooSrc::query_event));
i am processing the query events as specified below
gboolean query_event(const Glib::RefPtr<Gst::Pad>& pad, Glib::RefPtr<Gst::Query>& queryevent)
{
std::cout << "got a query event: " << pad->get_name() << ":" << queryevent->get_query_type() << std::endl;
switch (queryevent->get_query_type())
{
case Gst::QueryType::QUERY_CAPS:
{
Glib::RefPtr<Gst::QueryCaps> querycaps = Glib::RefPtr<Gst::QueryCaps>::cast_static(queryevent);
auto newquerycaps = Glib::RefPtr<Gst::QueryCaps>::cast_static(querycaps->create_writable());
auto caps = Gst::Caps::create_from_string(
"video/x-h264, stream-format=(string)byte-stream, alignment=(string)au");
newquerycaps->set_caps_result(caps);
return true;
}
}
return false;
}
but after the function has executed i get hit by the following error.
GStreamer-CRITICAL **: 20:04:41.081: gst_mini_object_ref: assertion 'mini_object != NULL' failed
to over come this, if we use the c interface for the above code , everything works perfectly fine.
gboolean query_event(const Glib::RefPtr<Gst::Pad>& pad, Glib::RefPtr<Gst::Query>& queryevent)
{
std::cout << "got a query event: " << pad->get_name() << ":" << queryevent->get_query_type() << std::endl;
switch (queryevent->get_query_type())
{
case Gst::QueryType::QUERY_CAPS:
{
std::cout << "Gst Query Event is writable:" << queryevent->is_writable() << std::endl;
auto * q = queryevent->gobj();
std::cout << "Gst Query is writable: " << gst_query_is_writable(q) << std::endl;
auto * wq = gst_query_make_writable(q);
auto * newcaps = gst_caps_new_simple("video/x-h264",
"stream-format",G_TYPE_STRING,"byte-stream",
"alignment",G_TYPE_STRING,"au",
NULL);
gst_query_set_caps_result(wq, newcaps);
std::cout << "Gst Query is written : " << std::endl;
gst_caps_unref (newcaps);
return true;
}
}
return false;
}
please do suggest.
--
Regards
Ankur Deep Jaiswal
Software Architect
Techgentsia Software Technologies Private Limited
Ernakulam