mirror of
https://github.com/HaishinKit/HaishinKit.swift.git
synced 2026-05-07 20:12:28 +00:00
33 lines
952 B
Swift
33 lines
952 B
Swift
import AVFoundation
|
|
import Foundation
|
|
import Testing
|
|
|
|
@testable import RTCHaishinKit
|
|
|
|
@Suite struct RTPJitterBufferTests {
|
|
final class Result: RTPJitterBufferDelegate {
|
|
var count = 0
|
|
|
|
func jitterBuffer(_ buffer: RTPJitterBuffer<RTPJitterBufferTests.Result>, sequenced: RTPPacket) {
|
|
count += 1
|
|
}
|
|
}
|
|
|
|
@Test func lostPacket() throws {
|
|
let result = Result()
|
|
let buffer = RTPJitterBuffer<Result>()
|
|
buffer.delegate = result
|
|
var packets: [RTPPacket] = []
|
|
for i in 0...100 {
|
|
packets.append(.init(version: 2, padding: false, extension: false, cc: 0, marker: false, payloadType: 0, sequenceNumber: UInt16(i), timestamp: UInt32(960 * (i + 1)), ssrc: 0, payload: Data()))
|
|
}
|
|
packets.remove(at: 30)
|
|
packets.remove(at: 50)
|
|
for packet in packets {
|
|
buffer.append(packet)
|
|
}
|
|
|
|
#expect(result.count == 99)
|
|
}
|
|
}
|