From: Wim Taymans Date: Fri, 19 Aug 2011 15:41:22 +0000 (+0200) Subject: more audio caps porting X-Git-Tag: RELEASE-0.11.1~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8023f49d19cfda3c60636feb62b515c25827e472;p=platform%2Fupstream%2Fgst-plugins-base.git more audio caps porting --- diff --git a/ext/alsa/gstalsa.c b/ext/alsa/gstalsa.c index 94ed44c..60f3f3e 100644 --- a/ext/alsa/gstalsa.c +++ b/ext/alsa/gstalsa.c @@ -17,7 +17,7 @@ #include "gstalsa.h" -#include +#include static GstCaps * gst_alsa_detect_rates (GstObject * obj, snd_pcm_hw_params_t * hw_params, @@ -117,18 +117,30 @@ gst_alsa_detect_formats (GstObject * obj, snd_pcm_hw_params_t * hw_params, for (i = 0; i < gst_caps_get_size (in_caps); ++i) { GstStructure *scopy; + const gchar *str; + GstAudioFormat format; + const GstAudioFormatInfo *finfo; gint w, width = 0, depth = 0; s = gst_caps_get_structure (in_caps, i); - if (!gst_structure_has_name (s, "audio/x-raw-int")) { - GST_WARNING_OBJECT (obj, "skipping non-int format"); + if (!gst_structure_has_name (s, "audio/x-raw")) { + GST_WARNING_OBJECT (obj, "skipping non-raw format"); continue; } - if (!gst_structure_get_int (s, "width", &width) || - !gst_structure_get_int (s, "depth", &depth)) + + str = gst_structure_get_string (s, "format"); + if (str == NULL) + continue; + + format = gst_audio_format_from_string (str); + if (format == GST_AUDIO_FORMAT_UNKNOWN) continue; - if (width == 0 || (width % 8) != 0) - continue; /* Only full byte widths are valid */ + + finfo = gst_audio_format_get_info (format); + + width = GST_AUDIO_FORMAT_INFO_WIDTH (finfo); + depth = GST_AUDIO_FORMAT_INFO_DEPTH (finfo); + for (w = 0; w < G_N_ELEMENTS (pcmformats); w++) if (pcmformats[w].width == width && pcmformats[w].depth == depth) break; @@ -137,22 +149,17 @@ gst_alsa_detect_formats (GstObject * obj, snd_pcm_hw_params_t * hw_params, if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat) && snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) { - /* template contains { true, false } or just one, leave it as it is */ scopy = gst_structure_copy (s); } else if (snd_pcm_format_mask_test (mask, pcmformats[w].sformat)) { scopy = gst_structure_copy (s); - gst_structure_set (scopy, "signed", G_TYPE_BOOLEAN, TRUE, NULL); + /* FIXME, remove unsigned version */ } else if (snd_pcm_format_mask_test (mask, pcmformats[w].uformat)) { scopy = gst_structure_copy (s); - gst_structure_set (scopy, "signed", G_TYPE_BOOLEAN, FALSE, NULL); + /* FIXME, remove signed version */ } else { scopy = NULL; } if (scopy) { - if (width > 8) { - /* TODO: proper endianness detection, for now it's CPU endianness only */ - gst_structure_set (scopy, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL); - } gst_caps_append_structure (caps, scopy); } } diff --git a/ext/ogg/gstoggstream.c b/ext/ogg/gstoggstream.c index fb19d87..93ec358 100644 --- a/ext/ogg/gstoggstream.c +++ b/ext/ogg/gstoggstream.c @@ -1565,56 +1565,36 @@ setup_pcm_mapper (GstOggStream * pad, ogg_packet * packet) switch (format) { case OGGPCM_FMT_S8: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 8, - "width", G_TYPE_INT, 8, "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S8", NULL); break; case OGGPCM_FMT_U8: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 8, - "width", G_TYPE_INT, 8, "signed", G_TYPE_BOOLEAN, FALSE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "U8", NULL); break; case OGGPCM_FMT_S16_LE: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 16, - "width", G_TYPE_INT, 16, - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S16_LE", NULL); break; case OGGPCM_FMT_S16_BE: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 16, - "width", G_TYPE_INT, 16, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S16_BE", NULL); break; case OGGPCM_FMT_S24_LE: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 24, - "width", G_TYPE_INT, 24, - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S24_3LE", NULL); break; case OGGPCM_FMT_S24_BE: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 24, - "width", G_TYPE_INT, 24, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S24_3BE", NULL); break; case OGGPCM_FMT_S32_LE: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 32, - "width", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S32_LE", NULL); break; case OGGPCM_FMT_S32_BE: - caps = gst_caps_new_simple ("audio/x-raw-int", - "depth", G_TYPE_INT, 32, - "width", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, - "signed", G_TYPE_BOOLEAN, TRUE, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "S32_BE", NULL); break; case OGGPCM_FMT_ULAW: caps = gst_caps_new_simple ("audio/x-mulaw", NULL); @@ -1623,30 +1603,26 @@ setup_pcm_mapper (GstOggStream * pad, ogg_packet * packet) caps = gst_caps_new_simple ("audio/x-alaw", NULL); break; case OGGPCM_FMT_FLT32_LE: - caps = gst_caps_new_simple ("audio/x-raw-float", - "width", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "F32_LE", NULL); break; case OGGPCM_FMT_FLT32_BE: - caps = gst_caps_new_simple ("audio/x-raw-float", - "width", G_TYPE_INT, 32, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "F32_BE", NULL); break; case OGGPCM_FMT_FLT64_LE: - caps = gst_caps_new_simple ("audio/x-raw-float", - "width", G_TYPE_INT, 64, - "endianness", G_TYPE_INT, G_LITTLE_ENDIAN, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "F64_LE", NULL); break; case OGGPCM_FMT_FLT64_BE: - caps = gst_caps_new_simple ("audio/x-raw-float", - "width", G_TYPE_INT, 64, - "endianness", G_TYPE_INT, G_BIG_ENDIAN, NULL); + caps = gst_caps_new_simple ("audio/x-raw", + "format", G_TYPE_STRING, "F64_BE", NULL); break; default: return FALSE; } - gst_caps_set_simple (caps, "audio/x-raw-int", + gst_caps_set_simple (caps, "rate", G_TYPE_INT, pad->granulerate_n, "channels", G_TYPE_INT, channels, NULL); pad->caps = caps; @@ -1862,7 +1838,7 @@ const GstOggMap mappers[] = { }, { "PCM ", 8, 0, - "audio/x-raw-int", + "audio/x-raw", setup_pcm_mapper, NULL, NULL, diff --git a/ext/vorbis/gstvorbisenc.c b/ext/vorbis/gstvorbisenc.c index 9862684..f5ff3d3 100644 --- a/ext/vorbis/gstvorbisenc.c +++ b/ext/vorbis/gstvorbisenc.c @@ -63,10 +63,9 @@ static GstStaticPadTemplate vorbis_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_STATIC_CAPS ("audio/x-raw-float, " - "rate = (int) [ 1, 200000 ], " - "channels = (int) [ 1, 256 ], " "endianness = (int) BYTE_ORDER, " - "width = (int) 32") + GST_STATIC_CAPS ("audio/x-raw, " + "format = (string) " GST_AUDIO_NE (F32) ", " + "rate = (int) [ 1, 200000 ], " "channels = (int) [ 1, 256 ]") ); static GstStaticPadTemplate vorbis_enc_src_factory = @@ -223,17 +222,15 @@ gst_vorbis_enc_generate_sink_caps (void) GstCaps *caps = gst_caps_new_empty (); int i, c; - gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float", + gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE (F32), "rate", GST_TYPE_INT_RANGE, 1, 200000, - "channels", G_TYPE_INT, 1, - "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, - NULL)); + "channels", G_TYPE_INT, 1, NULL)); - gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float", + gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE (F32), "rate", GST_TYPE_INT_RANGE, 1, 200000, - "channels", G_TYPE_INT, 2, - "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, - NULL)); + "channels", G_TYPE_INT, 2, NULL)); for (i = 3; i <= 8; i++) { GValue chanpos = { 0 }; @@ -249,21 +246,19 @@ gst_vorbis_enc_generate_sink_caps (void) } g_value_unset (&pos); - structure = gst_structure_new ("audio/x-raw-float", - "rate", GST_TYPE_INT_RANGE, 1, 200000, - "channels", G_TYPE_INT, i, - "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, NULL); + structure = gst_structure_new ("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE (F32), + "rate", GST_TYPE_INT_RANGE, 1, 200000, "channels", G_TYPE_INT, i, NULL); gst_structure_set_value (structure, "channel-positions", &chanpos); g_value_unset (&chanpos); gst_caps_append_structure (caps, structure); } - gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw-float", + gst_caps_append_structure (caps, gst_structure_new ("audio/x-raw", + "format", G_TYPE_STRING, GST_AUDIO_NE (F32), "rate", GST_TYPE_INT_RANGE, 1, 200000, - "channels", GST_TYPE_INT_RANGE, 9, 256, - "endianness", G_TYPE_INT, G_BYTE_ORDER, "width", G_TYPE_INT, 32, - NULL)); + "channels", GST_TYPE_INT_RANGE, 9, 256, NULL)); return caps; } diff --git a/gst/audioconvert/channelmixtest.c b/gst/audioconvert/channelmixtest.c index 096a683..595a139 100644 --- a/gst/audioconvert/channelmixtest.c +++ b/gst/audioconvert/channelmixtest.c @@ -41,12 +41,12 @@ main (gint argc, gchar ** argv) } tests[] = { /* stereo => mono */ { - "audio/x-raw-int, channels=2", "audio/x-raw-int, channels=1", { { + "audio/x-raw, channels=2", "audio/x-raw, channels=1", { { 0.5,}, { 0.5,},}}, /* mono => stereo */ { - "audio/x-raw-int, channels=1", "audio/x-raw-int, channels=2", { { + "audio/x-raw, channels=1", "audio/x-raw, channels=2", { { 1, 1,},}} }; diff --git a/gst/encoding/gstencodebin.c b/gst/encoding/gstencodebin.c index d2a8e81..6618751 100644 --- a/gst/encoding/gstencodebin.c +++ b/gst/encoding/gstencodebin.c @@ -231,8 +231,7 @@ struct _StreamGroup #define DEFAULT_RAW_CAPS \ "video/x-raw; " \ - "audio/x-raw-int; " \ - "audio/x-raw-float; " \ + "audio/x-raw; " \ "text/plain; " \ "text/x-pango-markup; " \ "video/x-dvd-subpicture; " \ @@ -482,8 +481,7 @@ gst_encode_bin_init (GstEncodeBin * encode_bin) GST_RANK_MARGINAL); encode_bin->raw_video_caps = gst_caps_from_string ("video/x-raw"); - encode_bin->raw_audio_caps = - gst_caps_from_string ("audio/x-raw-int;audio/x-raw-float"); + encode_bin->raw_audio_caps = gst_caps_from_string ("audio/x-raw"); /* encode_bin->raw_text_caps = */ /* gst_caps_from_string ("text/plain;text/x-pango-markup"); */ @@ -1264,7 +1262,7 @@ _create_stream_group (GstEncodeBin * ebin, GstEncodingProfile * sprof, /* FIXME : Once we have properties for specific converters, use those */ if (GST_IS_ENCODING_VIDEO_PROFILE (sprof)) { const gboolean native_video = - !!(ebin->flags & GST_ENC_FLAG_NO_VIDEO_CONVERSION); + ! !(ebin->flags & GST_ENC_FLAG_NO_VIDEO_CONVERSION); GstElement *cspace = NULL, *scale, *vrate, *cspace2 = NULL; GST_LOG ("Adding conversion elements for video stream");