@desklink/host 0.1.1 → 0.3.0
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.
- package/NOTICE +23 -0
- package/README.md +107 -55
- package/bin/desklink-host.mjs +2 -2
- package/dist/bridge.d.ts +1 -0
- package/dist/bridge.d.ts.map +1 -1
- package/dist/bridge.js +12 -4
- package/dist/bridge.js.map +1 -1
- package/dist/engineProcess.d.ts.map +1 -1
- package/dist/engineProcess.js +1 -0
- package/dist/engineProcess.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/keeper.d.ts +52 -0
- package/dist/keeper.d.ts.map +1 -0
- package/dist/keeper.js +101 -0
- package/dist/keeper.js.map +1 -0
- package/dist/protocol.d.ts +26 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/protocol.js.map +1 -1
- package/dist/resolveEngine.d.ts +3 -3
- package/dist/resolveEngine.d.ts.map +1 -1
- package/dist/resolveEngine.js +24 -11
- package/dist/resolveEngine.js.map +1 -1
- package/docs/BOUNDARY.md +20 -8
- package/docs/PROTOCOL.md +347 -24
- package/engine/Cargo.lock +47 -1
- package/engine/Cargo.toml +13 -2
- package/engine/build.rs +28 -2
- package/engine/native/nvenc_shim.c +453 -0
- package/engine/native/vaapi_shim.c +727 -0
- package/engine/native/vpx_shim.c +54 -4
- package/engine/native/vt_shim.c +448 -0
- package/engine/src/capture.rs +75 -55
- package/engine/src/capture_mac.rs +24 -14
- package/engine/src/convert.rs +286 -61
- package/engine/src/encoder.rs +122 -13
- package/engine/src/h264.rs +188 -0
- package/engine/src/h264_nvenc.rs +308 -0
- package/engine/src/h264_openh264.rs +735 -0
- package/engine/src/h264_vaapi.rs +263 -0
- package/engine/src/h264_vt.rs +368 -0
- package/engine/src/keeper.rs +622 -0
- package/engine/src/mac.rs +9 -6
- package/engine/src/main.rs +64 -4
- package/engine/src/peer.rs +887 -42
- package/engine/src/protocol.rs +153 -4
- package/engine/src/session.rs +1547 -137
- package/engine/src/x11.rs +210 -9
- package/engine/src/x11_mac.rs +12 -0
- package/engine/vendor/libva/COPYING +19 -0
- package/engine/vendor/libva/va/va.h +5450 -0
- package/engine/vendor/libva/va/va_dec_av1.h +695 -0
- package/engine/vendor/libva/va/va_dec_hevc.h +616 -0
- package/engine/vendor/libva/va/va_dec_jpeg.h +157 -0
- package/engine/vendor/libva/va/va_dec_vp8.h +249 -0
- package/engine/vendor/libva/va/va_dec_vp9.h +312 -0
- package/engine/vendor/libva/va/va_dec_vvc.h +688 -0
- package/engine/vendor/libva/va/va_drm.h +61 -0
- package/engine/vendor/libva/va/va_enc_av1.h +1010 -0
- package/engine/vendor/libva/va/va_enc_h264.h +659 -0
- package/engine/vendor/libva/va/va_enc_hevc.h +958 -0
- package/engine/vendor/libva/va/va_enc_jpeg.h +162 -0
- package/engine/vendor/libva/va/va_enc_mpeg2.h +308 -0
- package/engine/vendor/libva/va/va_enc_vp8.h +350 -0
- package/engine/vendor/libva/va/va_enc_vp9.h +639 -0
- package/engine/vendor/libva/va/va_fei.h +170 -0
- package/engine/vendor/libva/va/va_fei_h264.h +505 -0
- package/engine/vendor/libva/va/va_fei_hevc.h +254 -0
- package/engine/vendor/libva/va/va_prot.h +525 -0
- package/engine/vendor/libva/va/va_version.h +87 -0
- package/engine/vendor/libva/va/va_vpp.h +1590 -0
- package/engine/vendor/nv-codec-headers/LICENSE +24 -0
- package/engine/vendor/nv-codec-headers/README +7 -0
- package/engine/vendor/nv-codec-headers/include/ffnvcodec/nvEncodeAPI.h +3825 -0
- package/examples/reference-client.html +1 -1
- package/package.json +3 -2
package/engine/src/main.rs
CHANGED
|
@@ -23,6 +23,16 @@ mod encoder;
|
|
|
23
23
|
#[cfg(all(target_os = "macos", desklink_vpx))]
|
|
24
24
|
mod encoder;
|
|
25
25
|
#[cfg(any(target_os = "linux", all(target_os = "macos", desklink_vpx)))]
|
|
26
|
+
mod h264;
|
|
27
|
+
#[cfg(target_os = "linux")]
|
|
28
|
+
mod h264_nvenc;
|
|
29
|
+
#[cfg(target_os = "linux")]
|
|
30
|
+
mod h264_openh264;
|
|
31
|
+
#[cfg(target_os = "linux")]
|
|
32
|
+
mod h264_vaapi;
|
|
33
|
+
#[cfg(all(target_os = "macos", desklink_vpx))]
|
|
34
|
+
mod h264_vt;
|
|
35
|
+
#[cfg(any(target_os = "linux", all(target_os = "macos", desklink_vpx)))]
|
|
26
36
|
mod indicator;
|
|
27
37
|
#[cfg(target_os = "linux")]
|
|
28
38
|
mod input;
|
|
@@ -30,6 +40,8 @@ mod input;
|
|
|
30
40
|
#[path = "input_mac.rs"]
|
|
31
41
|
mod input;
|
|
32
42
|
#[cfg(target_os = "linux")]
|
|
43
|
+
mod keeper;
|
|
44
|
+
#[cfg(target_os = "linux")]
|
|
33
45
|
mod keymap;
|
|
34
46
|
#[cfg(target_os = "macos")]
|
|
35
47
|
#[path = "keymap_mac.rs"]
|
|
@@ -115,6 +127,7 @@ fn main() {
|
|
|
115
127
|
0
|
|
116
128
|
}
|
|
117
129
|
"serve" => report(runtime.block_on(serve())),
|
|
130
|
+
"keep" => keeper::command(&args[1..]),
|
|
118
131
|
"capture-probe" => report(runtime.block_on(probe(
|
|
119
132
|
args.get(1).and_then(|value| value.parse().ok()),
|
|
120
133
|
args.get(2).map(String::as_str),
|
|
@@ -154,6 +167,9 @@ fn print_help() {
|
|
|
154
167
|
|
|
155
168
|
USAGE:
|
|
156
169
|
desklink-host serve speak the local control protocol on stdin/stdout
|
|
170
|
+
desklink-host keep --display :N
|
|
171
|
+
keep one private X screen: kiosk geometry, focus,
|
|
172
|
+
and a JSON-lines window report on stdout
|
|
157
173
|
desklink-host capabilities print what this machine can do right now
|
|
158
174
|
desklink-host capture-probe [seconds] [display]
|
|
159
175
|
capture frames and report the stream; with a
|
|
@@ -281,12 +297,19 @@ fn frame_shape(frame: &crate::convert::I420) -> u64 {
|
|
|
281
297
|
async fn probe_portal(seconds: u64) -> Result<()> {
|
|
282
298
|
let portal = portal::open(None).await?;
|
|
283
299
|
eprintln!("portal source: {:?}", portal.source);
|
|
300
|
+
// The source's own size: a zero box converts nothing and reports no frames.
|
|
301
|
+
let (width, height) = crate::convert::fit(
|
|
302
|
+
portal.source.width.max(0) as usize,
|
|
303
|
+
portal.source.height.max(0) as usize,
|
|
304
|
+
usize::MAX,
|
|
305
|
+
usize::MAX,
|
|
306
|
+
);
|
|
284
307
|
|
|
285
308
|
let (tx, rx) = std_mpsc::channel();
|
|
286
309
|
let capture = capture::start(
|
|
287
310
|
portal,
|
|
288
|
-
|
|
289
|
-
|
|
311
|
+
width,
|
|
312
|
+
height,
|
|
290
313
|
30,
|
|
291
314
|
Box::new(move |frame, seq, _raw| {
|
|
292
315
|
let _ = tx.send((frame.width, frame.height, seq));
|
|
@@ -452,6 +475,14 @@ fn render_event(notice: session::Notice) -> Option<String> {
|
|
|
452
475
|
"session.frame.changed",
|
|
453
476
|
serde_json::json!({ "sessionId": session_id, "seq": seq, "damage": damage }),
|
|
454
477
|
),
|
|
478
|
+
session::SessionEvent::Input { input } => (
|
|
479
|
+
"session.input",
|
|
480
|
+
serde_json::json!({ "sessionId": session_id, "input": input }),
|
|
481
|
+
),
|
|
482
|
+
session::SessionEvent::KeyframeRequest { generation } => (
|
|
483
|
+
"session.keyframeRequest",
|
|
484
|
+
serde_json::json!({ "sessionId": session_id, "generation": generation }),
|
|
485
|
+
),
|
|
455
486
|
session::SessionEvent::RestoreToken(token) => (
|
|
456
487
|
"session.restoreToken",
|
|
457
488
|
serde_json::json!({ "sessionId": session_id, "token": token }),
|
|
@@ -460,9 +491,9 @@ fn render_event(notice: session::Notice) -> Option<String> {
|
|
|
460
491
|
"session.capture.stopped",
|
|
461
492
|
serde_json::json!({ "sessionId": session_id, "reason": reason }),
|
|
462
493
|
),
|
|
463
|
-
session::SessionEvent::Revoked { reason } => (
|
|
494
|
+
session::SessionEvent::Revoked { reason, code } => (
|
|
464
495
|
"session.revoked",
|
|
465
|
-
serde_json::json!({ "sessionId": session_id, "reason": reason }),
|
|
496
|
+
serde_json::json!({ "sessionId": session_id, "reason": reason, "code": code }),
|
|
466
497
|
),
|
|
467
498
|
};
|
|
468
499
|
serde_json::to_string(&Event {
|
|
@@ -524,6 +555,7 @@ async fn dispatch(
|
|
|
524
555
|
ttl: params.ttl_seconds.map(Duration::from_secs),
|
|
525
556
|
loopback_tcp: params.loopback_tcp,
|
|
526
557
|
agent_indicator: params.agent_indicator,
|
|
558
|
+
local_frames: params.local_frames,
|
|
527
559
|
ice_servers: params
|
|
528
560
|
.ice_servers
|
|
529
561
|
.into_iter()
|
|
@@ -581,6 +613,21 @@ async fn dispatch(
|
|
|
581
613
|
.map_err(|error| ErrorBody::new("transport", format!("{error:#}")))?;
|
|
582
614
|
Ok(serde_json::json!({ "accepted": true }))
|
|
583
615
|
}
|
|
616
|
+
"session.restart_ice" => {
|
|
617
|
+
// The client asks; the engine offers. The fresh offer travels as a
|
|
618
|
+
// new `session.description` event and the client answers it as
|
|
619
|
+
// usual, so no new event shape is needed and the session,
|
|
620
|
+
// generation and control channel survive.
|
|
621
|
+
let session = require_session(current)?;
|
|
622
|
+
let params: protocol::SessionRef = serde_json::from_value(request.params.clone())
|
|
623
|
+
.map_err(|error| ErrorBody::new("malformed", error.to_string()))?;
|
|
624
|
+
check_session(session, ¶ms.session_id, params.generation)?;
|
|
625
|
+
session
|
|
626
|
+
.restart_ice()
|
|
627
|
+
.await
|
|
628
|
+
.map_err(|error| ErrorBody::new("transport", format!("{error:#}")))?;
|
|
629
|
+
Ok(serde_json::json!({ "accepted": true }))
|
|
630
|
+
}
|
|
584
631
|
"session.clipboard.read" => {
|
|
585
632
|
let session = require_session(current)?;
|
|
586
633
|
let params: protocol::ClipboardParams = serde_json::from_value(request.params.clone())
|
|
@@ -625,6 +672,19 @@ async fn dispatch(
|
|
|
625
672
|
.frame(params.since, ¶ms.path, params.region)
|
|
626
673
|
.map_err(|error| ErrorBody::new(error.code, error.message))
|
|
627
674
|
}
|
|
675
|
+
"session.feed" => {
|
|
676
|
+
let session = require_session(current)?;
|
|
677
|
+
let params: protocol::FeedParams = serde_json::from_value(request.params.clone())
|
|
678
|
+
.map_err(|error| ErrorBody::new("malformed", error.to_string()))?;
|
|
679
|
+
check_session(session, ¶ms.session_id, None)?;
|
|
680
|
+
let data = params
|
|
681
|
+
.access_unit()
|
|
682
|
+
.map_err(|message| ErrorBody::new("malformed", message))?;
|
|
683
|
+
session
|
|
684
|
+
.feed(params.keyframe, data)
|
|
685
|
+
.map_err(|error| ErrorBody::new(error.code, error.message))?;
|
|
686
|
+
Ok(serde_json::json!({ "accepted": true }))
|
|
687
|
+
}
|
|
628
688
|
"session.metrics" => {
|
|
629
689
|
let session = require_session(current)?;
|
|
630
690
|
Ok(serde_json::to_value(session.metrics()).unwrap_or(serde_json::Value::Null))
|