Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
shogo4405 committed Feb 3, 2018
1 parent c1ea96e commit c03be8b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions Sources/RTMP/RTMPMuxer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ extension RTMPMuxer: VideoEncoderDelegate {
}

func sampleOutput(video sampleBuffer: CMSampleBuffer) {
guard let data: Data = sampleBuffer.dataBuffer?.data else {
return
}
let keyframe: Bool = !sampleBuffer.dependsOnOthers
var compositionTime: Int32 = 0
let presentationTimeStamp: CMTime = sampleBuffer.presentationTimeStamp
Expand All @@ -73,6 +70,9 @@ extension RTMPMuxer: VideoEncoderDelegate {
} else {
compositionTime = Int32((decodeTimeStamp.seconds - decodeTimeStamp.seconds) * 1000)
}
guard let data: Data = sampleBuffer.dataBuffer?.data, 0 <= delta else {
return
}
let delta: Double = (videoTimestamp == kCMTimeZero ? 0 : decodeTimeStamp.seconds - videoTimestamp.seconds) * 1000
var buffer: Data = Data([((keyframe ? FLVFrameType.key.rawValue : FLVFrameType.inter.rawValue) << 4) | FLVVideoCodec.avc.rawValue, FLVAVCPacketType.nal.rawValue])
buffer.append(contentsOf: compositionTime.bigEndian.data[1..<4])
Expand Down

0 comments on commit c03be8b

Please sign in to comment.