1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 // 18 // A2DP constants for Opus codec 19 // 20 21 #ifndef A2DP_VENDOR_OPUS_CONSTANTS_H 22 #define A2DP_VENDOR_OPUS_CONSTANTS_H 23 24 #define A2DP_OPUS_CODEC_LEN 9 25 26 #define A2DP_OPUS_CODEC_OUTPUT_CHS 2 27 #define A2DP_OPUS_CODEC_DEFAULT_SAMPLERATE 48000 28 #define A2DP_OPUS_CODEC_DEFAULT_FRAMESIZE 960 29 #define A2DP_OPUS_DECODE_BUFFER_LENGTH \ 30 (A2DP_OPUS_CODEC_OUTPUT_CHS * A2DP_OPUS_CODEC_DEFAULT_FRAMESIZE * 4) 31 32 // [Octet 0-3] Vendor ID 33 #define A2DP_OPUS_VENDOR_ID 0x000000E0 34 // [Octet 4-5] Vendor Specific Codec ID 35 #define A2DP_OPUS_CODEC_ID 0x0001 36 // [Octet 6], [Bits 0,1,2] Channel Mode 37 #define A2DP_OPUS_CHANNEL_MODE_MASK 0x07 38 #define A2DP_OPUS_CHANNEL_MODE_MONO 0x01 39 #define A2DP_OPUS_CHANNEL_MODE_STEREO 0x02 40 #define A2DP_OPUS_CHANNEL_MODE_DUAL_MONO 0x04 41 // [Octet 6], [Bits 3,4] Future 2, FrameSize 42 #define A2DP_OPUS_FRAMESIZE_MASK 0x18 43 #define A2DP_OPUS_10MS_FRAMESIZE 0x08 44 #define A2DP_OPUS_20MS_FRAMESIZE 0x10 45 // [Octet 6], [Bits 5] Sampling Frequency 46 #define A2DP_OPUS_SAMPLING_FREQ_MASK 0x80 47 #define A2DP_OPUS_SAMPLING_FREQ_48000 0x80 48 // [Octet 6], [Bits 6,7] Reserved 49 #define A2DP_OPUS_FUTURE_3 0x40 50 #define A2DP_OPUS_FUTURE_4 0x80 51 52 // Length of the Opus Media Payload header 53 #define A2DP_OPUS_MPL_HDR_LEN 1 54 55 #define A2DP_OPUS_OFFSET (AVDT_MEDIA_OFFSET + A2DP_OPUS_MPL_HDR_LEN) 56 57 #define A2DP_OPUS_HDR_F_MSK 0x80 58 #define A2DP_OPUS_HDR_S_MSK 0x40 59 #define A2DP_OPUS_HDR_L_MSK 0x20 60 #define A2DP_OPUS_HDR_NUM_MSK 0x0F 61 62 #endif 63