Esempio n. 1
0
static GstCaps *
gst_ac3_parse_get_sink_caps (GstBaseParse * parse, GstCaps * filter)
{
    GstCaps *peercaps, *templ;
    GstCaps *res;

    templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
    peercaps = gst_pad_get_allowed_caps (GST_BASE_PARSE_SRC_PAD (parse));

    if (peercaps) {
        guint i, n;

        /* Remove the framed and alignment field. We can convert
         * between different alignments. */
        peercaps = gst_caps_make_writable (peercaps);
        n = gst_caps_get_size (peercaps);
        for (i = 0; i < n; i++) {
            GstStructure *s = gst_caps_get_structure (peercaps, i);

            gst_structure_remove_field (s, "framed");
            gst_structure_remove_field (s, "alignment");
        }

        res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
        gst_caps_unref (peercaps);

        /* Append the template caps because we still want to accept
         * caps without any fields in the case upstream does not
         * know anything.
         */
        gst_caps_append (res, templ);
    } else {
        res = templ;
    }

    if (filter) {
        GstCaps *intersection;

        intersection =
            gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
        gst_caps_unref (res);
        res = intersection;
    }

    return res;
}
Esempio n. 2
0
static GstStructure *
get_channel_free_structure (const GstStructure * in_structure)
{
  GstStructure *s = gst_structure_copy (in_structure);

  gst_structure_remove_field (s, "channels");
  return s;
}
Esempio n. 3
0
static void
set_appsink_caps (GstElement * appsink, const GstCaps * caps,
    KmsRecordingProfile profile)
{
  GstStructure *str;
  GstCaps *sinkcaps;

  sinkcaps = gst_caps_copy (caps);

  str = gst_caps_get_structure (sinkcaps, 0);

  if (str == NULL) {
    GST_ERROR_OBJECT (appsink,
        "Can not get caps at index 0 from %" GST_PTR_FORMAT, sinkcaps);
    goto end;
  }

  if (!gst_structure_has_field (str, "framerate")) {
    GST_DEBUG_OBJECT (appsink, "No framerate in caps %" GST_PTR_FORMAT,
        sinkcaps);
  } else {
    GST_DEBUG_OBJECT (appsink, "Removing framerate from caps %" GST_PTR_FORMAT,
        sinkcaps);
    gst_structure_remove_field (str, "framerate");
  }

  switch (profile) {
    case KMS_RECORDING_PROFILE_WEBM:
    case KMS_RECORDING_PROFILE_WEBM_VIDEO_ONLY:
      /* Allow renegotiation of width and height because webmmux supports it */
      gst_structure_remove_field (str, "width");
      gst_structure_remove_field (str, "height");
      break;
    default:
      /* No to allow height and width renegotiation */
      break;
  }

  GST_DEBUG_OBJECT (appsink, "Setting sink caps %" GST_PTR_FORMAT, sinkcaps);
  g_object_set (appsink, "caps", sinkcaps, NULL);

end:

  gst_caps_unref (sinkcaps);
}
Esempio n. 4
0
static gboolean
gst_vdp_vpp_sink_setcaps (GstPad * pad, GstCaps * caps)
{
  GstVdpVideoPostProcess *vpp =
      GST_VDP_VIDEO_POST_PROCESS (gst_pad_get_parent (pad));
  GstStructure *structure;
  GstCaps *output_caps, *allowed_caps, *src_caps;
  gboolean res;

  /* extract interlaced flag */
  structure = gst_caps_get_structure (caps, 0);
  gst_structure_get_boolean (structure, "interlaced", &vpp->interlaced);

  allowed_caps = gst_pad_get_allowed_caps (vpp->srcpad);
  structure = gst_caps_get_structure (allowed_caps, 0);
  output_caps = gst_vdp_video_to_output_caps (caps);

  src_caps = gst_caps_intersect (output_caps, allowed_caps);
  gst_caps_truncate (src_caps);
  if (gst_caps_is_empty (src_caps))
    goto invalid_caps;

  GST_DEBUG ("output_caps: %" GST_PTR_FORMAT " allowed_caps: %" GST_PTR_FORMAT
      " src_caps: %" GST_PTR_FORMAT, output_caps, allowed_caps, src_caps);

  gst_caps_unref (output_caps);
  gst_caps_unref (allowed_caps);

  if (gst_vdp_vpp_is_interlaced (vpp)) {
    gint fps_n, fps_d;

    structure = gst_caps_get_structure (src_caps, 0);

    if (!gst_structure_get_fraction (structure, "framerate", &fps_n, &fps_d)) {
      gst_caps_unref (src_caps);
      goto invalid_caps;
    }

    gst_fraction_double (&fps_n, &fps_d);
    gst_structure_set (structure, "framerate", GST_TYPE_FRACTION, fps_n, fps_d,
        NULL);
    gst_structure_remove_field (structure, "interlaced");

    vpp->field_duration = gst_util_uint64_scale (GST_SECOND, fps_d, fps_n);
  }

  res = gst_pad_set_caps (vpp->srcpad, src_caps);

done:
  gst_object_unref (vpp);
  return res;

invalid_caps:
  GST_ERROR_OBJECT (vpp, "invalid caps: %" GST_PTR_FORMAT, caps);
  res = FALSE;
  goto done;
}
Esempio n. 5
0
GstCaps *
gst_vdp_yuv_to_video_caps (GstCaps * yuv_caps)
{
  GstCaps *video_caps;
  gint i;

  g_return_val_if_fail (GST_IS_CAPS (yuv_caps), NULL);

  video_caps = gst_caps_copy (yuv_caps);
  for (i = 0; i < gst_caps_get_size (video_caps); i++) {
    GstStructure *structure;
    guint32 fourcc;
    VdpChromaType chroma_type;

    structure = gst_caps_get_structure (video_caps, i);
    if (!gst_structure_has_name (structure, "video/x-raw-yuv"))
      goto not_yuv_error;

    if (!gst_structure_get_fourcc (structure, "format", &fourcc))
      goto no_format_error;

    chroma_type = -1;
    for (i = 0; i < G_N_ELEMENTS (formats); i++) {
      if (formats[i].fourcc == fourcc) {
        chroma_type = formats[i].chroma_type;
        break;
      }
    }

    if (chroma_type == -1)
      goto no_chroma_error;

    /* now we transform the caps */
    gst_structure_set_name (structure, "video/x-vdpau-video");
    gst_structure_remove_field (structure, "format");
    gst_structure_set (structure, "chroma-type", G_TYPE_INT, chroma_type, NULL);
  }

  return video_caps;

error:
  gst_caps_unref (video_caps);
  return NULL;

not_yuv_error:
  GST_WARNING ("The caps weren't of type \"video/x-raw-yuv\"");
  goto error;

no_format_error:
  GST_WARNING ("The caps didn't have a \"fourcc\" field");
  goto error;

no_chroma_error:
  GST_WARNING ("The caps had an invalid \"fourcc\" field");
  goto error;

}
Esempio n. 6
0
void CvCapture_GStreamer::removeFilter(const char *filter)
{
    if(!caps)
        return;

    GstStructure *s = gst_caps_get_structure(caps, 0);
    gst_structure_remove_field(s, filter);

    restartPipeline();
}
Esempio n. 7
0
static void icvRemoveFilter(CvCapture_GStreamer *cap, const char *filter)
{
	if(!cap->caps)
		return;

	GstStructure *s = gst_caps_get_structure(cap->caps, 0);
	gst_structure_remove_field(s, filter);

	icvRestartPipeline(cap);
}
Esempio n. 8
0
EXPORT_C
#endif

