Skip to content
  • Andrey Semashev's avatar
    bluetooth: Add support for A2DP AAC codec. · c6de7044
    Andrey Semashev authored
    Advanced Audio Coding (AAC) is a lossy audio codec, which implements
    a number of audio encoding tools and provides good audio quality
    at relatively low bitrate. It is standardized as ISO/IEC 13818-7 (a.k.a.
    MPEG-2 Part 7) and ISO/IEC 14496-3 (a.k.a. MPEG-4 Part 3) specifications.
    It has gained wide adoption, including in Bluetooth A2DP devices.
    
    Bluetooth A2DP specification standardizes the following AAC profiles:
    
     - MPEG-2 AAC Low Complexity (AAC LC)
     - MPEG-4 AAC LC
     - MPEG-4 AAC Long Term Prediction (AAC LTP)
     - MPEG-4 AAC Scalable
    
    The former 3 are supported by this new PulseAudio codec for both decoding
    and encoding.
    
    AAC decoder is implemented in ffmpeg/libavcodec as a built-in decoder.
    
    AAC encoder is implemented in ffmpeg/libavcodec in two variants:
    
     - built-in encoder, which is available since ffmpeg 3.0 (we require
       ffmpeg 3.1 because it introduces the modern API for working with
       codecs)
     - optional encoder backed by libfdk-aac
    
    The A2DP codec is able to use either of these two encoders, with the
    preference of libfdk-aac as it provides better audio quality. The choice
    of the encoder to use is made at runtime and only depends on whether ffmpeg
    was built with libfdk-aac or not. It does not add a build dependency on
    libfdk-aac to PulseAudio.
    
    Due to license incompatibility, the PulseAudio+ffmpeg+libfdk-aac combination
    cannot be distributed in binary form in some jurisdictions but it can be built
    by users locally from source. For binary-only distributions the built-in
    encoder can be used.
    
    Note that MPEG-4 AAC Scalable is supported by libfdk-aac when the library
    is used through its API directly, but this is not implemented in this
    PulseAudio codec at this point.
    
    The A2DP encoder supports dynamic bitrate adaptation, which currently means
    the encoder is able to reduce the output bitrate based on a callback
    indicating transport congestion. Up to 4 bitrate reduction steps are
    available, each step is 32 kbit/s. The default initial bitrate depends
    on input sampling rate and channel count. For 48 kHz stereo and 44.1 kHz
    stereo it amounts to 320 kbit/s.
    c6de7044