1 /* GStreamer libsndfile plugin
2  * Copyright (C) 2003 Andy Wingo <wingo at pobox dot com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 #include <gst/gst-i18n-plugin.h>
26 #include <string.h>
27 
28 #include "gstsf.h"
29 
30 /* sf formats */
31 
32 GstCaps *
gst_sf_create_audio_template_caps(void)33 gst_sf_create_audio_template_caps (void)
34 {
35   GstCaps *caps = gst_caps_new_empty ();
36   SF_FORMAT_INFO format_info;
37   const gchar *fmt;
38   gint k, count;
39 
40   sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (gint));
41 
42   for (k = 0; k < count; k++) {
43     format_info.format = k;
44     sf_command (NULL, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info));
45 
46     switch (format_info.format) {
47       case SF_FORMAT_IRCAM:    /* Berkeley/IRCAM/CARL */
48         fmt = "audio/x-ircam";
49         break;
50       case SF_FORMAT_NIST:     /* Sphere NIST format. */
51         fmt = "audio/x-nist";
52         break;
53       case SF_FORMAT_PAF:      /* Ensoniq PARIS file format. */
54         fmt = "audio/x-paris";
55         break;
56       case SF_FORMAT_SDS:      /* Midi Sample Dump Standard */
57         fmt = "audio/x-sds";
58         break;
59       case SF_FORMAT_SVX:      /* Amiga IFF / SVX8 / SV16 format. */
60         fmt = "audio/x-svx";
61         break;
62       case SF_FORMAT_VOC:      /* VOC files. */
63         fmt = "audio/x-voc";
64         break;
65       case SF_FORMAT_W64:      /* Sonic Foundry's 64 bit RIFF/WAV */
66         fmt = "audio/x-w64";
67         break;
68       case SF_FORMAT_XI:       /* Fasttracker 2 Extended Instrument */
69         fmt = "audio/x-xi";
70         break;
71       case SF_FORMAT_RF64:     /* RF64 WAV file */
72         fmt = "audio/x-rf64";
73         break;
74         /* does not make sense to expose that */
75       case SF_FORMAT_RAW:      /* RAW PCM data. */
76         /* we have other elements to handle these */
77       case SF_FORMAT_AIFF:     /* Apple/SGI AIFF format */
78       case SF_FORMAT_AU:       /* Sun/NeXT AU format */
79       case SF_FORMAT_FLAC:     /* FLAC lossless file format */
80       case SF_FORMAT_OGG:      /* Xiph OGG container */
81       case SF_FORMAT_WAV:      /* Microsoft WAV format */
82       case SF_FORMAT_WAVEX:    /* MS WAVE with WAVEFORMATEX */
83         fmt = NULL;
84         GST_LOG ("skipping format '%s'", format_info.name);
85         break;
86       case SF_FORMAT_MAT4:     /* Matlab (tm) V4.2 / GNU Octave 2.0 */
87       case SF_FORMAT_MAT5:     /* Matlab (tm) V5.0 / GNU Octave 2.1 */
88       case SF_FORMAT_PVF:      /* Portable Voice Format */
89       case SF_FORMAT_HTK:      /* HMM Tool Kit format */
90       case SF_FORMAT_AVR:      /* Audio Visual Research */
91       case SF_FORMAT_SD2:      /* Sound Designer 2 */
92       case SF_FORMAT_CAF:      /* Core Audio File format */
93       case SF_FORMAT_WVE:      /* Psion WVE format */
94       case SF_FORMAT_MPC2K:    /* Akai MPC 2000 sampler */
95       default:
96         fmt = NULL;
97         GST_WARNING ("format 0x%x: '%s' is not mapped", format_info.format,
98             format_info.name);
99     }
100     if (fmt != NULL) {
101       gst_caps_append_structure (caps, gst_structure_new_empty (fmt));
102     }
103   }
104   return gst_caps_simplify (caps);
105 }
106 
107 static gboolean
plugin_init(GstPlugin * plugin)108 plugin_init (GstPlugin * plugin)
109 {
110 #ifdef ENABLE_NLS
111   GST_DEBUG ("binding text domain %s to locale dir %s", GETTEXT_PACKAGE,
112       LOCALEDIR);
113   bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
114   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
115 #endif /* ENABLE_NLS */
116 
117   if (!gst_element_register (plugin, "sfdec", GST_RANK_MARGINAL,
118           gst_sf_dec_get_type ()))
119     return FALSE;
120 
121   return TRUE;
122 }
123 
124 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
125     GST_VERSION_MINOR,
126     sndfile,
127     "use libsndfile to read and write various audio formats",
128     plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
129