Compare commits

..
0 Commits
2 changed files with 0 additions and 87 deletions

No files matched your search

-85
View File
@@ -13,7 +13,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
lazy var preview = CaptureVideoPreview(layer: sr.contentLayer) lazy var preview = CaptureVideoPreview(layer: sr.contentLayer)
let button = NSButton(title: "Start Stream", target: self, action: #selector(Button)) let button = NSButton(title: "Start Stream", target: self, action: #selector(Button))
var isRunning = false var isRunning = false
static let controller = StreamWindowController()
// let udpclient = UDPClientImplementation(port: 03067) // let udpclient = UDPClientImplementation(port: 03067)
// let udpserver = UDPServerImplementation(host: "localhost", port: 03067, initialMessage: "kys") // let udpserver = UDPServerImplementation(host: "localhost", port: 03067, initialMessage: "kys")
@@ -43,11 +42,6 @@ class AppDelegate: NSObject, NSApplicationDelegate {
preview.topAnchor.constraint(equalTo: window.contentView!.topAnchor).isActive = true preview.topAnchor.constraint(equalTo: window.contentView!.topAnchor).isActive = true
preview.bottomAnchor.constraint(equalTo: window.contentView!.bottomAnchor).isActive = true preview.bottomAnchor.constraint(equalTo: window.contentView!.bottomAnchor).isActive = true
AppDelegate.controller.showWindow(nil)
// controller.streamView.display(sampleBuffer: sampleBuffer)
window.addChildWindow(AppDelegate.controller.window!, ordered: .above)
} }
func applicationWillTerminate(_ aNotification: Notification) { } func applicationWillTerminate(_ aNotification: Notification) { }
@@ -56,82 +50,3 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return true return true
} }
} }
import Cocoa
import AVFoundation
import VideoToolbox
final class StreamWindowView: NSView {
private let displayLayer = AVSampleBufferDisplayLayer()
override init(frame frameRect: NSRect) {
super.init(frame: frameRect)
wantsLayer = true
displayLayer.videoGravity = .resizeAspect
displayLayer.frame = bounds
displayLayer.autoresizingMask = [
.layerWidthSizable,
.layerHeightSizable
]
layer?.addSublayer(displayLayer)
}
required init?(coder: NSCoder) {
fatalError()
}
// Feed packets here.
func enqueue(packet: ScreamPacket) {
// POC:
// Pretend packet.data already contains one complete CMSampleBuffer.
//
// Later this will become:
// packet -> NAL units -> CMBlockBuffer ->
// CMSampleBuffer -> displayLayer.enqueue()
}
// POC helper
func display(sampleBuffer: CMSampleBuffer) {
displayLayer.enqueue(sampleBuffer)
}
func flush() {
displayLayer.flushAndRemoveImage()
}
}
import Cocoa
final class StreamWindowController: NSWindowController {
let streamView = StreamWindowView(frame: .zero)
convenience init() {
let window = NSWindow(
contentRect: NSRect(x: 100, y: 100, width: 1280, height: 720),
styleMask: [
.titled,
.closable,
.miniaturizable,
.resizable
],
backing: .buffered,
defer: false
)
self.init(window: window)
window.title = "Remote Stream"
window.contentView = streamView
// Hardcoded black background
streamView.layer?.backgroundColor = NSColor.black.cgColor
}
}
-2
View File
@@ -74,7 +74,6 @@ class CaptureEngine: NSObject {
infoFlagsOut: nil infoFlagsOut: nil
) { status, infoFlags, sampleBuffer in ) { status, infoFlags, sampleBuffer in
guard let sampleBuffer else { return } guard let sampleBuffer else { return }
AppDelegate.controller.streamView.display(sampleBuffer: sampleBuffer)
let packet = ScreamPacket( let packet = ScreamPacket(
timestamp: sampleBuffer.presentationTimeStamp.seconds, timestamp: sampleBuffer.presentationTimeStamp.seconds,
data: try! sampleBuffer.dataBuffer!.dataBytes(), data: try! sampleBuffer.dataBuffer!.dataBytes(),
@@ -85,7 +84,6 @@ class CaptureEngine: NSObject {
let data = try! JSONEncoder().encode(packet) let data = try! JSONEncoder().encode(packet)
self.udpServer.send(data) self.udpServer.send(data)
print(packet) print(packet)
AppDelegate.controller.streamView.enqueue(packet: packet)
} }
// outputHandler: self.outputHandler) // outputHandler: self.outputHandler)
continuation.yield(frame) continuation.yield(frame)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.