RTMP::RTMP(quid::Config&& conf) : Quiddity(std::forward<quid::Config>(conf)), shmcntr_(static_cast<Quiddity*>(this)), gst_pipeline_(std::make_unique<GstPipeliner>(nullptr, nullptr)) { stream_app_url_id_ = pmanage<MPtr(&PContainer::make_string)>( "stream_app_url", [this](const std::string& val) { stream_app_url_ = val; if (!stream_key_.empty() && (!audio_shmpath_.empty() || !video_shmpath_.empty())) return create_gst_pipeline(); return true; }, [this]() { return stream_app_url_; }, "Stream application URL", "RTMP address used to stream.", stream_app_url_); stream_key_id_ = pmanage<MPtr(&PContainer::make_string)>( "stream_key", [this](const std::string& val) { stream_key_ = val; if (!stream_app_url_.empty() && (!audio_shmpath_.empty() || !video_shmpath_.empty())) return create_gst_pipeline(); return true; }, [this]() { return stream_key_; }, "Stream key", "Stream application-specific stream key needed to link to application account.", stream_key_); shmcntr_.install_connect_method( [this](const std::string& shmpath) { if (StringUtils::ends_with(shmpath, "video-encoded")) return on_shmdata_connect(shmpath, ShmType::VIDEO); else return on_shmdata_connect(shmpath, ShmType::AUDIO); }, [this](const std::string& shmpath) { if (StringUtils::ends_with(shmpath, "video-encoded")) return on_shmdata_disconnect(ShmType::VIDEO); else return on_shmdata_disconnect(ShmType::AUDIO); }, nullptr, [this](const std::string& caps) { return can_sink_caps(caps); }, std::numeric_limits<unsigned int>::max()); }
static void demux_pad_added (GstElement * element, GstPad * pad, RsnDvdBin * dvdbin) { gboolean skip_mq = FALSE; GstPad *mq_pad = NULL; GstPad *dest_pad = NULL; GstCaps *caps; GstStructure *s; GST_DEBUG_OBJECT (dvdbin, "New pad: %" GST_PTR_FORMAT, pad); caps = gst_pad_get_caps (pad); if (caps == NULL) { GST_WARNING_OBJECT (dvdbin, "NULL caps from pad %" GST_PTR_FORMAT, pad); return; } if (!gst_caps_is_fixed (caps)) { GST_WARNING_OBJECT (dvdbin, "Unfixed caps %" GST_PTR_FORMAT " on pad %" GST_PTR_FORMAT, caps, pad); gst_caps_unref (caps); return; } GST_DEBUG_OBJECT (dvdbin, "Pad %" GST_PTR_FORMAT " has caps: %" GST_PTR_FORMAT, pad, caps); s = gst_caps_get_structure (caps, 0); g_return_if_fail (s != NULL); if (can_sink_caps (dvdbin->pieces[DVD_ELEM_VIDDEC], caps)) { dest_pad = gst_element_get_static_pad (dvdbin->pieces[DVD_ELEM_VIDDEC], "sink"); } else if (g_str_equal (gst_structure_get_name (s), "video/x-dvd-subpicture")) { dest_pad = gst_element_get_request_pad (dvdbin->pieces[DVD_ELEM_SPU_SELECT], "sink%d"); skip_mq = TRUE; } else if (can_sink_caps (dvdbin->pieces[DVD_ELEM_AUDDEC], caps)) { GST_LOG_OBJECT (dvdbin, "Found audio pad w/ caps %" GST_PTR_FORMAT, caps); dest_pad = gst_element_get_request_pad (dvdbin->pieces[DVD_ELEM_AUD_SELECT], "sink%d"); } else { GstStructure *s; GST_DEBUG_OBJECT (dvdbin, "Ignoring unusable pad w/ caps %" GST_PTR_FORMAT, caps); gst_element_post_message (GST_ELEMENT_CAST (dvdbin), gst_missing_decoder_message_new (GST_ELEMENT_CAST (dvdbin), caps)); s = gst_caps_get_structure (caps, 0); if (g_str_has_prefix ("video/", gst_structure_get_name (s))) { GST_ELEMENT_ERROR (dvdbin, STREAM, CODEC_NOT_FOUND, (NULL), ("No MPEG video decoder found")); } else { GST_ELEMENT_WARNING (dvdbin, STREAM, CODEC_NOT_FOUND, (NULL), ("No MPEG video decoder found")); } } gst_caps_unref (caps); if (dest_pad == NULL) { GST_DEBUG_OBJECT (dvdbin, "Don't know how to handle pad. Ignoring"); return; } if (skip_mq) { mq_pad = gst_object_ref (pad); } else { mq_pad = connect_thru_mq (dvdbin, pad); if (mq_pad == NULL) goto failed; GST_DEBUG_OBJECT (dvdbin, "Linking new pad %" GST_PTR_FORMAT " through multiqueue to %" GST_PTR_FORMAT, pad, dest_pad); } gst_pad_link (mq_pad, dest_pad); gst_object_unref (mq_pad); gst_object_unref (dest_pad); return; failed: GST_ELEMENT_ERROR (dvdbin, CORE, FAILED, (NULL), ("Failed to handle new demuxer pad %s", GST_PAD_NAME (pad))); if (mq_pad) gst_object_unref (mq_pad); if (dest_pad) gst_object_unref (dest_pad); return; }
bool PostureMerge::init() { init_startable(this); shmcntr_.install_connect_method([this](const std::string path){return connect(path);}, [this](const std::string path){return disconnect(path);}, [this](){return disconnect_all();}, [this](const std::string caps ){return can_sink_caps(caps);}, 8); calibration_path_prop_ = custom_props_->make_string_property("calibration_path", "Path to the calibration file", calibration_path_.c_str(), (GParamFlags) G_PARAM_READWRITE, PostureMerge::set_calibration_path, PostureMerge::get_calibration_path, this); install_property_by_pspec(custom_props_->get_gobject(), calibration_path_prop_, "calibration_path", "Path to the calibration file"); devices_path_prop_ = custom_props_->make_string_property("devices_path", "Path to the devices description file", devices_path_.c_str (), (GParamFlags) G_PARAM_READWRITE, PostureMerge::set_devices_path, PostureMerge::get_devices_path, this); install_property_by_pspec(custom_props_->get_gobject(), devices_path_prop_, "devices", "Path to the devices description file"); compress_cloud_prop_ = custom_props_->make_boolean_property("compress_cloud", "Compress the cloud if true", compress_cloud_, (GParamFlags) G_PARAM_READWRITE, PostureMerge::set_compress_cloud, PostureMerge::get_compress_cloud, this); install_property_by_pspec(custom_props_->get_gobject(), compress_cloud_prop_, "compress_cloud", "Compress the cloud if true"); reload_calibration_prop_ = custom_props_->make_boolean_property("reload_calibration", "Reload calibration at each frame", reload_calibration_, (GParamFlags) G_PARAM_READWRITE, PostureMerge::set_reload_calibration, PostureMerge::get_reload_calibration, this); install_property_by_pspec(custom_props_->get_gobject(), reload_calibration_prop_, "reload_calibration", "Reload calibration at each frame"); save_cloud_prop_ = custom_props_->make_boolean_property("save_cloud", "Save the current cloud if true", save_cloud_, (GParamFlags) G_PARAM_READWRITE, PostureMerge::set_save_cloud, PostureMerge::get_save_cloud, this); install_property_by_pspec(custom_props_->get_gobject(), save_cloud_prop_, "save_cloud", "Save the current cloud if true"); downsample_prop_ = custom_props_->make_boolean_property("downsample", "Activate the cloud downsampling", downsample_, (GParamFlags) G_PARAM_READWRITE, PostureMerge::set_downsample_active, PostureMerge::get_downsample_active, this); install_property_by_pspec(custom_props_->get_gobject(), downsample_prop_, "downsample", "Activate the cloud downsampling"); return true; }
bool PostureMerge::init() { init_startable(this); shmcntr_.install_connect_method([this](const std::string path) { return connect(path); }, [this](const std::string path) { return disconnect(path); }, [this]() { return disconnect_all(); }, [this](const std::string caps) { return can_sink_caps(caps); }, 8); pmanage<MPtr(&PContainer::make_string)>( "calibration_path", [this](const std::string& val) { calibration_path_ = val; if (calibration_reader_) { calibration_reader_->loadCalibration(calibration_path_); merger_->setCalibration(calibration_reader_->getCalibrationParams()); } return true; }, [this]() { return calibration_path_; }, "Calibration path", "Path to the calibration file", calibration_path_); pmanage<MPtr(&PContainer::make_bool)>("compress_cloud", [this](const bool& val) { compress_cloud_ = val; return true; }, [this]() { return compress_cloud_; }, "Compression", "Compress the cloud if true", compress_cloud_); pmanage<MPtr(&PContainer::make_bool)>("reload_calibration", [this](const bool& val) { reload_calibration_ = val; return true; }, [this]() { return reload_calibration_; }, "Reload calibration", "Reload calibration at each frame", reload_calibration_); pmanage<MPtr(&PContainer::make_bool)>("save_cloud", [this](const bool& val) { save_cloud_ = val; return true; }, [this]() { return save_cloud_; }, "Save current cloud", "Save the current cloud if true", save_cloud_); pmanage<MPtr(&PContainer::make_bool)>( "downsample", [this](const bool& active) { if (downsample_ != active && active == true) { downsample_ = active; downsample_resolution_id_ = pmanage<MPtr(&PContainer::make_double)>( "downsample_resolution", [this](const double& val) { downsample_resolution_ = val; if (merger_ != nullptr) merger_->setDownsampling(downsample_, downsample_resolution_); return true; }, [this]() { return downsample_resolution_; }, "Resampling resolution", "Resampling resolution", downsample_resolution_, 0.01, 1.0); } else if (downsample_ != active && active == false) { downsample_ = false; pmanage<MPtr(&PContainer::remove)>(downsample_resolution_id_); } if (merger_ != nullptr) merger_->setDownsampling(downsample_, downsample_resolution_); return true; }, [this]() { return downsample_; }, "Downsample", "Activate the cloud downsampling", downsample_); return true; }