+ updated caps for new float caps + added 'Library' to license at top of file since gst-inspect says LGPL

Original commit message from CVS:
+ updated caps for new float caps
+ added 'Library' to license at top of file since gst-inspect says LGPL
This commit is contained in:
Leif Johnson 2003-07-19 23:22:47 +00:00
parent e6f278e065
commit 0894ba5603

View file

@ -5,7 +5,7 @@
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de> * Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public * modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version. * version 2 of the License, or (at your option) any later version.
* *
@ -14,7 +14,7 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details. * General Public License for more details.
* *
* You should have received a copy of the GNU General Public * You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the Free * License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
@ -1240,45 +1240,34 @@ gst_alsa_get_format (GstCaps *caps)
/* we have to differentiate between int and float formats */ /* we have to differentiate between int and float formats */
mimetype = gst_caps_get_mime (caps); mimetype = gst_caps_get_mime (caps);
if (strcmp (mimetype, "audio/x-raw-int") == 0) { if (! strncmp (mimetype, "audio/x-raw-int", 15)) {
gboolean sign; gboolean sign;
gint width, depth, endianness; gint width, depth, endianness;
/* extract the needed information from the caps */ /* extract the needed information from the caps */
if (!gst_caps_get (caps, if (!gst_caps_get (caps,
"width", &width, "width", &width, "depth", &depth, "signed", &sign, NULL))
"depth", &depth,
"signed", &sign,
NULL))
goto error; goto error;
/* extract endianness if needed */ /* extract endianness if needed */
if (width > 8) { if (width > 8) {
if (!gst_caps_get (caps, if (!gst_caps_get (caps, "endianness", &endianness, NULL))
"endianness", &endianness,
NULL))
goto error; goto error;
} else { } else {
endianness = G_BYTE_ORDER; endianness = G_BYTE_ORDER;
} }
/* find corresponding alsa format */
ret->format = snd_pcm_build_linear_format (depth, width, sign ? 0 : 1, endianness == G_LITTLE_ENDIAN ? 0 : 1); ret->format = snd_pcm_build_linear_format (depth, width, sign ? 0 : 1, endianness == G_LITTLE_ENDIAN ? 0 : 1);
} else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
gint depth; } else if (! strncmp (mimetype, "audio/x-raw-float", 17)) {
gfloat intercept, slope; gint width;
/* get layout */ /* get layout */
if (!gst_caps_get (caps, "depth", &depth, if (!gst_caps_get (caps, "width", &width, NULL))
"intercept", &intercept,
"slope", &slope,
NULL))
goto error; goto error;
if (intercept != 0.0f || slope != 1.0f) {
goto error;
}
/* match layout to format wrt to endianness */ /* match layout to format wrt to endianness */
if (depth == 32) { if (width == 32) {
if (G_BYTE_ORDER == G_LITTLE_ENDIAN) { if (G_BYTE_ORDER == G_LITTLE_ENDIAN) {
ret->format = SND_PCM_FORMAT_FLOAT_LE; ret->format = SND_PCM_FORMAT_FLOAT_LE;
} else if (G_BYTE_ORDER == G_BIG_ENDIAN) { } else if (G_BYTE_ORDER == G_BIG_ENDIAN) {
@ -1286,7 +1275,7 @@ gst_alsa_get_format (GstCaps *caps)
} else { } else {
ret->format = SND_PCM_FORMAT_FLOAT; ret->format = SND_PCM_FORMAT_FLOAT;
} }
} else if (depth == 64) { } else if (width == 64) {
if (G_BYTE_ORDER == G_LITTLE_ENDIAN) { if (G_BYTE_ORDER == G_LITTLE_ENDIAN) {
ret->format = SND_PCM_FORMAT_FLOAT64_LE; ret->format = SND_PCM_FORMAT_FLOAT64_LE;
} else if (G_BYTE_ORDER == G_BIG_ENDIAN) { } else if (G_BYTE_ORDER == G_BIG_ENDIAN) {
@ -1297,16 +1286,15 @@ gst_alsa_get_format (GstCaps *caps)
} else { } else {
goto error; goto error;
} }
} else if (!strcmp (mimetype, "audio/x-alaw")) { } else if (!strncmp (mimetype, "audio/x-alaw", 12)) {
ret->format = SND_PCM_FORMAT_A_LAW; ret->format = SND_PCM_FORMAT_A_LAW;
} else if (!strcmp (mimetype, "audio/x-mulaw")) { } else if (!strncmp (mimetype, "audio/x-mulaw", 13)) {
ret->format = SND_PCM_FORMAT_MU_LAW; ret->format = SND_PCM_FORMAT_MU_LAW;
} }
/* get rate and channels */ /* get rate and channels */
if (!gst_caps_get (caps, "rate", &ret->rate, if (!gst_caps_get (caps,
"channels", &ret->channels, "rate", &ret->rate, "channels", &ret->channels, NULL))
NULL))
goto error; goto error;
return ret; return ret;
@ -1333,7 +1321,6 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
if (format == SND_PCM_FORMAT_A_LAW) { if (format == SND_PCM_FORMAT_A_LAW) {
return GST_CAPS_NEW (name, "audio/x-alaw", return GST_CAPS_NEW (name, "audio/x-alaw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT(2), "law", GST_PROPS_INT(2),
"width", GST_PROPS_INT(8), "width", GST_PROPS_INT(8),
"depth", GST_PROPS_INT(8), "depth", GST_PROPS_INT(8),
@ -1341,7 +1328,6 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
NULL); NULL);
} else if (format == SND_PCM_FORMAT_MU_LAW) { } else if (format == SND_PCM_FORMAT_MU_LAW) {
return GST_CAPS_NEW (name, "audio/x-mulaw", return GST_CAPS_NEW (name, "audio/x-mulaw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT(1), "law", GST_PROPS_INT(1),
"width", GST_PROPS_INT(8), "width", GST_PROPS_INT(8),
"depth", GST_PROPS_INT(8), "depth", GST_PROPS_INT(8),
@ -1349,8 +1335,8 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
NULL); NULL);
} else if (snd_pcm_format_linear (format)) { } else if (snd_pcm_format_linear (format)) {
/* int */ /* int */
GstProps *props = gst_props_new ("format", GST_PROPS_STRING ("int"), GstProps *props =
"width", GST_PROPS_INT(snd_pcm_format_physical_width (format)), gst_props_new ("width", GST_PROPS_INT(snd_pcm_format_physical_width (format)),
"depth", GST_PROPS_INT(snd_pcm_format_width (format)), "depth", GST_PROPS_INT(snd_pcm_format_width (format)),
"law", GST_PROPS_INT(0), "law", GST_PROPS_INT(0),
"signed", GST_PROPS_BOOLEAN (snd_pcm_format_signed (format) == 1 ? TRUE : FALSE), "signed", GST_PROPS_BOOLEAN (snd_pcm_format_signed (format) == 1 ? TRUE : FALSE),
@ -1376,12 +1362,10 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
if (!snd_pcm_format_cpu_endian (format)) if (!snd_pcm_format_cpu_endian (format))
return NULL; return NULL;
return GST_CAPS_NEW (name, "audio/x-raw-float", return GST_CAPS_NEW (name,
"depth", GST_PROPS_INT (snd_pcm_format_width (format)), "audio/x-raw-float",
"endianness", GST_PROPS_INT (G_BYTE_ORDER), "width", GST_PROPS_INT (snd_pcm_format_width (format)),
"intercept", GST_PROPS_FLOAT (0.), "endianness", GST_PROPS_INT (G_BYTE_ORDER));
"slope", GST_PROPS_FLOAT (1.),
NULL);
} }
return NULL; return NULL;
} }
@ -1490,7 +1474,7 @@ gst_alsa_get_caps (GstPad *pad, GstCaps *caps)
if (snd_pcm_format_mask_test (mask, i)) { if (snd_pcm_format_mask_test (mask, i)) {
GstCaps *caps = gst_alsa_get_caps_internal (i); GstCaps *caps = gst_alsa_get_caps_internal (i);
/* we can never use a format we can't set caps for */ /* we can never use a format we can't set caps for */
if (caps->properties != NULL) { if (caps != NULL && caps->properties != NULL) {
add_channels (caps->properties, min_rate, max_rate, min_channels, max_channels); add_channels (caps->properties, min_rate, max_rate, min_channels, max_channels);
ret = gst_caps_append (ret, caps); ret = gst_caps_append (ret, caps);
} }