示例#1
0
bool GstUtils::get_structure_field(const Structure& structure, const Glib::ustring& fieldname, RefPtr<const Caps>& value)
{
	Glib::ValueBase base;
	structure.get_field(fieldname, base);

	if (!GST_VALUE_HOLDS_CAPS(base.gobj()))
		return false;

	value = Glib::wrap(const_cast<GstCaps*>(gst_value_get_caps(base.gobj())), true);
	return true;
}
示例#2
0
ObjectNodeInfo GstUtils::parse_caps(const RefPtr<Caps>& caps)
{
	Glib::ustring caps_str;

	bool finish = true;

	if (!caps || caps->empty())
		caps_str = "EMPTY";
	else if (caps->is_any())
		caps_str = "ANY";
	else finish = false;

	if (finish)
		return ObjectNodeInfo(caps_str);

	ObjectNodeInfo ret;

	for (guint i = 0; i < caps->size(); i++)
	{
		Structure structure = caps->get_structure(i);
		ObjectNodeInfo obj;

		for (int j = 0; j < structure.size(); j++)
		{
			Glib::ustring field_name = structure.get_nth_field_name(j);
			Glib::ValueBase base;

			structure.get_field(field_name, base);
			obj.insert(field_name, ObjectNodeInfo(gst_value_serialize(base.gobj())));
		}
		ret.insert(structure.get_name(), obj);
	}


	return ret;
}