Exemplo n.º 1
0
void Uridecodebin::pad_to_shmdata_writer(GstElement* bin, GstPad* pad) {
  // detecting type of media
  bool stream_is_image = false;
  std::string padname = get_pad_name(pad);
  gchar** padname_split = g_strsplit_set(padname.c_str(), "/", -1);
  On_scope_exit { g_strfreev(padname_split); };
  stream_is_image = pad_is_image(padname);

  g_debug("uridecodebin new pad name is %s", padname.c_str());
  GstElement* shmdatasink = nullptr;
  GstUtils::make_element("shmdatasink", &shmdatasink);

  if (stream_is_image) {
    GstElement* decodebin = nullptr;
    GstUtils::make_element("decodebin", &decodebin);
    g_signal_connect(G_OBJECT(decodebin),
                     "pad-added",
                     (GCallback)Uridecodebin::decodebin_pad_added_cb,
                     (gpointer)this);
    g_object_set_data(G_OBJECT(decodebin), "decodebin", decodebin);
    g_object_set_data(G_OBJECT(decodebin), "shmdatasink", shmdatasink);
    g_object_set_data(G_OBJECT(decodebin), "bin", bin);
    gst_bin_add(GST_BIN(bin), decodebin);
    GstUtils::sync_state_with_parent(decodebin);
    GstPad* sinkpad = gst_element_get_static_pad(decodebin, "sink");
    On_scope_exit { gst_object_unref(sinkpad); };
    if (GST_PAD_LINK_OK != gst_pad_link(pad, sinkpad))
      g_warning("pad link failed from uridecodebin to decodebin (fixed image in uridecodebin)");
  } else {
Exemplo n.º 2
0
int Uridecodebin::autoplug_continue_cb(GstElement* /*bin */,
                                       GstPad* pad,
                                       GstCaps* caps,
                                       gpointer /*user_data*/) {
  GList* list = gst_registry_feature_filter(
      gst_registry_get(), (GstPluginFeatureFilter)sink_factory_filter, FALSE, caps);
  int length = g_list_length(list);
  gst_plugin_feature_list_free(list);

  if (length == 0 || pad_is_image(get_pad_name(pad))) return 0;

  return 1;
}
Exemplo n.º 3
0
void
kms_element_remove_sink_by_type_full (KmsElement * self,
    KmsElementPadType type, const gchar * description)
{
  gchar *pad_name = get_pad_name (type, description);
  GstPad *pad = gst_element_get_static_pad (GST_ELEMENT (self), pad_name);

  if (pad == NULL) {
    GST_WARNING_OBJECT (self, "Cannot get pad %s", pad_name);
    goto end;
  }

  kms_element_remove_sink (self, pad);
  g_object_unref (pad);

end:
  g_free (pad_name);
}
Exemplo n.º 4
0
GstPad *
kms_element_connect_sink_target_full (KmsElement * self, GstPad * target,
    KmsElementPadType type, const gchar * description)
{
  GstPad *pad;
  gchar *pad_name;
  GstPadTemplate *templ;

  templ = gst_static_pad_template_get (&sink_factory);

  pad_name = get_pad_name (type, description);

  pad = gst_ghost_pad_new_from_template (pad_name, target, templ);
  g_free (pad_name);
  g_object_unref (templ);

  if (type == KMS_ELEMENT_PAD_TYPE_VIDEO) {
    kms_utils_drop_until_keyframe (pad, TRUE);
    kms_utils_manage_gaps (pad);
  }

  gst_pad_set_query_function (pad, kms_element_pad_query);
  gst_pad_add_probe (pad,
      GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM | GST_PAD_PROBE_TYPE_EVENT_FLUSH,
      accept_eos_probe, self, NULL);
  g_signal_connect (G_OBJECT (pad), "unlinked",
      G_CALLBACK (send_flush_on_unlink), NULL);

  if (GST_STATE (self) >= GST_STATE_PAUSED
      || GST_STATE_PENDING (self) >= GST_STATE_PAUSED
      || GST_STATE_TARGET (self) >= GST_STATE_PAUSED) {
    gst_pad_set_active (pad, TRUE);
  }

  if (gst_element_add_pad (GST_ELEMENT (self), pad)) {
    kms_element_set_sink_input_stats (self, pad, type);
    return pad;
  }

  g_object_unref (pad);

  return NULL;
}