From c95476e06cc20c694366ae4d27bd7cab4f4a6cf8 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Tue, 9 Dec 2003 10:48:12 +0000 Subject: Convert to new caps Original commit message from CVS: Convert to new caps --- gst-libs/gst/audio/audio.c | 37 ++++++++++------- gst-libs/gst/audio/audio.h | 9 ++-- gst-libs/gst/media-info/media-info-priv.c | 21 +++++----- gst-libs/gst/media-info/media-info-priv.h | 8 ++-- gst-libs/gst/media-info/media-info-test.c | 56 ++----------------------- gst-libs/gst/media-info/media-info.c | 6 ++- gst-libs/gst/media-info/media-info.h | 14 +++---- gst-libs/gst/play/play.old.c | 68 +++++++++++++++---------------- gst-libs/gst/video/video.c | 33 ++++++++------- gst-libs/gst/video/video.h | 31 +++++++------- 10 files changed, 117 insertions(+), 166 deletions(-) diff --git a/gst-libs/gst/audio/audio.c b/gst-libs/gst/audio/audio.c index 3a723b891..3ae47b1e2 100644 --- a/gst-libs/gst/audio/audio.c +++ b/gst-libs/gst/audio/audio.c @@ -35,22 +35,23 @@ gst_audio_frame_byte_size (GstPad* pad) int width = 0; int channels = 0; - - GstCaps *caps = NULL; + GstCaps2 *caps; + GstStructure *structure; /* get caps of pad */ caps = GST_PAD_CAPS (pad); - if (caps == NULL) - { + if (caps == NULL) { /* ERROR: could not get caps of pad */ g_warning ("gstaudio: could not get caps of pad %s:%s\n", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); return 0; } - gst_caps_get_int (caps, "width", &width); - gst_caps_get_int (caps, "channels", &channels); + structure = gst_caps2_get_nth_cap (caps, 0); + + gst_structure_get_int (structure, "width", &width); + gst_structure_get_int (structure, "channels", &channels); return (width / 8) * channels; } @@ -81,8 +82,9 @@ gst_audio_frame_rate (GstPad *pad) * returns 0 if failed, rate if success */ { - GstCaps *caps = NULL; + GstCaps2 *caps = NULL; gint rate; + GstStructure *structure; /* get caps of pad */ caps = GST_PAD_CAPS (pad); @@ -94,7 +96,8 @@ gst_audio_frame_rate (GstPad *pad) return 0; } else { - gst_caps_get_int (caps, "rate", &rate); + structure = gst_caps2_get_nth_cap (caps, 0); + gst_structure_get_int (structure, "rate", &rate); return rate; } } @@ -114,7 +117,8 @@ gst_audio_length (GstPad* pad, GstBuffer* buf) double length; - GstCaps *caps = NULL; + GstCaps2 *caps = NULL; + GstStructure *structure; g_assert (GST_IS_BUFFER (buf)); /* get caps of pad */ @@ -128,10 +132,11 @@ gst_audio_length (GstPad* pad, GstBuffer* buf) } else { + structure = gst_caps2_get_nth_cap (caps, 0); bytes = GST_BUFFER_SIZE (buf); - gst_caps_get_int (caps, "width", &width); - gst_caps_get_int (caps, "channels", &channels); - gst_caps_get_int (caps, "rate", &rate); + gst_structure_get_int (structure, "width", &width); + gst_structure_get_int (structure, "channels", &channels); + gst_structure_get_int (structure, "rate", &rate); g_assert (bytes != 0); g_assert (width != 0); @@ -151,7 +156,8 @@ gst_audio_highest_sample_value (GstPad* pad) { gboolean is_signed = FALSE; gint width = 0; - GstCaps *caps = NULL; + GstCaps2 *caps = NULL; + GstStructure *structure; caps = GST_PAD_CAPS (pad); if (caps == NULL) @@ -160,8 +166,9 @@ gst_audio_highest_sample_value (GstPad* pad) GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); } - gst_caps_get_int (caps, "width", &width); - gst_caps_get_boolean (caps, "signed", &is_signed); + structure = gst_caps2_get_nth_cap (caps, 0); + gst_structure_get_int (structure, "width", &width); + gst_structure_get_boolean (structure, "signed", &is_signed); if (is_signed) --width; /* example : 16 bit, signed : samples between -32768 and 32767 */ diff --git a/gst-libs/gst/audio/audio.h b/gst-libs/gst/audio/audio.h index b87f22d57..1c7828c46 100644 --- a/gst-libs/gst/audio/audio.h +++ b/gst-libs/gst/audio/audio.h @@ -52,14 +52,13 @@ G_BEGIN_DECLS #define GST_AUDIO_INT_PAD_TEMPLATE_CAPS \ "audio/x-raw-int, " \ - "rate = (int) [ 1, " G_STRINGIFY(G_MAXINT) ", " \ - "channels = (int) [ 1, " G_STRINGIFY(G_MAXINT) ", " \ - "endianness = (int) { " G_STRINGIFY(G_LITTLE_ENDIAN) ", " \ - G_STRINGIFY(G_BIG_ENDIAN) "}, " \ + "rate = (int) [ 1, MAX ], " \ + "channels = (int) [ 1, MAX ], " \ + "endianness = (int) { LITTLE_ENDIAN, BIG_ENDIAN }, " \ "width = (int) { 8, 16, 32 }, " \ "depth = (int) [ 1, 32 ], " \ "signed = (boolean) { true, false }, " \ - "buffer-frames = (int) [ 1, " G_STRINGIFY(G_MAXINT) "]" + "buffer-frames = (int) [ 1, MAX ]" /* "standard" int audio is native order, 16 bit stereo. */ diff --git a/gst-libs/gst/media-info/media-info-priv.c b/gst-libs/gst/media-info/media-info-priv.c index 77981598d..b613ab86c 100644 --- a/gst-libs/gst/media-info/media-info-priv.c +++ b/gst-libs/gst/media-info/media-info-priv.c @@ -78,7 +78,7 @@ gmi_track_new (void) /* callbacks */ static void -have_type_callback (GstElement *typefind, GstCaps *type, GstMediaInfoPriv *priv) +have_type_callback (GstElement *typefind, GstCaps2 *type, GstMediaInfoPriv *priv) { priv->type = type; } @@ -136,13 +136,13 @@ gmi_reset (GstMediaInfo *info) if (priv->format) { GMI_DEBUG ("unreffing priv->format, error before this ?\n"); - gst_caps_unref (priv->format); + gst_caps2_free (priv->format); priv->format = NULL; } if (priv->metadata) { GMI_DEBUG ("unreffing priv->metadata, error before this ?\n"); - gst_caps_unref (priv->metadata); + gst_caps2_free (priv->metadata); priv->metadata = NULL; } if (priv->stream) @@ -193,12 +193,12 @@ gmi_seek_to_track (GstMediaInfo *info, long track) /* clear structs because of the seek */ if (priv->metadata) { - gst_caps_unref (priv->metadata); + gst_caps2_free (priv->metadata); priv->metadata = NULL; } if (priv->streaminfo) { - gst_caps_unref (priv->streaminfo); + gst_caps2_free (priv->streaminfo); priv->streaminfo = NULL; } return TRUE; @@ -293,7 +293,7 @@ gmi_clear_decoder (GstMediaInfo *info) /**** * typefind functions * find the type of a file and store it in the caps of the info - * FIXME: we might better return GstCaps instead of storing them + * FIXME: we might better return GstCaps2 instead of storing them * internally */ /* prepare for typefind, move from NULL to TYPEFIND */ @@ -304,7 +304,7 @@ gmip_find_type_pre (GstMediaInfoPriv *priv) if (priv->type) { /* we don't need to unref, this is done inside gsttypefind.c - gst_caps_unref (priv->type); + gst_caps2_free (priv->type); */ priv->type = NULL; } @@ -573,14 +573,13 @@ gmip_find_track_streaminfo_post (GstMediaInfoPriv *priv) &format, &value_end); if (res) { - GstPropsEntry *length; /* substract to get the length */ GMI_DEBUG("DEBUG: start %lld, end %lld\n", value_start, value_end); value_end -= value_start; /* FIXME: check units; this is in seconds */ - length = gst_props_entry_new ("length", - GST_PROPS_INT ((int) (value_end / 1E6))); - gst_props_add_entry (gst_caps_get_props (priv->streaminfo), length); + + gst_caps2_set_simple (priv->streaminfo, + "length", G_TYPE_INT, (int) (value_end / 1E6), NULL); } } } diff --git a/gst-libs/gst/media-info/media-info-priv.h b/gst-libs/gst/media-info/media-info-priv.h index 0a7aa5009..24da73332 100644 --- a/gst-libs/gst/media-info/media-info-priv.h +++ b/gst-libs/gst/media-info/media-info-priv.h @@ -64,14 +64,14 @@ struct GstMediaInfoPriv GstElement *typefind; - GstCaps *type; + GstCaps2 *type; GstPad *decoder_pad; /* pad for querying decoded caps */ GstPad *source_pad; /* pad for querying encoded caps */ - GstCaps *format; - GstCaps *metadata; + GstCaps2 *format; + GstCaps2 *metadata; gint metadata_iters; - GstCaps *streaminfo; + GstCaps2 *streaminfo; GstElement *decoder; /* will be != NULL during collection */ gchar *source_element; /* type of element used as source */ diff --git a/gst-libs/gst/media-info/media-info-test.c b/gst-libs/gst/media-info/media-info-test.c index 553e97c61..8e0c1f72e 100644 --- a/gst-libs/gst/media-info/media-info-test.c +++ b/gst-libs/gst/media-info/media-info-test.c @@ -4,56 +4,6 @@ #include #include "media-info.h" -static void -caps_print (GstCaps *caps) -{ - if (caps == NULL) return; - /* - if (!strcmp (gst_caps_get_mime (caps), "application/x-gst-metadata") || - !strcmp (gst_caps_get_mime (caps), "application/x-gst-streaminfo")) - */ - if (TRUE) - { - GstProps *props = caps->properties; - GList *walk; - - if (props == NULL) - { - g_print (" none\n"); - return; - } - walk = props->properties; - - while (walk) { - GstPropsEntry *entry = (GstPropsEntry *) walk->data; - const gchar *name; - const gchar *str_val; - gint int_val; - GstPropsType type; - - name = gst_props_entry_get_name (entry); - type = gst_props_entry_get_props_type (entry); - switch (type) { - case GST_PROPS_STRING_TYPE: - gst_props_entry_get_string (entry, &str_val); - g_print (" %s='%s'\n", name, str_val); - break; - case GST_PROPS_INT_TYPE: - gst_props_entry_get_int (entry, &int_val); - g_print (" %s=%d\n", name, int_val); - break; - default: - break; - } - - walk = g_list_next (walk); - } - } - else { - g_print (" unkown caps type\n"); - } -} - static void info_print (GstMediaInfoStream *stream) { @@ -77,11 +27,11 @@ info_print (GstMediaInfoStream *stream) g_print ("- track %d\n", i); track = (GstMediaInfoTrack *) p->data; g_print (" - metadata:\n"); - caps_print (track->metadata); + g_print ("%s\n", gst_caps2_to_string (track->metadata)); g_print (" - streaminfo:\n"); - caps_print (track->streaminfo); + g_print ("%s\n", gst_caps2_to_string (track->streaminfo)); g_print (" - format:\n"); - caps_print (track->format); + g_print ("%s\n", gst_caps2_to_string (track->format)); p = p->next; } } diff --git a/gst-libs/gst/media-info/media-info.c b/gst-libs/gst/media-info/media-info.c index 92957e16a..d22bdbb46 100644 --- a/gst-libs/gst/media-info/media-info.c +++ b/gst-libs/gst/media-info/media-info.c @@ -294,7 +294,8 @@ gst_media_info_read_idler (GstMediaInfo *info, GstMediaInfoStream **streamp) GMI_DEBUG("doing find_type_post\n"); gmip_find_type_post (priv); GMI_DEBUG("finding out mime type\n"); - mime = g_strdup (gst_caps_get_mime (priv->type)); + mime = g_strdup (gst_structure_get_name ( + gst_caps2_get_nth_cap(priv->type, 0))); GMI_DEBUG("found out mime type: %s\n", mime); decoder = gmi_get_decoder (info, mime); if (decoder == NULL) @@ -443,7 +444,8 @@ gst_media_info_read (GstMediaInfo *info, const char *location, guint16 flags) if (!gmip_find_type (priv)) return NULL; - mime = g_strdup (gst_caps_get_mime (priv->type)); + mime = g_strdup (gst_structure_get_name ( + gst_caps2_get_nth_cap(priv->type, 0))); GMI_DEBUG("mime type: %s\n", mime); /* c) figure out decoder */ diff --git a/gst-libs/gst/media-info/media-info.h b/gst-libs/gst/media-info/media-info.h index a718b626d..4ff628198 100644 --- a/gst-libs/gst/media-info/media-info.h +++ b/gst-libs/gst/media-info/media-info.h @@ -55,7 +55,7 @@ typedef struct gboolean seekable; gchar *mime; gchar *path; - GstCaps *caps; /* properties of the complete bitstream */ + GstCaps2 *caps; /* properties of the complete bitstream */ guint64 length_time; glong length_tracks; @@ -68,9 +68,9 @@ typedef struct * or one of a set of sequentially muxed streams */ typedef struct { - GstCaps *metadata; /* changeable metadata or tags */ - GstCaps *streaminfo; /* codec property stuff */ - GstCaps *format; /* properties of the logical stream */ + GstCaps2 *metadata; /* changeable metadata or tags */ + GstCaps2 *streaminfo; /* codec property stuff */ + GstCaps2 *format; /* properties of the logical stream */ guint64 length_time; @@ -80,7 +80,7 @@ typedef struct typedef struct { - GstCaps *caps; /* properties of the muxed concurrent stream */ + GstCaps2 *caps; /* properties of the muxed concurrent stream */ } GstMediaInfoConcurrent; #define GST_MEDIA_INFO_ERROR gst_media_info_error_quark () @@ -116,13 +116,13 @@ gboolean gst_media_info_read_many (GstMediaInfo *media_info, GList *locations, guint16 GST_MEDIA_INFO_FLAGS, GError **error); -GstCaps * gst_media_info_get_next (GstMediaInfo *media_info, +GstCaps2 * gst_media_info_get_next (GstMediaInfo *media_info, GError **error); /* * FIXME: reset ? gboolean gst_media_info_write (GstMediaInfo *media_info, const char *location, - GstCaps *media_info); + GstCaps2 *media_info); */ G_END_DECLS diff --git a/gst-libs/gst/play/play.old.c b/gst-libs/gst/play/play.old.c index 64963661a..dd787001b 100644 --- a/gst-libs/gst/play/play.old.c +++ b/gst-libs/gst/play/play.old.c @@ -26,6 +26,7 @@ #include "config.h" #endif +#include #include "play.h" enum @@ -906,43 +907,38 @@ gst_play_get_sink_element (GstPlay * play, else { /* If not a src pad checking caps */ - GstCaps *caps; - caps = gst_pad_get_caps (GST_PAD (pads->data)); - while (caps) + gboolean has_video_cap = FALSE, has_audio_cap = FALSE; + const char *media_type; + + media_type = gst_structure_get_name (gst_caps2_get_nth_cap ( + gst_pad_get_caps (GST_PAD (pads->data)), 0)); + if (strcmp (media_type, "audio/x-raw-int") == 0) + { + has_audio_cap = TRUE; + } + if ((strcmp (media_type, "video/x-raw-yuv") == 0) || + (strcmp (media_type, "video/x-raw-rgb") == 0)) + + { + has_video_cap = TRUE; + } + + switch (sink_type) { - gboolean has_video_cap = FALSE, has_audio_cap = FALSE; - if (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "audio/x-raw-int") == 0) - { - has_audio_cap = TRUE; - } - if ((g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-yuv") == 0) || - (g_ascii_strcasecmp (gst_caps_get_mime (caps), - "video/x-raw-rgb") == 0)) - - { - has_video_cap = TRUE; - } - - switch (sink_type) - { - case GST_PLAY_SINK_TYPE_AUDIO: - if (has_audio_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_VIDEO: - if (has_video_cap) - has_correct_type = TRUE; - break;; - case GST_PLAY_SINK_TYPE_ANY: - if ((has_video_cap) || (has_audio_cap)) - has_correct_type = TRUE; - break;; - default: - has_correct_type = FALSE; - } - caps = caps->next; + case GST_PLAY_SINK_TYPE_AUDIO: + if (has_audio_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_VIDEO: + if (has_video_cap) + has_correct_type = TRUE; + break;; + case GST_PLAY_SINK_TYPE_ANY: + if ((has_video_cap) || (has_audio_cap)) + has_correct_type = TRUE; + break;; + default: + has_correct_type = FALSE; } } pads = g_list_next (pads); diff --git a/gst-libs/gst/video/video.c b/gst-libs/gst/video/video.c index 0d4a2ea62..abcf9bc65 100644 --- a/gst-libs/gst/video/video.c +++ b/gst-libs/gst/video/video.c @@ -26,11 +26,12 @@ /* This is simply a convenience function, nothing more or less */ -gfloat +gdouble gst_video_frame_rate (GstPad *pad) { - gfloat fps = 0.; - GstCaps *caps; + gdouble fps = 0.; + GstCaps2 *caps; + GstStructure *structure; /* get pad caps */ caps = GST_PAD_CAPS (pad); @@ -41,16 +42,14 @@ gst_video_frame_rate (GstPad *pad) return 0.; } - if (!gst_caps_has_property_typed (caps, "framerate", - GST_PROPS_FLOAT_TYPE)) { + structure = gst_caps2_get_nth_cap (caps, 0); + if (!gst_structure_get_double (structure, "framerate", &fps)){ g_warning ("gstvideo: failed to get framerate property of pad %s:%s", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad)); return 0.; } - gst_caps_get_float (caps, "framerate", &fps); - GST_DEBUG ("Framerate request on pad %s:%s: %f", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME(pad), fps); @@ -63,9 +62,13 @@ gst_video_get_size (GstPad *pad, gint *width, gint *height) { - GstCaps *caps; + GstCaps2 *caps; + GstStructure *structure; + gboolean ret; g_return_val_if_fail (pad != NULL, FALSE); + g_return_val_if_fail (width != NULL, FALSE); + g_return_val_if_fail (height != NULL, FALSE); caps = GST_PAD_CAPS (pad); @@ -76,21 +79,17 @@ gst_video_get_size (GstPad *pad, return FALSE; } - if (!gst_caps_has_property_typed (caps, "width", - GST_PROPS_INT_TYPE) || - !gst_caps_has_property_typed (caps, "height", - GST_PROPS_FLOAT_TYPE)) { + structure = gst_caps2_get_nth_cap (caps, 0); + ret = gst_structure_get_int (structure, "width", width); + ret &= gst_structure_get_int (structure, "height", height); + + if (!ret) { g_warning ("gstvideo: failed to get size properties on pad %s:%s", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME(pad)); return FALSE; } - if (width) - gst_caps_get_int (caps, "width", width); - if (height) - gst_caps_get_int (caps, "height", height); - GST_DEBUG ("size request on pad %s:%s: %dx%d", GST_ELEMENT_NAME (gst_pad_get_parent (pad)), GST_PAD_NAME (pad), diff --git a/gst-libs/gst/video/video.h b/gst-libs/gst/video/video.h index 236002d9d..213494818 100644 --- a/gst-libs/gst/video/video.h +++ b/gst-libs/gst/video/video.h @@ -39,9 +39,9 @@ #define G_MASK_24_REVERSE 0x00ff00 #define B_MASK_24_REVERSE 0xff0000 -#define R_MASK_16 0xf800 -#define G_MASK_16 0x07e0 -#define B_MASK_16 0x001f +#define R_MASK_16 "0xf800" +#define G_MASK_16 "0x07e0" +#define B_MASK_16 "0x001f" #define R_MASK_15 0x8c00 #define G_MASK_15 0x03e0 @@ -183,18 +183,17 @@ "framerate", FPS_RANGE, \ NULL) -#define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_16 \ - gst_props_new ( \ - "bpp", GST_PROPS_INT (16), \ - "depth", GST_PROPS_INT (16), \ - "endianness", GST_PROPS_INT (G_BYTE_ORDER), \ - "red_mask", GST_PROPS_INT (R_MASK_16), \ - "green_mask", GST_PROPS_INT (G_MASK_16), \ - "blue_mask", GST_PROPS_INT (B_MASK_16), \ - "width", SIZE_RANGE, \ - "height", SIZE_RANGE, \ - "framerate", FPS_RANGE, \ - NULL) +#define GST_VIDEO_RGB_PAD_TEMPLATE_CAPS_16 \ + "video/x-raw-rgb, " \ + "bpp = (int) 16, " \ + "depth = (int) 16, " \ + "endianness = (int) BYTE_ORDER, " \ + "red_mask = (int) " R_MASK_16 ", " \ + "green_mask = (int) " G_MASK_16 ", " \ + "blue_mask = (int) " B_MASK_16 ", " \ + "width = " SIZE_RANGE ", " \ + "height = " SIZE_RANGE ", " \ + "framerate = " FPS_RANGE #define GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15 \ gst_props_new ( \ @@ -217,7 +216,7 @@ "framerate = " FPS_RANGE /* functions */ -gfloat gst_video_frame_rate (GstPad *pad); +gdouble gst_video_frame_rate (GstPad *pad); gboolean gst_video_get_size (GstPad *pad, gint *width, gint *height); -- cgit v1.2.1