RFC 3640 defined the rtp payload format for transport MPEG4 elementary stream. More importantly, I am only interested how to setup SDP for AAC High Bitrate and Low Bitrate
First, you need to have a AU header section in the RTP payload. In the AU header section, it has a 2 bytes AU headers length field that denote the length of the all AU headers in bits. For each AU header, it has a list of optional information. You will mostly only interested in AU size and Au index. See section 3.2.1 for details
Next, the SDP define the structure of the RTP payload. If mode exists, RFC 3640 has to be used. I will be focusing on AAC-lbr and AAC-hbr.
mode=AAC-lbr
- The maximum size of the frame is 63 bytes
- AAC frames must not be fragment
- 6 bits of AU size
- 2 bits to AU index (-delta)
- AU index field must be 0
- SDP must present sizeLength, indexLength, indexDeltaLength
- config is the hexadecimal of AudioSpecificConfig of 14496-3
Sample SDP entry
m=audio 49230 RTP/AVP 96 a=rtpmap:96 mpeg4-generic/22050/1 a=fmtp:96 streamtype=5; profile-level-id=14; mode=AAC-lbr; config= 1388; sizeLength=6; indexLength=2; indexDeltaLength=2; constantDuration=1024; maxDisplacement=5
See 3.3.5 for detail
mode=AAC-hbr
- The maximum size of the frame is 8191 bytes
- AAC frames can be interleaved and hence receivers must support de-interleaving
- 13 bits of AU size
- 3 bits to AU index (-delta)
- AU index field must be 0
- SDP must present sizeLength, indexLength, indexDeltaLength
- config is the hexadecimal of AudioSpecificConfig of 14496-3
Sample SDP entry
m=audio 49230 RTP/AVP 96 a=rtpmap:96 mpeg4-generic/48000/6 a=fmtp:96 streamtype=5; profile-level-id=16; mode=AAC-hbr; config=11B0; sizeLength=13; indexLength=3; indexDeltaLength=3; constantDuration=1024
Since each RTP AAC payload can be independently decoded, you can extract the raw AAC data in the rtp packet as follow
1. Since at AU header section, there is 2 bytes of AU headers length which denote the all AU headers length in bits, all you need is to read the 2 bytes value into integer and divided by 8. That will tell you the size of all raw AAC data size
2. Next, base on the sizeLength in SDP, you will know the size of each raw AAC data in the payload. Parse each AAC raw data according to the respective size denoted in each AU header
See 3.3.6 for detail
来源: RFC 3640 for AAC