void
gst_tag_list_remove_tag (GstTagList * list, const gchar * tag)
{
  g_return_if_fail (GST_IS_TAG_LIST (list));
  g_return_if_fail (tag != NULL);

  gst_structure_remove_field ((GstStructure *) list, tag);
}
Esempio n. 9
0
static GstCaps *
gst_cv_sobel_transform_caps (GstBaseTransform * trans, GstPadDirection dir,
    GstCaps * caps)
{
  GstCaps *output = NULL;
  GstStructure *structure;
  gint i;

  output = gst_caps_copy (caps);

  /* we accept anything from the template caps for either side */
  switch (dir) {
    case GST_PAD_SINK:
      for (i = 0; i < gst_caps_get_size (output); i++) {
        structure = gst_caps_get_structure (output, i);
        gst_structure_set (structure,
            "depth", G_TYPE_INT, 16,
            "bpp", G_TYPE_INT, 16,
            "signed", G_TYPE_BOOLEAN, TRUE,
            "endianness", G_TYPE_INT, 4321,
            NULL);
      }
      break;
    case GST_PAD_SRC:
      for (i = 0; i < gst_caps_get_size (output); i++) {
        structure = gst_caps_get_structure (output, i);
        gst_structure_set (structure,
            "depth", G_TYPE_INT, 8, "bpp", G_TYPE_INT, 8, NULL);
        gst_structure_remove_field (structure, "endianness");
        gst_structure_remove_field (structure, "signed");
      }
      break;
    default:
      gst_caps_unref (output);
      output = NULL;
      g_assert_not_reached ();
      break;
  }

  return output;
}
Esempio n. 10
0
/* copies the given caps */
static GstCaps *
gst_ffmpegcsp_caps_remove_format_info (GstCaps * caps)
{
  int i;
  GstStructure *structure;
  GstCaps *rgbcaps;
  GstCaps *graycaps;

  caps = gst_caps_copy (caps);

  for (i = 0; i < gst_caps_get_size (caps); i++) {
    structure = gst_caps_get_structure (caps, i);

    gst_structure_set_name (structure, "video/x-raw-yuv");
    gst_structure_remove_field (structure, "format");
    gst_structure_remove_field (structure, "endianness");
    gst_structure_remove_field (structure, "depth");
    gst_structure_remove_field (structure, "bpp");
    gst_structure_remove_field (structure, "red_mask");
    gst_structure_remove_field (structure, "green_mask");
    gst_structure_remove_field (structure, "blue_mask");
    gst_structure_remove_field (structure, "alpha_mask");
    gst_structure_remove_field (structure, "palette_data");
  }

  gst_caps_do_simplify (caps);
  rgbcaps = gst_caps_copy (caps);

  for (i = 0; i < gst_caps_get_size (rgbcaps); i++) {
    structure = gst_caps_get_structure (rgbcaps, i);

    gst_structure_set_name (structure, "video/x-raw-rgb");
  }
  graycaps = gst_caps_copy (caps);

  for (i = 0; i < gst_caps_get_size (graycaps); i++) {
    structure = gst_caps_get_structure (graycaps, i);

    gst_structure_set_name (structure, "video/x-raw-gray");
  }

  gst_caps_append (caps, graycaps);
  gst_caps_append (caps, rgbcaps);

  return caps;
}
Esempio n. 11
0
static GstCaps *
gst_smokeenc_getcaps (GstPad * pad)
{
  GstSmokeEnc *smokeenc = GST_SMOKEENC (gst_pad_get_parent (pad));
  GstPad *otherpad;
  GstCaps *result, *caps;
  const GstCaps *tcaps;
  const char *name;
  int i;
  GstStructure *structure = NULL;

  /* we want to proxy properties like width, height and framerate from the
     other end of the element */
  otherpad = (pad == smokeenc->srcpad) ? smokeenc->sinkpad : smokeenc->srcpad;

  /* get template caps, we always need this to fiter the peer caps */
  tcaps = gst_pad_get_pad_template_caps (otherpad);

  /* get any constraints on the peer pad */
  caps = gst_pad_peer_get_caps (otherpad);

  if (caps == NULL)
    caps = gst_caps_copy (tcaps);
  else
    caps = gst_caps_make_writable (caps);

  /* intersect with the template */
  result = gst_caps_intersect (caps, tcaps);
  gst_caps_unref (caps);

  if (pad == smokeenc->srcpad) {
    name = "video/x-smoke";
  } else {
    name = "video/x-raw-yuv";
  }

  /* we can only copy width, height, framerate from one side to the other */
  for (i = 0; i < gst_caps_get_size (result); i++) {
    structure = gst_caps_get_structure (result, i);

    gst_structure_set_name (structure, name);
    gst_structure_remove_field (structure, "format");
    /* ... but for the sink pad, we only do I420 anyway, so add that */
    if (pad == smokeenc->sinkpad) {
      gst_structure_set (structure, "format", GST_TYPE_FOURCC,
          GST_STR_FOURCC ("I420"), NULL);
    }
  }

  gst_object_unref (smokeenc);

  return result;
}
Esempio n. 12
0
static void
remove_fields (GstCaps * caps)
{
    guint i, n;

    n = gst_caps_get_size (caps);
    for (i = 0; i < n; i++) {
        GstStructure *s = gst_caps_get_structure (caps, i);

        gst_structure_remove_field (s, "parsed");
    }
}
/* return a list of caps where we only need to set
 * width and height to get fixed caps */
