static GstCaps * gst_dshowvideosrc_src_fixate (GstBaseSrc * bsrc, GstCaps * caps) { /* If there is no desired video size, set default video size to device preffered video size */ GstDshowVideoSrc *src = GST_DSHOWVIDEOSRC (bsrc); GstStructure *structure = gst_caps_get_structure (caps, 0); guint i = 0; gint res = -1; for (; i < gst_caps_get_size (src->caps) && res == -1; i++) { GstCaps *capstmp = gst_caps_copy_nth (src->caps, i); if (gst_caps_is_subset (caps, capstmp)) { res = i; } gst_caps_unref (capstmp); } if (res != -1) { GList *type_pin_mediatype = g_list_nth (src->pins_mediatypes, res); if (type_pin_mediatype) { GstCapturePinMediaType *pin_mediatype = (GstCapturePinMediaType *) type_pin_mediatype->data; gst_structure_fixate_field_nearest_int (structure, "width", pin_mediatype->defaultWidth); gst_structure_fixate_field_nearest_int (structure, "height", pin_mediatype->defaultHeight); gst_structure_fixate_field_nearest_fraction (structure, "framerate", pin_mediatype->defaultFPS, 1); } } return GST_BASE_SRC_CLASS (gst_dshowvideosrc_parent_class)->fixate (bsrc, caps); }
static GstCaps * gst_video_test_src_src_fixate (GstBaseSrc * bsrc, GstCaps * caps) { GstStructure *structure; caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); if (gst_structure_has_field (structure, "pixel-aspect-ratio")) gst_structure_fixate_field_nearest_fraction (structure, "pixel-aspect-ratio", 1, 1); if (gst_structure_has_field (structure, "colorimetry")) gst_structure_fixate_field_string (structure, "colorimetry", "bt601"); if (gst_structure_has_field (structure, "chroma-site")) gst_structure_fixate_field_string (structure, "chroma-site", "mpeg2"); if (gst_structure_has_field (structure, "interlace-mode")) gst_structure_fixate_field_string (structure, "interlace-mode", "progressive"); caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps); return caps; }
static GstCaps * gst_ladspa_source_type_fixate (GstBaseSrc * base, GstCaps * caps) { GstLADSPASource *ladspa = GST_LADSPA_SOURCE (base); GstStructure *structure; caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); GST_DEBUG_OBJECT (ladspa, "fixating samplerate to %d", GST_AUDIO_DEF_RATE); gst_structure_fixate_field_nearest_int (structure, "rate", GST_AUDIO_DEF_RATE); gst_structure_fixate_field_string (structure, "format", GST_AUDIO_NE (F32)); gst_structure_fixate_field_nearest_int (structure, "channels", ladspa->ladspa.klass->count.audio.out); caps = GST_BASE_SRC_CLASS (gst_ladspa_source_type_parent_class)->fixate (base, caps); return caps; }
/* this function is a bit of a last resort */ static GstCaps * gst_v4l2src_fixate (GstBaseSrc * basesrc, GstCaps * caps) { GstStructure *structure; gint i; GST_DEBUG_OBJECT (basesrc, "fixating caps %" GST_PTR_FORMAT, caps); caps = gst_caps_make_writable (caps); for (i = 0; i < gst_caps_get_size (caps); ++i) { structure = gst_caps_get_structure (caps, i); /* We are fixating to a reasonable 320x200 resolution and the maximum framerate resolution for that size */ if (gst_structure_has_field (structure, "width")) gst_structure_fixate_field_nearest_int (structure, "width", 320); if (gst_structure_has_field (structure, "height")) gst_structure_fixate_field_nearest_int (structure, "height", 200); if (gst_structure_has_field (structure, "framerate")) gst_structure_fixate_field_nearest_fraction (structure, "framerate", G_MAXINT, 1); if (gst_structure_has_field (structure, "format")) gst_structure_fixate_field (structure, "format"); } GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps); caps = GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps); return caps; }
static GstCaps * gst_inter_video_src_fixate (GstBaseSrc * src, GstCaps * caps) { GstInterVideoSrc *intervideosrc = GST_INTER_VIDEO_SRC (src); GstStructure *structure; GST_DEBUG_OBJECT (intervideosrc, "fixate"); caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); if (gst_structure_has_field (structure, "pixel-aspect-ratio")) gst_structure_fixate_field_nearest_fraction (structure, "pixel-aspect-ratio", 1, 1); if (gst_structure_has_field (structure, "color-matrix")) gst_structure_fixate_field_string (structure, "color-matrix", "sdtv"); if (gst_structure_has_field (structure, "chroma-site")) gst_structure_fixate_field_string (structure, "chroma-site", "mpeg2"); if (gst_structure_has_field (structure, "interlaced")) gst_structure_fixate_field_boolean (structure, "interlaced", FALSE); return caps; }
static void gst_base_audio_src_fixate (GstBaseSrc * bsrc, GstCaps * caps) { GstStructure *s; gint width, depth; s = gst_caps_get_structure (caps, 0); /* fields for all formats */ gst_structure_fixate_field_nearest_int (s, "rate", 44100); gst_structure_fixate_field_nearest_int (s, "channels", 2); gst_structure_fixate_field_nearest_int (s, "width", 16); /* fields for int */ if (gst_structure_has_field (s, "depth")) { gst_structure_get_int (s, "width", &width); /* round width to nearest multiple of 8 for the depth */ depth = GST_ROUND_UP_8 (width); gst_structure_fixate_field_nearest_int (s, "depth", depth); } if (gst_structure_has_field (s, "signed")) gst_structure_fixate_field_boolean (s, "signed", TRUE); if (gst_structure_has_field (s, "endianness")) gst_structure_fixate_field_nearest_int (s, "endianness", G_BYTE_ORDER); }
bool tcam_gst_fixate_caps (GstCaps* caps) { if (caps == nullptr || gst_caps_is_empty(caps) || gst_caps_is_any(caps)) { return FALSE; } GstStructure* structure = gst_caps_get_structure(caps, 0); if (gst_structure_has_field(structure, "width")) { gst_structure_fixate_field_nearest_int(structure, "width", G_MAXINT); } if (gst_structure_has_field(structure, "height")) { gst_structure_fixate_field_nearest_int(structure, "height", G_MAXINT); } if (gst_structure_has_field(structure, "framerate")) { gst_structure_fixate_field_nearest_fraction(structure, "framerate", G_MAXINT, 1); } return TRUE; }
static GstCaps * gst_speex_enc_sink_getcaps (GstPad * pad) { GstCaps *caps = gst_caps_copy (gst_pad_get_pad_template_caps (pad)); GstCaps *peercaps = NULL; GstSpeexEnc *enc = GST_SPEEX_ENC (gst_pad_get_parent_element (pad)); peercaps = gst_pad_peer_get_caps (enc->srcpad); if (peercaps) { if (!gst_caps_is_empty (peercaps) && !gst_caps_is_any (peercaps)) { GstStructure *ps = gst_caps_get_structure (peercaps, 0); GstStructure *s = gst_caps_get_structure (caps, 0); gint rate, channels; if (gst_structure_get_int (ps, "rate", &rate)) { gst_structure_fixate_field_nearest_int (s, "rate", rate); } if (gst_structure_get_int (ps, "channels", &channels)) { gst_structure_fixate_field_nearest_int (s, "channels", channels); } } gst_caps_unref (peercaps); } gst_object_unref (enc); return caps; }
static void gst_ks_video_src_fixate (GstBaseSrc * basesrc, GstCaps * caps) { GstStructure *structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", G_MAXINT); gst_structure_fixate_field_nearest_int (structure, "height", G_MAXINT); gst_structure_fixate_field_nearest_fraction (structure, "framerate", G_MAXINT, 1); }
static void gst_video_test_src_src_fixate (GstPad * pad, GstCaps * caps) { GstStructure *structure; structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); }
static gboolean gst_vis_src_negotiate (GstVisual * visual) { GstCaps *othercaps, *target, *intersect; GstStructure *structure; GstCaps *caps; caps = gst_pad_get_caps (visual->srcpad); /* see what the peer can do */ othercaps = gst_pad_peer_get_caps (visual->srcpad); if (othercaps) { intersect = gst_caps_intersect (othercaps, caps); gst_caps_unref (othercaps); gst_caps_unref (caps); if (gst_caps_is_empty (intersect)) goto no_format; target = gst_caps_copy_nth (intersect, 0); gst_caps_unref (intersect); } else { /* need a copy, we'll be modifying it when fixating */ target = gst_caps_copy (caps); gst_caps_unref (caps); } /* fixate in case something is not fixed. This does nothing if the value is * already fixed. For video we always try to fixate to something like * 320x240x30 by convention. */ structure = gst_caps_get_structure (target, 0); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); gst_pad_set_caps (visual->srcpad, target); gst_caps_unref (target); return TRUE; /* ERRORS */ no_format: { GST_ELEMENT_ERROR (visual, STREAM, FORMAT, (NULL), ("could not negotiate output format")); gst_caps_unref (intersect); return FALSE; } }
/* this function is a bit of a last resort */ static void gst_v4lsrc_fixate (GstBaseSrc * bsrc, GstCaps * caps) { GstStructure *structure; int i; int targetwidth, targetheight; GstV4lSrc *v4lsrc = GST_V4LSRC (bsrc); struct video_capability *vcap = &GST_V4LELEMENT (v4lsrc)->vcap; struct video_window *vwin = &GST_V4LELEMENT (v4lsrc)->vwin; if (GST_V4L_IS_OPEN (GST_V4LELEMENT (v4lsrc))) { GST_DEBUG_OBJECT (v4lsrc, "device reported w: %d-%d, h: %d-%d", vcap->minwidth, vcap->maxwidth, vcap->minheight, vcap->maxheight); targetwidth = vcap->minwidth; targetheight = vcap->minheight; /* if we can get the current vwin settings, we use those to fixate */ if (!gst_v4l_get_capabilities (GST_V4LELEMENT (v4lsrc))) GST_DEBUG_OBJECT (v4lsrc, "failed getting capabilities"); else { targetwidth = vwin->width; targetheight = vwin->height; } } else { GST_DEBUG_OBJECT (v4lsrc, "device closed, guessing"); targetwidth = 320; targetheight = 200; } GST_DEBUG_OBJECT (v4lsrc, "targetting %dx%d", targetwidth, targetheight); for (i = 0; i < gst_caps_get_size (caps); ++i) { const GValue *v; structure = gst_caps_get_structure (caps, i); gst_structure_fixate_field_nearest_int (structure, "width", targetwidth); gst_structure_fixate_field_nearest_int (structure, "height", targetheight); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 15, 2); v = gst_structure_get_value (structure, "format"); if (v && G_VALUE_TYPE (v) != GST_TYPE_FOURCC) { guint32 fourcc; g_return_if_fail (G_VALUE_TYPE (v) == GST_TYPE_LIST); fourcc = gst_value_get_fourcc (gst_value_list_get_value (v, 0)); gst_structure_set (structure, "format", GST_TYPE_FOURCC, fourcc, NULL); } } }
static void gst_osx_video_src_fixate (GstBaseSrc * bsrc, GstCaps * caps) { GstStructure *structure; int i; /* this function is for choosing defaults as a last resort */ for (i = 0; i < (int) gst_caps_get_size (caps); ++i) { structure = gst_caps_get_structure (caps, i); gst_structure_fixate_field_nearest_int (structure, "width", 640); gst_structure_fixate_field_nearest_int (structure, "height", 480); // ###: if we ever support choosing framerates, do something with this //gst_structure_fixate_field_nearest_fraction (structure, "framerate", 15, 2); } }
static gboolean gst_dtmf_src_negotiate (GstBaseSrc * basesrc) { GstDTMFSrc *dtmfsrc = GST_DTMF_SRC (basesrc); GstCaps *caps; GstStructure *s; gboolean ret; caps = gst_pad_get_allowed_caps (GST_BASE_SRC_PAD (basesrc)); if (!caps) caps = gst_caps_copy (gst_pad_get_pad_template_caps (GST_BASE_SRC_PAD (basesrc))); if (gst_caps_is_empty (caps)) return FALSE; gst_caps_truncate (caps); s = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (s, "rate", DEFAULT_SAMPLE_RATE); if (!gst_structure_get_int (s, "rate", &dtmfsrc->sample_rate)) { GST_ERROR_OBJECT (dtmfsrc, "Could not get rate"); gst_caps_unref (caps); return FALSE; } ret = gst_pad_set_caps (GST_BASE_SRC_PAD (basesrc), caps); gst_caps_unref (caps); return ret; }
static void fixate_vis_caps (RBVisualizerPlugin *plugin) { GstPad *pad; GstCaps *caps = NULL; const GstCaps *template_caps; pad = gst_element_get_static_pad (plugin->vis_plugin, "src"); template_caps = gst_pad_get_pad_template_caps (pad); gst_object_unref (pad); if (template_caps == NULL) { rb_debug ("vis element has no template caps?"); return; } caps = gst_caps_copy (template_caps); if (gst_caps_is_fixed (caps) == FALSE) { guint i; char *dbg; const VisualizerQuality *q = &rb_visualizer_quality[g_settings_get_enum (plugin->settings, "quality")]; rb_debug ("fixating caps towards %dx%d, %d/%d", q->width, q->height, q->fps_n, q->fps_d); caps = gst_caps_make_writable (caps); for (i = 0; i < gst_caps_get_size (caps); i++) { GstStructure *s = gst_caps_get_structure (caps, i); gst_structure_fixate_field_nearest_int (s, "width", q->width); gst_structure_fixate_field_nearest_int (s, "height", q->height); gst_structure_fixate_field_nearest_fraction (s, "framerate", q->fps_n, q->fps_d); } dbg = gst_caps_to_string (caps); rb_debug ("setting fixed caps on capsfilter: %s", dbg); g_free (dbg); g_object_set (plugin->capsfilter, "caps", caps, NULL); } else { char *dbg = gst_caps_to_string (caps); rb_debug ("vis element caps already fixed: %s", dbg); g_free (dbg); } gst_caps_unref (caps); }
static GstCaps * gst_gdiscreencapsrc_fixate (GstBaseSrc * bsrc, GstCaps * caps) { GstStructure *structure; caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", 640); gst_structure_fixate_field_nearest_int (structure, "height", 480); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); caps = GST_BASE_SRC_CLASS (parent_class)->fixate (bsrc, caps); return caps; }
static GstCaps * gst_aasink_fixate (GstBaseSink * bsink, GstCaps * caps) { GstStructure *structure; caps = gst_caps_make_writable (caps); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); caps = GST_BASE_SINK_CLASS (parent_class)->fixate (bsink, caps); return caps; }
static void gst_opus_dec_negotiate (GstOpusDec * dec, const GstAudioChannelPosition * pos) { GstCaps *caps = gst_pad_get_allowed_caps (GST_AUDIO_DECODER_SRC_PAD (dec)); GstStructure *s; GstAudioInfo info; if (caps) { caps = gst_caps_truncate (caps); caps = gst_caps_make_writable (caps); s = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (s, "rate", 48000); gst_structure_get_int (s, "rate", &dec->sample_rate); gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels); gst_structure_get_int (s, "channels", &dec->n_channels); gst_caps_unref (caps); } else { dec->sample_rate = 48000; } GST_INFO_OBJECT (dec, "Negotiated %d channels, %d Hz", dec->n_channels, dec->sample_rate); /* pass valid order to audio info */ if (pos) { memcpy (dec->opus_pos, pos, sizeof (pos[0]) * dec->n_channels); gst_audio_channel_positions_to_valid_order (dec->opus_pos, dec->n_channels); } /* set up source format */ gst_audio_info_init (&info); gst_audio_info_set_format (&info, GST_AUDIO_FORMAT_S16, dec->sample_rate, dec->n_channels, pos ? dec->opus_pos : NULL); gst_audio_decoder_set_output_format (GST_AUDIO_DECODER (dec), &info); /* but we still need the opus order for later reordering */ if (pos) { memcpy (dec->opus_pos, pos, sizeof (pos[0]) * dec->n_channels); gst_audio_channel_positions_to_valid_order (dec->opus_pos, dec->n_channels); } else { dec->opus_pos[0] = GST_AUDIO_CHANNEL_POSITION_INVALID; } dec->info = info; }
static void gst_droid_cam_src_vfsrc_fixatecaps (GstPad * pad, GstCaps * caps) { GstDroidCamSrc *src = GST_DROID_CAM_SRC (GST_OBJECT_PARENT (pad)); GstStructure *s; GST_LOG_OBJECT (src, "fixatecaps %" GST_PTR_FORMAT, caps); gst_caps_truncate (caps); s = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (s, "width", DEFAULT_VF_WIDTH); gst_structure_fixate_field_nearest_int (s, "height", DEFAULT_VF_HEIGHT); gst_structure_fixate_field_nearest_fraction (s, "framerate", DEFAULT_FPS, 1); GST_DEBUG_OBJECT (src, "caps now is %" GST_PTR_FORMAT, caps); }
static GstCaps * gst_rtp_celt_pay_getcaps (GstRTPBasePayload * payload, GstPad * pad, GstCaps * filter) { GstCaps *otherpadcaps; GstCaps *caps; const gchar *params; caps = gst_pad_get_pad_template_caps (pad); otherpadcaps = gst_pad_get_allowed_caps (payload->srcpad); if (otherpadcaps) { if (!gst_caps_is_empty (otherpadcaps)) { GstStructure *ps; GstStructure *s; gint clock_rate = 0, frame_size = 0, channels = 1; caps = gst_caps_make_writable (caps); ps = gst_caps_get_structure (otherpadcaps, 0); s = gst_caps_get_structure (caps, 0); if (gst_structure_get_int (ps, "clock-rate", &clock_rate)) { gst_structure_fixate_field_nearest_int (s, "rate", clock_rate); } if ((params = gst_structure_get_string (ps, "frame-size"))) frame_size = atoi (params); if (frame_size) gst_structure_set (s, "frame-size", G_TYPE_INT, frame_size, NULL); if ((params = gst_structure_get_string (ps, "encoding-params"))) { channels = atoi (params); gst_structure_fixate_field_nearest_int (s, "channels", channels); } GST_DEBUG_OBJECT (payload, "clock-rate=%d frame-size=%d channels=%d", clock_rate, frame_size, channels); } gst_caps_unref (otherpadcaps); } return caps; }
static GstCaps * gst_ks_video_src_fixate (GstBaseSrc * basesrc, GstCaps * caps) { GstStructure *structure; GstCaps *fixated_caps; gint i; fixated_caps = gst_caps_make_writable (caps); for (i = 0; i < gst_caps_get_size (fixated_caps); ++i) { structure = gst_caps_get_structure (fixated_caps, i); gst_structure_fixate_field_nearest_int (structure, "width", G_MAXINT); gst_structure_fixate_field_nearest_int (structure, "height", G_MAXINT); gst_structure_fixate_field_nearest_fraction (structure, "framerate", G_MAXINT, 1); } return gst_caps_fixate (fixated_caps); }
static void gst_dc1394_src_fixate (GstPad * pad, GstCaps * caps) { GstDc1394 *src = GST_DC1394 (gst_pad_get_parent (pad)); GstStructure *structure; int i; GST_LOG_OBJECT (src, " fixating caps to closest to 320x240 , 30 fps"); for (i = 0; i < gst_caps_get_size (caps); ++i) { structure = gst_caps_get_structure (caps, i); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); } gst_object_unref (GST_OBJECT (src)); }
static GstCaps * gst_inter_audio_src_fixate (GstBaseSrc * src, GstCaps * caps) { GstStructure *structure; GST_DEBUG_OBJECT (src, "fixate"); caps = gst_caps_make_writable (caps); caps = gst_caps_truncate (caps); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_string (structure, "format", GST_AUDIO_NE (S16)); gst_structure_fixate_field_nearest_int (structure, "channels", 2); gst_structure_fixate_field_nearest_int (structure, "rate", 48000); gst_structure_fixate_field_string (structure, "layout", "interleaved"); return caps; }
static gboolean gst_monoscope_src_negotiate (GstMonoscope * monoscope) { GstCaps *othercaps, *target, *intersect; GstStructure *structure; const GstCaps *templ; templ = gst_pad_get_pad_template_caps (monoscope->srcpad); GST_DEBUG_OBJECT (monoscope, "performing negotiation"); /* see what the peer can do */ othercaps = gst_pad_peer_get_caps (monoscope->srcpad); if (othercaps) { intersect = gst_caps_intersect (othercaps, templ); gst_caps_unref (othercaps); if (gst_caps_is_empty (intersect)) goto no_format; target = gst_caps_copy_nth (intersect, 0); gst_caps_unref (intersect); } else { target = gst_caps_ref ((GstCaps *) templ); } structure = gst_caps_get_structure (target, 0); gst_structure_fixate_field_nearest_int (structure, "width", 320); gst_structure_fixate_field_nearest_int (structure, "height", 240); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 25, 1); gst_pad_set_caps (monoscope->srcpad, target); gst_caps_unref (target); return TRUE; no_format: { gst_caps_unref (intersect); return FALSE; } }
static gboolean gst_goom_src_negotiate (GstGoom * goom) { GstCaps *othercaps, *target; GstStructure *structure; const GstCaps *templ; templ = gst_pad_get_pad_template_caps (goom->srcpad); GST_DEBUG_OBJECT (goom, "performing negotiation"); /* see what the peer can do */ othercaps = gst_pad_peer_get_caps (goom->srcpad); if (othercaps) { target = gst_caps_intersect (othercaps, templ); gst_caps_unref (othercaps); if (gst_caps_is_empty (target)) goto no_format; gst_caps_truncate (target); } else { target = gst_caps_ref ((GstCaps *) templ); } structure = gst_caps_get_structure (target, 0); gst_structure_fixate_field_nearest_int (structure, "width", DEFAULT_WIDTH); gst_structure_fixate_field_nearest_int (structure, "height", DEFAULT_HEIGHT); gst_structure_fixate_field_nearest_fraction (structure, "framerate", DEFAULT_FPS_N, DEFAULT_FPS_D); gst_pad_set_caps (goom->srcpad, target); gst_caps_unref (target); return TRUE; no_format: { gst_caps_unref (target); return FALSE; } }
static GstCaps * gst_rpi_cam_src_fixate (GstBaseSrc * basesrc, GstCaps * caps) { GstStructure *structure; gint i; GST_DEBUG_OBJECT (basesrc, "fixating caps %" GST_PTR_FORMAT, caps); caps = gst_caps_make_writable (caps); for (i = 0; i < gst_caps_get_size (caps); ++i) { structure = gst_caps_get_structure (caps, i); /* Fixate to 1920x1080 resolution if possible */ gst_structure_fixate_field_nearest_int (structure, "width", 1920); gst_structure_fixate_field_nearest_int (structure, "height", 1080); gst_structure_fixate_field_nearest_fraction (structure, "framerate", 30, 1); gst_structure_fixate_field (structure, "format"); } GST_DEBUG_OBJECT (basesrc, "fixated caps %" GST_PTR_FORMAT, caps); caps = GST_BASE_SRC_CLASS (parent_class)->fixate (basesrc, caps); return caps; }
static GstCaps * gst_opus_dec_negotiate (GstOpusDec * dec) { GstCaps *caps = gst_pad_get_allowed_caps (GST_AUDIO_DECODER_SRC_PAD (dec)); GstStructure *s; caps = gst_caps_make_writable (caps); gst_caps_truncate (caps); s = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (s, "rate", 48000); gst_structure_get_int (s, "rate", &dec->sample_rate); gst_structure_fixate_field_nearest_int (s, "channels", dec->n_channels); gst_structure_get_int (s, "channels", &dec->n_channels); GST_INFO_OBJECT (dec, "Negotiated %d channels, %d Hz", dec->n_channels, dec->sample_rate); return caps; }
static GstCaps * gst_mikmod_srcfixate (GstPad * pad, const GstCaps * caps) { GstCaps *ret; GstStructure *structure; /* FIXME: select est caps here */ if (gst_caps_get_size (caps) > 1) return NULL; ret = gst_caps_copy (caps); structure = gst_caps_get_structure (ret, 0); if (gst_structure_fixate_field_nearest_int (structure, "channels", 2)) return ret; if (gst_structure_fixate_field_nearest_int (structure, "rate", 44100)) return ret; gst_caps_free (ret); return NULL; }
static gboolean gstbt_sim_syn_setup (GstBtAudioSynth * base, GstPad * pad, GstCaps * caps) { GstStructure *structure; gint i, n = gst_caps_get_size (caps); for (i = 0; i < n; i++) { structure = gst_caps_get_structure (caps, i); gst_structure_fixate_field_nearest_int (structure, "channels", 1); } return TRUE; }
static void gst_aravis_fixate_caps (GstPad * pad, GstCaps * caps) { GstAravis *gst_aravis = GST_ARAVIS (gst_pad_get_parent_element (pad)); GstStructure *structure; gint width; gint height; double frame_rate; arv_camera_get_region (gst_aravis->camera, NULL, NULL, &width, &height); frame_rate = arv_camera_get_frame_rate (gst_aravis->camera); structure = gst_caps_get_structure (caps, 0); gst_structure_fixate_field_nearest_int (structure, "width", width); gst_structure_fixate_field_nearest_int (structure, "height", height); gst_structure_fixate_field_nearest_fraction (structure, "framerate", (double) (0.5 + frame_rate), 1); GST_LOG_OBJECT (gst_aravis, "Fixate caps"); g_object_unref (gst_aravis); }