diff --git a/Gemfile b/Gemfile index 4c8e15317..6ceb93d37 100644 --- a/Gemfile +++ b/Gemfile @@ -3,4 +3,5 @@ source 'https://rubygems.org' gem 'cocoapods' gem 'fastlane' gem 'jazzy' +gem 'synx' diff --git a/Gemfile.lock b/Gemfile.lock index 93b6c469b..b830f6c7c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -32,6 +32,7 @@ GEM aws-eventstream (~> 1, >= 1.0.2) babosa (1.0.4) claide (1.0.3) + clamp (0.6.5) cocoapods (1.10.1) addressable (~> 2.6) claide (>= 1.0.2, < 2.0) @@ -71,6 +72,7 @@ GEM cocoapods-try (1.2.0) colored (1.2) colored2 (3.1.2) + colorize (0.8.1) commander (4.6.0) highline (~> 2.0.0) concurrent-ruby (1.1.9) @@ -247,6 +249,10 @@ GEM CFPropertyList naturally sqlite3 (1.4.2) + synx (0.2.1) + clamp (~> 0.6) + colorize (~> 0.7) + xcodeproj (~> 1.0) terminal-notifier (2.0.0) terminal-table (1.8.0) unicode-display_width (~> 1.1, >= 1.1.1) @@ -288,6 +294,7 @@ DEPENDENCIES cocoapods fastlane jazzy + synx BUNDLED WITH 2.1.2 diff --git a/Sources/Util/MachUtil.swift b/Sources/Util/MachUtil.swift deleted file mode 100644 index b47213916..000000000 --- a/Sources/Util/MachUtil.swift +++ /dev/null @@ -1,21 +0,0 @@ -import Foundation - -public struct MachUtil { - public static let nanosPerUsec: UInt64 = 1000 - public static let nanosPerMsec: UInt64 = 1000 * 1000 - public static let nanosPerSec: UInt64 = 1000 * 1000 * 1000 - - private static var timebase: mach_timebase_info_data_t = { - var timebase = mach_timebase_info_data_t() - mach_timebase_info(&timebase) - return timebase - }() - - public static func nanosToAbs(_ nanos: UInt64) -> UInt64 { - nanos * UInt64(timebase.denom) / UInt64(timebase.numer) - } - - public static func absToNanos(_ abs: UInt64) -> UInt64 { - abs * UInt64(timebase.numer) / UInt64(timebase.denom) - } -} diff --git a/Sources/Util/TimerDriver.swift b/Sources/Util/TimerDriver.swift deleted file mode 100644 index 4946776ad..000000000 --- a/Sources/Util/TimerDriver.swift +++ /dev/null @@ -1,75 +0,0 @@ -import Foundation - -public protocol TimerDriverDelegate: AnyObject { - func tick(_ driver: TimerDriver) -} - -// MARK: - -public class TimerDriver { - public var interval: UInt64 = MachUtil.nanosToAbs(10 * MachUtil.nanosPerMsec) - - var queue: DispatchQueue? - weak var delegate: TimerDriverDelegate? - - private var runloop: RunLoop? - private var nextFire: UInt64 = 0 - private var timer: Timer? { - didSet { - oldValue?.invalidate() - timer.map { - RunLoop.current.add($0, forMode: RunLoop.Mode.common) - } - } - } - - public func setDelegate(_ delegate: TimerDriverDelegate, withQueue: DispatchQueue? = nil) { - self.delegate = delegate - self.queue = withQueue - } - - @objc - private func on(timer: Timer) { - guard nextFire <= mach_absolute_time() else { - return - } - if let queue: DispatchQueue = queue { - queue.sync { - self.delegate?.tick(self) - } - } else { - delegate?.tick(self) - } - nextFire += interval - } -} - -extension TimerDriver: Running { - // MARK: Running - public var isRunning: Atomic { - .init(runloop != nil) - } - - public func startRunning() { - DispatchQueue.global(qos: .userInteractive).async { - guard self.runloop == nil else { - return - } - self.timer = Timer( - timeInterval: 0.0001, target: self, selector: #selector(self.on), userInfo: nil, repeats: true - ) - self.nextFire = mach_absolute_time() + self.interval - self.delegate?.tick(self) - self.runloop = .current - self.runloop?.run() - } - } - - public func stopRunning() { - guard let runloop: RunLoop = runloop else { - return - } - timer = nil - CFRunLoopStop(runloop.getCFRunLoop()) - self.runloop = nil - } -} diff --git a/Tests/RTSP/SessionDescriptionTests.swift b/Tests/RTSP/SessionDescriptionTests.swift deleted file mode 100644 index 8a6cc45f7..000000000 --- a/Tests/RTSP/SessionDescriptionTests.swift +++ /dev/null @@ -1,32 +0,0 @@ -import Foundation -import XCTest - -@testable import HaishinKit - -final class SessionDescriptionTests: XCTestCase { - static let contents: String = - "v=0\n" + - "o=- 486606654 486606654 IN IP4 127.0.0.1\n" + - "s=sample.mp4\n" + - "c=IN IP4 0.0.0.0\n" + - "t=0 0\n" + - "a=sdplang:en\n" + - "a=range:npt=0- 634.633\n" + - "a=control:*\n" + - "m=audio 0 RTP/AVP 96\n" + - "a=rtpmap:96 mpeg4-generic/48000/2\n" + - "a=fmtp:96 profile-level-id=1;mode=AAC-hbr;sizelength=13;indexlength=3;indexdeltalength=3;config=119056e500\n" + - "a=control:trackID=1\n" + - "m=video 0 RTP/AVP 97\n" + - "a=rtpmap:97 H264/90000\n" + - "a=fmtp:97 packetization-mode=1;profile-level-id=42C015;sprop-parameter-sets=Z0LAFdoCAJbARAAAAwAEAAADAPA8WLqA,aM4yyA==\n" + - "a=cliprect:0,0,288,512\n" + - "a=framesize:97 512-288\n" + - "a=framerate:30.0\n" + - "a=control:trackID=2" - - func testString() { - var session: SessionDescription = SessionDescription() - session.description = SessionDescriptionTests.contents - } -}