Add bluez5 plugins

This commit is contained in:
Wim Taymans 2018-01-11 10:23:37 +01:00
parent 4a57f88345
commit 7d5f302f93
12 changed files with 3809 additions and 0 deletions

View file

@ -0,0 +1,123 @@
/*
* BlueALSA - bluez-a2dp.c
* Copyright (c) 2016-2017 Arkadiusz Bokowy
*
* This file is a part of bluez-alsa.
*
* This project is licensed under the terms of the MIT license.
*
*/
#include "a2dp-codecs.h"
const a2dp_sbc_t bluez_a2dp_sbc = {
.frequency =
SBC_SAMPLING_FREQ_16000 |
SBC_SAMPLING_FREQ_32000 |
SBC_SAMPLING_FREQ_44100 |
SBC_SAMPLING_FREQ_48000,
.channel_mode =
SBC_CHANNEL_MODE_MONO |
SBC_CHANNEL_MODE_DUAL_CHANNEL |
SBC_CHANNEL_MODE_STEREO |
SBC_CHANNEL_MODE_JOINT_STEREO,
.block_length =
SBC_BLOCK_LENGTH_4 |
SBC_BLOCK_LENGTH_8 |
SBC_BLOCK_LENGTH_12 |
SBC_BLOCK_LENGTH_16,
.subbands =
SBC_SUBBANDS_4 |
SBC_SUBBANDS_8,
.allocation_method =
SBC_ALLOCATION_SNR |
SBC_ALLOCATION_LOUDNESS,
.min_bitpool = MIN_BITPOOL,
.max_bitpool = MAX_BITPOOL,
};
#if ENABLE_MP3
const a2dp_mpeg_t bluez_a2dp_mpeg = {
.layer =
MPEG_LAYER_MP1 |
MPEG_LAYER_MP2 |
MPEG_LAYER_MP3,
.crc = 1,
.channel_mode =
MPEG_CHANNEL_MODE_MONO |
MPEG_CHANNEL_MODE_DUAL_CHANNEL |
MPEG_CHANNEL_MODE_STEREO |
MPEG_CHANNEL_MODE_JOINT_STEREO,
.mpf = 1,
.frequency =
MPEG_SAMPLING_FREQ_16000 |
MPEG_SAMPLING_FREQ_22050 |
MPEG_SAMPLING_FREQ_24000 |
MPEG_SAMPLING_FREQ_32000 |
MPEG_SAMPLING_FREQ_44100 |
MPEG_SAMPLING_FREQ_48000,
.bitrate =
MPEG_BIT_RATE_VBR |
MPEG_BIT_RATE_320000 |
MPEG_BIT_RATE_256000 |
MPEG_BIT_RATE_224000 |
MPEG_BIT_RATE_192000 |
MPEG_BIT_RATE_160000 |
MPEG_BIT_RATE_128000 |
MPEG_BIT_RATE_112000 |
MPEG_BIT_RATE_96000 |
MPEG_BIT_RATE_80000 |
MPEG_BIT_RATE_64000 |
MPEG_BIT_RATE_56000 |
MPEG_BIT_RATE_48000 |
MPEG_BIT_RATE_40000 |
MPEG_BIT_RATE_32000 |
MPEG_BIT_RATE_FREE,
};
#endif
#if ENABLE_AAC
const a2dp_aac_t bluez_a2dp_aac = {
.object_type =
/* NOTE: AAC Long Term Prediction and AAC Scalable are
* not supported by the FDK-AAC library. */
AAC_OBJECT_TYPE_MPEG2_AAC_LC |
AAC_OBJECT_TYPE_MPEG4_AAC_LC,
AAC_INIT_FREQUENCY(
AAC_SAMPLING_FREQ_8000 |
AAC_SAMPLING_FREQ_11025 |
AAC_SAMPLING_FREQ_12000 |
AAC_SAMPLING_FREQ_16000 |
AAC_SAMPLING_FREQ_22050 |
AAC_SAMPLING_FREQ_24000 |
AAC_SAMPLING_FREQ_32000 |
AAC_SAMPLING_FREQ_44100 |
AAC_SAMPLING_FREQ_48000 |
AAC_SAMPLING_FREQ_64000 |
AAC_SAMPLING_FREQ_88200 |
AAC_SAMPLING_FREQ_96000)
.channels =
AAC_CHANNELS_1 |
AAC_CHANNELS_2,
.vbr = 1,
AAC_INIT_BITRATE(0xFFFF)
};
#endif
#if ENABLE_APTX
const a2dp_aptx_t bluez_a2dp_aptx = {
.info.vendor_id = APTX_VENDOR_ID,
.info.codec_id = APTX_CODEC_ID,
.channel_mode =
/* NOTE: Used apt-X library does not support
* single channel (mono) mode. */
APTX_CHANNEL_MODE_DUAL_CHANNEL |
APTX_CHANNEL_MODE_STEREO |
APTX_CHANNEL_MODE_JOINT_STEREO,
.frequency =
APTX_SAMPLING_FREQ_16000 |
APTX_SAMPLING_FREQ_32000 |
APTX_SAMPLING_FREQ_44100 |
APTX_SAMPLING_FREQ_48000,
};
#endif

