1 /* $NetBSD$ */ 2 3 /*- 4 * Copyright (c) 2015 Nathanial Sloss <nathanialsloss@yahoo.com.au> 5 * 6 * This software is dedicated to the memory of - 7 * Baron James Anlezark (Barry) - 1 Jan 1949 - 13 May 2012. 8 * 9 * Barry was a man who loved his music. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions and the following disclaimer. 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in the 18 * documentation and/or other materials provided with the distribution. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 30 * POSSIBILITY OF SUCH DAMAGE. 31 */ 32 33 #ifndef _AVDTP_SIGNAL_H_ 34 #define _AVDTP_SIGNAL_H_ 35 36 #include <stdint.h> 37 #include <stdbool.h> 38 39 /* Our endpoint. */ 40 #define INTSEP 8 41 #define ACPSEP 8 42 43 /* AVDTP signals. */ 44 45 #define AVDTP_DISCOVER 0x01 46 #define AVDTP_GET_CAPABILITIES 0x02 47 #define AVDTP_SET_CONFIGURATION 0x03 48 #define AVDTP_GET_CONFIGURATION 0x04 49 #define AVDTP_RECONFIGURE 0x05 50 #define AVDTP_OPEN 0x06 51 #define AVDTP_START 0x07 52 #define AVDTP_CLOSE 0x08 53 #define AVDTP_SUSPEND 0x09 54 #define AVDTP_ABORT 0x0a 55 #define AVDTP_SECUURITY_CONTROL 0x0b 56 57 /* Signal Command & Response Header Masks. */ 58 59 #define TRANSACTIONLABEL 0xf0 60 #define TRANSACTIONLABEL_S 4 61 #define SIGNALID_MASK 0x3f 62 #define PACKETTYPE 0x0c 63 #define PACKETTYPE_S 0x02 64 #define MESSAGETYPE 0x03 65 #define SIGNALIDENTIFIER 0x3f 66 #define DISCOVER_SEP_IN_USE 0x02 67 #define DISCOVER_IS_SINK 0x08 68 69 /* Packet Types */ 70 #define singlePacket 0x0 71 #define startPacket 0x1 72 #define continuePacket 0x2 73 #define endPacket 0x3 74 75 /* Message Types */ 76 #define COMMAND 0x0 77 #define RESPONSEACCEPT 0x2 78 #define RESPONSEREJECT 0x3 79 80 /* Response general error/success lengths */ 81 #define AVDTP_LEN_SUCCESS 2 82 #define AVDTP_LEN_ERROR 3 83 84 /* Error codes */ 85 #define BAD_HEADER_FORMAT 0x01 86 #define BAD_LENGTH 0x11 87 #define BAD_ACP_SEID 0x12 88 #define SEP_IN_USE 0x13 89 #define SEP_NOT_IN_USE 0x14 90 #define BAD_SERV_CATAGORY 0x17 91 #define BAD_PAYLOAD_FORMAT 0x18 92 #define NOT_SUPPORTED_COMMAND 0x19 93 #define INVALID_CAPABILITIES 0x1a 94 95 #define BAD_RECOVERY_TYPE 0x22 96 #define BAD_MEDIA_TRANSPORT_FORMAT 0x23 97 #define BAD_RECOVERY_FORMAT 0x25 98 #define BAD_ROHC_FORMAT 0x26 99 #define BAD_CP_FORMAT 0x27 100 #define BAD_MULTIPLEXING_FORMAT 0x28 101 #define UNSUPPORTED_CONFIGURATION 0x29 102 #define BAD_STATE 0x31 103 104 /* Service Capabilities Field. */ 105 #define mediaTransport 0x1 106 #define reporting 0x2 107 #define recovery 0x3 108 #define contentProtection 0x4 109 #define headerCompression 0x5 110 #define multiplexing 0x6 111 #define mediaCodec 0x7 112 113 /* Media Codec Capabilities */ 114 #define mediaCodecSbc 0x00 115 #define mediaCodecMpeg1 0x01 116 #define mediaCodecMpeg2 0x02 117 118 #define SBC_CODEC_ID 0x0 119 #define mediaTypeAudio 0x0 120 121 struct bt_config; 122 123 int avdtpSendAccept(int, uint8_t, uint8_t); 124 int avdtpSendReject(int, uint8_t, uint8_t); 125 int avdtpSendDiscResponseAudio(int, uint8_t, uint8_t, uint8_t); 126 int avdtpDiscoverAndConfig(struct bt_config *, bool); 127 int avdtpSetConfiguration(int, uint8_t, uint8_t *, int); 128 int avdtpOpen(int, uint8_t); 129 int avdtpStart(int, uint8_t); 130 int avdtpClose(int, uint8_t); 131 int avdtpSuspend(int, uint8_t); 132 int avdtpAbort(int, uint8_t); 133 134 /* Return < 0 if error, processed signal otherwise. */ 135 int avdtpACPHandlePacket(struct bt_config *cfg); 136 /* Free state allocated in avdtpACPHandlePacket(), if any. */ 137 void avdtpACPFree(struct bt_config *cfg); 138 139 #endif /* _AVDTP_SIGNAL_H_ */ 140