1 /* 2 * 3 * BlueZ - Bluetooth protocol stack for Linux 4 * 5 * Copyright (C) 2004-2010 Marcel Holtmann <marcel (at) holtmann.org> 6 * 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 * 22 */ 23 24 #ifdef HAVE_CONFIG_H 25 #include <config.h> 26 #endif 27 28 #include <string.h> 29 30 #include <gst/gst.h> 31 32 #include "gstsbcutil.h" 33 #include <sbc.h> 34 35 #include "gstsbcenc.h" 36 #include "gstsbcdec.h" 37 #include "gstsbcparse.h" 38 #include "gstavdtpsink.h" 39 #include "gsta2dpsink.h" 40 #include "gstrtpsbcpay.h" 41 42 static GstStaticCaps sbc_caps = GST_STATIC_CAPS("audio/x-sbc"); 43 44 #define SBC_CAPS (gst_static_caps_get(&sbc_caps)) 45 46 static void sbc_typefind(GstTypeFind *tf, gpointer ignore) 47 { 48 GstCaps *caps; 49 guint8 *aux; 50 sbc_t sbc; 51 guint8 *data = gst_type_find_peek(tf, 0, 32); 52 53 if (data == NULL) 54 return; 55 56 if (sbc_init(&sbc, 0) < 0) 57 return; 58 59 aux = g_new(guint8, 32); 60 memcpy(aux, data, 32); 61 if (sbc_parse(&sbc, aux, 32) < 0) 62 goto done; 63 64 caps = gst_sbc_parse_caps_from_sbc(&sbc); 65 gst_type_find_suggest(tf, GST_TYPE_FIND_POSSIBLE, caps); 66 gst_caps_unref(caps); 67 68 done: 69 g_free(aux); 70 sbc_finish(&sbc); 71 } 72 73 static gchar *sbc_exts[] = { "sbc", NULL }; 74 75 static gboolean plugin_init(GstPlugin *plugin) 76 { 77 GST_INFO("Bluetooth plugin %s", VERSION); 78 79 if (gst_type_find_register(plugin, "sbc", 80 GST_RANK_PRIMARY, sbc_typefind, sbc_exts, 81 SBC_CAPS, NULL, NULL) == FALSE) 82 return FALSE; 83 84 if (!gst_sbc_enc_plugin_init(plugin)) 85 return FALSE; 86 87 if (!gst_sbc_dec_plugin_init(plugin)) 88 return FALSE; 89 90 if (!gst_sbc_parse_plugin_init(plugin)) 91 return FALSE; 92 93 if (!gst_avdtp_sink_plugin_init(plugin)) 94 return FALSE; 95 96 if (!gst_a2dp_sink_plugin_init(plugin)) 97 return FALSE; 98 99 if (!gst_rtp_sbc_pay_plugin_init(plugin)) 100 return FALSE; 101 102 return TRUE; 103 } 104 105 extern GstPluginDesc gst_plugin_desc __attribute__ ((visibility("default"))); 106 107 GST_PLUGIN_DEFINE(GST_VERSION_MAJOR, GST_VERSION_MINOR, 108 "bluetooth", "Bluetooth plugin library", 109 plugin_init, VERSION, "LGPL", "BlueZ", "http://www.bluez.org/") 110