+ 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>
*
* 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
* 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
* 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
* 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 */
mimetype = gst_caps_get_mime (caps);
if (strcmp (mimetype, "audio/x-raw-int") == 0) {
if (! strncmp (mimetype, "audio/x-raw-int", 15)) {
gboolean sign;
gint width, depth, endianness;
/* extract the needed information from the caps */
if (!gst_caps_get (caps,
"width", &width,
"depth", &depth,
"signed", &sign,
NULL))
"width", &width, "depth", &depth, "signed", &sign, NULL))
goto error;
/* extract endianness if needed */
if (width > 8) {
if (!gst_caps_get (caps,
"endianness", &endianness,
NULL))
if (!gst_caps_get (caps, "endianness", &endianness, NULL))
goto error;
} else {
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);
} else if (strcmp (mimetype, "audio/x-raw-float") == 0) {
gint depth;
gfloat intercept, slope;
} else if (! strncmp (mimetype, "audio/x-raw-float", 17)) {
gint width;
/* get layout */
if (!gst_caps_get (caps, "depth", &depth,
"intercept", &intercept,
"slope", &slope,
NULL))
if (!gst_caps_get (caps, "width", &width, NULL))
goto error;
if (intercept != 0.0f || slope != 1.0f) {
goto error;
}
/* match layout to format wrt to endianness */
if (depth == 32) {
if (width == 32) {
if (G_BYTE_ORDER == G_LITTLE_ENDIAN) {
ret->format = SND_PCM_FORMAT_FLOAT_LE;
} else if (G_BYTE_ORDER == G_BIG_ENDIAN) {
@ -1286,7 +1275,7 @@ gst_alsa_get_format (GstCaps *caps)
} else {
ret->format = SND_PCM_FORMAT_FLOAT;
}
} else if (depth == 64) {
} else if (width == 64) {
if (G_BYTE_ORDER == G_LITTLE_ENDIAN) {
ret->format = SND_PCM_FORMAT_FLOAT64_LE;
} else if (G_BYTE_ORDER == G_BIG_ENDIAN) {
@ -1297,16 +1286,15 @@ gst_alsa_get_format (GstCaps *caps)
} else {
goto error;
}
} else if (!strcmp (mimetype, "audio/x-alaw")) {
} else if (!strncmp (mimetype, "audio/x-alaw", 12)) {
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;
}
/* get rate and channels */
if (!gst_caps_get (caps, "rate", &ret->rate,
"channels", &ret->channels,
NULL))
if (!gst_caps_get (caps,
"rate", &ret->rate, "channels", &ret->channels, NULL))
goto error;
return ret;
@ -1333,7 +1321,6 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
if (format == SND_PCM_FORMAT_A_LAW) {
return GST_CAPS_NEW (name, "audio/x-alaw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT(2),
"width", GST_PROPS_INT(8),
"depth", GST_PROPS_INT(8),
@ -1341,7 +1328,6 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
NULL);
} else if (format == SND_PCM_FORMAT_MU_LAW) {
return GST_CAPS_NEW (name, "audio/x-mulaw",
"format", GST_PROPS_STRING ("int"),
"law", GST_PROPS_INT(1),
"width", GST_PROPS_INT(8),
"depth", GST_PROPS_INT(8),
@ -1349,8 +1335,8 @@ gst_alsa_get_caps_internal (snd_pcm_format_t format)
NULL);
} else if (snd_pcm_format_linear (format)) {
/* int */
GstProps *props = gst_props_new ("format", GST_PROPS_STRING ("int"),
"width", GST_PROPS_INT(snd_pcm_format_physical_width (format)),
GstProps *props =
gst_props_new ("width", GST_PROPS_INT(snd_pcm_format_physical_width (format)),
"depth", GST_PROPS_INT(snd_pcm_format_width (format)),
"law", GST_PROPS_INT(0),
"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))
return NULL;
return GST_CAPS_NEW (name, "audio/x-raw-float",
"depth", GST_PROPS_INT (snd_pcm_format_width (format)),
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"intercept", GST_PROPS_FLOAT (0.),
"slope", GST_PROPS_FLOAT (1.),
NULL);
return GST_CAPS_NEW (name,
"audio/x-raw-float",
"width", GST_PROPS_INT (snd_pcm_format_width (format)),
"endianness", GST_PROPS_INT (G_BYTE_ORDER));
}
return NULL;
}
@ -1490,7 +1474,7 @@ gst_alsa_get_caps (GstPad *pad, GstCaps *caps)
if (snd_pcm_format_mask_test (mask, i)) {
GstCaps *caps = gst_alsa_get_caps_internal (i);
/* 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);
ret = gst_caps_append (ret, caps);
}