⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 avinfo.c

📁 BlueZ源码
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * *  BlueZ - Bluetooth protocol stack for Linux * *  Copyright (C) 2006-2007  Nokia Corporation *  Copyright (C) 2004-2008  Marcel Holtmann <marcel@holtmann.org> * * *  This program is free software; you can redistribute it and/or modify *  it under the terms of the GNU General Public License as published by *  the Free Software Foundation; either version 2 of the License, or *  (at your option) any later version. * *  This program 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 General Public License for more details. * *  You should have received a copy of the GNU General Public License *  along with this program; if not, write to the Free Software *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA * */#ifdef HAVE_CONFIG_H#include <config.h>#endif#include <stdio.h>#include <errno.h>#include <ctype.h>#include <fcntl.h>#include <unistd.h>#include <stdlib.h>#include <string.h>#include <getopt.h>#include <stdint.h>#include <sys/param.h>#include <sys/ioctl.h>#include <sys/socket.h>#include <bluetooth/bluetooth.h>#include <bluetooth/hci.h>#include <bluetooth/hci_lib.h>#include <bluetooth/l2cap.h>#define AVDTP_PSM			25/* Commands */#define AVDTP_DISCOVER			0x01#define AVDTP_GET_CAPABILITIES		0x02#define AVDTP_PKT_TYPE_SINGLE		0x00#define AVDTP_MSG_TYPE_COMMAND		0x00/* SEP capability categories */#define AVDTP_MEDIA_TRANSPORT		0x01#define AVDTP_REPORTING			0x02#define AVDTP_RECOVERY			0x03#define AVDTP_CONTENT_PROTECTION	0x04#define AVDTP_HEADER_COMPRESSION	0x05#define AVDTP_MULTIPLEXING		0x06#define AVDTP_MEDIA_CODEC		0x07/* SEP types definitions */#define AVDTP_SEP_TYPE_SOURCE		0x00#define AVDTP_SEP_TYPE_SINK		0x01/* Media types definitions */#define AVDTP_MEDIA_TYPE_AUDIO		0x00#define AVDTP_MEDIA_TYPE_VIDEO		0x01#define AVDTP_MEDIA_TYPE_MULTIMEDIA	0x02#define A2DP_CODEC_SBC			0x00#define A2DP_CODEC_MPEG12		0x01#define A2DP_CODEC_MPEG24		0x02#define A2DP_CODEC_ATRAC		0x03#define SBC_SAMPLING_FREQ_16000		(1 << 3)#define SBC_SAMPLING_FREQ_32000		(1 << 2)#define SBC_SAMPLING_FREQ_44100		(1 << 1)#define SBC_SAMPLING_FREQ_48000		(1 << 0)#define SBC_CHANNEL_MODE_MONO		(1 << 3)#define SBC_CHANNEL_MODE_DUAL_CHANNEL	(1 << 2)#define SBC_CHANNEL_MODE_STEREO		(1 << 1)#define SBC_CHANNEL_MODE_JOINT_STEREO	(1 << 0)#define SBC_BLOCK_LENGTH_4		(1 << 3)#define SBC_BLOCK_LENGTH_8		(1 << 2)#define SBC_BLOCK_LENGTH_12		(1 << 1)#define SBC_BLOCK_LENGTH_16		(1 << 0)#define SBC_SUBBANDS_4			(1 << 1)#define SBC_SUBBANDS_8			(1 << 0)#define SBC_ALLOCATION_SNR		(1 << 1)#define SBC_ALLOCATION_LOUDNESS		(1 << 0)#define MPEG_CHANNEL_MODE_MONO		(1 << 3)#define MPEG_CHANNEL_MODE_DUAL_CHANNEL	(1 << 2)#define MPEG_CHANNEL_MODE_STEREO	(1 << 1)#define MPEG_CHANNEL_MODE_JOINT_STEREO	(1 << 0)#define MPEG_LAYER_MP1			(1 << 2)#define MPEG_LAYER_MP2			(1 << 1)#define MPEG_LAYER_MP3			(1 << 0)#define MPEG_SAMPLING_FREQ_16000	(1 << 5)#define MPEG_SAMPLING_FREQ_22050	(1 << 4)#define MPEG_SAMPLING_FREQ_24000	(1 << 3)#define MPEG_SAMPLING_FREQ_32000	(1 << 2)#define MPEG_SAMPLING_FREQ_44100	(1 << 1)#define MPEG_SAMPLING_FREQ_48000	(1 << 0)#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		0x0001struct avdtp_service_capability {	uint8_t category;	uint8_t length;	uint8_t data[0];} __attribute__ ((packed));#if __BYTE_ORDER == __LITTLE_ENDIANstruct avdtp_header {	uint8_t message_type:2;	uint8_t packet_type:2;	uint8_t transaction:4;	uint8_t signal_id:6;	uint8_t rfa0:2;} __attribute__ ((packed));struct seid_info {	uint8_t rfa0:1;	uint8_t inuse:1;	uint8_t seid:6;	uint8_t rfa2:3;	uint8_t type:1;	uint8_t media_type:4;} __attribute__ ((packed));struct seid_req {	struct avdtp_header header;	uint8_t rfa0:2;	uint8_t acp_seid:6;} __attribute__ ((packed));struct avdtp_media_codec_capability {	uint8_t rfa0:4;	uint8_t media_type:4;	uint8_t media_codec_type;	uint8_t data[0];} __attribute__ ((packed));struct sbc_codec_cap {	struct avdtp_media_codec_capability cap;	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));struct mpeg_codec_cap {	struct avdtp_media_codec_capability cap;	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));#elif __BYTE_ORDER == __BIG_ENDIANstruct avdtp_header {	uint8_t transaction:4;	uint8_t packet_type:2;	uint8_t message_type:2;	uint8_t rfa0:2;	uint8_t signal_id:6;} __attribute__ ((packed));struct seid_info {	uint8_t seid:6;	uint8_t inuse:1;	uint8_t rfa0:1;	uint8_t media_type:4;	uint8_t type:1;	uint8_t rfa2:3;} __attribute__ ((packed));struct seid_req {	struct avdtp_header header;	uint8_t acp_seid:6;	uint8_t rfa0:2;} __attribute__ ((packed));struct avdtp_media_codec_capability {	uint8_t media_type:4;	uint8_t rfa0:4;	uint8_t media_codec_type;	uint8_t data[0];} __attribute__ ((packed));struct sbc_codec_cap {	struct avdtp_media_codec_capability cap;	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));struct mpeg_codec_cap {	struct avdtp_media_codec_capability cap;	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));#else#error "Unknown byte order"#endifstruct discover_resp {	struct avdtp_header header;	struct seid_info seps[0];} __attribute__ ((packed));struct getcap_resp {	struct avdtp_header header;	uint8_t caps[0];} __attribute__ ((packed));static void print_mpeg12(struct mpeg_codec_cap *mpeg){	printf("\tMedia Codec: MPEG12\n\t\tChannel Modes: ");	if (mpeg->channel_mode & MPEG_CHANNEL_MODE_MONO)		printf("Mono ");	if (mpeg->channel_mode & MPEG_CHANNEL_MODE_DUAL_CHANNEL)		printf("DualChannel ");	if (mpeg->channel_mode & MPEG_CHANNEL_MODE_STEREO)		printf("Stereo ");	if (mpeg->channel_mode & MPEG_CHANNEL_MODE_JOINT_STEREO)		printf("JointStereo");	printf("\n\t\tFrequencies: ");	if (mpeg->frequency & MPEG_SAMPLING_FREQ_16000)		printf("16Khz ");	if (mpeg->frequency & MPEG_SAMPLING_FREQ_22050)		printf("22.05Khz ");	if (mpeg->frequency & MPEG_SAMPLING_FREQ_24000)		printf("24Khz ");	if (mpeg->frequency & MPEG_SAMPLING_FREQ_32000)		printf("32Khz ");	if (mpeg->frequency & MPEG_SAMPLING_FREQ_44100)		printf("44.1Khz ");	if (mpeg->frequency & MPEG_SAMPLING_FREQ_48000)		printf("48Khz ");	printf("\n\t\tCRC: %s", mpeg->crc ? "Yes" : "No");	printf("\n\t\tLayer: ");	if (mpeg->layer & MPEG_LAYER_MP1)		printf("1 ");	if (mpeg->layer & MPEG_LAYER_MP2)		printf("2 ");	if (mpeg->layer & MPEG_LAYER_MP3)		printf("3 ");	printf("\n\t\tBit Rate: ");	if (mpeg->bitrate & MPEG_BIT_RATE_FREE)		printf("Free format");	else {		if (mpeg->bitrate & MPEG_BIT_RATE_32000)			printf("32kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_40000)			printf("40kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_48000)			printf("48kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_56000)			printf("56kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_64000)			printf("64kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_80000)			printf("80kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_96000)			printf("96kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_112000)			printf("112kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_128000)			printf("128kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_160000)			printf("160kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_192000)			printf("192kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_224000)			printf("224kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_256000)			printf("256kbps ");		if (mpeg->bitrate & MPEG_BIT_RATE_320000)			printf("320kbps ");	}	printf("\n\t\tVBR: %s", mpeg->bitrate & MPEG_BIT_RATE_VBR ? "Yes" :		"No");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -