コード例 #1
0
ファイル: kmselement.c プロジェクト: shelsonjava/kms-core
KmsElementPadType
kms_element_get_pad_type (KmsElement * self, GstPad * pad)
{
  KmsElementPadType type;
  GstPadTemplate *templ;

  g_return_val_if_fail (self != NULL, KMS_ELEMENT_PAD_TYPE_DATA);

  templ = gst_pad_get_pad_template (pad);

  if (templ ==
      gst_element_class_get_pad_template (GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS
              (self)), AUDIO_SRC_PAD) ||
      g_strstr_len (GST_OBJECT_NAME (pad), -1, "audio")) {
    type = KMS_ELEMENT_PAD_TYPE_AUDIO;
  } else if (templ ==
      gst_element_class_get_pad_template (GST_ELEMENT_CLASS (G_OBJECT_GET_CLASS
              (self)), VIDEO_SRC_PAD) ||
      g_strstr_len (GST_OBJECT_NAME (pad), -1, "video")) {
    type = KMS_ELEMENT_PAD_TYPE_VIDEO;
  } else {
    type = KMS_ELEMENT_PAD_TYPE_DATA;
  }

  gst_object_unref (templ);

  return type;
}
コード例 #2
0
static void
gst_rg_volume_init (GstRgVolume * self)
{
  GObjectClass *volume_class;
  GstPad *volume_pad, *ghost_pad;

  self->album_mode = DEFAULT_ALBUM_MODE;
  self->headroom = DEFAULT_HEADROOM;
  self->pre_amp = DEFAULT_PRE_AMP;
  self->fallback_gain = DEFAULT_FALLBACK_GAIN;
  self->target_gain = 0.0;
  self->result_gain = 0.0;

  self->volume_element = gst_element_factory_make ("volume", "rgvolume-volume");
  if (G_UNLIKELY (self->volume_element == NULL)) {
    GstMessage *msg;

    GST_WARNING_OBJECT (self, "could not create volume element");
    msg = gst_missing_element_message_new (GST_ELEMENT_CAST (self), "volume");
    gst_element_post_message (GST_ELEMENT_CAST (self), msg);

    /* Nothing else to do, we will refuse the state change from NULL to READY to
     * indicate that something went very wrong.  It is doubtful that someone
     * attempts changing our state though, since we end up having no pads! */
    return;
  }

  volume_class = G_OBJECT_GET_CLASS (G_OBJECT (self->volume_element));
  self->max_volume = G_PARAM_SPEC_DOUBLE
      (g_object_class_find_property (volume_class, "volume"))->maximum;

  GST_BIN_CLASS (parent_class)->add_element (GST_BIN_CAST (self),
      self->volume_element);

  volume_pad = gst_element_get_static_pad (self->volume_element, "sink");
  ghost_pad = gst_ghost_pad_new_from_template ("sink", volume_pad,
      gst_pad_get_pad_template (volume_pad));
  gst_object_unref (volume_pad);
  gst_pad_set_event_function (ghost_pad, gst_rg_volume_sink_event);
  gst_element_add_pad (GST_ELEMENT_CAST (self), ghost_pad);

  volume_pad = gst_element_get_static_pad (self->volume_element, "src");
  ghost_pad = gst_ghost_pad_new_from_template ("src", volume_pad,
      gst_pad_get_pad_template (volume_pad));
  gst_object_unref (volume_pad);
  gst_element_add_pad (GST_ELEMENT_CAST (self), ghost_pad);
}
コード例 #3
0
ファイル: gst-utils.cpp プロジェクト: dulton/switcher
void GstUtils::release_request_pad(GstPad *pad, gpointer user_data) {
  // checking if the pad has been requested and releasing it needed
  GstPadTemplate *pad_templ = gst_pad_get_pad_template(pad);
  if (nullptr != pad_templ
      && GST_PAD_TEMPLATE_PRESENCE(pad_templ) == GST_PAD_REQUEST) {
    gst_element_release_request_pad((GstElement *)user_data,
                                    pad);
    gst_object_unref(pad);  // release does not free
  }
  //gst_object_unref(pad_templ);  // bug in gst 0.10 ?
  gst_object_unref(pad);  // for iterator
}
コード例 #4
0
ファイル: base-reader.c プロジェクト: step21/shmdata
void
shmdata_base_reader_release_request_pad (GstPad *pad, gpointer user_data)
{
    //checking if the pad has been requested and releasing it needed
    GstPadTemplate *pad_templ = gst_pad_get_pad_template (pad);
    if (GST_PAD_TEMPLATE_PRESENCE (pad_templ) == GST_PAD_REQUEST) {
        gst_element_release_request_pad ((GstElement *)user_data,
                                         pad);
        gst_object_unref(pad);
    }
    // gst_object_unref(pad_templ);  // bug in gst 0.10 ?
    gst_object_unref(pad);  // for pad iterator
}
コード例 #5
0
static void
debug_dump_pad (GstPad * pad, const gchar * color_name,
    const gchar * element_name, GstDebugGraphDetails details, FILE * out,
    const gint indent)
{
  GstPadTemplate *pad_templ;
  GstPadPresence presence;
  gchar *pad_name;
  const gchar *style_name;
  const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)];

  pad_name = debug_dump_make_object_name (GST_OBJECT (pad));

  /* pad availability */
  style_name = "filled,solid";
  if ((pad_templ = gst_pad_get_pad_template (pad))) {
    presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ);
    if (presence == GST_PAD_SOMETIMES) {
      style_name = "filled,dotted";
    } else if (presence == GST_PAD_REQUEST) {
      style_name = "filled,dashed";
    }
  }
  if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
    gchar pad_flags[4];
    const gchar *activation_mode = "-><";

    /* check if pad flags */
    pad_flags[0] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED) ? 'B' : 'b';
    pad_flags[1] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING) ? 'F' : 'f';
    pad_flags[2] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING) ? 'B' : 'b';
    pad_flags[3] = '\0';

    fprintf (out,
        "%s  %s_%s [color=black, fillcolor=\"%s\", label=\"%s\\n[%c][%s]\", height=\"0.2\", style=\"%s\"];\n",
        spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
        activation_mode[pad->mode], pad_flags, style_name);
  } else {
    fprintf (out,
        "%s  %s_%s [color=black, fillcolor=\"%s\", label=\"%s\", height=\"0.2\", style=\"%s\"];\n",
        spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
        style_name);
  }

  g_free (pad_name);
}
コード例 #6
0
ファイル: gstrtpdtmfmux.c プロジェクト: spunktsch/svtplayer
static GstPad *
gst_rtp_dtmf_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
    const gchar * name)
{
  GstPad *pad;

  pad = GST_CALL_PARENT_WITH_DEFAULT (GST_ELEMENT_CLASS, request_new_pad,
      (element, templ, name), NULL);

  if (pad) {
    GstRTPMuxPadPrivate *padpriv;

    GST_OBJECT_LOCK (element);
    padpriv = gst_pad_get_element_private (pad);

    if (gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element),
            "priority_sink_%d") == gst_pad_get_pad_template (pad))
      padpriv->priority = TRUE;
    GST_OBJECT_UNLOCK (element);
  }

  return pad;
}
コード例 #7
0
static GstPad *
gst_rtp_dtmf_mux_request_new_pad (GstElement * element, GstPadTemplate * templ,
    const gchar * name, const GstCaps * caps)
{
  GstPad *pad;

  pad =
      GST_ELEMENT_CLASS (gst_rtp_dtmf_mux_parent_class)->request_new_pad
      (element, templ, name, caps);

  if (pad) {
    GstRTPMuxPadPrivate *padpriv;

    GST_OBJECT_LOCK (element);
    padpriv = gst_pad_get_element_private (pad);

    if (gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (element),
            "priority_sink_%u") == gst_pad_get_pad_template (pad))
      padpriv->priority = TRUE;
    GST_OBJECT_UNLOCK (element);
  }

  return pad;
}
コード例 #8
0
ファイル: mxfmux.c プロジェクト: ChinnaSuhas/ossbuild
static gboolean
gst_mxf_mux_setcaps (GstPad * pad, GstCaps * caps)
{
  GstMXFMux *mux = GST_MXF_MUX (gst_pad_get_parent (pad));
  GstMXFMuxPad *cpad = (GstMXFMuxPad *) gst_pad_get_element_private (pad);
  gboolean ret = TRUE;
  MXFUUID d_instance_uid = { {0,} };
  MXFMetadataFileDescriptor *old_descriptor = cpad->descriptor;
  GList *l;

  GST_DEBUG_OBJECT (pad, "Setting caps %" GST_PTR_FORMAT, caps);

  if (old_descriptor) {
    memcpy (&d_instance_uid, &MXF_METADATA_BASE (old_descriptor)->instance_uid,
        16);
    cpad->descriptor = NULL;
    g_free (cpad->mapping_data);
    cpad->mapping_data = NULL;
  }

  cpad->descriptor =
      cpad->writer->get_descriptor (gst_pad_get_pad_template (pad), caps,
      &cpad->write_func, &cpad->mapping_data);

  if (!cpad->descriptor) {
    GST_ERROR_OBJECT (mux,
        "Couldn't get descriptor for pad '%s' with caps %" GST_PTR_FORMAT,
        GST_PAD_NAME (pad), caps);
    gst_object_unref (mux);
    return FALSE;
  }

  if (mxf_uuid_is_zero (&d_instance_uid))
    mxf_uuid_init (&d_instance_uid, mux->metadata);

  memcpy (&MXF_METADATA_BASE (cpad->descriptor)->instance_uid, &d_instance_uid,
      16);

  if (old_descriptor) {
    for (l = mux->metadata_list; l; l = l->next) {
      MXFMetadataBase *tmp = l->data;

      if (mxf_uuid_is_equal (&d_instance_uid, &tmp->instance_uid)) {
        l->data = cpad->descriptor;
        break;
      }
    }
  } else {
    mux->metadata_list = g_list_prepend (mux->metadata_list, cpad->descriptor);
  }

  g_hash_table_replace (mux->metadata,
      &MXF_METADATA_BASE (cpad->descriptor)->instance_uid, cpad->descriptor);

  if (old_descriptor) {
    if (mux->preface && mux->preface->content_storage &&
        mux->preface->content_storage->packages) {
      guint i, j;

      for (i = 0; i < mux->preface->content_storage->n_packages; i++) {
        MXFMetadataSourcePackage *package;

        if (!MXF_IS_METADATA_SOURCE_PACKAGE (mux->preface->content_storage->
                packages[i]))
          continue;

        package =
            MXF_METADATA_SOURCE_PACKAGE (mux->preface->content_storage->
            packages[i]);

        if (!package->descriptor)
          continue;

        if (MXF_IS_METADATA_MULTIPLE_DESCRIPTOR (package->descriptor)) {
          MXFMetadataMultipleDescriptor *tmp =
              MXF_METADATA_MULTIPLE_DESCRIPTOR (package->descriptor);

          for (j = 0; j < tmp->n_sub_descriptors; j++) {
            if (tmp->sub_descriptors[j] ==
                MXF_METADATA_GENERIC_DESCRIPTOR (old_descriptor)) {
              tmp->sub_descriptors[j] =
                  MXF_METADATA_GENERIC_DESCRIPTOR (cpad->descriptor);
              memcpy (&tmp->sub_descriptors_uids[j], &d_instance_uid, 16);
            }
          }
        } else if (package->descriptor ==
            MXF_METADATA_GENERIC_DESCRIPTOR (old_descriptor)) {
          package->descriptor =
              MXF_METADATA_GENERIC_DESCRIPTOR (cpad->descriptor);
          memcpy (&package->descriptor_uid, &d_instance_uid, 16);
        }
      }
    }
  }

  gst_object_unref (mux);

  return ret;
}
コード例 #9
0
static void
debug_dump_pad (GstPad * pad, const gchar * color_name,
    const gchar * element_name, GstDebugGraphDetails details, GString * str,
    const gint indent)
{
  GstPadTemplate *pad_templ;
  GstPadPresence presence;
  gchar *pad_name;
  const gchar *style_name;
  const gchar *spc = &spaces[MAX (sizeof (spaces) - (1 + indent * 2), 0)];

  pad_name = debug_dump_make_object_name (GST_OBJECT (pad));

  /* pad availability */
  style_name = "filled,solid";
  if ((pad_templ = gst_pad_get_pad_template (pad))) {
    presence = GST_PAD_TEMPLATE_PRESENCE (pad_templ);
    gst_object_unref (pad_templ);
    if (presence == GST_PAD_SOMETIMES) {
      style_name = "filled,dotted";
    } else if (presence == GST_PAD_REQUEST) {
      style_name = "filled,dashed";
    }
  }
  if (details & GST_DEBUG_GRAPH_SHOW_STATES) {
    gchar pad_flags[4];
    const gchar *activation_mode = "-><";
    const gchar *task_mode = "";
    GstTask *task;

    GST_OBJECT_LOCK (pad);
    task = GST_PAD_TASK (pad);
    if (task) {
      switch (gst_task_get_state (task)) {
        case GST_TASK_STARTED:
          task_mode = "[T]";
          break;
        case GST_TASK_PAUSED:
          task_mode = "[t]";
          break;
        default:
          /* Invalid task state, ignoring */
          break;
      }
    }
    GST_OBJECT_UNLOCK (pad);

    /* check if pad flags */
    pad_flags[0] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKED) ? 'B' : 'b';
    pad_flags[1] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_FLUSHING) ? 'F' : 'f';
    pad_flags[2] =
        GST_OBJECT_FLAG_IS_SET (pad, GST_PAD_FLAG_BLOCKING) ? 'B' : 'b';
    pad_flags[3] = '\0';

    g_string_append_printf (str,
        "%s  %s_%s [color=black, fillcolor=\"%s\", label=\"%s\\n[%c][%s]%s\", height=\"0.2\", style=\"%s\"];\n",
        spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
        activation_mode[pad->mode], pad_flags, task_mode, style_name);
  } else {
    g_string_append_printf (str,
        "%s  %s_%s [color=black, fillcolor=\"%s\", label=\"%s\", height=\"0.2\", style=\"%s\"];\n",
        spc, element_name, pad_name, color_name, GST_OBJECT_NAME (pad),
        style_name);
  }

  g_free (pad_name);
}