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