APPL_TRACE_DEBUG("%s: peer %s handle:%d local_sep:%d", __func__,
p_scb->peer_addr.ToString().c_str(), p_scb->hndl, local_sep);
- A2DP_DumpCodecInfo(p_evt_cfg->codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_evt_cfg->codec_info).c_str());
memcpy(p_scb->cfg.codec_info, p_evt_cfg->codec_info, AVDT_CODEC_SIZE);
bta_av_save_addr(p_scb, p_data->str_msg.bd_addr);
"%s: peer %s handle:%d num_seps:%d sep_info_idx:%d wait:0x%x", __func__,
p_scb->peer_addr.ToString().c_str(), p_scb->hndl, p_scb->num_seps,
p_scb->sep_info_idx, p_scb->wait);
- A2DP_DumpCodecInfo(p_scb->peer_cap.codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->peer_cap.codec_info).c_str());
cfg = p_scb->peer_cap;
/* let application know the capability of the SNK */
p_scb->sep_info_idx++;
APPL_TRACE_DEBUG("%s: result: sep_info_idx:%d", __func__,
p_scb->sep_info_idx);
- A2DP_DumpCodecInfo(cfg.codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(cfg.codec_info).c_str());
if (p_scb->num_seps > p_scb->sep_info_idx) {
/* Some devices have seps at the end of the discover list, which is not */
p_scb->peer_cap.num_codec);
APPL_TRACE_DEBUG("%s: media type 0x%x, 0x%x", __func__, media_type,
p_scb->media_type);
- A2DP_DumpCodecInfo(p_scb->cfg.codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str());
/* if codec present and we get a codec configuration */
if ((p_scb->peer_cap.num_codec != 0) && (media_type == p_scb->media_type) &&
APPL_TRACE_DEBUG("%s: result: sep_info_idx=%d", __func__,
p_scb->sep_info_idx);
- A2DP_DumpCodecInfo(p_scb->cfg.codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str());
APPL_TRACE_DEBUG("%s: initiator UUID = 0x%x", __func__, uuid_int);
if (uuid_int == UUID_SERVCLASS_AUDIO_SOURCE)
APPL_TRACE_DEBUG(
"%s: p_scb->sep_info_idx=%d p_scb->rcfg_idx=%d p_rcfg->sep_info_idx=%d",
__func__, p_scb->sep_info_idx, p_scb->rcfg_idx, p_rcfg->sep_info_idx);
- A2DP_DumpCodecInfo(p_scb->peer_cap.codec_info);
- A2DP_DumpCodecInfo(p_scb->cfg.codec_info);
- A2DP_DumpCodecInfo(p_rcfg->codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->peer_cap.codec_info).c_str());
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str());
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_rcfg->codec_info).c_str());
p_cfg->num_protect = p_rcfg->num_protect;
memcpy(p_cfg->codec_info, p_rcfg->codec_info, AVDT_CODEC_SIZE);
} else {
// Reconfigure
APPL_TRACE_DEBUG("%s: reconfig", __func__);
- A2DP_DumpCodecInfo(p_scb->cfg.codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str());
AVDT_ReconfigReq(p_scb->avdt_handle, &p_scb->cfg);
p_scb->cfg.psc_mask = p_scb->cur_psc_mask;
}
APPL_TRACE_DEBUG("%s: calling AVDT_ReconfigReq", __func__);
/* reconfig the stream */
- A2DP_DumpCodecInfo(p_scb->cfg.codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str());
AVDT_ReconfigReq(p_scb->avdt_handle, &p_scb->cfg);
p_scb->cfg.psc_mask = p_scb->cur_psc_mask;
}
BTA_AV_NUM_SEPS, &bta_av_proc_stream_evt);
} else {
APPL_TRACE_DEBUG("%s: calling AVDT_OpenReq()", __func__);
- A2DP_DumpCodecInfo(p_scb->cfg.codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->cfg.codec_info).c_str());
/* we may choose to use a different SEP at reconfig.
* adjust the sep_idx now */
APPL_TRACE_DEBUG("%s: num_protect:0x%02x protect_info:0x%02x%02x%02x",
__func__, *p_num_protect, p_protect_info[0],
p_protect_info[1], p_protect_info[2]);
- A2DP_DumpCodecInfo(p_codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_codec_info).c_str());
// Find the peer
BtaAvCoPeer* p_peer = FindPeerAndUpdate(bta_av_handle, peer_address);
APPL_TRACE_DEBUG("%s: num_protect:0x%02x protect_info:0x%02x%02x%02x",
__func__, *p_num_protect, p_protect_info[0],
p_protect_info[1], p_protect_info[2]);
- A2DP_DumpCodecInfo(p_codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_codec_info).c_str());
// Find the peer
BtaAvCoPeer* p_peer = FindPeerAndUpdate(bta_av_handle, peer_address);
APPL_TRACE_DEBUG("%s: num_protect:0x%02x protect_info:0x%02x%02x%02x",
__func__, num_protect, p_protect_info[0], p_protect_info[1],
p_protect_info[2]);
- A2DP_DumpCodecInfo(p_codec_info);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_codec_info).c_str());
// Find the peer
BtaAvCoPeer* p_peer = FindPeerAndUpdate(bta_av_handle, peer_address);
uint8_t num_protect,
const uint8_t* p_protect_info) {
APPL_TRACE_DEBUG("%s: peer %s", __func__, p_peer->addr.ToString().c_str());
- A2DP_DumpCodecInfo(new_codec_config);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(new_codec_config).c_str());
std::lock_guard<std::recursive_mutex> lock(codec_lock_);
APPL_TRACE_DEBUG("%s: peer_address=%s", __func__,
p_peer->addr.ToString().c_str());
- A2DP_DumpCodecInfo(p_ota_codec_config);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_ota_codec_config).c_str());
*p_restart_output = false;
if (restart_output) {
APPL_TRACE_DEBUG("%s: restart output", __func__);
- A2DP_DumpCodecInfo(result_codec_config);
+ APPL_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(result_codec_config).c_str());
*p_restart_output = true;
p_peer->p_sink = p_sink;
#include <sstream>
#include <type_traits>
+#include <base/logging.h>
+
/* Prints intergral parameter x as hex string, with '0' fill */
template <typename T>
std::string loghex(T x) {
return tmp.str();
}
+/**
+ * Append a field name to a string.
+ *
+ * The field names are added to the string with "|" in between.
+ *
+ * @param p_result a pointer to the result string to add the field name to
+ * @param append if true the field name will be added
+ * @param name the field name to add
+ * @return the result string
+ */
+inline std::string& AppendField(std::string* p_result, bool append,
+ const std::string& name) {
+ CHECK(p_result != nullptr);
+ if (!append) return *p_result;
+ if (!p_result->empty()) *p_result += "|";
+ *p_result += name;
+ return *p_result;
+}
+
#endif
return true;
}
-bool A2DP_DumpCodecInfoAac(const uint8_t* p_codec_info) {
+std::string A2DP_CodecInfoStringAac(const uint8_t* p_codec_info) {
+ std::stringstream res;
+ std::string field;
tA2DP_STATUS a2dp_status;
tA2DP_AAC_CIE aac_cie;
- LOG_VERBOSE(LOG_TAG, "%s", __func__);
-
a2dp_status = A2DP_ParseInfoAac(&aac_cie, p_codec_info, true);
if (a2dp_status != A2DP_SUCCESS) {
- LOG_ERROR(LOG_TAG, "%s: A2DP_ParseInfoAac fail:%d", __func__, a2dp_status);
- return false;
- }
-
- LOG_VERBOSE(LOG_TAG, "\tobjectType: 0x%x", aac_cie.objectType);
- if (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG2_LC) {
- LOG_VERBOSE(LOG_TAG, "\tobjectType: (MPEG-2 AAC LC)");
- }
- if (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG4_LC) {
- LOG_VERBOSE(LOG_TAG, "\tobjectType: (MPEG-4 AAC LC)");
- }
- if (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG4_LTP) {
- LOG_VERBOSE(LOG_TAG, "\tobjectType: (MPEG-4 AAC LTP)");
- }
- if (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG4_SCALABLE) {
- LOG_VERBOSE(LOG_TAG, "\tobjectType: (MPEG-4 AAC Scalable)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: 0x%x", aac_cie.sampleRate);
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_8000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (8000)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_11025) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (11025)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_12000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (12000)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_16000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (16000)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_22050) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (22050)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_24000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (24000)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_32000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (32000)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_44100) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (44100)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_48000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (48000)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_64000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (64000)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_88200) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (88200)");
- }
- if (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_96000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (96000)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tch_mode: 0x%x", aac_cie.channelMode);
- if (aac_cie.channelMode == A2DP_AAC_CHANNEL_MODE_MONO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Mono)");
- }
- if (aac_cie.channelMode == A2DP_AAC_CHANNEL_MODE_STEREO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Stereo)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tvariableBitRateSupport: %s",
- (aac_cie.variableBitRateSupport != 0) ? "true" : "false");
-
- LOG_VERBOSE(LOG_TAG, "\tbitRate: %u", aac_cie.bitRate);
-
- return true;
+ res << "A2DP_ParseInfoAac fail: " << loghex(a2dp_status);
+ return res.str();
+ }
+
+ res << "\tname: AAC\n";
+
+ // Object type
+ field.clear();
+ AppendField(&field, (aac_cie.objectType == 0), "NONE");
+ AppendField(&field, (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG2_LC),
+ "(MPEG-2 AAC LC)");
+ AppendField(&field, (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG4_LC),
+ "(MPEG-4 AAC LC)");
+ AppendField(&field, (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG4_LTP),
+ "(MPEG-4 AAC LTP)");
+ AppendField(&field,
+ (aac_cie.objectType & A2DP_AAC_OBJECT_TYPE_MPEG4_SCALABLE),
+ "(MPEG-4 AAC Scalable)");
+ res << "\tobjectType: " << field << " (" << loghex(aac_cie.objectType)
+ << ")\n";
+
+ // Sample frequency
+ field.clear();
+ AppendField(&field, (aac_cie.sampleRate == 0), "NONE");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_8000),
+ "8000");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_11025),
+ "11025");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_12000),
+ "12000");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_16000),
+ "16000");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_22050),
+ "22050");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_24000),
+ "24000");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_32000),
+ "32000");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_44100),
+ "44100");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_48000),
+ "48000");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_64000),
+ "64000");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_88200),
+ "88200");
+ AppendField(&field, (aac_cie.sampleRate & A2DP_AAC_SAMPLING_FREQ_96000),
+ "96000");
+ res << "\tsamp_freq: " << field << " (" << loghex(aac_cie.sampleRate)
+ << ")\n";
+
+ // Channel mode
+ field.clear();
+ AppendField(&field, (aac_cie.channelMode == 0), "NONE");
+ AppendField(&field, (aac_cie.channelMode == A2DP_AAC_CHANNEL_MODE_MONO),
+ "Mono");
+ AppendField(&field, (aac_cie.channelMode == A2DP_AAC_CHANNEL_MODE_STEREO),
+ "Stereo");
+ res << "\tch_mode: " << field << " (" << loghex(aac_cie.channelMode) << ")\n";
+
+ // Variable bit rate support
+ res << "\tvariableBitRateSupport: " << std::boolalpha
+ << (aac_cie.variableBitRateSupport != 0) << "\n";
+
+ // Bit rate
+ res << "\tbitRate: " << std::to_string(aac_cie.bitRate) << "\n";
+
+ return res.str();
}
const tA2DP_ENCODER_INTERFACE* A2DP_GetEncoderInterfaceAac(
return false;
}
-bool A2DP_DumpCodecInfo(const uint8_t* p_codec_info) {
+std::string A2DP_CodecInfoString(const uint8_t* p_codec_info) {
tA2DP_CODEC_TYPE codec_type = A2DP_GetCodecType(p_codec_info);
- LOG_VERBOSE(LOG_TAG, "%s: codec_type = 0x%x", __func__, codec_type);
-
switch (codec_type) {
case A2DP_MEDIA_CT_SBC:
- return A2DP_DumpCodecInfoSbc(p_codec_info);
+ return A2DP_CodecInfoStringSbc(p_codec_info);
case A2DP_MEDIA_CT_AAC:
- return A2DP_DumpCodecInfoAac(p_codec_info);
+ return A2DP_CodecInfoStringAac(p_codec_info);
case A2DP_MEDIA_CT_NON_A2DP:
- return A2DP_VendorDumpCodecInfo(p_codec_info);
+ return A2DP_VendorCodecInfoString(p_codec_info);
default:
break;
}
- LOG_ERROR(LOG_TAG, "%s: unsupported codec type 0x%x", __func__, codec_type);
- return false;
+ return "Unsupported codec type: " + loghex(codec_type);
}
return true;
}
-bool A2DP_DumpCodecInfoSbc(const uint8_t* p_codec_info) {
+std::string A2DP_CodecInfoStringSbc(const uint8_t* p_codec_info) {
+ std::stringstream res;
+ std::string field;
tA2DP_STATUS a2dp_status;
tA2DP_SBC_CIE sbc_cie;
- LOG_VERBOSE(LOG_TAG, "%s", __func__);
-
a2dp_status = A2DP_ParseInfoSbc(&sbc_cie, p_codec_info, true);
if (a2dp_status != A2DP_SUCCESS) {
- LOG_ERROR(LOG_TAG, "%s: A2DP_ParseInfoSbc fail:%d", __func__, a2dp_status);
- return false;
- }
-
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: 0x%x", sbc_cie.samp_freq);
- if (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_16) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (16000)");
- }
- if (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_32) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (32000)");
- }
- if (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_44) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (44100)");
- }
- if (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_48) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (48000)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tch_mode: 0x%x", sbc_cie.ch_mode);
- if (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_MONO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Mono)");
- }
- if (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_DUAL) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Dual)");
- }
- if (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_STEREO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Stereo)");
- }
- if (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_JOINT) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Joint)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tblock_len: 0x%x", sbc_cie.block_len);
- if (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_4) {
- LOG_VERBOSE(LOG_TAG, "\tblock_len: (4)");
- }
- if (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_8) {
- LOG_VERBOSE(LOG_TAG, "\tblock_len: (8)");
- }
- if (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_12) {
- LOG_VERBOSE(LOG_TAG, "\tblock_len: (12)");
- }
- if (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_16) {
- LOG_VERBOSE(LOG_TAG, "\tblock_len: (16)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tnum_subbands: 0x%x", sbc_cie.num_subbands);
- if (sbc_cie.num_subbands & A2DP_SBC_IE_SUBBAND_4) {
- LOG_VERBOSE(LOG_TAG, "\tnum_subbands: (4)");
- }
- if (sbc_cie.num_subbands & A2DP_SBC_IE_SUBBAND_8) {
- LOG_VERBOSE(LOG_TAG, "\tnum_subbands: (8)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\talloc_method: 0x%x)", sbc_cie.alloc_method);
- if (sbc_cie.alloc_method & A2DP_SBC_IE_ALLOC_MD_S) {
- LOG_VERBOSE(LOG_TAG, "\talloc_method: (SNR)");
- }
- if (sbc_cie.alloc_method & A2DP_SBC_IE_ALLOC_MD_L) {
- LOG_VERBOSE(LOG_TAG, "\talloc_method: (Loundess)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tBit pool Min:%d Max:%d", sbc_cie.min_bitpool,
- sbc_cie.max_bitpool);
-
- return true;
+ res << "A2DP_ParseInfoSbc fail: " << loghex(a2dp_status);
+ return res.str();
+ }
+
+ res << "\tname: SBC\n";
+
+ // Sample frequency
+ field.clear();
+ AppendField(&field, (sbc_cie.samp_freq == 0), "NONE");
+ AppendField(&field, (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_16), "16000");
+ AppendField(&field, (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_32), "32000");
+ AppendField(&field, (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_44), "44100");
+ AppendField(&field, (sbc_cie.samp_freq & A2DP_SBC_IE_SAMP_FREQ_48), "48000");
+ res << "\tsamp_freq: " << field << " (" << loghex(sbc_cie.samp_freq) << ")\n";
+
+ // Channel mode
+ field.clear();
+ AppendField(&field, (sbc_cie.ch_mode == 0), "NONE");
+ AppendField(&field, (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_MONO), "Mono");
+ AppendField(&field, (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_DUAL), "Dual");
+ AppendField(&field, (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_STEREO), "Stereo");
+ AppendField(&field, (sbc_cie.ch_mode & A2DP_SBC_IE_CH_MD_JOINT), "Joint");
+ res << "\tch_mode: " << field << " (" << loghex(sbc_cie.ch_mode) << ")\n";
+
+ // Block length
+ field.clear();
+ AppendField(&field, (sbc_cie.block_len == 0), "NONE");
+ AppendField(&field, (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_4), "4");
+ AppendField(&field, (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_8), "8");
+ AppendField(&field, (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_12), "12");
+ AppendField(&field, (sbc_cie.block_len & A2DP_SBC_IE_BLOCKS_16), "16");
+ res << "\tblock_len: " << field << " (" << loghex(sbc_cie.block_len) << ")\n";
+
+ // Number of subbands
+ field.clear();
+ AppendField(&field, (sbc_cie.num_subbands == 0), "NONE");
+ AppendField(&field, (sbc_cie.num_subbands & A2DP_SBC_IE_SUBBAND_4), "4");
+ AppendField(&field, (sbc_cie.num_subbands & A2DP_SBC_IE_SUBBAND_8), "8");
+ res << "\tnum_subbands: " << field << " (" << loghex(sbc_cie.num_subbands)
+ << ")\n";
+
+ // Allocation method
+ field.clear();
+ AppendField(&field, (sbc_cie.alloc_method == 0), "NONE");
+ AppendField(&field, (sbc_cie.alloc_method & A2DP_SBC_IE_ALLOC_MD_S), "SNR");
+ AppendField(&field, (sbc_cie.alloc_method & A2DP_SBC_IE_ALLOC_MD_L),
+ "Loundess");
+ res << "\talloc_method: " << field << " (" << loghex(sbc_cie.alloc_method)
+ << ")\n";
+
+ // Min/max bitloop
+ res << "\tBit pool Min: " << std::to_string(sbc_cie.min_bitpool)
+ << " Max: " << std::to_string(sbc_cie.max_bitpool);
+
+ return res.str();
}
const tA2DP_ENCODER_INTERFACE* A2DP_GetEncoderInterfaceSbc(
return false;
}
-bool A2DP_VendorDumpCodecInfo(const uint8_t* p_codec_info) {
+std::string A2DP_VendorCodecInfoString(const uint8_t* p_codec_info) {
uint32_t vendor_id = A2DP_VendorCodecGetVendorId(p_codec_info);
uint16_t codec_id = A2DP_VendorCodecGetCodecId(p_codec_info);
// Check for aptX
if (vendor_id == A2DP_APTX_VENDOR_ID &&
codec_id == A2DP_APTX_CODEC_ID_BLUETOOTH) {
- return A2DP_VendorDumpCodecInfoAptx(p_codec_info);
+ return A2DP_VendorCodecInfoStringAptx(p_codec_info);
}
// Check for aptX-HD
if (vendor_id == A2DP_APTX_HD_VENDOR_ID &&
codec_id == A2DP_APTX_HD_CODEC_ID_BLUETOOTH) {
- return A2DP_VendorDumpCodecInfoAptxHd(p_codec_info);
+ return A2DP_VendorCodecInfoStringAptxHd(p_codec_info);
}
// Check for LDAC
if (vendor_id == A2DP_LDAC_VENDOR_ID && codec_id == A2DP_LDAC_CODEC_ID) {
- return A2DP_VendorDumpCodecInfoLdac(p_codec_info);
+ return A2DP_VendorCodecInfoStringLdac(p_codec_info);
}
// Add checks based on <vendor_id, codec_id>
- return false;
+ return "Unsupported codec vendor_id: " + loghex(vendor_id) +
+ " codec_id: " + loghex(codec_id);
}
return true;
}
-bool A2DP_VendorDumpCodecInfoAptx(const uint8_t* p_codec_info) {
+std::string A2DP_VendorCodecInfoStringAptx(const uint8_t* p_codec_info) {
+ std::stringstream res;
+ std::string field;
tA2DP_STATUS a2dp_status;
tA2DP_APTX_CIE aptx_cie;
- LOG_VERBOSE(LOG_TAG, "%s", __func__);
-
a2dp_status = A2DP_ParseInfoAptx(&aptx_cie, p_codec_info, true);
if (a2dp_status != A2DP_SUCCESS) {
- LOG_ERROR(LOG_TAG, "%s: A2DP_ParseInfoAptx fail:%d", __func__, a2dp_status);
- return false;
- }
-
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: 0x%x", aptx_cie.sampleRate);
- if (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_44100) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (44100)");
- }
- if (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_48000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (48000)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tch_mode: 0x%x", aptx_cie.channelMode);
- if (aptx_cie.channelMode & A2DP_APTX_CHANNELS_MONO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Mono)");
- }
- if (aptx_cie.channelMode & A2DP_APTX_CHANNELS_STEREO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Stereo)");
- }
-
- return true;
+ res << "A2DP_ParseInfoAptx fail: " << loghex(a2dp_status);
+ return res.str();
+ }
+
+ res << "\tname: aptX\n";
+
+ // Sample frequency
+ field.clear();
+ AppendField(&field, (aptx_cie.sampleRate == 0), "NONE");
+ AppendField(&field, (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_44100),
+ "44100");
+ AppendField(&field, (aptx_cie.sampleRate & A2DP_APTX_SAMPLERATE_48000),
+ "48000");
+ res << "\tsamp_freq: " << field << " (" << loghex(aptx_cie.sampleRate)
+ << ")\n";
+
+ // Channel mode
+ field.clear();
+ AppendField(&field, (aptx_cie.channelMode == 0), "NONE");
+ AppendField(&field, (aptx_cie.channelMode & A2DP_APTX_CHANNELS_MONO), "Mono");
+ AppendField(&field, (aptx_cie.channelMode & A2DP_APTX_CHANNELS_STEREO),
+ "Stereo");
+ res << "\tch_mode: " << field << " (" << loghex(aptx_cie.channelMode)
+ << ")\n";
+
+ return res.str();
}
const tA2DP_ENCODER_INTERFACE* A2DP_VendorGetEncoderInterfaceAptx(
return true;
}
-bool A2DP_VendorDumpCodecInfoAptxHd(const uint8_t* p_codec_info) {
+std::string A2DP_VendorCodecInfoStringAptxHd(const uint8_t* p_codec_info) {
+ std::stringstream res;
+ std::string field;
tA2DP_STATUS a2dp_status;
tA2DP_APTX_HD_CIE aptx_hd_cie;
- LOG_VERBOSE(LOG_TAG, "%s", __func__);
-
a2dp_status = A2DP_ParseInfoAptxHd(&aptx_hd_cie, p_codec_info, true);
if (a2dp_status != A2DP_SUCCESS) {
- LOG_ERROR(LOG_TAG, "%s: A2DP_ParseInfoAptxHd fail:%d", __func__,
- a2dp_status);
- return false;
- }
-
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: 0x%x", aptx_hd_cie.sampleRate);
- if (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_44100) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (44100)");
- }
- if (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_48000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (48000)");
- }
-
- LOG_VERBOSE(LOG_TAG, "\tch_mode: 0x%x", aptx_hd_cie.channelMode);
- if (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_MONO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Mono)");
- }
- if (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_STEREO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Stereo)");
- }
-
- return true;
+ res << "A2DP_ParseInfoAptxHd fail: " << loghex(a2dp_status);
+ return res.str();
+ }
+
+ res << "\tname: aptX-HD\n";
+
+ // Sample frequency
+ field.clear();
+ AppendField(&field, (aptx_hd_cie.sampleRate == 0), "NONE");
+ AppendField(&field, (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_44100),
+ "44100");
+ AppendField(&field, (aptx_hd_cie.sampleRate & A2DP_APTX_HD_SAMPLERATE_48000),
+ "48000");
+ res << "\tsamp_freq: " << field << " (" << loghex(aptx_hd_cie.sampleRate)
+ << ")\n";
+
+ // Channel mode
+ field.clear();
+ AppendField(&field, (aptx_hd_cie.channelMode == 0), "NONE");
+ AppendField(&field, (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_MONO),
+ "Mono");
+ AppendField(&field, (aptx_hd_cie.channelMode & A2DP_APTX_HD_CHANNELS_STEREO),
+ "Stereo");
+ res << "\tch_mode: " << field << " (" << loghex(aptx_hd_cie.channelMode)
+ << ")\n";
+
+ return res.str();
}
const tA2DP_ENCODER_INTERFACE* A2DP_VendorGetEncoderInterfaceAptxHd(
return true;
}
-bool A2DP_VendorDumpCodecInfoLdac(const uint8_t* p_codec_info) {
+std::string A2DP_VendorCodecInfoStringLdac(const uint8_t* p_codec_info) {
+ std::stringstream res;
+ std::string field;
tA2DP_STATUS a2dp_status;
tA2DP_LDAC_CIE ldac_cie;
- LOG_VERBOSE(LOG_TAG, "%s", __func__);
-
a2dp_status = A2DP_ParseInfoLdac(&ldac_cie, p_codec_info, true);
if (a2dp_status != A2DP_SUCCESS) {
- LOG_ERROR(LOG_TAG, "%s: A2DP_ParseInfoLdac fail:%d", __func__, a2dp_status);
- return false;
- }
-
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: 0x%x", ldac_cie.sampleRate);
- if (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_44100) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (44100)");
- }
- if (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_48000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (48000)");
- }
- if (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_88200) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (88200)");
- }
- if (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_96000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (96000)");
- }
- if (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_176400) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (176400)");
- }
- if (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_192000) {
- LOG_VERBOSE(LOG_TAG, "\tsamp_freq: (192000)");
+ res << "A2DP_ParseInfoLdac fail: " << loghex(a2dp_status);
+ return res.str();
}
- LOG_VERBOSE(LOG_TAG, "\tch_mode: 0x%x", ldac_cie.channelMode);
- if (ldac_cie.channelMode & A2DP_LDAC_CHANNEL_MODE_MONO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Mono)");
- }
- if (ldac_cie.channelMode & A2DP_LDAC_CHANNEL_MODE_DUAL) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Dual)");
- }
- if (ldac_cie.channelMode & A2DP_LDAC_CHANNEL_MODE_STEREO) {
- LOG_VERBOSE(LOG_TAG, "\tch_mode: (Stereo)");
- }
-
- return true;
+ res << "\tname: LDAC\n";
+
+ // Sample frequency
+ field.clear();
+ AppendField(&field, (ldac_cie.sampleRate == 0), "NONE");
+ AppendField(&field, (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_44100),
+ "44100");
+ AppendField(&field, (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_48000),
+ "48000");
+ AppendField(&field, (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_88200),
+ "88200");
+ AppendField(&field, (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_96000),
+ "96000");
+ AppendField(&field, (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_176400),
+ "176400");
+ AppendField(&field, (ldac_cie.sampleRate & A2DP_LDAC_SAMPLING_FREQ_192000),
+ "192000");
+ res << "\tsamp_freq: " << field << " (" << loghex(ldac_cie.sampleRate)
+ << ")\n";
+
+ // Channel mode
+ field.clear();
+ AppendField(&field, (ldac_cie.channelMode == 0), "NONE");
+ AppendField(&field, (ldac_cie.channelMode & A2DP_LDAC_CHANNEL_MODE_MONO),
+ "Mono");
+ AppendField(&field, (ldac_cie.channelMode & A2DP_LDAC_CHANNEL_MODE_DUAL),
+ "Dual");
+ AppendField(&field, (ldac_cie.channelMode & A2DP_LDAC_CHANNEL_MODE_STEREO),
+ "Stereo");
+ res << "\tch_mode: " << field << " (" << loghex(ldac_cie.channelMode)
+ << ")\n";
+
+ return res.str();
}
const tA2DP_ENCODER_INTERFACE* A2DP_VendorGetEncoderInterfaceLdac(
/* send event to scb */
if (result == AVDT_SUCCESS) {
- A2DP_DumpCodecInfo(p_cfg->codec_info);
+ AVDT_TRACE_DEBUG("%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_cfg->codec_info).c_str());
evt.msg.config_cmd.hdr.seid = seid;
evt.msg.config_cmd.hdr.ccb_idx = avdt_ccb_to_idx(p_ccb);
p_scb->in_use, p_scb, p_scb->stream_config.scb_index);
if (!p_scb->in_use) {
- A2DP_DumpCodecInfo(p_scb->stream_config.cfg.codec_info);
- A2DP_DumpCodecInfo(p_data->msg.config_cmd.p_cfg->codec_info);
+ AVDT_TRACE_DEBUG(
+ "%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_scb->stream_config.cfg.codec_info).c_str());
+ AVDT_TRACE_DEBUG(
+ "%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_data->msg.config_cmd.p_cfg->codec_info).c_str());
AvdtpSepConfig* p_cfg = p_data->msg.config_cmd.p_cfg;
if (A2DP_GetCodecType(p_scb->stream_config.cfg.codec_info) ==
A2DP_GetCodecType(p_cfg->codec_info)) {
void avdt_scb_snd_reconfig_req(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) {
AVDT_TRACE_DEBUG("%s: p_scb->peer_seid=%d p_data->msg.hdr.seid=%d", __func__,
p_scb->peer_seid, p_data->msg.hdr.seid);
- A2DP_DumpCodecInfo(p_data->msg.config_cmd.p_cfg->codec_info);
+ AVDT_TRACE_DEBUG(
+ "%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_data->msg.config_cmd.p_cfg->codec_info).c_str());
p_scb->req_cfg = *p_data->msg.config_cmd.p_cfg;
p_data->msg.hdr.seid = p_scb->peer_seid;
void avdt_scb_snd_setconfig_req(AvdtpScb* p_scb, tAVDT_SCB_EVT* p_data) {
AvdtpSepConfig *p_req, *p_cfg;
- AVDT_TRACE_DEBUG("%s", __func__);
- A2DP_DumpCodecInfo(p_data->msg.config_cmd.p_cfg->codec_info);
+ AVDT_TRACE_DEBUG(
+ "%s: codec: %s", __func__,
+ A2DP_CodecInfoString(p_data->msg.config_cmd.p_cfg->codec_info).c_str());
/* copy API parameters to scb, set scb as in use */
bool A2DP_BuildCodecHeaderAac(const uint8_t* p_codec_info, BT_HDR* p_buf,
uint16_t frames_per_packet);
-// Decodes and displays A2DP AAC codec info when using |LOG_DEBUG|.
-// |p_codec_info| is a pointer to the AAC codec_info to decode and display.
-// Returns true if the codec information is valid, otherwise false.
-bool A2DP_DumpCodecInfoAac(const uint8_t* p_codec_info);
+// Decodes A2DP AAC codec info into a human readable string.
+// |p_codec_info| is a pointer to the AAC codec_info to decode.
+// Returns a string describing the codec information.
+std::string A2DP_CodecInfoStringAac(const uint8_t* p_codec_info);
// Gets the A2DP AAC encoder interface that can be used to encode and prepare
// A2DP packets for transmission - see |tA2DP_ENCODER_INTERFACE|.
bool A2DP_InitCodecConfig(btav_a2dp_codec_index_t codec_index,
AvdtpSepConfig* p_cfg);
-// Decodes and displays A2DP codec info when using |LOG_DEBUG|.
-// |p_codec_info| is a pointer to the codec_info to decode and display.
-// Returns true if the codec information is valid, otherwise false.
-bool A2DP_DumpCodecInfo(const uint8_t* p_codec_info);
+// Decodes A2DP codec info into a human readable string.
+// |p_codec_info| is a pointer to the codec_info to decode.
+// Returns a string describing the codec information.
+std::string A2DP_CodecInfoString(const uint8_t* p_codec_info);
// Add enum-based flag operators to the btav_a2dp_codec_config_t fields
#ifndef DEFINE_ENUM_FLAG_OPERATORS
bool A2DP_BuildCodecHeaderSbc(const uint8_t* p_codec_info, BT_HDR* p_buf,
uint16_t frames_per_packet);
-// Decodes and displays A2DP SBC codec info when using |LOG_DEBUG|.
-// |p_codec_info| is a pointer to the SBC codec_info to decode and display.
-// Returns true if the codec information is valid, otherwise false.
-bool A2DP_DumpCodecInfoSbc(const uint8_t* p_codec_info);
+// Decodes A2DP SBC codec info into a human readable string.
+// |p_codec_info| is a pointer to the SBC codec_info to decode.
+// Returns a string describing the codec information.
+std::string A2DP_CodecInfoStringSbc(const uint8_t* p_codec_info);
// Gets the A2DP SBC encoder interface that can be used to encode and prepare
// A2DP packets for transmission - see |tA2DP_ENCODER_INTERFACE|.
bool A2DP_VendorInitCodecConfig(btav_a2dp_codec_index_t codec_index,
AvdtpSepConfig* p_cfg);
-// Decodes and displays A2DP vendor codec info when using |LOG_DEBUG|.
-// |p_codec_info| is a pointer to the codec_info to decode and display.
-// Returns true if the codec information is valid, otherwise false.
-bool A2DP_VendorDumpCodecInfo(const uint8_t* p_codec_info);
+// Decodes A2DP vendor codec info into a human readable string.
+// |p_codec_info| is a pointer to the codec_info to decode.
+// Returns a string describing the codec information.
+std::string A2DP_VendorCodecInfoString(const uint8_t* p_codec_info);
#endif // A2DP_VENDOR_H
bool A2DP_VendorBuildCodecHeaderAptx(const uint8_t* p_codec_info, BT_HDR* p_buf,
uint16_t frames_per_packet);
-// Decodes and displays A2DP aptX codec info when using |LOG_DEBUG|.
-// |p_codec_info| is a pointer to the aptX codec_info to decode and display.
-// Returns true if the codec information is valid, otherwise false.
-bool A2DP_VendorDumpCodecInfoAptx(const uint8_t* p_codec_info);
+// Decodes A2DP aptX codec info into a human readable string.
+// |p_codec_info| is a pointer to the aptX codec_info to decode.
+// Returns a string describing the codec information.
+std::string A2DP_VendorCodecInfoStringAptx(const uint8_t* p_codec_info);
// Gets the A2DP aptX encoder interface that can be used to encode and prepare
// A2DP packets for transmission - see |tA2DP_ENCODER_INTERFACE|.
BT_HDR* p_buf,
uint16_t frames_per_packet);
-// Decodes and displays A2DP aptX-HD codec info when using |LOG_DEBUG|.
-// |p_codec_info| is a pointer to the aptX-HD codec_info to decode and display.
-// Returns true if the codec information is valid, otherwise false.
-bool A2DP_VendorDumpCodecInfoAptxHd(const uint8_t* p_codec_info);
+// Decodes A2DP aptX-HD codec info into a human readable string.
+// |p_codec_info| is a pointer to the aptX-HD codec_info to decode.
+// Returns a string describing the codec information.
+std::string A2DP_VendorCodecInfoStringAptxHd(const uint8_t* p_codec_info);
// Gets the A2DP aptX-HD encoder interface that can be used to encode and
// prepare A2DP packets for transmission - see |tA2DP_ENCODER_INTERFACE|.
bool A2DP_VendorBuildCodecHeaderLdac(const uint8_t* p_codec_info, BT_HDR* p_buf,
uint16_t frames_per_packet);
-// Decodes and displays A2DP LDAC codec info when using |LOG_DEBUG|.
-// |p_codec_info| is a pointer to the LDAC codec_info to decode and display.
-// Returns true if the codec information is valid, otherwise false.
-bool A2DP_VendorDumpCodecInfoLdac(const uint8_t* p_codec_info);
+// Decodes A2DP LDAC codec info into a human readable string.
+// |p_codec_info| is a pointer to the LDAC codec_info to decode.
+// Returns a string describing the codec information.
+std::string A2DP_VendorCodecInfoStringLdac(const uint8_t* p_codec_info);
// Gets the A2DP LDAC encoder interface that can be used to encode and prepare
// A2DP packets for transmission - see |tA2DP_ENCODER_INTERFACE|.