private string GetAudioTrack(RtspProtocol pFrom, StreamCapabilities pCapabilities)
{
pFrom.CustomParameters["audioTrackId"] = "1"; //md5(format("A%u%s",pFrom->GetId(), STR(generateRandomString(4))), true);
string result = "";
switch (pCapabilities.AudioCodecId)
{
case AudioCodec.Aac:
result += "m=audio 0 RTP/AVP 96\r\n";
result += "a=recvonly\r\n";
result += $"a=rtpmap:96 mpeg4-generic/{pCapabilities.Aac._sampleRate}/2\r\n";
//FINEST("result: %s", STR(result));
result += "a=control:trackID="
+ pFrom.CustomParameters["audioTrackId"] + "\r\n";
//rfc3640-fmtp-explained.txt Chapter 4.1
result +=
$"a=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; {pCapabilities.Aac.GetRTSPFmtpConfig()}; SizeLength=13; IndexLength=3; IndexDeltaLength=3;\r\n";
break;
case AudioCodec.Speex:
result += "m=audio 0 RTP/AVP 98\r\n";
result += "a=rtpmap:98 speex/16000\r\n";
//FINEST("result: %s", STR(result));
result += "a=control:trackID="+ pFrom.CustomParameters["audioTrackId"] + "\r\n";
//http://www.rfc-editor.org/rfc/rfc5574.txt
result +="a=fmtp:98 mode=\"7,any\"\r\n";
break;
default:
WARN("Unsupported audio codec: {0}", pCapabilities.AudioCodecId);
break;
}
return result;
}