2003-07-16 16:08:13 +00:00
|
|
|
/* GStreamer libsndfile plugin
|
|
|
|
* Copyright (C) 2003 Andy Wingo <wingo at pobox dot com>
|
2003-06-16 14:56:34 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:38:00 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-06-16 14:56:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2003-11-06 23:36:33 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2003-11-07 12:47:02 +00:00
|
|
|
|
2007-06-25 11:02:21 +00:00
|
|
|
#include <gst/gst-i18n-plugin.h>
|
2003-06-16 14:56:34 +00:00
|
|
|
#include <string.h>
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
#include "gstsf.h"
|
|
|
|
|
2003-07-16 16:08:13 +00:00
|
|
|
|
2007-02-02 13:28:05 +00:00
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_major_types_get_type (void)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
static GType sf_major_types_type = 0;
|
|
|
|
static GEnumValue *sf_major_types = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (!sf_major_types_type) {
|
2003-06-16 14:56:34 +00:00
|
|
|
SF_FORMAT_INFO format_info;
|
2004-03-14 22:34:33 +00:00
|
|
|
int k, count;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int));
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
sf_major_types = g_new0 (GEnumValue, count + 1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (k = 0; k < count; k++) {
|
|
|
|
format_info.format = k;
|
|
|
|
sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info,
|
2004-03-15 19:32:27 +00:00
|
|
|
sizeof (format_info));
|
2003-06-16 14:56:34 +00:00
|
|
|
sf_major_types[k].value = format_info.format;
|
|
|
|
sf_major_types[k].value_name = g_strdup (format_info.name);
|
|
|
|
sf_major_types[k].value_nick = g_strdup (format_info.extension);
|
|
|
|
|
|
|
|
/* Irritatingly enough, there exist major_types with the same extension. Let's
|
|
|
|
just hope that sndfile gives us the list in alphabetical order, as it
|
|
|
|
currently does. */
|
2004-03-14 22:34:33 +00:00
|
|
|
if (k > 0
|
2004-03-15 19:32:27 +00:00
|
|
|
&& strcmp (sf_major_types[k].value_nick,
|
|
|
|
sf_major_types[k - 1].value_nick) == 0) {
|
2007-02-02 13:28:05 +00:00
|
|
|
g_free ((gchar *) sf_major_types[k].value_nick);
|
2004-03-15 19:32:27 +00:00
|
|
|
sf_major_types[k].value_nick =
|
|
|
|
g_strconcat (sf_major_types[k - 1].value_nick, "-",
|
|
|
|
sf_major_types[k].value_name, NULL);
|
2007-02-02 13:28:05 +00:00
|
|
|
g_strcanon ((gchar *) sf_major_types[k].value_nick,
|
2004-03-15 19:32:27 +00:00
|
|
|
G_CSET_A_2_Z G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_major_types_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_enum_register_static ("GstSndfileMajorTypes", sf_major_types);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
return sf_major_types_type;
|
|
|
|
}
|
|
|
|
|
2007-02-02 13:28:05 +00:00
|
|
|
GType
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_sf_minor_types_get_type (void)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
|
|
|
static GType sf_minor_types_type = 0;
|
|
|
|
static GEnumValue *sf_minor_types = NULL;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
if (!sf_minor_types_type) {
|
2003-06-16 14:56:34 +00:00
|
|
|
SF_FORMAT_INFO format_info;
|
2004-03-14 22:34:33 +00:00
|
|
|
int k, count;
|
2003-06-16 14:56:34 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int));
|
2003-06-16 14:56:34 +00:00
|
|
|
|
|
|
|
sf_minor_types = g_new0 (GEnumValue, count + 1);
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
for (k = 0; k < count; k++) {
|
|
|
|
format_info.format = k;
|
|
|
|
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &format_info,
|
2004-03-15 19:32:27 +00:00
|
|
|
sizeof (format_info));
|
2003-06-16 14:56:34 +00:00
|
|
|
sf_minor_types[k].value = format_info.format;
|
|
|
|
sf_minor_types[k].value_name = g_strdup (format_info.name);
|
|
|
|
sf_minor_types[k].value_nick = g_ascii_strdown (format_info.name, -1);
|
2007-02-02 13:28:05 +00:00
|
|
|
g_strcanon ((gchar *) sf_minor_types[k].value_nick,
|
|
|
|
G_CSET_a_2_z G_CSET_DIGITS "-", '-');
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
sf_minor_types_type =
|
2004-03-15 19:32:27 +00:00
|
|
|
g_enum_register_static ("GstSndfileMinorTypes", sf_minor_types);
|
2003-06-16 14:56:34 +00:00
|
|
|
}
|
|
|
|
return sf_minor_types_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2004-03-14 22:34:33 +00:00
|
|
|
plugin_init (GstPlugin * plugin)
|
2003-06-16 14:56:34 +00:00
|
|
|
{
|
2007-06-25 11:02:21 +00:00
|
|
|
#ifdef ENABLE_NLS
|
|
|
|
GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
|
|
|
|
LOCALEDIR);
|
|
|
|
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
|
2008-08-07 16:20:30 +00:00
|
|
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
2007-06-25 11:02:21 +00:00
|
|
|
#endif /* ENABLE_NLS */
|
|
|
|
|
2007-02-02 13:28:05 +00:00
|
|
|
if (!gst_element_register (plugin, "sfsink", GST_RANK_NONE,
|
|
|
|
gst_sf_sink_get_type ()))
|
2003-07-16 16:08:13 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2007-02-05 18:42:45 +00:00
|
|
|
if (!gst_element_register (plugin, "sfsrc", GST_RANK_NONE,
|
|
|
|
gst_sf_src_get_type ()))
|
|
|
|
return FALSE;
|
|
|
|
|
2003-06-16 14:56:34 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
2012-04-05 16:02:56 +00:00
|
|
|
sndfile,
|
2005-08-14 16:10:55 +00:00
|
|
|
"use libsndfile to read and write audio from and to files",
|
2006-04-01 10:09:11 +00:00
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
|