示例#1
0
static GstBin *
kms_agnostic_bin2_create_bin_for_caps (KmsAgnosticBin2 * self, GstCaps * caps)
{
  GstBin *dec_bin;
  KmsEncTreeBin *enc_bin;
  GstElement *input_element, *output_tee;

  dec_bin = kms_agnostic_bin2_get_or_create_dec_bin (self, caps);
  if (dec_bin == NULL) {
    return NULL;
  }

  if (is_raw_caps (caps)) {
    return dec_bin;
  }

  enc_bin = kms_enc_tree_bin_new (caps, self->priv->default_bitrate);
  if (enc_bin == NULL) {
    return NULL;
  }

  gst_bin_add (GST_BIN (self), GST_ELEMENT (enc_bin));
  gst_element_sync_state_with_parent (GST_ELEMENT (enc_bin));

  output_tee = kms_tree_bin_get_output_tee (KMS_TREE_BIN (dec_bin));
  input_element = kms_tree_bin_get_input_element (KMS_TREE_BIN (enc_bin));
  link_element_to_tee (output_tee, input_element);

  kms_agnostic_bin2_insert_bin (self, GST_BIN (enc_bin));

  return GST_BIN (enc_bin);
}
示例#2
0
static GstBin *
kms_agnostic_bin2_get_or_create_dec_bin (KmsAgnosticBin2 * self, GstCaps * caps)
{
  GstCaps *raw_caps = kms_agnostic_bin2_get_raw_caps (caps);

  if (raw_caps != NULL) {
    GstBin *dec_bin;

    GST_DEBUG ("Raw caps: %" GST_PTR_FORMAT, raw_caps);
    dec_bin = kms_agnostic_bin2_find_bin_for_caps (self, raw_caps);

    if (dec_bin == NULL) {
      dec_bin = kms_agnostic_bin2_create_dec_bin (self, raw_caps);

      if (dec_bin != NULL) {
        kms_agnostic_bin2_insert_bin (self, dec_bin);
      }
    }

    gst_caps_unref (raw_caps);

    return dec_bin;
  } else {
    GST_ELEMENT_WARNING (self, CORE, NEGOTIATION,
        ("Formats are not compatible"), ("Formats are not compatible"));
    return NULL;
  }
}
示例#3
0
static GstBin *
kms_agnostic_bin2_create_rtp_pay_bin (KmsAgnosticBin2 * self, GstCaps * caps)
{
  KmsRtpPayTreeBin *bin;
  GstBin *enc_bin;
  GstElement *output_tee, *input_element;
  GstCaps *input_caps;
  GstPad *sink;

  bin = kms_rtp_pay_tree_bin_new (caps);

  if (bin == NULL) {
    return NULL;
  }

  gst_bin_add (GST_BIN (self), GST_ELEMENT (bin));
  gst_element_sync_state_with_parent (GST_ELEMENT (bin));

  input_element = kms_tree_bin_get_input_element (KMS_TREE_BIN (bin));
  sink = gst_element_get_static_pad (input_element, "sink");
  input_caps = gst_pad_query_caps (sink, NULL);
  g_object_unref (sink);

  enc_bin = kms_agnostic_bin2_find_or_create_bin_for_caps (self, input_caps);
  kms_agnostic_bin2_insert_bin (self, GST_BIN (bin));
  gst_caps_unref (input_caps);

  output_tee = kms_tree_bin_get_output_tee (KMS_TREE_BIN (enc_bin));
  gst_element_link (output_tee, input_element);

  return GST_BIN (bin);
}
示例#4
0
static GstPadProbeReturn
input_bin_src_caps_probe (GstPad * pad, GstPadProbeInfo * info, gpointer bin)
{
  KmsAgnosticBin2 *self = KMS_AGNOSTIC_BIN2 (GST_OBJECT_PARENT (bin));
  GstEvent *event = gst_pad_probe_info_get_event (info);
  GstCaps *current_caps;

  if (self == NULL) {
    GST_WARNING_OBJECT (bin, "Parent agnosticbin seems to be released");
    return GST_PAD_PROBE_OK;
  }

  GST_TRACE_OBJECT (self, "Event in parser pad: %" GST_PTR_FORMAT, event);

  if (GST_EVENT_TYPE (event) != GST_EVENT_CAPS) {
    return GST_PAD_PROBE_OK;
  }

  KMS_AGNOSTIC_BIN2_LOCK (self);

  self->priv->started = TRUE;
  if (self->priv->input_bin_src_caps != NULL) {
    gst_caps_unref (self->priv->input_bin_src_caps);
  }

  gst_event_parse_caps (event, &current_caps);
  self->priv->input_bin_src_caps = gst_caps_copy (current_caps);
  kms_agnostic_bin2_insert_bin (self, GST_BIN (bin));

  GST_INFO_OBJECT (self, "Setting current caps to: %" GST_PTR_FORMAT,
      current_caps);

  kms_element_for_each_src_pad (GST_ELEMENT (self),
      (KmsPadIterationAction) add_linked_pads, self);

  KMS_AGNOSTIC_BIN2_UNLOCK (self);

  return GST_PAD_PROBE_REMOVE;
}
示例#5
0
static GstBin *
kms_agnostic_bin2_create_bin_for_caps (KmsAgnosticBin2 * self, GstCaps * caps)
{
  GstBin *dec_bin;
  KmsEncTreeBin *enc_bin;
  GstElement *input_element, *output_tee;

  if (kms_utils_caps_are_rtp (caps)) {
    return kms_agnostic_bin2_create_rtp_pay_bin (self, caps);
  }

  dec_bin = kms_agnostic_bin2_get_or_create_dec_bin (self, caps);
  if (dec_bin == NULL) {
    return NULL;
  }

  if (kms_utils_caps_are_raw (caps)) {
    return dec_bin;
  }

  enc_bin =
      kms_enc_tree_bin_new (caps, TARGET_BITRATE_DEFAULT,
      self->priv->min_bitrate, self->priv->max_bitrate,
      self->priv->codec_config);
  if (enc_bin == NULL) {
    return NULL;
  }

  gst_bin_add (GST_BIN (self), GST_ELEMENT (enc_bin));
  gst_element_sync_state_with_parent (GST_ELEMENT (enc_bin));

  output_tee = kms_tree_bin_get_output_tee (KMS_TREE_BIN (dec_bin));
  input_element = kms_tree_bin_get_input_element (KMS_TREE_BIN (enc_bin));
  gst_element_link (output_tee, input_element);

  kms_agnostic_bin2_insert_bin (self, GST_BIN (enc_bin));

  return GST_BIN (enc_bin);
}