       if not avcInfo?
         throw new Error "[rtmp:publish] malformed video data: avcInfo is missing"
       nalUnits = flv.splitNALUnits info.nalUnits, avcInfo.nalUnitLengthSize
+      for nalUnit in nalUnits
+        nalUnitType = h264.getNALUnitType nalUnit
+        if nalUnitType is h264.NAL_UNIT_TYPE_IDR_PICTURE  # 5
+          isKeyFrame = true
       nalUnitGlob = h264.concatWithStartCodePrefix nalUnits
     when flv.AVC_PACKET_TYPE_EOS
       console.log "[rtmp:publish] received an EOS from upstream video"

  return {
    info: info
    nalUnitGlob: nalUnitGlob
  }

parseAudioMessage = (stream, buf) ->

      @emit 'stream_reset', args...
    @rtmpSession.on 'video_start', (args...) =>
      @emit 'video_start', args...
    @rtmpSession.on 'video_iframe', (args...) =>
      @emit 'video_iframe', args...
    @rtmpSession.on 'audio_start', (args...) =>
      @emit 'audio_start', args...
    @rtmpSession.on 'video_data', (args...) =>
