/** * gst_pb_utils_add_codec_description_to_tag_list: * @taglist: a #GstTagList * @codec_tag: a GStreamer codec tag such as #GST_TAG_AUDIO_CODEC, * #GST_TAG_VIDEO_CODEC or #GST_TAG_CODEC * @caps: the (fixed) #GstCaps for which a codec tag should be added. * * Adds a codec tag describing the format specified by @caps to @taglist. * * Returns: TRUE if a codec tag was added, FALSE otherwise. */ gboolean gst_pb_utils_add_codec_description_to_tag_list (GstTagList * taglist, const gchar * codec_tag, const GstCaps * caps) { const FormatInfo *info; gchar *desc; g_return_val_if_fail (taglist != NULL, FALSE); g_return_val_if_fail (GST_IS_TAG_LIST (taglist), FALSE); g_return_val_if_fail (codec_tag != NULL, FALSE); g_return_val_if_fail (gst_tag_exists (codec_tag), FALSE); g_return_val_if_fail (gst_tag_get_type (codec_tag) == G_TYPE_STRING, FALSE); g_return_val_if_fail (caps != NULL, FALSE); g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); info = find_format_info (caps); if (info == NULL) return FALSE; desc = format_info_get_desc (info, caps); gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, codec_tag, desc, NULL); g_free (desc); return TRUE; }
/** * gst_pb_utils_get_encoder_description: * @caps: the (fixed) #GstCaps for which an encoder description is needed * * Returns a localised string describing an encoder for the format specified * in @caps, for use in error dialogs or other messages to be seen by the user. * Should never return NULL unless @factory_name or @caps are invalid. * * This function is mainly for internal use, applications would typically * use gst_missing_plugin_message_get_description() to get a description of * a missing feature from a missing-plugin message. * * Returns: a newly-allocated description string, or NULL on error. Free * string with g_free() when not needed any longer. */ gchar * gst_pb_utils_get_encoder_description (const GstCaps * caps) { gchar *str, *ret; GstCaps *tmp; g_return_val_if_fail (caps != NULL, NULL); g_return_val_if_fail (GST_IS_CAPS (caps), NULL); tmp = copy_and_clean_caps (caps); g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL); /* special-case RTP caps */ if (caps_are_rtp_caps (tmp, "video", &str)) { ret = g_strdup_printf (_("%s video RTP payloader"), str); } else if (caps_are_rtp_caps (tmp, "audio", &str)) { ret = g_strdup_printf (_("%s audio RTP payloader"), str); } else if (caps_are_rtp_caps (tmp, "application", &str)) { ret = g_strdup_printf (_("%s RTP payloader"), str); } else { const FormatInfo *info; str = gst_pb_utils_get_codec_description (tmp); info = find_format_info (tmp); if (info != NULL && (info->flags & FLAG_CONTAINER) != 0) { ret = g_strdup_printf (_("%s muxer"), str); } else { ret = g_strdup_printf (_("%s encoder"), str); } } g_free (str); gst_caps_unref (tmp); return ret; }
GstVaapiDecoder * gst_vaapi_decoder_new (const GstVaapiDecoderClass * klass, GstVaapiDisplay * display, GstCaps * caps) { GstVaapiDecoder *decoder; g_return_val_if_fail (display != NULL, NULL); g_return_val_if_fail (GST_IS_CAPS (caps), NULL); decoder = (GstVaapiDecoder *) gst_vaapi_mini_object_new (GST_VAAPI_MINI_OBJECT_CLASS (klass)); if (!decoder) return NULL; if (!gst_vaapi_decoder_init (decoder, display, caps)) goto error; return decoder; /* ERRORS */ error: { gst_vaapi_decoder_unref (decoder); return NULL; } }
/** * gst_missing_encoder_message_new: * @element: the #GstElement posting the message * @encode_caps: the (fixed) caps for which an encoder element is needed * * Creates a missing-plugin message for @element to notify the application * that an encoder element for a particular set of (fixed) caps is missing. * This function is mainly for use in plugins. * * Returns: (transfer full): a new #GstMessage, or NULL on error */ GstMessage * gst_missing_encoder_message_new (GstElement * element, const GstCaps * encode_caps) { GstStructure *s; GstCaps *caps; gchar *description; g_return_val_if_fail (element != NULL, NULL); g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); g_return_val_if_fail (encode_caps != NULL, NULL); g_return_val_if_fail (GST_IS_CAPS (encode_caps), NULL); g_return_val_if_fail (!gst_caps_is_any (encode_caps), NULL); g_return_val_if_fail (!gst_caps_is_empty (encode_caps), NULL); g_return_val_if_fail (gst_caps_is_fixed (encode_caps), NULL); description = gst_pb_utils_get_encoder_description (encode_caps); caps = copy_and_clean_caps (encode_caps); s = gst_structure_new ("missing-plugin", "type", G_TYPE_STRING, "encoder", "detail", GST_TYPE_CAPS, caps, "name", G_TYPE_STRING, description, NULL); gst_caps_unref (caps); g_free (description); return gst_message_new_element (GST_OBJECT_CAST (element), s); }
bool getVideoSizeAndFormatFromCaps(GstCaps* caps, WebCore::IntSize& size, GstVideoFormat& format, int& pixelAspectRatioNumerator, int& pixelAspectRatioDenominator, int& stride) { #ifdef GST_API_VERSION_1 GstVideoInfo info; if (!gst_video_info_from_caps(&info, caps)) return false; format = GST_VIDEO_INFO_FORMAT(&info); size.setWidth(GST_VIDEO_INFO_WIDTH(&info)); size.setHeight(GST_VIDEO_INFO_HEIGHT(&info)); pixelAspectRatioNumerator = GST_VIDEO_INFO_PAR_N(&info); pixelAspectRatioDenominator = GST_VIDEO_INFO_PAR_D(&info); stride = GST_VIDEO_INFO_PLANE_STRIDE(&info, 0); #else gint width, height; if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps) || !gst_video_format_parse_caps(caps, &format, &width, &height) || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator, &pixelAspectRatioDenominator)) return false; size.setWidth(width); size.setHeight(height); stride = size.width() * 4; #endif return true; }
/** * gst_codec_utils_h265_caps_set_level_tier_and_profile: * @caps: the #GstCaps to which the level, tier and profile are to be added * @profile_tier_level: Pointer to the profile_tier_level struct * @len: Length of the data available in @profile_tier_level. * * Sets the level, tier and profile in @caps if it can be determined from * @profile_tier_level. See gst_codec_utils_h265_get_level(), * gst_codec_utils_h265_get_tier() and gst_codec_utils_h265_get_profile() * for more details on the parameters. * * Returns: %TRUE if the level, tier, profile could be set, %FALSE otherwise. * * Since 1.4 */ gboolean gst_codec_utils_h265_caps_set_level_tier_and_profile (GstCaps * caps, const guint8 * profile_tier_level, guint len) { const gchar *level, *tier, *profile; g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); g_return_val_if_fail (GST_CAPS_IS_SIMPLE (caps), FALSE); g_return_val_if_fail (GST_SIMPLE_CAPS_HAS_NAME (caps, "video/x-h265"), FALSE); g_return_val_if_fail (profile_tier_level != NULL, FALSE); level = gst_codec_utils_h265_get_level (profile_tier_level, len); if (level != NULL) gst_caps_set_simple (caps, "level", G_TYPE_STRING, level, NULL); tier = gst_codec_utils_h265_get_tier (profile_tier_level, len); if (tier != NULL) gst_caps_set_simple (caps, "tier", G_TYPE_STRING, tier, NULL); profile = gst_codec_utils_h265_get_profile (profile_tier_level, len); if (profile != NULL) gst_caps_set_simple (caps, "profile", G_TYPE_STRING, profile, NULL); GST_LOG ("profile : %s", (profile) ? profile : "---"); GST_LOG ("tier : %s", (tier) ? tier : "---"); GST_LOG ("level : %s", (level) ? level : "---"); return (level != NULL && tier != NULL && profile != NULL); }
/*! * \brief OpenIMAJCapGStreamer::setFilter * \param prop the property name * \param type glib property type * \param v1 the value * \param v2 second value of property type requires it, else NULL * Filter the output formats by setting appsink caps properties */ void OpenIMAJCapGStreamer::setFilter(const char *prop, GType type, int v1, int v2) { if(!caps || !( GST_IS_CAPS (caps) )) { if(type == G_TYPE_INT) { caps = gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR", prop, type, v1, NULL); } else { caps = gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR", prop, type, v1, v2, NULL); } } else { if (! gst_caps_is_writable(caps)) caps = gst_caps_make_writable (caps); if(type == G_TYPE_INT){ gst_caps_set_simple(caps, prop, type, v1, NULL); }else{ gst_caps_set_simple(caps, prop, type, v1, v2, NULL); } } caps = gst_caps_fixate(caps); gst_app_sink_set_caps(GST_APP_SINK(sink), caps); }
// Returns the size of the video IntSize MediaPlayerPrivate::naturalSize() const { if (!hasVideo()) return IntSize(); // TODO: handle possible clean aperture data. See // https://bugzilla.gnome.org/show_bug.cgi?id=596571 // TODO: handle possible transformation matrix. See // https://bugzilla.gnome.org/show_bug.cgi?id=596326 int width = 0, height = 0; if (GstPad* pad = gst_element_get_static_pad(m_videoSink, "sink")) { GstCaps* caps = GST_PAD_CAPS(pad); gfloat pixelAspectRatio; gint pixelAspectRatioNumerator, pixelAspectRatioDenominator; if (!GST_IS_CAPS(caps) || !gst_caps_is_fixed(caps) || !gst_video_format_parse_caps(caps, NULL, &width, &height) || !gst_video_parse_caps_pixel_aspect_ratio(caps, &pixelAspectRatioNumerator, &pixelAspectRatioDenominator)) { gst_object_unref(GST_OBJECT(pad)); return IntSize(); } pixelAspectRatio = (gfloat) pixelAspectRatioNumerator / (gfloat) pixelAspectRatioDenominator; width *= pixelAspectRatio; height /= pixelAspectRatio; gst_object_unref(GST_OBJECT(pad)); } return IntSize(width, height); }
/** * gst_pb_utils_get_codec_description: * @caps: the (fixed) #GstCaps for which an format description is needed * * Returns a localised (as far as this is possible) string describing the * media format specified in @caps, for use in error dialogs or other messages * to be seen by the user. Should never return NULL unless @caps is invalid. * * Also see the convenience function * gst_pb_utils_add_codec_description_to_tag_list(). * * Returns: a newly-allocated description string, or NULL on error. Free * string with g_free() when not needed any longer. */ gchar * gst_pb_utils_get_codec_description (const GstCaps * caps) { const FormatInfo *info; gchar *str, *comma; GstCaps *tmp; g_return_val_if_fail (caps != NULL, NULL); g_return_val_if_fail (GST_IS_CAPS (caps), NULL); tmp = copy_and_clean_caps (caps); g_return_val_if_fail (gst_caps_is_fixed (tmp), NULL); info = find_format_info (tmp); if (info) { str = format_info_get_desc (info, tmp); } else { str = gst_caps_to_string (tmp); /* cut off everything after the media type, if there is anything */ if ((comma = strchr (str, ','))) { *comma = '\0'; g_strchomp (str); /* we could do something more elaborate here, like taking into account * audio/, video/, image/ and application/ prefixes etc. */ } GST_WARNING ("No description available for media type: %s", str); } gst_caps_unref (tmp); return str; }
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; }
/** * gst_encoding_container_profile_new: * @name: (allow-none): The name of the container profile, can be %NULL * @description: (allow-none): The description of the container profile, * can be %NULL * @format: The format to use for this profile * @preset: (allow-none): The preset to use for this profile. * * Creates a new #GstEncodingContainerProfile. * * Returns: The newly created #GstEncodingContainerProfile. */ GstEncodingContainerProfile * gst_encoding_container_profile_new (const gchar * name, const gchar * description, GstCaps * format, const gchar * preset) { g_return_val_if_fail (GST_IS_CAPS (format), NULL); return (GstEncodingContainerProfile *) common_creation (GST_TYPE_ENCODING_CONTAINER_PROFILE, format, preset, name, description, NULL, 0); }
gboolean gst_vdp_caps_to_rgba_format (GstCaps * caps, VdpRGBAFormat * rgba_format) { GstStructure *structure; gint c_bpp, c_depth, c_endianness, c_red_mask, c_green_mask, c_blue_mask, c_alpha_mask; gint i; g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); if (!gst_caps_is_fixed (caps)) return FALSE; structure = gst_caps_get_structure (caps, 0); if (!gst_structure_has_name (structure, "video/x-raw-rgb")) return FALSE; if (!gst_structure_get_int (structure, "bpp", &c_bpp) || !gst_structure_get_int (structure, "depth", &c_depth) || !gst_structure_get_int (structure, "endianness", &c_endianness) || !gst_structure_get_int (structure, "red_mask", &c_red_mask) || !gst_structure_get_int (structure, "green_mask", &c_green_mask) || !gst_structure_get_int (structure, "blue_mask", &c_blue_mask) || !gst_structure_get_int (structure, "alpha_mask", &c_alpha_mask)) return FALSE; for (i = 0; i < G_N_ELEMENTS (rgba_formats); i++) { gint bpp, depth, endianness, red_mask, green_mask, blue_mask, alpha_mask; GstCaps *rgb_caps = gst_static_caps_get (&rgba_formats[i].caps); structure = gst_caps_get_structure (rgb_caps, 0); gst_structure_get_int (structure, "bpp", &bpp); gst_structure_get_int (structure, "depth", &depth); gst_structure_get_int (structure, "endianness", &endianness); gst_structure_get_int (structure, "red_mask", &red_mask); gst_structure_get_int (structure, "green_mask", &green_mask); gst_structure_get_int (structure, "blue_mask", &blue_mask); gst_structure_get_int (structure, "alpha_mask", &alpha_mask); if (c_bpp == bpp && c_depth == depth && c_endianness == endianness && c_red_mask == red_mask && c_green_mask == green_mask && c_blue_mask == blue_mask && c_alpha_mask == alpha_mask) { gst_caps_unref (rgb_caps); *rgba_format = rgba_formats[i].format; return TRUE; } gst_caps_unref (rgb_caps); } return FALSE; }
/* Create new stream from params in caps */ static GstSrtpDecSsrcStream * update_session_stream_from_caps (GstSrtpDec * filter, guint32 ssrc, GstCaps * caps) { GstSrtpDecSsrcStream *stream = NULL; GstSrtpDecSsrcStream *old_stream = NULL; err_status_t err; g_return_val_if_fail (GST_IS_SRTP_DEC (filter), NULL); g_return_val_if_fail (GST_IS_CAPS (caps), NULL); stream = get_stream_from_caps (filter, caps, ssrc); old_stream = find_stream_by_ssrc (filter, ssrc); if (stream && old_stream && stream->rtp_cipher == old_stream->rtp_cipher && stream->rtcp_cipher == old_stream->rtcp_cipher && stream->rtp_auth == old_stream->rtp_auth && stream->rtcp_auth == old_stream->rtcp_auth && stream->key && old_stream->key && gst_buffer_get_size (stream->key) == gst_buffer_get_size (old_stream->key)) { GstMapInfo info; if (gst_buffer_map (old_stream->key, &info, GST_MAP_READ)) { gboolean equal; equal = (gst_buffer_memcmp (stream->key, 0, info.data, info.size) == 0); gst_buffer_unmap (old_stream->key, &info); if (equal) { free_stream (stream); return old_stream; } } } /* Remove existing stream, if any */ gst_srtp_dec_remove_stream (filter, ssrc); if (stream) { /* Create new session stream */ err = init_session_stream (filter, ssrc, stream); if (err != err_status_ok) { if (stream->key) gst_buffer_unref (stream->key); g_slice_free (GstSrtpDecSsrcStream, stream); stream = NULL; } } return stream; }
/** * gst_encoding_profile_set_restriction: * @profile: a #GstEncodingProfile * @restriction: (transfer full): the restriction to apply * * Set the restriction #GstCaps to apply before the encoder * that will be used in the profile. See gst_encoding_profile_get_restriction() * for more about restrictions. Does not apply to #GstEncodingContainerProfile. */ void gst_encoding_profile_set_restriction (GstEncodingProfile * profile, GstCaps * restriction) { g_return_if_fail (GST_IS_CAPS (restriction)); g_return_if_fail (GST_IS_ENCODING_PROFILE (profile)); if (profile->restriction) gst_caps_unref (profile->restriction); profile->restriction = restriction; g_object_notify_by_pspec (G_OBJECT (profile), _properties[PROP_RESTRICTION_CAPS]); }
/* * Boilerplates BaseSrc add pad. */ void gst_my_base_source_class_add_pad_template (GstBaseSrcClass * base_class, GstCaps * srccaps) { GstElementClass *elem_class = GST_ELEMENT_CLASS (base_class); GstPadTemplate *pad_template; g_return_if_fail (GST_IS_CAPS (srccaps)); pad_template = gst_pad_template_new (GST_BASE_TRANSFORM_SRC_NAME, GST_PAD_SRC, GST_PAD_ALWAYS, srccaps); gst_element_class_add_pad_template (elem_class, pad_template); }
void gst_raw_parse_class_set_src_pad_template (GstRawParseClass * klass, const GstCaps * allowed_caps) { GstElementClass *element_class = GST_ELEMENT_CLASS (klass); g_return_if_fail (GST_IS_RAW_PARSE_CLASS (klass)); g_return_if_fail (allowed_caps != NULL); g_return_if_fail (GST_IS_CAPS (allowed_caps)); gst_element_class_add_pad_template (element_class, gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, gst_caps_copy (allowed_caps))); }
static void on_caps(GstElement *sink, GParamSpec *pspec, OwrMediaRenderer *media_renderer) { GstCaps *caps; OWR_UNUSED(pspec); g_object_get(sink, "caps", &caps, NULL); if (GST_IS_CAPS(caps)) { GST_INFO_OBJECT(media_renderer, "%s renderer - configured with caps: %" GST_PTR_FORMAT, media_renderer->priv->media_type == OWR_MEDIA_TYPE_AUDIO ? "Audio" : media_renderer->priv->media_type == OWR_MEDIA_TYPE_VIDEO ? "Video" : "Unknown", caps); } }
static void on_caps(GstElement *source, GParamSpec *pspec, OwrMediaSource *media_source) { gchar *media_source_name; GstCaps *caps; OWR_UNUSED(pspec); g_object_get(source, "caps", &caps, NULL); g_object_get(media_source, "name", &media_source_name, NULL); if (GST_IS_CAPS(caps)) { GST_INFO_OBJECT(source, "%s - configured with caps: %" GST_PTR_FORMAT, media_source_name, caps); } }
gboolean gtk_gst_widget_set_caps (GtkGstWidget * widget, GstCaps * caps) { GMainContext *main_context = g_main_context_default (); GstVideoInfo v_info; g_return_val_if_fail (GTK_IS_GST_WIDGET (widget), FALSE); g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); g_return_val_if_fail (gst_caps_is_fixed (caps), FALSE); if (widget->priv->caps && gst_caps_is_equal_fixed (widget->priv->caps, caps)) return TRUE; if (!gst_video_info_from_caps (&v_info, caps)) return FALSE; /* FIXME: support other formats */ #if G_BYTE_ORDER == G_LITTLE_ENDIAN g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_BGRA || GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_BGRx, FALSE); #else g_return_val_if_fail (GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_ARGB || GST_VIDEO_INFO_FORMAT (&v_info) == GST_VIDEO_FORMAT_xRGB, FALSE); #endif g_mutex_lock (&widget->priv->lock); if (!_calculate_par (widget, &v_info)) { g_mutex_unlock (&widget->priv->lock); return FALSE; } gst_caps_replace (&widget->priv->caps, caps); widget->priv->v_info = v_info; widget->priv->negotiated = TRUE; g_mutex_unlock (&widget->priv->lock); gtk_widget_queue_resize (GTK_WIDGET (widget)); g_main_context_invoke (main_context, (GSourceFunc) _queue_resize, widget); return TRUE; }
const gchar * pb_utils_get_file_extension_from_caps (const GstCaps * caps) { const FormatInfo *info; const gchar *ext = NULL; GstCaps *stripped_caps; g_assert (GST_IS_CAPS (caps)); stripped_caps = copy_and_clean_caps (caps); g_assert (gst_caps_is_fixed (stripped_caps)); info = find_format_info (stripped_caps); if (info && info->ext[0] != '\0') { ext = info->ext; } else if (info && info->desc == NULL) { const GstStructure *s; s = gst_caps_get_structure (stripped_caps, 0); /* cases where we have to evaluate the caps more closely */ if (strcmp (info->type, "audio/mpeg") == 0) { int version = 0, layer = 3; if (gst_structure_get_int (s, "mpegversion", &version)) { if (version == 2 || version == 4) { ext = "aac"; } else if (version == 1) { gst_structure_get_int (s, "layer", &layer); if (layer == 1) ext = "mp1"; else if (layer == 2) ext = "mp2"; else ext = "mp3"; } } } } gst_caps_unref (stripped_caps); return ext; }
extern void gstreamer_get_video_dimensions(int *widthp, int *heightp) { const char *format = NULL; *widthp = 0; *heightp = 0; int framerate_numerator = 0; int framerate_denom = 0; int pixel_aspect_ratio_num = 0; int pixel_aspect_ratio_denom = 0; GList *list = g_list_first(created_pads_list); while (list != NULL) { GstPad *pad = list->data; GstCaps *caps = gst_pad_get_current_caps(pad); if (GST_IS_CAPS(caps)) read_video_props(caps, &format, widthp, heightp, &framerate_numerator, &framerate_denom, &pixel_aspect_ratio_num, &pixel_aspect_ratio_denom); list = g_list_next(list); } }
/** * ges_track_set_caps: * @track: a #GESTrack * @caps: the #GstCaps to set * * Sets the given @caps on the track. */ void ges_track_set_caps (GESTrack * track, const GstCaps * caps) { GESTrackPrivate *priv; g_return_if_fail (GES_IS_TRACK (track)); g_return_if_fail (GST_IS_CAPS (caps)); GST_DEBUG ("track:%p, caps:%" GST_PTR_FORMAT, track, caps); priv = track->priv; if (priv->caps) gst_caps_unref (priv->caps); priv->caps = gst_caps_copy (caps); g_object_set (priv->composition, "caps", caps, NULL); /* FIXME : update all trackobjects ? */ }
/*! * \brief CvCapture_GStreamer::setFilter * \param prop the property name * \param type glib property type * \param v1 the value * \param v2 second value of property type requires it, else NULL * Filter the output formats by setting appsink caps properties */ void CvCapture_GStreamer::setFilter(const char *prop, int type, int v1, int v2) { //printf("GStreamer: setFilter \n"); if(!caps || !( GST_IS_CAPS (caps) )) { if(type == G_TYPE_INT) { #if GST_VERSION_MAJOR == 0 caps = gst_caps_new_simple("video/x-raw-rgb", prop, type, v1, NULL); #else caps = gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR", prop, type, v1, NULL); #endif } else { #if GST_VERSION_MAJOR == 0 caps = gst_caps_new_simple("video/x-raw-rgb", prop, type, v1, v2, NULL); #else caps = gst_caps_new_simple("video/x-raw","format",G_TYPE_STRING,"BGR", prop, type, v1, v2, NULL); #endif } } else { #if GST_VERSION_MAJOR > 0 if (! gst_caps_is_writable(caps)) caps = gst_caps_make_writable (caps); #endif if(type == G_TYPE_INT){ gst_caps_set_simple(caps, prop, type, v1, NULL); }else{ gst_caps_set_simple(caps, prop, type, v1, v2, NULL); } } #if GST_VERSION_MAJOR > 0 caps = gst_caps_fixate(caps); #endif gst_app_sink_set_caps(GST_APP_SINK(sink), caps); //printf("filtering with %s\n", gst_caps_to_string(caps)); }
/** * gst_vaapi_decoder_vc1_new: * @display: a #GstVaapiDisplay * @caps: a #GstCaps holding codec information * * Creates a new #GstVaapiDecoder for VC-1 decoding. The @caps can * hold extra information like codec-data and pictured coded size. * * Return value: the newly allocated #GstVaapiDecoder object */ GstVaapiDecoder * gst_vaapi_decoder_vc1_new(GstVaapiDisplay *display, GstCaps *caps) { GstVaapiDecoderVC1 *decoder; g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL); g_return_val_if_fail(GST_IS_CAPS(caps), NULL); decoder = g_object_new( GST_VAAPI_TYPE_DECODER_VC1, "display", display, "caps", caps, NULL ); if (!decoder->priv->is_constructed) { g_object_unref(decoder); return NULL; } return GST_VAAPI_DECODER_CAST(decoder); }
/** * gst_vaapi_decoder_ffmpeg_new: * @display: a #GstVaapiDisplay * @caps: a #GstCaps holding codec information * * Creates a new #GstVaapiDecoder based on FFmpeg where the codec is * determined from @caps. The @caps can hold extra information like * codec-data and pictured coded size. * * Return value: the newly allocated #GstVaapiDecoder object */ GstVaapiDecoder * gst_vaapi_decoder_ffmpeg_new(GstVaapiDisplay *display, GstCaps *caps) { GstVaapiDecoderFfmpeg *ffdecoder; g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL); g_return_val_if_fail(GST_IS_CAPS(caps), NULL); ffdecoder = g_object_new( GST_VAAPI_TYPE_DECODER_FFMPEG, "display", display, "caps", caps, NULL ); if (!ffdecoder->priv->is_constructed) { g_object_unref(ffdecoder); return NULL; } return GST_VAAPI_DECODER_CAST(ffdecoder); }
extern void gstreamer_get_video_info(const char **formatp, int *widthp, int *heightp, int *framerate_numeratorp, int *framerate_denomp, int *pixel_aspect_ratio_nump, int *pixel_aspect_ratio_denomp) { *formatp = NULL; *widthp = 0; *heightp = 0; *framerate_numeratorp = 0; *framerate_denomp = 0; *pixel_aspect_ratio_nump = 0; *pixel_aspect_ratio_denomp = 0; GList *list = g_list_first(created_pads_list); while (list != NULL) { GstPad *pad = list->data; GstCaps *caps = gst_pad_get_current_caps(pad); if (GST_IS_CAPS(caps)) read_video_props(caps, formatp, widthp, heightp, framerate_numeratorp, framerate_denomp, pixel_aspect_ratio_nump, pixel_aspect_ratio_denomp); list = g_list_next(list); } }
/** * gst_missing_encoder_installer_detail_new: * @encode_caps: the (fixed) caps for which an encoder element is needed * * Returns an opaque string containing all the details about the missing * element to be passed to an external installer called via * gst_install_plugins_async() or gst_install_plugins_sync(). * * This function is mainly for applications that call external plugin * installation mechanisms using one of the two above-mentioned functions in * the case where the application knows exactly what kind of plugin it is * missing. * * Returns: a newly-allocated detail string, or NULL on error. Free string * with g_free() when not needed any longer. * * Since: 0.10.15 */ gchar * gst_missing_encoder_installer_detail_new (const GstCaps * encode_caps) { GstCaps *caps; gchar *detail_str, *caps_str, *desc; g_return_val_if_fail (encode_caps != NULL, NULL); g_return_val_if_fail (GST_IS_CAPS (encode_caps), NULL); g_return_val_if_fail (!gst_caps_is_any (encode_caps), NULL); g_return_val_if_fail (!gst_caps_is_empty (encode_caps), NULL); g_return_val_if_fail (gst_caps_is_fixed (encode_caps), NULL); desc = gst_pb_utils_get_encoder_description (encode_caps); caps = copy_and_clean_caps (encode_caps); caps_str = gst_caps_to_string (caps); detail_str = gst_installer_detail_new (desc, "encoder", caps_str); g_free (caps_str); gst_caps_unref (caps); return detail_str; }
gboolean pb_utils_is_tag (const GstCaps * caps) { const FormatInfo *info; GstCaps *stripped_caps; gboolean is_tag = FALSE; g_assert (GST_IS_CAPS (caps)); stripped_caps = copy_and_clean_caps (caps); g_assert (gst_caps_is_fixed (stripped_caps)); info = find_format_info (stripped_caps); if (info) { is_tag = (info->flags & FLAG_TAG) != 0; } gst_caps_unref (stripped_caps); return is_tag; }
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; }
/** * gst_pb_utils_add_codec_description_to_tag_list: * @taglist: a #GstTagList * @codec_tag: (allow-none): a GStreamer codec tag such as #GST_TAG_AUDIO_CODEC, * #GST_TAG_VIDEO_CODEC or #GST_TAG_CODEC. If none is specified, * the function will attempt to detect the appropriate category. * @caps: the (fixed) #GstCaps for which a codec tag should be added. * * Adds a codec tag describing the format specified by @caps to @taglist. * * Returns: TRUE if a codec tag was added, FALSE otherwise. */ gboolean gst_pb_utils_add_codec_description_to_tag_list (GstTagList * taglist, const gchar * codec_tag, const GstCaps * caps) { const FormatInfo *info; gchar *desc; g_return_val_if_fail (taglist != NULL, FALSE); g_return_val_if_fail (GST_IS_TAG_LIST (taglist), FALSE); g_return_val_if_fail (codec_tag == NULL || (gst_tag_exists (codec_tag) && gst_tag_get_type (codec_tag) == G_TYPE_STRING), FALSE); g_return_val_if_fail (caps != NULL, FALSE); g_return_val_if_fail (GST_IS_CAPS (caps), FALSE); info = find_format_info (caps); if (info == NULL) return FALSE; /* Attempt to find tag classification */ if (codec_tag == NULL) { if (info->flags & FLAG_CONTAINER) codec_tag = GST_TAG_CONTAINER_FORMAT; else if (info->flags & FLAG_AUDIO) codec_tag = GST_TAG_AUDIO_CODEC; else if (info->flags & FLAG_VIDEO) codec_tag = GST_TAG_VIDEO_CODEC; else if (info->flags & FLAG_SUB) codec_tag = GST_TAG_SUBTITLE_CODEC; else codec_tag = GST_TAG_CODEC; } desc = format_info_get_desc (info, caps); gst_tag_list_add (taglist, GST_TAG_MERGE_REPLACE, codec_tag, desc, NULL); g_free (desc); return TRUE; }