docs: public static AudioFormat streamToAudioFormat(final StreamHeaderPacket header) {
      checkNotNull(header);
      checkArgument(header.type == StreamHeaderPacket.AUDIO);
  
      // Vars that go into the AudioFormat
      AudioFormat.Encoding encoding;
      float sampleRate = header.sampleRate.floatValue();
      int bits = 8;
      boolean bigEndian = false;
  
      final byte[] fourcc = header.fourcc;
  
      if (Arrays.equals(fourcc, new byte[] {'A', 'L', 'A', 'W'})) {
        encoding = AudioFormat.Encoding.ALAW;
  
      } else if (Arrays.equals(fourcc, new byte[] {'U', 'L', 'A', 'W'})) {
        encoding = AudioFormat.Encoding.ULAW;
  
      } else if (fourcc.length == 4) {
        byte type;
        byte interleaving;
  
        if (fourcc[0] == 'P') {
          bigEndian = false;
          type = fourcc[1];
          interleaving = fourcc[2];
          bits = fourcc[3];
        } else if (fourcc[3] == 'P') {
          bigEndian = true;
          type = fourcc[2];
          interleaving = fourcc[1];
          bits = fourcc[0];
        } else {
          throw new IllegalArgumentException(
              "unknown fourcc value: '" + fourccToString(fourcc) + "'");
        }
  
        if (interleaving != 'D') {
          throw new IllegalArgumentException(
              "unsupported interleaving '"
                  + interleaving
                  + "' in fourcc value '"
                  + fourccToString(fourcc)
                  + "'");
        }
  
        switch (type) {
          case 'S':
            encoding = AudioFormat.Encoding.PCM_SIGNED;
            break;
          case 'U':
            encoding = AudioFormat.Encoding.PCM_UNSIGNED;
            break;
          case 'F':
            encoding = AudioFormat.Encoding.PCM_FLOAT;
            break;
          default:
            throw new IllegalArgumentException(
                "unknown fourcc '" + fourccToString(fourcc) + "' type: " + type);
        }
      } else {
        throw new IllegalArgumentException("unknown fourcc value: '" + fourccToString(fourcc) + "'");
      }
  
      int frameSize = (bits * header.channels) / 8;
      float frameRate = sampleRate; // This may not be true for the compressed formats
  
      return new AudioFormat(
          encoding, sampleRate, bits, header.channels, frameSize, frameRate, bigEndian);
    }