View file

@ -0,0 +1,298 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2006-2010 Nokia Corporation
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef BLUEALSA_A2DPCODECS_H_
#define BLUEALSA_A2DPCODECS_H_
#include <stdint.h>
#define A2DP_CODEC_SBC 0x00
#define A2DP_CODEC_MPEG12 0x01
#define A2DP_CODEC_MPEG24 0x02
#define A2DP_CODEC_ATRAC 0x03
#define A2DP_CODEC_VENDOR 0xFF
/* customized 16-bit vendor extension */
#define A2DP_CODEC_VENDOR_APTX 0x4FFF
#define A2DP_CODEC_VENDOR_LDAC 0x2DFF
#define SBC_SAMPLING_FREQ_48000 (1 << 0)
#define SBC_SAMPLING_FREQ_44100 (1 << 1)
#define SBC_SAMPLING_FREQ_32000 (1 << 2)
#define SBC_SAMPLING_FREQ_16000 (1 << 3)
#define SBC_CHANNEL_MODE_JOINT_STEREO (1 << 0)
#define SBC_CHANNEL_MODE_STEREO (1 << 1)
#define SBC_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
#define SBC_CHANNEL_MODE_MONO (1 << 3)
#define SBC_BLOCK_LENGTH_16 (1 << 0)
#define SBC_BLOCK_LENGTH_12 (1 << 1)
#define SBC_BLOCK_LENGTH_8 (1 << 2)
#define SBC_BLOCK_LENGTH_4 (1 << 3)
#define SBC_SUBBANDS_8 (1 << 0)
#define SBC_SUBBANDS_4 (1 << 1)
#define SBC_ALLOCATION_LOUDNESS (1 << 0)
#define SBC_ALLOCATION_SNR (1 << 1)
#define MIN_BITPOOL 2
#define MAX_BITPOOL 64
#define MPEG_CHANNEL_MODE_JOINT_STEREO (1 << 0)
#define MPEG_CHANNEL_MODE_STEREO (1 << 1)
#define MPEG_CHANNEL_MODE_DUAL_CHANNEL (1 << 2)
#define MPEG_CHANNEL_MODE_MONO (1 << 3)
#define MPEG_LAYER_MP3 (1 << 0)
#define MPEG_LAYER_MP2 (1 << 1)
#define MPEG_LAYER_MP1 (1 << 2)
#define MPEG_SAMPLING_FREQ_48000 (1 << 0)
#define MPEG_SAMPLING_FREQ_44100 (1 << 1)
#define MPEG_SAMPLING_FREQ_32000 (1 << 2)
#define MPEG_SAMPLING_FREQ_24000 (1 << 3)
#define MPEG_SAMPLING_FREQ_22050 (1 << 4)
#define MPEG_SAMPLING_FREQ_16000 (1 << 5)
#define MPEG_BIT_RATE_VBR 0x8000
#define MPEG_BIT_RATE_320000 0x4000
#define MPEG_BIT_RATE_256000 0x2000
#define MPEG_BIT_RATE_224000 0x1000
#define MPEG_BIT_RATE_192000 0x0800
#define MPEG_BIT_RATE_160000 0x0400
#define MPEG_BIT_RATE_128000 0x0200
#define MPEG_BIT_RATE_112000 0x0100
#define MPEG_BIT_RATE_96000 0x0080
#define MPEG_BIT_RATE_80000 0x0040
#define MPEG_BIT_RATE_64000 0x0020
#define MPEG_BIT_RATE_56000 0x0010
#define MPEG_BIT_RATE_48000 0x0008
#define MPEG_BIT_RATE_40000 0x0004
#define MPEG_BIT_RATE_32000 0x0002
#define MPEG_BIT_RATE_FREE 0x0001
#define AAC_OBJECT_TYPE_MPEG2_AAC_LC 0x80
#define AAC_OBJECT_TYPE_MPEG4_AAC_LC 0x40
#define AAC_OBJECT_TYPE_MPEG4_AAC_LTP 0x20
#define AAC_OBJECT_TYPE_MPEG4_AAC_SCA 0x10
#define AAC_SAMPLING_FREQ_8000 0x0800
#define AAC_SAMPLING_FREQ_11025 0x0400
#define AAC_SAMPLING_FREQ_12000 0x0200
#define AAC_SAMPLING_FREQ_16000 0x0100
#define AAC_SAMPLING_FREQ_22050 0x0080
#define AAC_SAMPLING_FREQ_24000 0x0040
#define AAC_SAMPLING_FREQ_32000 0x0020
#define AAC_SAMPLING_FREQ_44100 0x0010
#define AAC_SAMPLING_FREQ_48000 0x0008
#define AAC_SAMPLING_FREQ_64000 0x0004
#define AAC_SAMPLING_FREQ_88200 0x0002
#define AAC_SAMPLING_FREQ_96000 0x0001
#define AAC_CHANNELS_1 0x02
#define AAC_CHANNELS_2 0x01
#define AAC_GET_BITRATE(a) ((a).bitrate1 << 16 | \
(a).bitrate2 << 8 | (a).bitrate3)
#define AAC_GET_FREQUENCY(a) ((a).frequency1 << 4 | (a).frequency2)
#define AAC_SET_BITRATE(a, b) \
do { \
(a).bitrate1 = ((b) >> 16) & 0x7f; \
(a).bitrate2 = ((b) >> 8) & 0xff; \
(a).bitrate3 = (b) & 0xff; \
} while (0)
#define AAC_SET_FREQUENCY(a, f) \
do { \
(a).frequency1 = ((f) >> 4) & 0xff; \
(a).frequency2 = (f) & 0x0f; \
} while (0)
#define AAC_INIT_BITRATE(b) \
.bitrate1 = ((b) >> 16) & 0x7f, \
.bitrate2 = ((b) >> 8) & 0xff, \
.bitrate3 = (b) & 0xff,
#define AAC_INIT_FREQUENCY(f) \
.frequency1 = ((f) >> 4) & 0xff, \
.frequency2 = (f) & 0x0f,
#define APTX_VENDOR_ID 0x0000004f
#define APTX_CODEC_ID 0x0001
#define APTX_CHANNEL_MODE_MONO 0x08
#define APTX_CHANNEL_MODE_DUAL_CHANNEL 0x04
#define APTX_CHANNEL_MODE_STEREO 0x02
#define APTX_CHANNEL_MODE_JOINT_STEREO 0x01
#define APTX_SAMPLING_FREQ_16000 0x08
#define APTX_SAMPLING_FREQ_32000 0x04
#define APTX_SAMPLING_FREQ_44100 0x02
#define APTX_SAMPLING_FREQ_48000 0x01
#define LDAC_VENDOR_ID 0x0000012d
#define LDAC_CODEC_ID 0x00aa
typedef struct {
uint32_t vendor_id;
uint16_t codec_id;
} __attribute__ ((packed)) a2dp_vendor_codec_t;
#if __BYTE_ORDER == __LITTLE_ENDIAN
typedef struct {
uint8_t channel_mode:4;
uint8_t frequency:4;
uint8_t allocation_method:2;
uint8_t subbands:2;
uint8_t block_length:4;
uint8_t min_bitpool;
uint8_t max_bitpool;
} __attribute__ ((packed)) a2dp_sbc_t;
static inline int a2dp_sbc_get_channels(a2dp_sbc_t *config)
{
switch (config->channel_mode) {
case SBC_CHANNEL_MODE_MONO:
return 1;
case SBC_CHANNEL_MODE_DUAL_CHANNEL:
case SBC_CHANNEL_MODE_STEREO:
case SBC_CHANNEL_MODE_JOINT_STEREO:
return 2;
default:
return -1;
}
}
static inline int a2dp_sbc_get_frequency(a2dp_sbc_t *config)
{
switch (config->frequency) {
case SBC_SAMPLING_FREQ_16000:
return 16000;
case SBC_SAMPLING_FREQ_32000:
return 32000;
case SBC_SAMPLING_FREQ_44100:
return 44100;
case SBC_SAMPLING_FREQ_48000:
return 48000;
default:
return -1;
}
}
typedef struct {
uint8_t channel_mode:4;
uint8_t crc:1;
uint8_t layer:3;
uint8_t frequency:6;
uint8_t mpf:1;
uint8_t rfa:1;
uint16_t bitrate;
} __attribute__ ((packed)) a2dp_mpeg_t;
typedef struct {
uint8_t object_type;
uint8_t frequency1;
uint8_t rfa:2;
uint8_t channels:2;
uint8_t frequency2:4;
uint8_t bitrate1:7;
uint8_t vbr:1;
uint8_t bitrate2;
uint8_t bitrate3;
} __attribute__ ((packed)) a2dp_aac_t;
typedef struct {
a2dp_vendor_codec_t info;
uint8_t channel_mode:4;
uint8_t frequency:4;
} __attribute__ ((packed)) a2dp_aptx_t;
typedef struct {
a2dp_vendor_codec_t info;
uint8_t unknown[2];
} __attribute__ ((packed)) a2dp_ldac_t;
#elif __BYTE_ORDER == __BIG_ENDIAN
typedef struct {
uint8_t frequency:4;
uint8_t channel_mode:4;
uint8_t block_length:4;
uint8_t subbands:2;
uint8_t allocation_method:2;
uint8_t min_bitpool;
uint8_t max_bitpool;
} __attribute__ ((packed)) a2dp_sbc_t;
typedef struct {
uint8_t layer:3;
uint8_t crc:1;
uint8_t channel_mode:4;
uint8_t rfa:1;
uint8_t mpf:1;
uint8_t frequency:6;
uint16_t bitrate;
} __attribute__ ((packed)) a2dp_mpeg_t;
typedef struct {
uint8_t object_type;
uint8_t frequency1;
uint8_t frequency2:4;
uint8_t channels:2;
uint8_t rfa:2;
uint8_t vbr:1;
uint8_t bitrate1:7;
uint8_t bitrate2;
uint8_t bitrate3;
} __attribute__ ((packed)) a2dp_aac_t;
typedef struct {
a2dp_vendor_codec_t info;
uint8_t frequency:4;
uint8_t channel_mode:4;
} __attribute__ ((packed)) a2dp_aptx_t;
typedef struct {
a2dp_vendor_codec_t info;
uint8_t unknown[2];
} __attribute__ ((packed)) a2dp_ldac_t;
#else
#error "Unknown byte order"
#endif
const a2dp_sbc_t bluez_a2dp_sbc;
#if ENABLE_MP3
const a2dp_mpeg_t bluez_a2dp_mpeg;
#endif
#if ENABLE_AAC
const a2dp_aac_t bluez_a2dp_aac;
#endif
#if ENABLE_APTX
const a2dp_aptx_t bluez_a2dp_aptx;
#endif
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

