crtmpserver incorrectly believes that aac audio always stereo

79 views
Skip to first unread message

Alexey Tsarev

unread,
Mar 25, 2016, 8:30:20 AM3/25/16
to C++ RTMP Server
Hello all,
I am tried to send web camera video/audio stream for ivideon server.
I found that ivideon hangs if I stream mono aac.

During debuging/investigation I found this line:
result += format("a=rtpmap:96 mpeg4-generic/%"PRIu32"/2\r\n", pInfo->_samplingRate);
in the file: sources/thelib/src/protocols/rtp/basertspappprotocolhandler.cpp

I sniffed traffic and got (marked bold):
v=0
o=- 648 0 IN IP4 10.1.1.1
s=myStream
c=IN IP4 10.1.1.1
t=0 0
a=recvonly
a=control:*
a=range:npt=now-
m=audio 0 RTP/AVP 96
a=recvonly
a=rtpmap:96 mpeg4-generic/8000/2
a=control:trackID=1
a=fmtp:96 streamtype=5; profile-level-id=15; mode=AAC-hbr; config=158856e500; SizeLength=13; IndexLength=3; IndexDeltaLength=3;
m=video 0 RTP/AVP 97
a=recvonly
a=control:trackID=2
a=rtpmap:97 H264/90000


So crtmpserver incorrectly believes that aac audio always stereo.

https://tools.ietf.org/html/rfc3640 says that audio channels may omitted only in a case if only one channel present:
   a=rtpmap:<payload type> <encoding name>/<clock rate>[/<encoding
             parameters>]

   For audio streams, <encoding parameters> specifies the number of
   audio channels: 2 for stereo material (see RFC 2327 [5]) and 1 for
   mono.  Provided no additional parameters are needed, this parameter
   may be omitted for mono material, hence its default value is 1.

Alexey Tsarev

unread,
Mar 26, 2016, 10:27:28 AM3/26/16
to C++ RTMP Server
There is the solution:

result += format("a=rtpmap:96 mpeg4-generic/%"PRIu32"/%u\r\n",
pInfo->_samplingRate, pInfo->_channelsCount);

пятница, 25 марта 2016 г., 15:30:20 UTC+3 пользователь Alexey Tsarev написал:
Reply all
Reply to author
Forward
0 new messages