Esempio n. 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);
}
Esempio n. 2
0
static GstBin *
kms_agnostic_bin2_create_dec_bin (KmsAgnosticBin2 * self,
    const GstCaps * raw_caps)
{
  KmsDecTreeBin *dec_bin;
  GstElement *output_tee, *input_element;
  GstCaps *caps = self->priv->input_bin_src_caps;

  if (caps == NULL || raw_caps == NULL) {
    return NULL;
  }

  dec_bin = kms_dec_tree_bin_new (caps, raw_caps);
  if (dec_bin == NULL) {
    return NULL;
  }

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

  output_tee =
      kms_tree_bin_get_output_tee (KMS_TREE_BIN (self->priv->input_bin));
  input_element = kms_tree_bin_get_input_element (KMS_TREE_BIN (dec_bin));
  link_element_to_tee (output_tee, input_element);

  return GST_BIN (dec_bin);
}
Esempio n. 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);
}
Esempio n. 4
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);
}
Esempio n. 5
0
static void
kms_agnostic_bin2_configure_input (KmsAgnosticBin2 * self, const GstCaps * caps)
{
  KmsParseTreeBin *parse_bin;
  GstElement *parser;
  GstPad *parser_src;
  GstElement *input_element;

  KMS_AGNOSTIC_BIN2_LOCK (self);

  if (self->priv->input_bin != NULL) {
    kms_tree_bin_unlink_input_element_from_tee (KMS_TREE_BIN (self->
            priv->input_bin));
  }

  parse_bin = kms_parse_tree_bin_new (caps);
  self->priv->input_bin = GST_BIN (parse_bin);

  parser = kms_parse_tree_bin_get_parser (KMS_PARSE_TREE_BIN (parse_bin));
  parser_src = gst_element_get_static_pad (parser, "src");
  gst_pad_add_probe (parser_src, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM,
      input_bin_src_caps_probe, g_object_ref (parse_bin), g_object_unref);
  g_object_unref (parser_src);

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

  input_element = kms_tree_bin_get_input_element (KMS_TREE_BIN (parse_bin));
  link_element_to_tee (self->priv->input_tee, input_element);

  self->priv->started = FALSE;

  GST_DEBUG ("Removing old treebins");
  g_hash_table_foreach (self->priv->bins, remove_bin, self);
  g_hash_table_remove_all (self->priv->bins);

  KMS_AGNOSTIC_BIN2_UNLOCK (self);
}