static GList *
video_crop_get_test_caps (GstElement * videocrop)
{
  GstCaps *templ, *allowed_caps;
  GstPad *srcpad;
  GList *list = NULL;
  guint i;

  srcpad = gst_element_get_static_pad (videocrop, "src");
  fail_unless (srcpad != NULL);
  templ = gst_pad_get_pad_template_caps (srcpad);
  fail_unless (templ != NULL);

  allowed_caps = gst_caps_normalize (templ);

  for (i = 0; i < gst_caps_get_size (allowed_caps); ++i) {
    GstStructure *new_structure;
    GstCaps *single_caps;

    single_caps = gst_caps_new_empty ();
    new_structure =
        gst_structure_copy (gst_caps_get_structure (allowed_caps, i));
    gst_structure_set (new_structure, "framerate", GST_TYPE_FRACTION,
        1, 1, NULL);
    gst_structure_remove_field (new_structure, "width");
    gst_structure_remove_field (new_structure, "height");
    gst_caps_append_structure (single_caps, new_structure);

    GST_DEBUG ("have caps %" GST_PTR_FORMAT, single_caps);
    /* should be fixed without width/height */
    fail_unless (gst_caps_is_fixed (single_caps));

    list = g_list_prepend (list, single_caps);
  }

  gst_caps_unref (allowed_caps);
  gst_object_unref (srcpad);

  return list;
}
Esempio n. 14
0
void gst_caps_change_name (GstCaps* caps, const char* name)
{
    for (unsigned int i = 0; i < gst_caps_get_size(caps); ++i)
    {
        GstStructure* struc = gst_caps_get_structure(caps, i);

        if (struc != nullptr)
        {
            gst_structure_set_name(struc, name);
            gst_structure_remove_field(struc, "format");
        }
    }
}
Esempio n. 15
0
/*!
 * \brief OpenIMAJCapGStreamer::removeFilter
 * \param filter filter to remove
 * remove the specified filter from the appsink template caps
 */
