     ntp_sec = sec + EPOCH
     ntp_usec = Math.round(ms * 1000 * NTP_SCALE_FRAC)
     return [ntp_sec, ntp_usec]
+
+  readAACPayload: (params) ->
+    info = {}
+    info.auHeadersLengthBits = bits.read_bits 16  # in bits
+    info.numAUHeaders = info.auHeadersLengthBits / 16
+    auHeaders = []
+    for i in [0...info.numAUHeaders]
+      params.index = i
+      auHeaders.push api.readAACAUHeader params
+    info.auHeaders = auHeaders
+    info.accessUnits = []
+    for auHeader in auHeaders
+      info.accessUnits.push bits.read_bytes auHeader.auSize
+      accessUnit = info.accessUnits[info.accessUnits.length-1]
+    return info
+
+  readAACAUHeader: (params) ->
+    if not params.sizelength?
+      throw new Error "sizelength is not defined in params"
+    info = {}
+    # size in octets of the associated Access Unit in the
+    # Access Unit Data Section in the same RTP packet
+    info.auSize = bits.read_bits params.sizelength
+    # serial number of the associated Access Unit (fragment).
+    if not params.index?
+      throw new Error "index is not defined in params"
+    if params.index > 0
+      if not params.indexdeltalength?
+        throw new Error "indexdeltalength is not defined in params"
+      info.auIndexDelta = bits.read_bits params.indexdeltalength
+    else
+      if not params.indexlength?
+        throw new Error "indexlength is not defined in params"
+      info.auIndex = bits.read_bits params.indexlength
+    return info
 
   # Used for encapsulating AAC audio data
   # opts:

      info.csrc.push bits.read_bits 32
    return info

  parsePackets: (buf) ->
    bits.push_stash()
    bits.set_data buf

  RTCP_PACKET_TYPE_SOURCE_DESCRIPTION : 202  # SDES
  RTCP_PACKET_TYPE_GOODBYE            : 203  # BYE
  RTCP_PACKET_TYPE_APPLICATION_DEFINED: 204  # APP

  H264_NAL_UNIT_TYPE_STAP_A: 24
  H264_NAL_UNIT_TYPE_STAP_B: 25
  H264_NAL_UNIT_TYPE_MTAP16: 26
  H264_NAL_UNIT_TYPE_MTAP24: 27
  H264_NAL_UNIT_TYPE_FU_A  : 28
  H264_NAL_UNIT_TYPE_FU_B  : 29

  emit: (name, data...) ->
    if eventListeners[name]?
      for listener in eventListeners[name]
        listener data...
    return

  on: (name, listener) ->
    if eventListeners[name]?
      eventListeners[name].push listener
    else
      eventListeners[name] = [ listener ]


  readRTCPSenderReport: ->
    # RFC 3550 - 6.4.1 SR: Sender Report RTCP Packet
