@livedesk/client 0.1.84 → 0.1.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
12
12
  private let width: Int
13
13
  private let height: Int
14
14
  private let fps: Int
15
+ private let bitrateKbps: Int
15
16
  private let queue = DispatchQueue(label: "dev.livedesk.screencapturekit.frames", qos: .userInteractive)
16
17
  private let writeLock = NSLock()
17
18
  private var stream: SCStream?
@@ -19,11 +20,12 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
19
20
  private var frameCount: Int = 0
20
21
  private var encodedCount: Int = 0
21
22
 
22
- init(displayIndex: Int, width: Int, height: Int, fps: Int) {
23
+ init(displayIndex: Int, width: Int, height: Int, fps: Int, bitrateKbps: Int) {
23
24
  self.displayIndex = max(0, displayIndex)
24
25
  self.width = max(2, width)
25
26
  self.height = max(2, height)
26
27
  self.fps = max(1, fps)
28
+ self.bitrateKbps = max(500, bitrateKbps)
27
29
  super.init()
28
30
  }
29
31
 
@@ -50,7 +52,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
50
52
  self.stream = stream
51
53
  try await stream.startCapture()
52
54
 
53
- fputs("LiveDeskSCK started displayIndex=\(displayIndex) displayID=\(display.displayID) size=\(width)x\(height) fps=\(fps)\n", stderr)
55
+ fputs("LiveDeskSCK started displayIndex=\(displayIndex) displayID=\(display.displayID) size=\(width)x\(height) fps=\(fps) bitrateKbps=\(bitrateKbps)\n", stderr)
54
56
  while !Task.isCancelled {
55
57
  try await Task.sleep(nanoseconds: 1_000_000_000)
56
58
  }
@@ -80,7 +82,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
80
82
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameInterval, value: NSNumber(value: 1))
81
83
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, value: NSNumber(value: max(0.001, 1.0 / Double(fps))))
82
84
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_ExpectedFrameRate, value: NSNumber(value: fps))
83
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: max(3_500_000, width * height * fps / 4)))
85
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: bitrateKbps * 1000))
84
86
  VTCompressionSessionPrepareToEncodeFrames(session)
85
87
  compressionSession = session
86
88
  }
@@ -257,9 +259,10 @@ struct LiveDeskSCKMain {
257
259
  let width = intArg("--width", default: 960)
258
260
  let height = intArg("--height", default: 540)
259
261
  let fps = intArg("--fps", default: 30)
262
+ let bitrateKbps = intArg("--bitrate-kbps", default: max(3500, width * height * fps / 4000))
260
263
 
261
264
  do {
262
- let encoder = LiveDeskScreenCaptureKitEncoder(displayIndex: displayIndex, width: width, height: height, fps: fps)
265
+ let encoder = LiveDeskScreenCaptureKitEncoder(displayIndex: displayIndex, width: width, height: height, fps: fps, bitrateKbps: bitrateKbps)
263
266
  try await encoder.start()
264
267
  } catch {
265
268
  fputs("LiveDeskSCK failed: \(error)\n", stderr)
@@ -12,6 +12,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
12
12
  private let width: Int
13
13
  private let height: Int
14
14
  private let fps: Int
15
+ private let bitrateKbps: Int
15
16
  private let queue = DispatchQueue(label: "dev.livedesk.screencapturekit.frames", qos: .userInteractive)
16
17
  private let writeLock = NSLock()
17
18
  private var stream: SCStream?
@@ -19,11 +20,12 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
19
20
  private var frameCount: Int = 0
20
21
  private var encodedCount: Int = 0
21
22
 
22
- init(displayIndex: Int, width: Int, height: Int, fps: Int) {
23
+ init(displayIndex: Int, width: Int, height: Int, fps: Int, bitrateKbps: Int) {
23
24
  self.displayIndex = max(0, displayIndex)
24
25
  self.width = max(2, width)
25
26
  self.height = max(2, height)
26
27
  self.fps = max(1, fps)
28
+ self.bitrateKbps = max(500, bitrateKbps)
27
29
  super.init()
28
30
  }
29
31
 
@@ -50,7 +52,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
50
52
  self.stream = stream
51
53
  try await stream.startCapture()
52
54
 
53
- fputs("LiveDeskSCK started displayIndex=\(displayIndex) displayID=\(display.displayID) size=\(width)x\(height) fps=\(fps)\n", stderr)
55
+ fputs("LiveDeskSCK started displayIndex=\(displayIndex) displayID=\(display.displayID) size=\(width)x\(height) fps=\(fps) bitrateKbps=\(bitrateKbps)\n", stderr)
54
56
  while !Task.isCancelled {
55
57
  try await Task.sleep(nanoseconds: 1_000_000_000)
56
58
  }
@@ -80,7 +82,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
80
82
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameInterval, value: NSNumber(value: 1))
81
83
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, value: NSNumber(value: max(0.001, 1.0 / Double(fps))))
82
84
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_ExpectedFrameRate, value: NSNumber(value: fps))
83
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: max(3_500_000, width * height * fps / 4)))
85
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: bitrateKbps * 1000))
84
86
  VTCompressionSessionPrepareToEncodeFrames(session)
85
87
  compressionSession = session
86
88
  }
@@ -257,9 +259,10 @@ struct LiveDeskSCKMain {
257
259
  let width = intArg("--width", default: 960)
258
260
  let height = intArg("--height", default: 540)
259
261
  let fps = intArg("--fps", default: 30)
262
+ let bitrateKbps = intArg("--bitrate-kbps", default: max(3500, width * height * fps / 4000))
260
263
 
261
264
  do {
262
- let encoder = LiveDeskScreenCaptureKitEncoder(displayIndex: displayIndex, width: width, height: height, fps: fps)
265
+ let encoder = LiveDeskScreenCaptureKitEncoder(displayIndex: displayIndex, width: width, height: height, fps: fps, bitrateKbps: bitrateKbps)
263
266
  try await encoder.start()
264
267
  } catch {
265
268
  fputs("LiveDeskSCK failed: \(error)\n", stderr)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.84",
3
+ "version": "0.1.85",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {