之前写过几篇USB 发射的文章,如下链接,现在在通话的基础上增加新的玩法。
https://blog.csdn.net/TengTaiTech/article/details/137339630?spm=1001.2014.3001.5501
https://blog.csdn.net/TengTaiTech/article/details/137790676?spm=1001.2014.3001.5501
可以更换USB输入方式到AUX,链路如下:
此方案可以保证音质,又同时兼顾一对二的方案。
如果想体验音乐和通话切换,也可以用户按键切换实现。可以动态切换。
bool kymeraA2dpSource_ConfigurePacketiser(void)
{
DEBUG_LOG_FN_ENTRY(“kymeraA2dpSource_ConfigurePacketiser”);
kymeraTaskData *theKymera = KymeraGetTaskData();
const a2dp_codec_settings *codec_settings = theKymera->a2dp_output_params;
uint16 codec_mtu = codec_settings->codecData.packet_size;
Source source = PanicNull(ChainGetOutput(theKymera->chain_input_handle, EPR_SOURCE_ENCODE_OUT));
if (codec_settings->sink == NULL)
{
return FALSE;
}
Transform packetiser = PanicNull(TransformPacketise(source, codec_settings->sink));
switch (codec_settings->seid)
{
case AV_SEID_APTX_CLASSIC_SRC:
{
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_CODEC, VM_TRANSFORM_PACKETISE_CODEC_APTX));
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_MODE, VM_TRANSFORM_PACKETISE_MODE_RTP));
}
break;
case AV_SEID_APTXHD_SRC:
{
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_CODEC, VM_TRANSFORM_PACKETISE_CODEC_APTX));
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_MODE, VM_TRANSFORM_PACKETISE_MODE_RTP));
}
break;
case AV_SEID_APTX_ADAPTIVE_SRC:
{
uint16 codec_ssrc;
vm_transform_packetise_codec codec_format;
if (theKymera->split_tx_mode)
{
/* Signal to the packetiser to add the extra header bytes required for HQ 96kHz split tx streaming. */
codec_format = VM_TRANSFORM_PACKETISE_CODEC_APTX_ADAPTIVE;
}
else
{
/* Non-split tx uses the regular aptX packetiser codec configuration. */
codec_format = VM_TRANSFORM_PACKETISE_CODEC_APTX;
}
switch (kymera_a2dp_source_data.aptxad_active_mode)
{
case aptxad_mode_low_latency:
codec_ssrc = aptxAdaptiveLowLatencyStreamId_SSRC_Q2Q();
codec_mtu = 668;
break;
case aptxad_mode_high_quality:
default:
codec_ssrc = aptxAdaptiveHQStreamId_SSRC();
break;
}
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_CODEC, codec_format));
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_MODE, VM_TRANSFORM_PACKETISE_MODE_TWSPLUS));
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_RTP_SSRC, codec_ssrc));
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_RTP_SSRC_HI, 0));
}
break;
case AV_SEID_SBC_SRC:
{
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_CODEC, VM_TRANSFORM_PACKETISE_CODEC_SBC));
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_MODE, VM_TRANSFORM_PACKETISE_MODE_RTP));
}
break;
default:
break;
}
/* Do not check result of configuring MTU, because this feature is licensed on some platforms, e.g. QCC3056.
If the license check fails, it will return FALSE, but play silence. This is ok, and we should continue.
Some codecs do not account for the RTP header in their packet_size. So the MTU we pass to the packetiser
must account for potentially an extra 12 bytes (RTP_HEADER_SIZE_MAX). It does not matter if these bytes
end up not being utilised - the MTU is simply an upper limit to avoid fragmentation.
*/
TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_MTU, codec_mtu + RTP_HEADER_SIZE_MAX);
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_SAMPLE_RATE, (uint16)codec_settings->rate));
/* aptX HD needs a special configuration */
if (codec_settings->seid == AV_SEID_APTXHD_SRC)
{
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_CPENABLE, 1));
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_SCMS, 0));
}
else
{
PanicFalse(TransformConfigure(packetiser, VM_TRANSFORM_PACKETISE_CPENABLE, (uint16)codec_settings->codecData.content_protection));
}
PanicFalse(TransformStart(packetiser));
theKymera->packetiser = packetiser;
return TRUE;
}