Bluetooth A2DP & AVRCP Profiles bluez programming

 

Bluetooth A2DP & AVRCP Profiles
Understanding Advanced Audio Distribution & Remote Control in Bluetooth — with BlueZ Examples
Profile
A2DP + AVRCP
Stack
BlueZ / Linux
Layer
AVDTP / AVCTP
Codec
SBC (mandatory)

SEO Keywords:

Bluetooth A2DP profile Advanced Audio Distribution AVRCP profile SBC codec Bluetooth Bluetooth audio sink source AVDTP protocol Bluetooth AVCTP BlueZ audio streaming Bluetooth headphone Linux Bluetooth remote control

What Are Bluetooth Audio Profiles?

Hello students welcome to this free bluetooth development course by embedded pathashala, in this post i will explain you about Bluetooth A2DP & AVRCP Profiles, Bluetooth profiles are standardised rules that tell two devices how to talk to each other for a specific purpose. Think of them as agreements: one device says “I will stream stereo audio” and the other says “I will receive and play it.” Without a shared profile, two devices simply would not understand each other, even if they are both Bluetooth-enabled.

This article covers two tightly related profiles — A2DP (Advanced Audio Distribution Profile) and AVRCP (Audio/Video Remote Control Profile). Together they handle stereo music streaming and remote-control commands like play, pause, and skip track. Every Bluetooth headphone, speaker, and car audio system you have ever used relies on both of these profiles.

A2DP — Advanced Audio Distribution Profile

What Problem Does A2DP Solve?

Early Bluetooth could send voice calls wirelessly (thanks to the Hands-Free Profile), but voice calls use very narrow audio — they sound “telephone-quality.” If you tried to stream music that way, it would sound terrible. A2DP was designed specifically to handle high-quality stereo audio over Bluetooth, giving you CD-quality sound on wireless headphones and speakers.

One important distinction from Hands-Free: A2DP is one-directional only. Audio flows from the source (e.g., your phone) to the sink (e.g., your headphones). There is no return audio path. Hands-Free, on the other hand, is bi-directional because phone calls go both ways.

A2DP depends on two lower-level specifications: GAP (Generic Access Profile) and GAVDP (Generic Audio/Video Distribution Profile). GAP handles discoverability and connection setup; GAVDP provides the general framework for streaming audio or video data.

One-directional audio Stereo quality Depends on GAP + GAVDP Uses AVDTP transport

A2DP Roles: Source (SRC) and Sink (SNK)

A2DP defines exactly two roles. Every device in an A2DP connection plays one of them:

  • Source (SRC): The device that produces the audio stream. It encodes the raw audio samples and sends them over Bluetooth. Examples: a smartphone, laptop, or media player.
  • Sink (SNK): The device that receives the encoded audio, decodes it, and plays it back. Examples: wireless headphones, Bluetooth speaker, or car audio system.

A2DP Architecture — Source to Sink

📱 Mobile Phone
(Audio Source — SRC)
Application
(Audio Source)
↓ raw PCM samples
SBC Encoder
↓ encoded frames
AVDTP
L2CAP
Lower Layers
(ACL Link)

SBC Encoded
Audio Stream
ACL Bluetooth
Radio Link
SDP
Service
Discovery

🎧 Stereo Headphone
(Audio Sink — SNK)
Lower Layers
(ACL Link)
↑ encoded frames
L2CAP
AVDTP
↑ encoded frames
SBC Decoder
↑ PCM to speaker
Application
(Audio Sink)

In the diagram above, the mobile phone (SRC) takes raw audio samples from the music app, compresses them with the SBC codec, hands the encoded packets to AVDTP, which transports them over L2CAP and the ACL radio link to the headphone (SNK). The headphone reverses the process — AVDTP receives, SBC decoder decompresses, and the audio plays through the speakers.

Real-World A2DP Use Cases

The A2DP spec lists these everyday examples to help you understand which device is the SRC and which is the SNK:

Use Case Source (SRC) Sink (SNK)
Play music from laptop to Bluetooth speaker 💻 Laptop 🔊 Bluetooth Speaker
Stream phone music to car stereo 📱 Mobile Phone 🚗 Car Audio System
Wireless headphone music listening 📱 Smartphone 🎧 Stereo Headphones

Note on point-to-multipoint: A2DP does not natively support sending audio to multiple sinks at once. However, you can achieve this by creating two separate A2DP connections and routing the same audio stream over both connections simultaneously. This is sometimes called “Bluetooth audio broadcasting” in practice.

A2DP Codecs — How Audio Gets Compressed

Raw (uncompressed) audio is enormous. A 48 kHz, 16-bit stereo audio stream needs about 1.5 Mbps of bandwidth. Bluetooth’s ACL link typically provides far less than that for a single connection, so A2DP encodes (compresses) the audio before sending it. On the receiving side, it is decoded back to raw audio. This happens in real time, with very low delay.

A2DP supports several codec options:

SBC MANDATORY

Sub-Band Codec. The default codec that every A2DP device must support. It is intentionally simple — low CPU usage, low memory footprint, and real-time encoding/decoding. Supports sampling rates from 16 kHz up to 48 kHz. At 48 kHz, SBC delivers CD-quality audio. Perfect for headphones with limited processing power.

MPEG-1/2 Audio OPTIONAL

The same family as MP3. Higher quality than SBC at the same bitrate, but needs more processing power. Not all devices implement it.

MPEG-2/4 AAC OPTIONAL

AAC is used by Apple devices. Better compression efficiency than MP3. iPhones and AirPods use AAC as the preferred codec when connected to Apple hardware.

ATRAC Family OPTIONAL

Sony’s proprietary codec, historically used in MiniDisc players and Sony Walkmans. Optional and rarely seen outside Sony devices.

Non-A2DP (Vendor) Codecs OPTIONAL

A2DP allows vendors to plug in their own proprietary codecs. This is how aptX (Qualcomm), aptX HD, aptX Adaptive, and LDAC (Sony) work. These codecs offer significantly better sound quality than SBC but require both devices to support the same codec.

Deep Dive: How SBC Works (Sub-Band Codec)

SBC (Sub-Band Codec) was specifically designed for the constraints of Bluetooth devices — small memory, low CPU power, and battery-sensitive operation. Here is a simplified explanation of what it does:

  1. Sub-band filtering: The audio frequency range (e.g., 20 Hz to 20 kHz) is split into 4 or 8 frequency bands using a filter bank.
  2. Quantisation: Each band’s samples are quantised (rounded) with a number of bits proportional to how important that frequency range is to human hearing.
  3. Bit allocation: More bits are given to frequency bands that carry more perceptible information, and fewer bits to ranges humans barely notice.
  4. Framing: The quantised values are packed into SBC frames and handed to AVDTP for transmission.

The result is a stream that is typically 3–5× smaller than the original PCM audio, at quality that is very close to CD audio for casual listening.

BlueZ SBC configuration structure (from the BlueZ source):

/* From BlueZ sbc/sbc.h — SBC codec configuration */
typedef struct {
    uint8_t frequency;      /* Sampling frequency: 16000, 32000, 44100, 48000 Hz */
    uint8_t blocks;         /* Number of blocks: 4, 8, 12, or 16 */
    uint8_t subbands;       /* Number of sub-bands: 4 or 8 */
    uint8_t mode;           /* Channel mode: MONO, DUAL_CHANNEL, STEREO, JOINT_STEREO */
    uint8_t allocation;     /* Bit allocation: LOUDNESS or SNR */
    uint8_t min_bitpool;    /* Minimum bitpool value (controls quality) */
    uint8_t max_bitpool;    /* Maximum bitpool value */
} sbc_t;

A higher max_bitpool value means higher quality but more bandwidth. A typical stereo stream at 44.1 kHz uses a bitpool of around 53, giving roughly 328 kbps.

Step-by-Step: Audio Data Flow in A2DP
A2DP Audio Data Flow — Source Side to Sink Side

SOURCE DEVICE (e.g., Phone)
1 Music app generates raw PCM audio samples (e.g., 44100 samples/sec, 16-bit stereo)
2 SBC codec encodes the samples into compressed SBC frames (much smaller)
3 AVDTP layer wraps frames into RTP packets and sends them via L2CAP
4 ACL Bluetooth radio link transmits the data wirelessly to the Sink

━━━━━━━━━━━━━━━━━━━━━━━━━━ 📶 ━━━━━━━━━━━━━━━━━━━━━━━━━━

SINK DEVICE (e.g., Headphone)
5 ACL radio receives packets and passes up through L2CAP to AVDTP
6 SBC decoder decompresses the frames back to raw PCM audio samples
7 Audio sink application feeds the PCM samples to the DAC and speakers 🔊

AVRCP — Audio/Video Remote Control Profile

What Problem Does AVRCP Solve?

Imagine you are listening to music on your phone via Bluetooth headphones while jogging. Your phone is in your pocket. You want to skip to the next track — but you do not want to pull your phone out. AVRCP is exactly the profile that allows your headphone to send a “next track” command to your phone, and your phone to respond by changing the song.

AVRCP standardises how control commands (play, pause, stop, volume up, next track, etc.) are exchanged between Bluetooth devices. Think of it as the Bluetooth version of a TV remote control.

AVRCP depends only on GAP (Generic Access Profile). Unlike A2DP which uses AVDTP for data transport, AVRCP uses AVCTP (Audio/Video Control Transport Protocol) to carry its commands.

Remote control over Bluetooth Uses AVCTP transport Depends on GAP AV/C command set

AVRCP Roles: Controller (CT) and Target (TG)

Just like A2DP, AVRCP defines two roles for every connection:

  • Controller (CT): The device that initiates a command. It decides what action to request. Example: a Bluetooth headphone pressing the “pause” button sends a command to the phone.
  • Target (TG): The device that receives the command, executes it, and sends back a response (success or failure). Example: the phone receives “pause” and pauses the music player.

AVRCP Architecture — Controller to Target

🎧 Headphone
(Controller — CT)
Application
(Controller)
↓ AVRCP command
AVCTP
L2CAP
Lower Layers

AVRCP Command
(e.g., PAUSE)
Response
(ACCEPTED)
SDP
Service
Discovery

📱 Mobile Phone
(Target — TG)
Lower Layers
L2CAP
AVCTP
Application
(Target)

Notice the two-way arrows in the middle — AVRCP is a request–response protocol. The controller sends a command and the target sends back a confirmation. This way the controller knows whether its request was actually carried out.

AVRCP Commands — The Full List

AVRCP covers a wide range of control operations. Not every device has to support all of them — a simple headphone button might only implement play/pause, while a full home-theatre controller could support all of the following:

▶ Play ⏸ Pause ⏹ Stop ⏩ Fast Forward ⏪ Rewind 🔊 Volume Up 🔉 Volume Down 🔇 Mute 📺 Channel Up 📺 Channel Down ℹ Unit/Subunit Info

The “Unit/Subunit Info” command is interesting — it lets one device ask another device what type it is (e.g., Player/Recorder, Monitor/Amplifier, Tuner) and what sub-units it contains. This allows auto-discovery of capabilities, similar to how SDP (Service Discovery Protocol) works at the Bluetooth level.

Real-World AVRCP Use Cases
Use Case Controller (CT) Target (TG)
Headphone skip-track button 🎧 Headphone 📱 Phone (music app)
PC controls DVD player 💻 PC 📀 DVD Player
Car steering-wheel button controls phone 🚗 Car Steering Controls 📱 Smartphone

AV/C Command Set — Borrowed from IEEE 1394

AVRCP does not invent its own command language from scratch. Instead, it borrows the AV/C command set from the IEEE 1394 (FireWire) trade association specification. This is a great example of how Bluetooth reuses existing, proven industry standards instead of reinventing the wheel.

The AV/C (Audio/Video Control) command set defines a structured way to send commands to audio and video equipment. Commands are organised by “unit” and “subunit” type — you first identify what kind of device you’re talking to, then you send the appropriate command for that device type. This makes AVRCP work cleanly across a very wide variety of device types.

A2DP + AVRCP Working Together

In nearly every real Bluetooth audio product, A2DP and AVRCP are deployed together as a pair. A2DP handles the audio stream; AVRCP handles the control commands. Here is how they interact in a typical “headphone + phone” scenario:

A2DP + AVRCP Combined Flow
A2DP Stream ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━▶ 🎵 Audio playing in headphone
AVRCP CMD ◀━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ⏭ User presses Next Track
AVRCP RSP ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━▶ ✅ Phone accepts command
A2DP Stream ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━▶ 🎵 New track audio begins

The A2DP stream runs continuously. When the user presses next track on the headphone, AVRCP sends the command over a completely separate logical channel (AVCTP, not AVDTP). The phone processes it, switches tracks, and the new audio automatically flows back through the existing A2DP stream. The two profiles are independent but complementary.

Summary — Key Takeaways
A2DP

  • One-directional stereo audio
  • Source (SRC) → Sink (SNK)
  • Uses AVDTP over L2CAP
  • SBC codec is mandatory
  • Depends on GAP + GAVDP
AVRCP

  • Two-way remote control commands
  • Controller (CT) → Target (TG)
  • Uses AVCTP over L2CAP
  • Borrows AV/C command set
  • Depends on GAP only

Continue Learning Bluetooth

This article is part of a full Bluetooth development series covering profiles, BlueZ stack, and BLE.

Next: BlueZ Setup & hciconfig Back to Bluetooth Overview

Leave a Reply

Your email address will not be published. Required fields are marked *