void OpenIMAJCapGStreamer::removeFilter(const char *filter)
{
    if(!caps)
        return;
    
    if (! gst_caps_is_writable(caps))
        caps = gst_caps_make_writable (caps);
    
    GstStructure *s = gst_caps_get_structure(caps, 0);
    gst_structure_remove_field(s, filter);
    
    gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
}
Esempio n. 16
0
GstCaps *
gst_vdp_video_to_output_caps (GstCaps * video_caps)
{
  GstCaps *output_caps;
  gint i;

  g_return_val_if_fail (GST_IS_CAPS (video_caps), NULL);

  output_caps = gst_caps_copy (video_caps);
  for (i = 0; i < gst_caps_get_size (video_caps); i++) {

    GstStructure *structure, *rgb_structure;

    structure = gst_caps_get_structure (output_caps, i);
    if (!gst_structure_has_name (structure, "video/x-vdpau-video"))
      goto not_video_error;

    rgb_structure = gst_structure_copy (structure);

    gst_structure_set_name (structure, "video/x-vdpau-output");
    gst_structure_remove_field (structure, "chroma-type");
    gst_vdp_video_remove_pixel_aspect_ratio (structure);

    gst_structure_set_name (rgb_structure, "video/x-raw-rgb");
    gst_structure_remove_field (rgb_structure, "chroma-type");
    gst_vdp_video_remove_pixel_aspect_ratio (rgb_structure);
    gst_caps_append_structure (output_caps, rgb_structure);
  }

  return output_caps;

error:
  gst_caps_unref (output_caps);
  return NULL;

not_video_error:
  GST_WARNING ("The caps weren't of type \"video/x-vdpau-video\"");
  goto error;
}
void
ges_base_xml_formatter_add_layer (GESBaseXmlFormatter * self,
    GType extractable_type, guint priority, GstStructure * properties,
    const gchar * metadatas, GError ** error)
{
  LayerEntry *entry;
  GESAsset *asset;
  GESLayer *layer;
  gboolean auto_transition = FALSE;
  GESBaseXmlFormatterPrivate *priv = _GET_PRIV (self);

  if (priv->check_only)
    return;

  if (extractable_type == G_TYPE_NONE)
    layer = ges_layer_new ();
  else {
    asset = ges_asset_request (extractable_type, NULL, error);
    if (asset == NULL) {
      if (error && *error == NULL) {
        g_set_error (error, G_MARKUP_ERROR,
            G_MARKUP_ERROR_INVALID_CONTENT,
            "Layer type %s could not be created'",
            g_type_name (extractable_type));
        return;
      }
    }
    layer = GES_LAYER (ges_asset_extract (asset, error));
  }

  ges_layer_set_priority (layer, priority);
  ges_timeline_add_layer (GES_FORMATTER (self)->timeline, layer);
  if (properties) {
    if (gst_structure_get_boolean (properties, "auto-transition",
            &auto_transition))
      gst_structure_remove_field (properties, "auto-transition");

    gst_structure_foreach (properties,
        (GstStructureForeachFunc) set_property_foreach, layer);
  }

  if (metadatas)
    ges_meta_container_add_metas_from_string (GES_META_CONTAINER (layer),
        metadatas);

  entry = g_slice_new0 (LayerEntry);
  entry->layer = gst_object_ref (layer);
  entry->auto_trans = auto_transition;

  g_hash_table_insert (priv->layers, GINT_TO_POINTER (priority), entry);
}
/* remove framerate in writable @caps */
static void
gst_image_freeze_remove_fps (GstImageFreeze * self, GstCaps * caps)
{
    gint i, n;

    n = gst_caps_get_size (caps);
    for (i = 0; i < n; i++) {
        GstStructure *s = gst_caps_get_structure (caps, i);

        gst_structure_remove_field (s, "framerate");
        gst_structure_set (s, "framerate", GST_TYPE_FRACTION_RANGE, 0, 1, G_MAXINT,
                           1, NULL);
    }
}
static GstCaps *
gst_audio_panorama_transform_caps (GstBaseTransform * base,
    GstPadDirection direction, GstCaps * caps, GstCaps * filter)
{
  GstCaps *res;
  GstStructure *structure;

  /* transform caps gives one single caps so we can just replace
   * the channel property with our range. */
  res = gst_caps_copy (caps);
  structure = gst_caps_get_structure (res, 0);
  if (direction == GST_PAD_SRC) {
    GST_INFO ("allow 1-2 channels");
    gst_structure_set (structure, "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
    gst_structure_remove_field (structure, "channel-mask");
  } else {
    GST_INFO ("allow 2 channels");
    gst_structure_set (structure, "channels", G_TYPE_INT, 2, NULL);
    gst_structure_remove_field (structure, "channel-mask");
  }

  return res;
}
Esempio n. 20
0
static GstCaps *
gst_mill_color_transform_caps (GstBaseTransform * btrans,
GstPadDirection direction, GstCaps * caps)
{
  const GstCaps *tmpl_caps = NULL;
  GstCaps *result = NULL, *local_caps = NULL;
  guint i;

  local_caps = gst_caps_copy (caps);

  for (i = 0; i < gst_caps_get_size (local_caps); i++) {
    GstStructure *structure = gst_caps_get_structure (local_caps, i);

    /* Throw away the structure name and set it to transformed format */
    if (direction == GST_PAD_SINK) {
      gst_structure_set_name (structure, "video/x-raw-yuv");
    } else if (direction == GST_PAD_SRC) {
      gst_structure_set_name (structure, "video/x-raw-rgb");
    }
    /* Remove any specific parameter from the structure */
    gst_structure_remove_field (structure, "format");
    gst_structure_remove_field (structure, "endianness");
    gst_structure_remove_field (structure, "depth");
    gst_structure_remove_field (structure, "bpp");
    gst_structure_remove_field (structure, "red_mask");
    gst_structure_remove_field (structure, "green_mask");
    gst_structure_remove_field (structure, "blue_mask");
    gst_structure_remove_field (structure, "alpha_mask");
  }

  /* Get the appropriate template */
  if (direction == GST_PAD_SINK) {
    tmpl_caps = gst_static_pad_template_get_caps (&src_template);
  } else if (direction == GST_PAD_SRC) {
    tmpl_caps = gst_static_pad_template_get_caps (&sink_template);
  }

  /* Intersect with our template caps */
  result = gst_caps_intersect (local_caps, tmpl_caps);

  gst_caps_unref (local_caps);
  gst_caps_do_simplify (result);

  GST_LOG ("transformed %" GST_PTR_FORMAT " to %" GST_PTR_FORMAT, caps, result);

  return result;
}
Esempio n. 21
0
/* return a list of caps where we only need to set
 * width and height to get fixed caps */
static GList *
video_crop_get_test_caps (GstElement * videocrop)
{
    const GstCaps *allowed_caps;
    GstPad *srcpad;
    GList *list = NULL;
    guint i;

    srcpad = gst_element_get_static_pad (videocrop, "src");
    g_assert (srcpad != NULL);
    allowed_caps = gst_pad_get_pad_template_caps (srcpad);
    g_assert (allowed_caps != NULL);

    for (i = 0; i < gst_caps_get_size (allowed_caps); ++i) {
        GstStructure *new_structure;
        GstCaps *single_caps;

        single_caps = gst_caps_new_empty ();
        new_structure =
            gst_structure_copy (gst_caps_get_structure (allowed_caps, i));
        gst_structure_set (new_structure, "framerate", GST_TYPE_FRACTION,
                           FRAMERATE, 1, NULL);
        gst_structure_remove_field (new_structure, "width");
        gst_structure_remove_field (new_structure, "height");
        gst_caps_append_structure (single_caps, new_structure);

        /* should be fixed without width/height */
        g_assert (gst_caps_is_fixed (single_caps));

        list = g_list_prepend (list, single_caps);
    }

    gst_object_unref (srcpad);

    return list;
}
Esempio n. 22
0
/*!
 * \brief CvCapture_GStreamer::removeFilter
 * \param filter filter to remove
 * remove the specified filter from the appsink template caps
 */
void CvCapture_GStreamer::removeFilter(const char *filter)
{
    if(!caps)
        return;

#if GST_VERSION_MAJOR > 0
    if (! gst_caps_is_writable(caps))
        caps = gst_caps_make_writable (caps);
#endif

    GstStructure *s = gst_caps_get_structure(caps, 0);
    gst_structure_remove_field(s, filter);

    gst_app_sink_set_caps(GST_APP_SINK(sink), caps);
}
Esempio n. 23
0
static void
gst_vdp_video_remove_pixel_aspect_ratio (GstStructure * structure)
{
  gint par_n, par_d;

  if (gst_structure_get_fraction (structure, "pixel-aspect-ratio", &par_n,
          &par_d)) {
    gint width;

    gst_structure_get_int (structure, "width", &width);
    width = gst_util_uint64_scale_int (width, par_n, par_d);
    gst_structure_set (structure, "width", G_TYPE_INT, width, NULL);

    gst_structure_remove_field (structure, "pixel-aspect-ratio");
  }
}
Esempio n. 24
0
/* copies the given caps */
static GstCaps *
gst_ffmpegscale_caps_remove_format_info (GstCaps * caps)
{
    int i;
    GstStructure *structure;

    caps = gst_caps_copy (caps);

    for (i = 0; i < gst_caps_get_size (caps); i++) {
        structure = gst_caps_get_structure (caps, i);

        gst_structure_remove_field (structure, "format");
    }

    return caps;
}
static GstCaps *
gst_mpegv_parse_get_caps (GstBaseParse * parse, GstCaps * filter)
{
  GstCaps *peercaps, *templ;
  GstCaps *res;

  templ = gst_pad_get_pad_template_caps (GST_BASE_PARSE_SINK_PAD (parse));
  peercaps = gst_pad_peer_query_caps (GST_BASE_PARSE_SRC_PAD (parse), filter);
  if (peercaps) {
    guint i, n;

    /* Remove the parsed field */
    peercaps = gst_caps_make_writable (peercaps);
    n = gst_caps_get_size (peercaps);
    for (i = 0; i < n; i++) {
      GstStructure *s = gst_caps_get_structure (peercaps, i);
      gst_structure_remove_field (s, "parsed");
    }

    res = gst_caps_intersect_full (peercaps, templ, GST_CAPS_INTERSECT_FIRST);
    gst_caps_unref (peercaps);
    res = gst_caps_make_writable (res);

    /* Append the template caps because we still want to accept
     * caps without any fields in the case upstream does not
     * know anything.
     */
    gst_caps_append (res, templ);
  } else {
    res = templ;
  }

  if (filter) {
    GstCaps *intersection;

    intersection =
        gst_caps_intersect_full (filter, res, GST_CAPS_INTERSECT_FIRST);
    gst_caps_unref (res);
    res = intersection;
  }

  return res;
}
static void
clear_caps (GstCaps * caps, gboolean only_clock_rate)
{
  gint i, j;

  /* Lets only match on the clock-rate */
  for (i = 0; i < gst_caps_get_size (caps); i++) {
    GstStructure *s = gst_caps_get_structure (caps, i);

    for (j = 0; j < gst_structure_n_fields (s); j++) {
      const gchar *name = gst_structure_nth_field_name (s, j);

      if (strcmp (name, "clock-rate") && (only_clock_rate ||
              (strcmp (name, "ssrc")))) {
        gst_structure_remove_field (s, name);
        j--;
      }
    }
  }
}
Esempio n. 27
0
static GstCaps *
gst_ffmpegscale_transform_caps (GstBaseTransform * trans,
    GstPadDirection direction, GstCaps * caps)
{
  GstCaps *retcaps;
  int i;

  retcaps = gst_caps_copy (caps);

  for (i = 0; i < gst_caps_get_size (retcaps); i++) {
    GstStructure *structure = gst_caps_get_structure (retcaps, i);

    gst_structure_set (structure,
        "width", GST_TYPE_INT_RANGE, 16, 4096,
        "height", GST_TYPE_INT_RANGE, 16, 4096, NULL);
    gst_structure_remove_field (structure, "pixel-aspect-ratio");
  }

  return retcaps;
}
/* For each raw video structure, adds a variant with format unset */
static gboolean
fix_video_caps_format(GstCapsFeatures *f, GstStructure *s, gpointer user_data)
{
    GstCaps *ret = GST_CAPS(user_data);
    OWR_UNUSED(f);

    gst_caps_append_structure(ret, gst_structure_copy(s));

    /* Don't mess with non-raw structures */
    if (!gst_structure_has_name(s, "video/x-raw"))
        goto done;

    if (gst_structure_has_field(s, "format")) {
        GstStructure *tmp = gst_structure_copy(s);
        gst_structure_remove_field(tmp, "format");
        gst_caps_append_structure(ret, tmp);
    }

done:
    return TRUE;
}
/* For each raw video structure, adds a variant with framerate unset */
static gboolean
fix_video_caps_framerate(GstCapsFeatures *f, GstStructure *s, gpointer user_data)
{
    GstCaps *ret = GST_CAPS(user_data);
    gint fps_n, fps_d;

    gst_caps_append_structure_full(ret, gst_structure_copy(s), f ? gst_caps_features_copy(f) : NULL);

    /* Don't mess with non-raw structures */
    if (!gst_structure_has_name(s, "video/x-raw"))
        goto done;

    /* If possible try to limit the framerate at the source already */
    if (gst_structure_get_fraction(s, "framerate", &fps_n, &fps_d)) {
        GstStructure *tmp = gst_structure_copy(s);
        gst_structure_remove_field(tmp, "framerate");
        gst_caps_append_structure_full(ret, tmp, f ? gst_caps_features_copy(f) : NULL);
    }

done:
    return TRUE;
}
Esempio n. 30
0
static GstCaps *
strip_mview_fields (GstCaps * incaps, GstVideoMultiviewFlags keep_flags)
{
  GstCaps *outcaps = gst_caps_make_writable (incaps);

  gint i, n;

  n = gst_caps_get_size (outcaps);
  for (i = 0; i < n; i++) {
    GstStructure *st = gst_caps_get_structure (outcaps, i);
    GstVideoMultiviewFlags flags, mask;

    gst_structure_remove_field (st, "multiview-mode");
    if (gst_structure_get_flagset (st, "multiview-flags", &flags, &mask)) {
      flags &= keep_flags;
      mask = keep_flags;
      gst_structure_set (st, "multiview-flags",
          GST_TYPE_VIDEO_MULTIVIEW_FLAGSET, flags, mask, NULL);
    }
  }

  return outcaps;
}