@livedesk/client 0.1.77 → 0.1.79

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,7 +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 queue = DispatchQueue(label: "dev.livedesk.screencapturekit.frames")
15
+ private let queue = DispatchQueue(label: "dev.livedesk.screencapturekit.frames", qos: .userInteractive)
16
16
  private let writeLock = NSLock()
17
17
  private var stream: SCStream?
18
18
  private var compressionSession: VTCompressionSession?
@@ -41,7 +41,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
41
41
  configuration.width = width
42
42
  configuration.height = height
43
43
  configuration.minimumFrameInterval = CMTime(value: 1, timescale: CMTimeScale(fps))
44
- configuration.queueDepth = 3
44
+ configuration.queueDepth = 1
45
45
  configuration.showsCursor = false
46
46
  configuration.pixelFormat = kCVPixelFormatType_32BGRA
47
47
 
@@ -77,10 +77,10 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
77
77
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_RealTime, value: kCFBooleanTrue)
78
78
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AllowFrameReordering, value: kCFBooleanFalse)
79
79
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_ProfileLevel, value: kVTProfileLevel_H264_Baseline_AutoLevel)
80
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameInterval, value: NSNumber(value: fps))
81
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, value: NSNumber(value: 1))
80
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameInterval, value: NSNumber(value: 1))
81
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, value: NSNumber(value: max(0.001, 1.0 / Double(fps))))
82
82
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_ExpectedFrameRate, value: NSNumber(value: fps))
83
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: max(2_500_000, width * height * fps / 6)))
83
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: max(3_500_000, width * height * fps / 4)))
84
84
  VTCompressionSessionPrepareToEncodeFrames(session)
85
85
  compressionSession = session
86
86
  }
@@ -109,12 +109,15 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
109
109
  frameCount += 1
110
110
  let pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
111
111
  let duration = CMTime(value: 1, timescale: CMTimeScale(fps))
112
+ let frameProperties = NSMutableDictionary()
113
+ frameProperties[kVTEncodeFrameOptionKey_ForceKeyFrame] = kCFBooleanTrue
114
+
112
115
  let status = VTCompressionSessionEncodeFrame(
113
116
  session,
114
117
  imageBuffer: imageBuffer,
115
118
  presentationTimeStamp: pts,
116
119
  duration: duration,
117
- frameProperties: nil,
120
+ frameProperties: frameProperties,
118
121
  sourceFrameRefcon: nil,
119
122
  infoFlagsOut: nil)
120
123
 
@@ -245,6 +248,10 @@ struct LiveDeskSCKMain {
245
248
  fputs("LiveDeskSCK requires macOS 12.3 or later.\n", stderr)
246
249
  exit(2)
247
250
  }
251
+ guard CGPreflightScreenCaptureAccess() else {
252
+ fputs("LiveDeskSCK screen recording permission is not granted.\n", stderr)
253
+ exit(10)
254
+ }
248
255
 
249
256
  let displayIndex = intArg("--display-index", default: 0)
250
257
  let width = intArg("--width", default: 960)
@@ -12,7 +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 queue = DispatchQueue(label: "dev.livedesk.screencapturekit.frames")
15
+ private let queue = DispatchQueue(label: "dev.livedesk.screencapturekit.frames", qos: .userInteractive)
16
16
  private let writeLock = NSLock()
17
17
  private var stream: SCStream?
18
18
  private var compressionSession: VTCompressionSession?
@@ -41,7 +41,7 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
41
41
  configuration.width = width
42
42
  configuration.height = height
43
43
  configuration.minimumFrameInterval = CMTime(value: 1, timescale: CMTimeScale(fps))
44
- configuration.queueDepth = 3
44
+ configuration.queueDepth = 1
45
45
  configuration.showsCursor = false
46
46
  configuration.pixelFormat = kCVPixelFormatType_32BGRA
47
47
 
@@ -77,10 +77,10 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
77
77
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_RealTime, value: kCFBooleanTrue)
78
78
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AllowFrameReordering, value: kCFBooleanFalse)
79
79
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_ProfileLevel, value: kVTProfileLevel_H264_Baseline_AutoLevel)
80
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameInterval, value: NSNumber(value: fps))
81
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, value: NSNumber(value: 1))
80
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameInterval, value: NSNumber(value: 1))
81
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_MaxKeyFrameIntervalDuration, value: NSNumber(value: max(0.001, 1.0 / Double(fps))))
82
82
  VTSessionSetProperty(session, key: kVTCompressionPropertyKey_ExpectedFrameRate, value: NSNumber(value: fps))
83
- VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: max(2_500_000, width * height * fps / 6)))
83
+ VTSessionSetProperty(session, key: kVTCompressionPropertyKey_AverageBitRate, value: NSNumber(value: max(3_500_000, width * height * fps / 4)))
84
84
  VTCompressionSessionPrepareToEncodeFrames(session)
85
85
  compressionSession = session
86
86
  }
@@ -109,12 +109,15 @@ final class LiveDeskScreenCaptureKitEncoder: NSObject, SCStreamOutput, SCStreamD
109
109
  frameCount += 1
110
110
  let pts = CMSampleBufferGetPresentationTimeStamp(sampleBuffer)
111
111
  let duration = CMTime(value: 1, timescale: CMTimeScale(fps))
112
+ let frameProperties = NSMutableDictionary()
113
+ frameProperties[kVTEncodeFrameOptionKey_ForceKeyFrame] = kCFBooleanTrue
114
+
112
115
  let status = VTCompressionSessionEncodeFrame(
113
116
  session,
114
117
  imageBuffer: imageBuffer,
115
118
  presentationTimeStamp: pts,
116
119
  duration: duration,
117
- frameProperties: nil,
120
+ frameProperties: frameProperties,
118
121
  sourceFrameRefcon: nil,
119
122
  infoFlagsOut: nil)
120
123
 
@@ -245,6 +248,10 @@ struct LiveDeskSCKMain {
245
248
  fputs("LiveDeskSCK requires macOS 12.3 or later.\n", stderr)
246
249
  exit(2)
247
250
  }
251
+ guard CGPreflightScreenCaptureAccess() else {
252
+ fputs("LiveDeskSCK screen recording permission is not granted.\n", stderr)
253
+ exit(10)
254
+ }
248
255
 
249
256
  let displayIndex = intArg("--display-index", default: 0)
250
257
  let width = intArg("--width", default: 960)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@livedesk/client",
3
- "version": "0.1.77",
3
+ "version": "0.1.79",
4
4
  "description": "LiveDesk local remote client",
5
5
  "type": "module",
6
6
  "bin": {