174
spa/plugins/bluez5/defs.h Normal file
View file

@ -0,0 +1,174 @@
/* Spa Bluez5 Monitor
* Copyright (C) 2017 Wim Taymans <wim.taymans@gmail.com>
*
* 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
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __SPA_BLUEZ5_DEFS_H__
#define __SPA_BLUEZ5_DEFS_H__
#ifdef __cplusplus
extern "C" {
#endif
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter1"
#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device1"
#define BLUEZ_MEDIA_INTERFACE BLUEZ_SERVICE ".Media1"
#define BLUEZ_MEDIA_ENDPOINT_INTERFACE BLUEZ_SERVICE ".MediaEndpoint1"
#define BLUEZ_MEDIA_TRANSPORT_INTERFACE BLUEZ_SERVICE ".MediaTransport1"
#define ENDPOINT_INTROSPECT_XML \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
"<node>" \
" <interface name=\"" BLUEZ_MEDIA_ENDPOINT_INTERFACE "\">" \
" <method name=\"SetConfiguration\">" \
" <arg name=\"transport\" direction=\"in\" type=\"o\"/>" \
" <arg name=\"properties\" direction=\"in\" type=\"ay\"/>" \
" </method>" \
" <method name=\"SelectConfiguration\">" \
" <arg name=\"capabilities\" direction=\"in\" type=\"ay\"/>" \
" <arg name=\"configuration\" direction=\"out\" type=\"ay\"/>" \
" </method>" \
" <method name=\"ClearConfiguration\">" \
" <arg name=\"transport\" direction=\"in\" type=\"o\"/>" \
" </method>" \
" <method name=\"Release\">" \
" </method>" \
" </interface>" \
" <interface name=\"org.freedesktop.DBus.Introspectable\">" \
" <method name=\"Introspect\">" \
" <arg name=\"data\" type=\"s\" direction=\"out\"/>" \
" </method>" \
" </interface>" \
"</node>"
#define BLUEZ_ERROR_NOT_SUPPORTED "org.bluez.Error.NotSupported"
#define SPA_BT_UUID_A2DP_SOURCE "0000110A-0000-1000-8000-00805F9B34FB"
#define SPA_BT_UUID_A2DP_SINK "0000110B-0000-1000-8000-00805F9B34FB"
#define SPA_BT_UUID_HSP_HS "00001108-0000-1000-8000-00805F9B34FB"
#define SPA_BT_UUID_HSP_AG "00001112-0000-1000-8000-00805F9B34FB"
#define SPA_BT_UUID_HFP_HF "0000111E-0000-1000-8000-00805F9B34FB"
#define SPA_BT_UUID_HFP_AG "0000111F-0000-1000-8000-00805F9B34FB"
enum spa_bt_profile {
SPA_BT_PROFILE_NULL = 0,
SPA_BT_PROFILE_A2DP_SOURCE = (1 << 0),
SPA_BT_PROFILE_A2DP_SINK = (1 << 1),
SPA_BT_PROFILE_HSP_HS = (1 << 2),
SPA_BT_PROFILE_HSP_AG = (1 << 3),
SPA_BT_PROFILE_HFP_HF = (1 << 4),
SPA_BT_PROFILE_HFP_AG = (1 << 5),
};
static inline enum spa_bt_profile spa_bt_profile_from_uuid(const char *uuid)
{
if (strcasecmp(uuid, SPA_BT_UUID_A2DP_SOURCE) == 0)
return SPA_BT_PROFILE_A2DP_SOURCE;
else if (strcasecmp(uuid, SPA_BT_UUID_A2DP_SINK) == 0)
return SPA_BT_PROFILE_A2DP_SINK;
else if (strcasecmp(uuid, SPA_BT_UUID_HSP_HS) == 0)
return SPA_BT_PROFILE_HSP_HS;
else if (strcasecmp(uuid, SPA_BT_UUID_HSP_AG) == 0)
return SPA_BT_PROFILE_HSP_AG;
else if (strcasecmp(uuid, SPA_BT_UUID_HFP_HF) == 0)
return SPA_BT_PROFILE_HFP_HF;
else if (strcasecmp(uuid, SPA_BT_UUID_HFP_AG) == 0)
return SPA_BT_PROFILE_HFP_AG;
else
return 0;
}
struct spa_bt_monitor;
struct spa_bt_adapter {
struct spa_list link;
struct spa_bt_monitor *monitor;
char *path;
char *alias;
char *address;
char *name;
uint32_t bluetooth_class;
uint32_t profiles;
int powered;
};
struct spa_bt_device {
struct spa_list link;
struct spa_bt_monitor *monitor;
char *path;
char *alias;
char *address;
char *adapter_path;
char *name;
char *icon;
uint32_t bluetooth_class;
uint16_t appearance;
uint16_t RSSI;
int paired;
int trusted;
int connected;
int blocked;
uint32_t profiles;
};
enum spa_bt_transport_state {
SPA_BT_TRANSPORT_STATE_IDLE,
SPA_BT_TRANSPORT_STATE_PENDING,
SPA_BT_TRANSPORT_STATE_ACTIVE,
};
struct spa_bt_transport {
struct spa_list link;
struct spa_bt_monitor *monitor;
char *path;
struct spa_bt_device *device;
enum spa_bt_profile profile;
enum spa_bt_transport_state state;
int codec;
void *configuration;
int configuration_len;
bool acquired;
int fd;
uint16_t read_mtu;
uint16_t write_mtu;
int (*acquire) (struct spa_bt_transport *trans, bool optional);
int (*release) (struct spa_bt_transport *trans);
};
static inline enum spa_bt_transport_state spa_bt_transport_state_from_string(const char *value)
{
if (strcasecmp("idle", value) == 0)
return SPA_BT_TRANSPORT_STATE_IDLE;
else if (strcasecmp("pending", value) == 0)
return SPA_BT_TRANSPORT_STATE_PENDING;
else if (strcasecmp("active", value) == 0)
return SPA_BT_TRANSPORT_STATE_ACTIVE;
else
return SPA_BT_TRANSPORT_STATE_IDLE;
}
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* __SPA_BLUEZ5_DEFS_H__ */

View file

@ -0,0 +1,12 @@
bluez5_sources = ['plugin.c',
'a2dp-sink.c',
'bluez5-monitor.c']
bluez5lib = shared_library('spa-bluez5',
bluez5_sources,
include_directories : [ spa_inc, spa_libinc ],
dependencies : [ dbus_dep, sbc_dep ],
link_with : spalib,
install : true,
install_dir : '@0@/spa/bluez5'.format(get_option('libdir')))

View file

@ -0,0 +1,53 @@
/* Spa Volume plugin
* Copyright (C) 2016 Wim Taymans <wim.taymans@gmail.com>
*
* 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
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include <errno.h>
#include <stdio.h>
#include <spa/support/plugin.h>
#define MAX_FACTORIES 16
static const struct spa_handle_factory *factories[MAX_FACTORIES];
static int n_factories;
int spa_handle_factory_register(const struct spa_handle_factory *factory)
{
if (n_factories >= MAX_FACTORIES) {
fprintf(stderr, "too many factories\n");
return -ENOMEM;
}
factories[n_factories++] = factory;
return 0;
}
int
spa_handle_factory_enum(const struct spa_handle_factory **factory, uint32_t *index)
{
spa_return_val_if_fail(factory != NULL, -EINVAL);
spa_return_val_if_fail(index != NULL, -EINVAL);
if (*index >= n_factories)
return 0;
*factory = factories[(*index)++];
return 1;
}

74
spa/plugins/bluez5/rtp.h Normal file
View file

@ -0,0 +1,74 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2004-2010 Marcel Holtmann <marcel@holtmann.org>
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#if __BYTE_ORDER == __LITTLE_ENDIAN
struct rtp_header {
unsigned cc:4;
unsigned x:1;
unsigned p:1;
unsigned v:2;
unsigned pt:7;
unsigned m:1;
uint16_t sequence_number;
uint32_t timestamp;
uint32_t ssrc;
uint32_t csrc[0];
} __attribute__ ((packed));
struct rtp_payload {
unsigned frame_count:4;
unsigned rfa0:1;
unsigned is_last_fragment:1;
unsigned is_first_fragment:1;
unsigned is_fragmented:1;
} __attribute__ ((packed));
#elif __BYTE_ORDER == __BIG_ENDIAN
struct rtp_header {
unsigned v:2;
unsigned p:1;
unsigned x:1;
unsigned cc:4;
unsigned m:1;
unsigned pt:7;
uint16_t sequence_number;
uint32_t timestamp;
uint32_t ssrc;
uint32_t csrc[0];
} __attribute__ ((packed));
struct rtp_payload {
unsigned is_fragmented:1;
unsigned is_first_fragment:1;
unsigned is_last_fragment:1;
unsigned rfa0:1;
unsigned frame_count:4;
} __attribute__ ((packed));
#else
#error "Unknown byte order"
#endif

View file

@ -1,6 +1,7 @@
subdir('alsa')
subdir('audiomixer')
subdir('audiotestsrc')
subdir('bluez5')
if avcodec_dep.found()
subdir('ffmpeg')
endif