BlueGit

ict rusty-teams

feat(calls): video and screen share in calls and meetings

| Before | After |
|---|---|
| Audio only | Receive video: up to 4 participant slots plus a screen-share line, picked by recent speaker; H264 decoded by libwebrtc and drawn in the tiles at up to 30 fps |
| - | Shared screen on the stage with "<name> is sharing", people strip on the right, double click = full window, Esc back |
| - | Camera button (camera picker) with self view; Share screen menu (entire screen or a window), "You are sharing" with Stop |

- Send is single-layer H264; the mixer accepted camera and screen streams (verified in a self-created Meet now meeting with generated patterns, about 640 video packets per run, roster showed both streams).
- Camera and line switching via updateMediaDescriptions; sender stop through RtpParameters.active (set_track(None) crashes in the libwebrtc crate).
- Cameras are enumerated only inside a call (nokhwa); screen and window capture via libwebrtc DesktopCapturer on Windows and Linux.
- Not yet verified with a second person: their camera and screen arriving, our picture on their side, video in 1:1 and incoming calls (incoming stays audio-only for now).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

metis Daniel Däschle · pushed by metis

Authored 2026-10-10 · 7 weeks ago

Hash
1acd5db4de40cf0069e0e88b337d9f50b0dadfcc
Parent
f2d5d5c7
32 files changed +3402 −178
Cargo.lock +506 −123
@@ -103,7 +103,7 @@ version = "0.8.4"
103 103 source = "registry+https://github.com/rust-lang/crates.io-index"
104 104 checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
105 105 dependencies = [
106 "cfg-if",
106 "cfg-if 1.0.5",
107 107 "cipher",
108 108 "cpufeatures 0.2.17",
109 109 "zeroize",
@@ -115,7 +115,7 @@ version = "0.8.12"
115 115 source = "registry+https://github.com/rust-lang/crates.io-index"
116 116 checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
117 117 dependencies = [
118 "cfg-if",
118 "cfg-if 1.0.5",
119 119 "const-random",
120 120 "once_cell",
121 121 "version_check",
@@ -163,7 +163,7 @@ checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d"
163 163 dependencies = [
164 164 "alsa-sys",
165 165 "bitflags 2.13.2",
166 "cfg-if",
166 "cfg-if 1.0.5",
167 167 "libc",
168 168 ]
169 169
@@ -436,13 +436,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
436 436 checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
437 437 dependencies = [
438 438 "autocfg",
439 "cfg-if",
439 "cfg-if 1.0.5",
440 440 "concurrent-queue",
441 441 "futures-io",
442 442 "futures-lite",
443 443 "parking",
444 444 "polling",
445 "rustix",
445 "rustix 1.1.5",
446 446 "slab",
447 447 "windows-sys 0.61.2",
448 448 ]
@@ -481,10 +481,10 @@ dependencies = [
481 481 "async-signal",
482 482 "async-task",
483 483 "blocking",
484 "cfg-if",
484 "cfg-if 1.0.5",
485 485 "event-listener",
486 486 "futures-lite",
487 "rustix",
487 "rustix 1.1.5",
488 488 ]
489 489
490 490 [[package]]
@@ -507,10 +507,10 @@ dependencies = [
507 507 "async-io",
508 508 "async-lock",
509 509 "atomic-waker",
510 "cfg-if",
510 "cfg-if 1.0.5",
511 511 "futures-core",
512 512 "futures-io",
513 "rustix",
513 "rustix 1.1.5",
514 514 "signal-hook-registry",
515 515 "slab",
516 516 "windows-sys 0.61.2",
@@ -540,7 +540,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
540 540 checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"
541 541 dependencies = [
542 542 "atk-sys",
543 "glib",
543 "glib 0.18.5",
544 544 "libc",
545 545 ]
546 546
@@ -550,10 +550,10 @@ version = "0.18.2"
550 550 source = "registry+https://github.com/rust-lang/crates.io-index"
551 551 checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"
552 552 dependencies = [
553 "glib-sys",
554 "gobject-sys",
553 "glib-sys 0.18.1",
554 "gobject-sys 0.18.0",
555 555 "libc",
556 "system-deps",
556 "system-deps 6.2.2",
557 557 ]
558 558
559 559 [[package]]
@@ -684,7 +684,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
684 684 checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"
685 685 dependencies = [
686 686 "addr2line",
687 "cfg-if",
687 "cfg-if 1.0.5",
688 688 "libc",
689 689 "miniz_oxide 0.8.9",
690 690 "object",
@@ -710,6 +710,29 @@ version = "0.23.1"
710 710 source = "registry+https://github.com/rust-lang/crates.io-index"
711 711 checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
712 712
713 [[package]]
714 name = "bindgen"
715 version = "0.65.1"
716 source = "registry+https://github.com/rust-lang/crates.io-index"
717 checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
718 dependencies = [
719 "bitflags 1.3.2",
720 "cexpr",
721 "clang-sys",
722 "lazy_static",
723 "lazycell",
724 "log",
725 "peeking_take_while",
726 "prettyplease",
727 "proc-macro2",
728 "quote",
729 "regex",
730 "rustc-hash 1.1.0",
731 "shlex 1.3.0",
732 "syn 2.0.119",
733 "which 4.4.2",
734 ]
735
713 736 [[package]]
714 737 name = "bindgen"
715 738 version = "0.72.1"
@@ -946,7 +969,7 @@ checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"
946 969 dependencies = [
947 970 "bitflags 2.13.2",
948 971 "cairo-sys-rs",
949 "glib",
972 "glib 0.18.5",
950 973 "libc",
951 974 "once_cell",
952 975 "thiserror 1.0.69",
@@ -958,9 +981,9 @@ version = "0.18.2"
958 981 source = "registry+https://github.com/rust-lang/crates.io-index"
959 982 checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"
960 983 dependencies = [
961 "glib-sys",
984 "glib-sys 0.18.1",
962 985 "libc",
963 "system-deps",
986 "system-deps 6.2.2",
964 987 ]
965 988
966 989 [[package]]
@@ -972,6 +995,7 @@ dependencies = [
972 995 "flate2",
973 996 "futures-util",
974 997 "libwebrtc",
998 "nokhwa",
975 999 "serde",
976 1000 "serde_json",
977 1001 "session",
@@ -989,7 +1013,7 @@ checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e"
989 1013 dependencies = [
990 1014 "bitflags 2.13.2",
991 1015 "polling",
992 "rustix",
1016 "rustix 1.1.5",
993 1017 "tracing",
994 1018 ]
995 1019
@@ -1000,7 +1024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1000 1024 checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa"
1001 1025 dependencies = [
1002 1026 "calloop",
1003 "rustix",
1027 "rustix 1.1.5",
1004 1028 "wayland-backend",
1005 1029 "wayland-client",
1006 1030 ]
@@ -1066,9 +1090,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1066 1090 checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
1067 1091 dependencies = [
1068 1092 "smallvec",
1069 "target-lexicon",
1093 "target-lexicon 0.12.16",
1094 ]
1095
1096 [[package]]
1097 name = "cfg-expr"
1098 version = "0.20.10"
1099 source = "registry+https://github.com/rust-lang/crates.io-index"
1100 checksum = "9ba9e9ec16c447027685b1f897b720e18e9a8afd00bd7332c483537e38086c9f"
1101 dependencies = [
1102 "smallvec",
1103 "target-lexicon 0.13.5",
1070 1104 ]
1071 1105
1106 [[package]]
1107 name = "cfg-if"
1108 version = "0.1.10"
1109 source = "registry+https://github.com/rust-lang/crates.io-index"
1110 checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
1111
1072 1112 [[package]]
1073 1113 name = "cfg-if"
1074 1114 version = "1.0.5"
@@ -1096,7 +1136,7 @@ version = "0.10.2"
1096 1136 source = "registry+https://github.com/rust-lang/crates.io-index"
1097 1137 checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
1098 1138 dependencies = [
1099 "cfg-if",
1139 "cfg-if 1.0.5",
1100 1140 "cpufeatures 0.3.1",
1101 1141 "rand_core 0.10.1",
1102 1142 ]
@@ -1216,6 +1256,21 @@ dependencies = [
1216 1256 "cc",
1217 1257 ]
1218 1258
1259 [[package]]
1260 name = "cocoa"
1261 version = "0.20.2"
1262 source = "registry+https://github.com/rust-lang/crates.io-index"
1263 checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8"
1264 dependencies = [
1265 "bitflags 1.3.2",
1266 "block",
1267 "core-foundation 0.7.0",
1268 "core-graphics 0.19.2",
1269 "foreign-types 0.3.2",
1270 "libc",
1271 "objc",
1272 ]
1273
1219 1274 [[package]]
1220 1275 name = "cocoa"
1221 1276 version = "0.25.0"
@@ -1227,7 +1282,7 @@ dependencies = [
1227 1282 "cocoa-foundation 0.1.2",
1228 1283 "core-foundation 0.9.4",
1229 1284 "core-graphics 0.23.2",
1230 "foreign-types",
1285 "foreign-types 0.5.0",
1231 1286 "libc",
1232 1287 "objc",
1233 1288 ]
@@ -1243,7 +1298,7 @@ dependencies = [
1243 1298 "cocoa-foundation 0.2.1",
1244 1299 "core-foundation 0.10.1",
1245 1300 "core-graphics 0.24.0",
1246 "foreign-types",
1301 "foreign-types 0.5.0",
1247 1302 "libc",
1248 1303 "objc",
1249 1304 ]
@@ -1341,7 +1396,7 @@ version = "0.1.7"
1341 1396 source = "registry+https://github.com/rust-lang/crates.io-index"
1342 1397 checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
1343 1398 dependencies = [
1344 "cfg-if",
1399 "cfg-if 1.0.5",
1345 1400 "wasm-bindgen",
1346 1401 ]
1347 1402
@@ -1389,13 +1444,23 @@ dependencies = [
1389 1444 "unicode-segmentation",
1390 1445 ]
1391 1446
1447 [[package]]
1448 name = "core-foundation"
1449 version = "0.7.0"
1450 source = "registry+https://github.com/rust-lang/crates.io-index"
1451 checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
1452 dependencies = [
1453 "core-foundation-sys 0.7.0",
1454 "libc",
1455 ]
1456
1392 1457 [[package]]
1393 1458 name = "core-foundation"
1394 1459 version = "0.9.4"
1395 1460 source = "registry+https://github.com/rust-lang/crates.io-index"
1396 1461 checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
1397 1462 dependencies = [
1398 "core-foundation-sys",
1463 "core-foundation-sys 0.8.7",
1399 1464 "libc",
1400 1465 ]
1401 1466
@@ -1405,16 +1470,34 @@ version = "0.10.1"
1405 1470 source = "registry+https://github.com/rust-lang/crates.io-index"
1406 1471 checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
1407 1472 dependencies = [
1408 "core-foundation-sys",
1473 "core-foundation-sys 0.8.7",
1409 1474 "libc",
1410 1475 ]
1411 1476
1477 [[package]]
1478 name = "core-foundation-sys"
1479 version = "0.7.0"
1480 source = "registry+https://github.com/rust-lang/crates.io-index"
1481 checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
1482
1412 1483 [[package]]
1413 1484 name = "core-foundation-sys"
1414 1485 version = "0.8.7"
1415 1486 source = "registry+https://github.com/rust-lang/crates.io-index"
1416 1487 checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
1417 1488
1489 [[package]]
1490 name = "core-graphics"
1491 version = "0.19.2"
1492 source = "registry+https://github.com/rust-lang/crates.io-index"
1493 checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
1494 dependencies = [
1495 "bitflags 1.3.2",
1496 "core-foundation 0.7.0",
1497 "foreign-types 0.3.2",
1498 "libc",
1499 ]
1500
1418 1501 [[package]]
1419 1502 name = "core-graphics"
1420 1503 version = "0.23.2"
@@ -1424,7 +1507,7 @@ dependencies = [
1424 1507 "bitflags 1.3.2",
1425 1508 "core-foundation 0.9.4",
1426 1509 "core-graphics-types 0.1.3",
1427 "foreign-types",
1510 "foreign-types 0.5.0",
1428 1511 "libc",
1429 1512 ]
1430 1513
@@ -1437,7 +1520,7 @@ dependencies = [
1437 1520 "bitflags 2.13.2",
1438 1521 "core-foundation 0.10.1",
1439 1522 "core-graphics-types 0.2.0",
1440 "foreign-types",
1523 "foreign-types 0.5.0",
1441 1524 "libc",
1442 1525 ]
1443 1526
@@ -1450,7 +1533,7 @@ dependencies = [
1450 1533 "bitflags 2.13.2",
1451 1534 "core-foundation 0.9.4",
1452 1535 "core-graphics-types 0.1.3",
1453 "foreign-types",
1536 "foreign-types 0.5.0",
1454 1537 "libc",
1455 1538 ]
1456 1539
@@ -1484,11 +1567,22 @@ checksum = "4416167a69126e617f8d0a214af0e3c1dbdeffcb100ddf72dcd1a1ac9893c146"
1484 1567 dependencies = [
1485 1568 "bitflags 2.13.2",
1486 1569 "block",
1487 "cfg-if",
1570 "cfg-if 1.0.5",
1488 1571 "core-foundation 0.10.1",
1489 1572 "libc",
1490 1573 ]
1491 1574
1575 [[package]]
1576 name = "core-media-sys"
1577 version = "0.1.2"
1578 source = "registry+https://github.com/rust-lang/crates.io-index"
1579 checksum = "273bf3fc5bf51fd06a7766a84788c1540b6527130a0bce39e00567d6ab9f31f1"
1580 dependencies = [
1581 "cfg-if 0.1.10",
1582 "core-foundation-sys 0.7.0",
1583 "libc",
1584 ]
1585
1492 1586 [[package]]
1493 1587 name = "core-text"
1494 1588 version = "21.0.0"
@@ -1497,7 +1591,7 @@ checksum = "a593227b66cbd4007b2a050dfdd9e1d1318311409c8d600dc82ba1b15ca9c130"
1497 1591 dependencies = [
1498 1592 "core-foundation 0.10.1",
1499 1593 "core-graphics 0.24.0",
1500 "foreign-types",
1594 "foreign-types 0.5.0",
1501 1595 "libc",
1502 1596 ]
1503 1597
@@ -1512,7 +1606,21 @@ dependencies = [
1512 1606 "core-graphics2",
1513 1607 "io-surface",
1514 1608 "libc",
1515 "metal",
1609 "metal 0.33.0",
1610 ]
1611
1612 [[package]]
1613 name = "core-video-sys"
1614 version = "0.1.4"
1615 source = "registry+https://github.com/rust-lang/crates.io-index"
1616 checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
1617 dependencies = [
1618 "cfg-if 0.1.10",
1619 "core-foundation-sys 0.7.0",
1620 "core-graphics 0.19.2",
1621 "libc",
1622 "metal 0.18.0",
1623 "objc",
1516 1624 ]
1517 1625
1518 1626 [[package]]
@@ -1622,7 +1730,7 @@ version = "1.5.2"
1622 1730 source = "registry+https://github.com/rust-lang/crates.io-index"
1623 1731 checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
1624 1732 dependencies = [
1625 "cfg-if",
1733 "cfg-if 1.0.5",
1626 1734 ]
1627 1735
1628 1736 [[package]]
@@ -2049,7 +2157,7 @@ version = "0.8.42"
2049 2157 source = "registry+https://github.com/rust-lang/crates.io-index"
2050 2158 checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"
2051 2159 dependencies = [
2052 "cfg-if",
2160 "cfg-if 1.0.5",
2053 2161 "core_detect",
2054 2162 "multiversion_no_op",
2055 2163 "rustversion",
@@ -2334,6 +2442,18 @@ dependencies = [
2334 2442 "bitflags 1.3.2",
2335 2443 ]
2336 2444
2445 [[package]]
2446 name = "flume"
2447 version = "0.11.1"
2448 source = "registry+https://github.com/rust-lang/crates.io-index"
2449 checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095"
2450 dependencies = [
2451 "futures-core",
2452 "futures-sink",
2453 "nanorand",
2454 "spin 0.9.9",
2455 ]
2456
2337 2457 [[package]]
2338 2458 name = "flume"
2339 2459 version = "0.12.0"
@@ -2405,6 +2525,15 @@ dependencies = [
2405 2525 "ttf-parser",
2406 2526 ]
2407 2527
2528 [[package]]
2529 name = "foreign-types"
2530 version = "0.3.2"
2531 source = "registry+https://github.com/rust-lang/crates.io-index"
2532 checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
2533 dependencies = [
2534 "foreign-types-shared 0.1.1",
2535 ]
2536
2408 2537 [[package]]
2409 2538 name = "foreign-types"
2410 2539 version = "0.5.0"
@@ -2412,7 +2541,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2412 2541 checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
2413 2542 dependencies = [
2414 2543 "foreign-types-macros",
2415 "foreign-types-shared",
2544 "foreign-types-shared 0.3.1",
2416 2545 ]
2417 2546
2418 2547 [[package]]
@@ -2426,6 +2555,12 @@ dependencies = [
2426 2555 "syn 3.0.6",
2427 2556 ]
2428 2557
2558 [[package]]
2559 name = "foreign-types-shared"
2560 version = "0.1.1"
2561 source = "registry+https://github.com/rust-lang/crates.io-index"
2562 checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
2563
2429 2564 [[package]]
2430 2565 name = "foreign-types-shared"
2431 2566 version = "0.3.1"
@@ -2620,7 +2755,7 @@ dependencies = [
2620 2755 "gdk-pixbuf",
2621 2756 "gdk-sys",
2622 2757 "gio",
2623 "glib",
2758 "glib 0.18.5",
2624 2759 "libc",
2625 2760 "pango",
2626 2761 ]
@@ -2633,7 +2768,7 @@ checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec"
2633 2768 dependencies = [
2634 2769 "gdk-pixbuf-sys",
2635 2770 "gio",
2636 "glib",
2771 "glib 0.18.5",
2637 2772 "libc",
2638 2773 "once_cell",
2639 2774 ]
@@ -2644,11 +2779,11 @@ version = "0.18.0"
2644 2779 source = "registry+https://github.com/rust-lang/crates.io-index"
2645 2780 checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"
2646 2781 dependencies = [
2647 "gio-sys",
2648 "glib-sys",
2649 "gobject-sys",
2782 "gio-sys 0.18.1",
2783 "glib-sys 0.18.1",
2784 "gobject-sys 0.18.0",
2650 2785 "libc",
2651 "system-deps",
2786 "system-deps 6.2.2",
2652 2787 ]
2653 2788
2654 2789 [[package]]
@@ -2659,13 +2794,13 @@ checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7"
2659 2794 dependencies = [
2660 2795 "cairo-sys-rs",
2661 2796 "gdk-pixbuf-sys",
2662 "gio-sys",
2663 "glib-sys",
2664 "gobject-sys",
2797 "gio-sys 0.18.1",
2798 "glib-sys 0.18.1",
2799 "gobject-sys 0.18.0",
2665 2800 "libc",
2666 2801 "pango-sys",
2667 2802 "pkg-config",
2668 "system-deps",
2803 "system-deps 6.2.2",
2669 2804 ]
2670 2805
2671 2806 [[package]]
@@ -2684,7 +2819,7 @@ version = "1.1.0"
2684 2819 source = "registry+https://github.com/rust-lang/crates.io-index"
2685 2820 checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
2686 2821 dependencies = [
2687 "rustix",
2822 "rustix 1.1.5",
2688 2823 "windows-link 0.2.1",
2689 2824 ]
2690 2825
@@ -2703,7 +2838,7 @@ version = "0.2.17"
2703 2838 source = "registry+https://github.com/rust-lang/crates.io-index"
2704 2839 checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
2705 2840 dependencies = [
2706 "cfg-if",
2841 "cfg-if 1.0.5",
2707 2842 "js-sys",
2708 2843 "libc",
2709 2844 "wasi",
@@ -2716,7 +2851,7 @@ version = "0.3.4"
2716 2851 source = "registry+https://github.com/rust-lang/crates.io-index"
2717 2852 checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
2718 2853 dependencies = [
2719 "cfg-if",
2854 "cfg-if 1.0.5",
2720 2855 "js-sys",
2721 2856 "libc",
2722 2857 "r-efi 5.3.0",
@@ -2730,7 +2865,7 @@ version = "0.4.3"
2730 2865 source = "registry+https://github.com/rust-lang/crates.io-index"
2731 2866 checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
2732 2867 dependencies = [
2733 "cfg-if",
2868 "cfg-if 1.0.5",
2734 2869 "js-sys",
2735 2870 "libc",
2736 2871 "r-efi 6.0.0",
@@ -2774,8 +2909,8 @@ dependencies = [
2774 2909 "futures-core",
2775 2910 "futures-io",
2776 2911 "futures-util",
2777 "gio-sys",
2778 "glib",
2912 "gio-sys 0.18.1",
2913 "glib 0.18.5",
2779 2914 "libc",
2780 2915 "once_cell",
2781 2916 "pin-project-lite",
@@ -2789,13 +2924,26 @@ version = "0.18.1"
2789 2924 source = "registry+https://github.com/rust-lang/crates.io-index"
2790 2925 checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"
2791 2926 dependencies = [
2792 "glib-sys",
2793 "gobject-sys",
2927 "glib-sys 0.18.1",
2928 "gobject-sys 0.18.0",
2794 2929 "libc",
2795 "system-deps",
2930 "system-deps 6.2.2",
2796 2931 "winapi",
2797 2932 ]
2798 2933
2934 [[package]]
2935 name = "gio-sys"
2936 version = "0.21.5"
2937 source = "registry+https://github.com/rust-lang/crates.io-index"
2938 checksum = "0071fe88dba8e40086c8ff9bbb62622999f49628344b1d1bf490a48a29d80f22"
2939 dependencies = [
2940 "glib-sys 0.21.5",
2941 "gobject-sys 0.21.5",
2942 "libc",
2943 "system-deps 7.0.8",
2944 "windows-sys 0.52.0",
2945 ]
2946
2799 2947 [[package]]
2800 2948 name = "gl_generator"
2801 2949 version = "0.14.0"
@@ -2819,10 +2967,10 @@ dependencies = [
2819 2967 "futures-executor",
2820 2968 "futures-task",
2821 2969 "futures-util",
2822 "gio-sys",
2823 "glib-macros",
2824 "glib-sys",
2825 "gobject-sys",
2970 "gio-sys 0.18.1",
2971 "glib-macros 0.18.5",
2972 "glib-sys 0.18.1",
2973 "gobject-sys 0.18.0",
2826 2974 "libc",
2827 2975 "memchr",
2828 2976 "once_cell",
@@ -2830,6 +2978,27 @@ dependencies = [
2830 2978 "thiserror 1.0.69",
2831 2979 ]
2832 2980
2981 [[package]]
2982 name = "glib"
2983 version = "0.21.5"
2984 source = "registry+https://github.com/rust-lang/crates.io-index"
2985 checksum = "16de123c2e6c90ce3b573b7330de19be649080ec612033d397d72da265f1bd8b"
2986 dependencies = [
2987 "bitflags 2.13.2",
2988 "futures-channel",
2989 "futures-core",
2990 "futures-executor",
2991 "futures-task",
2992 "futures-util",
2993 "gio-sys 0.21.5",
2994 "glib-macros 0.21.5",
2995 "glib-sys 0.21.5",
2996 "gobject-sys 0.21.5",
2997 "libc",
2998 "memchr",
2999 "smallvec",
3000 ]
3001
2833 3002 [[package]]
2834 3003 name = "glib-macros"
2835 3004 version = "0.18.5"
@@ -2844,6 +3013,19 @@ dependencies = [
2844 3013 "syn 2.0.119",
2845 3014 ]
2846 3015
3016 [[package]]
3017 name = "glib-macros"
3018 version = "0.21.5"
3019 source = "registry+https://github.com/rust-lang/crates.io-index"
3020 checksum = "cf59b675301228a696fe01c3073974643365080a76cc3ed5bc2cbc466ad87f17"
3021 dependencies = [
3022 "heck 0.5.0",
3023 "proc-macro-crate 3.5.0",
3024 "proc-macro2",
3025 "quote",
3026 "syn 2.0.119",
3027 ]
3028
2847 3029 [[package]]
2848 3030 name = "glib-sys"
2849 3031 version = "0.18.1"
@@ -2851,7 +3033,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2851 3033 checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898"
2852 3034 dependencies = [
2853 3035 "libc",
2854 "system-deps",
3036 "system-deps 6.2.2",
3037 ]
3038
3039 [[package]]
3040 name = "glib-sys"
3041 version = "0.21.5"
3042 source = "registry+https://github.com/rust-lang/crates.io-index"
3043 checksum = "2d95e1a3a19ae464a7286e14af9a90683c64d70c02532d88d87ce95056af3e6c"
3044 dependencies = [
3045 "libc",
3046 "system-deps 7.0.8",
2855 3047 ]
2856 3048
2857 3049 [[package]]
@@ -2911,9 +3103,20 @@ version = "0.18.0"
2911 3103 source = "registry+https://github.com/rust-lang/crates.io-index"
2912 3104 checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"
2913 3105 dependencies = [
2914 "glib-sys",
3106 "glib-sys 0.18.1",
3107 "libc",
3108 "system-deps 6.2.2",
3109 ]
3110
3111 [[package]]
3112 name = "gobject-sys"
3113 version = "0.21.5"
3114 source = "registry+https://github.com/rust-lang/crates.io-index"
3115 checksum = "2dca35da0d19a18f4575f3cb99fe1c9e029a2941af5662f326f738a21edaf294"
3116 dependencies = [
3117 "glib-sys 0.21.5",
2915 3118 "libc",
2916 "system-deps",
3119 "system-deps 7.0.8",
2917 3120 ]
2918 3121
2919 3122 [[package]]
@@ -3085,7 +3288,7 @@ dependencies = [
3085 3288 "async-channel",
3086 3289 "async-task",
3087 3290 "backtrace",
3088 "bindgen",
3291 "bindgen 0.72.1",
3089 3292 "bitflags 2.13.2",
3090 3293 "chrono",
3091 3294 "core-video",
@@ -3163,14 +3366,14 @@ dependencies = [
3163 3366 "derive_more 2.1.1",
3164 3367 "dispatch2",
3165 3368 "etagere",
3166 "foreign-types",
3369 "foreign-types 0.5.0",
3167 3370 "gpui-pre",
3168 3371 "gpui-pre-util",
3169 3372 "image",
3170 3373 "libc",
3171 3374 "log",
3172 3375 "mach2",
3173 "metal",
3376 "metal 0.33.0",
3174 3377 "objc2 0.6.5",
3175 3378 "objc2-foundation 0.3.2",
3176 3379 "objc2-quartz-core 0.3.2",
@@ -3289,13 +3492,13 @@ dependencies = [
3289 3492 "block2 0.6.2",
3290 3493 "cocoa 0.26.1",
3291 3494 "core-foundation 0.10.1",
3292 "core-foundation-sys",
3495 "core-foundation-sys 0.8.7",
3293 3496 "core-graphics 0.24.0",
3294 3497 "core-text",
3295 3498 "core-video",
3296 3499 "ctor",
3297 3500 "dispatch2",
3298 "foreign-types",
3501 "foreign-types 0.5.0",
3299 3502 "futures",
3300 3503 "gpui-pre",
3301 3504 "gpui-pre-apple",
@@ -3449,7 +3652,7 @@ dependencies = [
3449 3652 "async-task",
3450 3653 "backtrace",
3451 3654 "chrono",
3452 "flume",
3655 "flume 0.12.0",
3453 3656 "futures",
3454 3657 "parking_lot",
3455 3658 "rand 0.9.5",
@@ -3489,7 +3692,7 @@ checksum = "e1635ae7d0b05400bfa211ddef6c67dc8d9f223c463022c2b3bf2c1c14c6044f"
3489 3692 dependencies = [
3490 3693 "anyhow",
3491 3694 "log",
3492 "which",
3695 "which 8.0.6",
3493 3696 ]
3494 3697
3495 3698 [[package]]
@@ -3563,8 +3766,6 @@ dependencies = [
3563 3766 [[package]]
3564 3767 name = "gpui-pre-windows"
3565 3768 version = "0.3.8"
3566 source = "registry+https://github.com/rust-lang/crates.io-index"
3567 checksum = "371f9bb13f97e3bea2f8b8e5e81232bb74d735153c244ae67f7400e743925b1c"
3568 3769 dependencies = [
3569 3770 "accesskit",
3570 3771 "accesskit_windows",
@@ -3658,7 +3859,7 @@ dependencies = [
3658 3859 "gdk",
3659 3860 "gdk-pixbuf",
3660 3861 "gio",
3661 "glib",
3862 "glib 0.18.5",
3662 3863 "gtk-sys",
3663 3864 "gtk3-macros",
3664 3865 "libc",
@@ -3676,12 +3877,12 @@ dependencies = [
3676 3877 "cairo-sys-rs",
3677 3878 "gdk-pixbuf-sys",
3678 3879 "gdk-sys",
3679 "gio-sys",
3680 "glib-sys",
3681 "gobject-sys",
3880 "gio-sys 0.18.1",
3881 "glib-sys 0.18.1",
3882 "gobject-sys 0.18.0",
3682 3883 "libc",
3683 3884 "pango-sys",
3684 "system-deps",
3885 "system-deps 6.2.2",
3685 3886 ]
3686 3887
3687 3888 [[package]]
@@ -3722,7 +3923,7 @@ version = "2.7.1"
3722 3923 source = "registry+https://github.com/rust-lang/crates.io-index"
3723 3924 checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
3724 3925 dependencies = [
3725 "cfg-if",
3926 "cfg-if 1.0.5",
3726 3927 "crunchy",
3727 3928 "num-traits",
3728 3929 "zerocopy",
@@ -3849,6 +4050,15 @@ dependencies = [
3849 4050 "digest 0.10.7",
3850 4051 ]
3851 4052
4053 [[package]]
4054 name = "home"
4055 version = "0.5.12"
4056 source = "registry+https://github.com/rust-lang/crates.io-index"
4057 checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
4058 dependencies = [
4059 "windows-sys 0.61.2",
4060 ]
4061
3852 4062 [[package]]
3853 4063 name = "html5ever"
3854 4064 version = "0.27.0"
@@ -3991,7 +4201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3991 4201 checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
3992 4202 dependencies = [
3993 4203 "android_system_properties",
3994 "core-foundation-sys",
4204 "core-foundation-sys 0.8.7",
3995 4205 "iana-time-zone-haiku",
3996 4206 "js-sys",
3997 4207 "log",
@@ -4227,7 +4437,7 @@ version = "0.1.13"
4227 4437 source = "registry+https://github.com/rust-lang/crates.io-index"
4228 4438 checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
4229 4439 dependencies = [
4230 "cfg-if",
4440 "cfg-if 1.0.5",
4231 4441 "js-sys",
4232 4442 "wasm-bindgen",
4233 4443 "web-sys",
@@ -4261,7 +4471,7 @@ checksum = "554b8c5d64ec09a3a520fe58e4d48a73e00ff32899cdcbe32a4877afd4968b8e"
4261 4471 dependencies = [
4262 4472 "cgl",
4263 4473 "core-foundation 0.10.1",
4264 "core-foundation-sys",
4474 "core-foundation-sys 0.8.7",
4265 4475 "leaky-cow",
4266 4476 ]
4267 4477
@@ -4336,7 +4546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
4336 4546 checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
4337 4547 dependencies = [
4338 4548 "cesu8",
4339 "cfg-if",
4549 "cfg-if 1.0.5",
4340 4550 "combine",
4341 4551 "jni-sys 0.3.1",
4342 4552 "log",
@@ -4351,7 +4561,7 @@ version = "0.22.4"
4351 4561 source = "registry+https://github.com/rust-lang/crates.io-index"
4352 4562 checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498"
4353 4563 dependencies = [
4354 "cfg-if",
4564 "cfg-if 1.0.5",
4355 4565 "combine",
4356 4566 "jni-macros",
4357 4567 "jni-sys 0.4.1",
@@ -4419,7 +4629,7 @@ version = "0.3.106"
4419 4629 source = "registry+https://github.com/rust-lang/crates.io-index"
4420 4630 checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
4421 4631 dependencies = [
4422 "cfg-if",
4632 "cfg-if 1.0.5",
4423 4633 "futures-util",
4424 4634 "wasm-bindgen",
4425 4635 ]
@@ -4501,6 +4711,12 @@ version = "1.5.1"
4501 4711 source = "registry+https://github.com/rust-lang/crates.io-index"
4502 4712 checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
4503 4713
4714 [[package]]
4715 name = "lazycell"
4716 version = "1.3.0"
4717 source = "registry+https://github.com/rust-lang/crates.io-index"
4718 checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
4719
4504 4720 [[package]]
4505 4721 name = "leak"
4506 4722 version = "0.1.2"
@@ -4528,7 +4744,7 @@ version = "0.9.0"
4528 4744 source = "registry+https://github.com/rust-lang/crates.io-index"
4529 4745 checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"
4530 4746 dependencies = [
4531 "glib",
4747 "glib 0.18.5",
4532 4748 "gtk",
4533 4749 "gtk-sys",
4534 4750 "libappindicator-sys",
@@ -4574,7 +4790,7 @@ version = "0.7.4"
4574 4790 source = "registry+https://github.com/rust-lang/crates.io-index"
4575 4791 checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
4576 4792 dependencies = [
4577 "cfg-if",
4793 "cfg-if 1.0.5",
4578 4794 "winapi",
4579 4795 ]
4580 4796
@@ -4584,7 +4800,7 @@ version = "0.8.9"
4584 4800 source = "registry+https://github.com/rust-lang/crates.io-index"
4585 4801 checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
4586 4802 dependencies = [
4587 "cfg-if",
4803 "cfg-if 1.0.5",
4588 4804 "windows-link 0.2.1",
4589 4805 ]
4590 4806
@@ -4621,6 +4837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
4621 4837 checksum = "14f9145a63a8439508a9b5b51dffa4b1c12f812f49fcc4310ebae3d467f639ab"
4622 4838 dependencies = [
4623 4839 "cxx",
4840 "glib 0.21.5",
4624 4841 "jni 0.21.1",
4625 4842 "js-sys",
4626 4843 "lazy_static",
@@ -4665,6 +4882,12 @@ version = "0.2.3"
4665 4882 source = "registry+https://github.com/rust-lang/crates.io-index"
4666 4883 checksum = "7e57c38c1e860fd37c604281cdfb1dd2216977fd76a50f85ba2f388ef3219616"
4667 4884
4885 [[package]]
4886 name = "linux-raw-sys"
4887 version = "0.4.15"
4888 source = "registry+https://github.com/rust-lang/crates.io-index"
4889 checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
4890
4668 4891 [[package]]
4669 4892 name = "linux-raw-sys"
4670 4893 version = "0.12.1"
@@ -4887,7 +5110,7 @@ version = "0.1.1"
4887 5110 source = "registry+https://github.com/rust-lang/crates.io-index"
4888 5111 checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519"
4889 5112 dependencies = [
4890 "cfg-if",
5113 "cfg-if 1.0.5",
4891 5114 "rayon",
4892 5115 ]
4893 5116
@@ -4897,7 +5120,7 @@ version = "0.10.6"
4897 5120 source = "registry+https://github.com/rust-lang/crates.io-index"
4898 5121 checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
4899 5122 dependencies = [
4900 "cfg-if",
5123 "cfg-if 1.0.5",
4901 5124 "digest 0.10.7",
4902 5125 ]
4903 5126
@@ -4925,6 +5148,21 @@ dependencies = [
4925 5148 "autocfg",
4926 5149 ]
4927 5150
5151 [[package]]
5152 name = "metal"
5153 version = "0.18.0"
5154 source = "registry+https://github.com/rust-lang/crates.io-index"
5155 checksum = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0"
5156 dependencies = [
5157 "bitflags 1.3.2",
5158 "block",
5159 "cocoa 0.20.2",
5160 "core-graphics 0.19.2",
5161 "foreign-types 0.3.2",
5162 "log",
5163 "objc",
5164 ]
5165
4928 5166 [[package]]
4929 5167 name = "metal"
4930 5168 version = "0.33.0"
@@ -4934,7 +5172,7 @@ dependencies = [
4934 5172 "bitflags 2.13.2",
4935 5173 "block",
4936 5174 "core-graphics-types 0.2.0",
4937 "foreign-types",
5175 "foreign-types 0.5.0",
4938 5176 "log",
4939 5177 "objc",
4940 5178 "paste",
@@ -5039,7 +5277,7 @@ dependencies = [
5039 5277 "arrayvec",
5040 5278 "bit-set 0.9.1",
5041 5279 "bitflags 2.13.2",
5042 "cfg-if",
5280 "cfg-if 1.0.5",
5043 5281 "cfg_aliases",
5044 5282 "codespan-reporting",
5045 5283 "half",
@@ -5056,6 +5294,15 @@ dependencies = [
5056 5294 "unicode-ident",
5057 5295 ]
5058 5296
5297 [[package]]
5298 name = "nanorand"
5299 version = "0.7.0"
5300 source = "registry+https://github.com/rust-lang/crates.io-index"
5301 checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
5302 dependencies = [
5303 "getrandom 0.2.17",
5304 ]
5305
5059 5306 [[package]]
5060 5307 name = "ndk"
5061 5308 version = "0.9.0"
@@ -5106,6 +5353,72 @@ version = "0.2.0"
5106 5353 source = "registry+https://github.com/rust-lang/crates.io-index"
5107 5354 checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
5108 5355
5356 [[package]]
5357 name = "nokhwa"
5358 version = "0.10.11"
5359 source = "registry+https://github.com/rust-lang/crates.io-index"
5360 checksum = "9d63f10b450319a0ace7aa8e0e25477d1fdb345313a97e220e886175539a1dbb"
5361 dependencies = [
5362 "flume 0.11.1",
5363 "image",
5364 "nokhwa-bindings-linux",
5365 "nokhwa-bindings-macos",
5366 "nokhwa-bindings-windows",
5367 "nokhwa-core",
5368 "paste",
5369 "thiserror 2.0.21",
5370 ]
5371
5372 [[package]]
5373 name = "nokhwa-bindings-linux"
5374 version = "0.1.4"
5375 source = "registry+https://github.com/rust-lang/crates.io-index"
5376 checksum = "bb67e22201a53322291740ca064b20eaaade7222ef0349f312d9b37b004e1984"
5377 dependencies = [
5378 "libc",
5379 "nokhwa-core",
5380 "v4l",
5381 ]
5382
5383 [[package]]
5384 name = "nokhwa-bindings-macos"
5385 version = "0.2.4"
5386 source = "registry+https://github.com/rust-lang/crates.io-index"
5387 checksum = "f70d3908ea68324e44a6b3a0f885aa59e433fb1f6678839d09e0df7d226fb42d"
5388 dependencies = [
5389 "block",
5390 "cocoa-foundation 0.2.1",
5391 "core-foundation 0.10.1",
5392 "core-media-sys",
5393 "core-video-sys",
5394 "flume 0.11.1",
5395 "nokhwa-core",
5396 "objc",
5397 "once_cell",
5398 ]
5399
5400 [[package]]
5401 name = "nokhwa-bindings-windows"
5402 version = "0.4.6"
5403 source = "registry+https://github.com/rust-lang/crates.io-index"
5404 checksum = "5be28886bad8abcec3655c1f24b965b4cb596a72b23164c910c54439ce55d2a4"
5405 dependencies = [
5406 "nokhwa-core",
5407 "once_cell",
5408 "windows 0.62.2",
5409 ]
5410
5411 [[package]]
5412 name = "nokhwa-core"
5413 version = "0.1.9"
5414 source = "registry+https://github.com/rust-lang/crates.io-index"
5415 checksum = "b1cba20bebd3bd9ae22f9273ade5bbe49da3e047c8512b53fbaf8b4b9c80d496"
5416 dependencies = [
5417 "bytes",
5418 "image",
5419 "thiserror 2.0.21",
5420 ]
5421
5109 5422 [[package]]
5110 5423 name = "nom"
5111 5424 version = "7.1.3"
@@ -5843,7 +6156,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
5843 6156 checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
5844 6157 dependencies = [
5845 6158 "gio",
5846 "glib",
6159 "glib 0.18.5",
5847 6160 "libc",
5848 6161 "once_cell",
5849 6162 "pango-sys",
@@ -5855,10 +6168,10 @@ version = "0.18.0"
5855 6168 source = "registry+https://github.com/rust-lang/crates.io-index"
5856 6169 checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"
5857 6170 dependencies = [
5858 "glib-sys",
5859 "gobject-sys",
6171 "glib-sys 0.18.1",
6172 "gobject-sys 0.18.0",
5860 6173 "libc",
5861 "system-deps",
6174 "system-deps 6.2.2",
5862 6175 ]
5863 6176
5864 6177 [[package]]
@@ -5883,7 +6196,7 @@ version = "0.9.12"
5883 6196 source = "registry+https://github.com/rust-lang/crates.io-index"
5884 6197 checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
5885 6198 dependencies = [
5886 "cfg-if",
6199 "cfg-if 1.0.5",
5887 6200 "libc",
5888 6201 "redox_syscall",
5889 6202 "smallvec",
@@ -5931,6 +6244,12 @@ dependencies = [
5931 6244 "hmac",
5932 6245 ]
5933 6246
6247 [[package]]
6248 name = "peeking_take_while"
6249 version = "0.1.2"
6250 source = "registry+https://github.com/rust-lang/crates.io-index"
6251 checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
6252
5934 6253 [[package]]
5935 6254 name = "percent-encoding"
5936 6255 version = "2.3.2"
@@ -6113,11 +6432,11 @@ version = "3.11.0"
6113 6432 source = "registry+https://github.com/rust-lang/crates.io-index"
6114 6433 checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"
6115 6434 dependencies = [
6116 "cfg-if",
6435 "cfg-if 1.0.5",
6117 6436 "concurrent-queue",
6118 6437 "hermit-abi",
6119 6438 "pin-project-lite",
6120 "rustix",
6439 "rustix 1.1.5",
6121 6440 "windows-sys 0.61.2",
6122 6441 ]
6123 6442
@@ -6339,7 +6658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
6339 6658 checksum = "046aa45b989642ec2e4717c8e72d677b13edd831a4d3b6cf37d9a3e54912496a"
6340 6659 dependencies = [
6341 6660 "bytemuck",
6342 "cfg-if",
6661 "cfg-if 1.0.5",
6343 6662 "libm",
6344 6663 "num-complex",
6345 6664 "paste",
@@ -6588,7 +6907,7 @@ dependencies = [
6588 6907 "av1-grain",
6589 6908 "bitstream-io",
6590 6909 "built",
6591 "cfg-if",
6910 "cfg-if 1.0.5",
6592 6911 "interpolate_name",
6593 6912 "itertools 0.14.0",
6594 6913 "libc",
@@ -6874,7 +7193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
6874 7193 checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
6875 7194 dependencies = [
6876 7195 "cc",
6877 "cfg-if",
7196 "cfg-if 1.0.5",
6878 7197 "getrandom 0.2.17",
6879 7198 "libc",
6880 7199 "untrusted",
@@ -7050,6 +7369,19 @@ dependencies = [
7050 7369 "semver",
7051 7370 ]
7052 7371
7372 [[package]]
7373 name = "rustix"
7374 version = "0.38.44"
7375 source = "registry+https://github.com/rust-lang/crates.io-index"
7376 checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
7377 dependencies = [
7378 "bitflags 2.13.2",
7379 "errno",
7380 "libc",
7381 "linux-raw-sys 0.4.15",
7382 "windows-sys 0.52.0",
7383 ]
7384
7053 7385 [[package]]
7054 7386 name = "rustix"
7055 7387 version = "1.1.5"
@@ -7059,7 +7391,7 @@ dependencies = [
7059 7391 "bitflags 2.13.2",
7060 7392 "errno",
7061 7393 "libc",
7062 "linux-raw-sys",
7394 "linux-raw-sys 0.12.1",
7063 7395 "windows-sys 0.61.2",
7064 7396 ]
7065 7397
@@ -7117,7 +7449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
7117 7449 checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98"
7118 7450 dependencies = [
7119 7451 "core-foundation 0.10.1",
7120 "core-foundation-sys",
7452 "core-foundation-sys 0.8.7",
7121 7453 "jni 0.22.4",
7122 7454 "log",
7123 7455 "once_cell",
@@ -7305,7 +7637,7 @@ checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"
7305 7637 dependencies = [
7306 7638 "bitflags 2.13.2",
7307 7639 "core-foundation 0.10.1",
7308 "core-foundation-sys",
7640 "core-foundation-sys 0.8.7",
7309 7641 "libc",
7310 7642 "security-framework-sys",
7311 7643 ]
@@ -7316,7 +7648,7 @@ version = "2.17.0"
7316 7648 source = "registry+https://github.com/rust-lang/crates.io-index"
7317 7649 checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3"
7318 7650 dependencies = [
7319 "core-foundation-sys",
7651 "core-foundation-sys 0.8.7",
7320 7652 "libc",
7321 7653 ]
7322 7654
@@ -7515,7 +7847,7 @@ version = "0.10.7"
7515 7847 source = "registry+https://github.com/rust-lang/crates.io-index"
7516 7848 checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8"
7517 7849 dependencies = [
7518 "cfg-if",
7850 "cfg-if 1.0.5",
7519 7851 "cpufeatures 0.2.17",
7520 7852 "digest 0.10.7",
7521 7853 ]
@@ -7532,7 +7864,7 @@ version = "0.10.9"
7532 7864 source = "registry+https://github.com/rust-lang/crates.io-index"
7533 7865 checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
7534 7866 dependencies = [
7535 "cfg-if",
7867 "cfg-if 1.0.5",
7536 7868 "cpufeatures 0.2.17",
7537 7869 "digest 0.10.7",
7538 7870 ]
@@ -7543,7 +7875,7 @@ version = "0.11.0"
7543 7875 source = "registry+https://github.com/rust-lang/crates.io-index"
7544 7876 checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
7545 7877 dependencies = [
7546 "cfg-if",
7878 "cfg-if 1.0.5",
7547 7879 "cpufeatures 0.3.1",
7548 7880 "digest 0.11.3",
7549 7881 ]
@@ -8068,7 +8400,7 @@ version = "0.31.4"
8068 8400 source = "registry+https://github.com/rust-lang/crates.io-index"
8069 8401 checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be"
8070 8402 dependencies = [
8071 "core-foundation-sys",
8403 "core-foundation-sys 0.8.7",
8072 8404 "libc",
8073 8405 "memchr",
8074 8406 "ntapi",
@@ -8093,7 +8425,7 @@ version = "0.6.0"
8093 8425 source = "registry+https://github.com/rust-lang/crates.io-index"
8094 8426 checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
8095 8427 dependencies = [
8096 "core-foundation-sys",
8428 "core-foundation-sys 0.8.7",
8097 8429 "libc",
8098 8430 ]
8099 8431
@@ -8103,13 +8435,26 @@ version = "6.2.2"
8103 8435 source = "registry+https://github.com/rust-lang/crates.io-index"
8104 8436 checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
8105 8437 dependencies = [
8106 "cfg-expr",
8438 "cfg-expr 0.15.8",
8107 8439 "heck 0.5.0",
8108 8440 "pkg-config",
8109 8441 "toml 0.8.23",
8110 8442 "version-compare",
8111 8443 ]
8112 8444
8445 [[package]]
8446 name = "system-deps"
8447 version = "7.0.8"
8448 source = "registry+https://github.com/rust-lang/crates.io-index"
8449 checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7"
8450 dependencies = [
8451 "cfg-expr 0.20.10",
8452 "heck 0.5.0",
8453 "pkg-config",
8454 "toml 1.1.6+spec-1.1.0",
8455 "version-compare",
8456 ]
8457
8113 8458 [[package]]
8114 8459 name = "taffy"
8115 8460 version = "0.13.0"
@@ -8128,8 +8473,8 @@ version = "0.2.0"
8128 8473 source = "registry+https://github.com/rust-lang/crates.io-index"
8129 8474 checksum = "271450eb289cb4d8d0720c6ce70c72c8c858c93dd61fc625881616752e6b98f6"
8130 8475 dependencies = [
8131 "cfg-if",
8132 "core-foundation-sys",
8476 "cfg-if 1.0.5",
8477 "core-foundation-sys 0.8.7",
8133 8478 "libc",
8134 8479 "objc",
8135 8480 ]
@@ -8140,6 +8485,12 @@ version = "0.12.16"
8140 8485 source = "registry+https://github.com/rust-lang/crates.io-index"
8141 8486 checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
8142 8487
8488 [[package]]
8489 name = "target-lexicon"
8490 version = "0.13.5"
8491 source = "registry+https://github.com/rust-lang/crates.io-index"
8492 checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
8493
8143 8494 [[package]]
8144 8495 name = "tauri-winrt-notification"
8145 8496 version = "0.8.1"
@@ -8181,7 +8532,7 @@ dependencies = [
8181 8532 "fastrand",
8182 8533 "getrandom 0.4.3",
8183 8534 "once_cell",
8184 "rustix",
8535 "rustix 1.1.5",
8185 8536 "windows-sys 0.61.2",
8186 8537 ]
8187 8538
@@ -8251,7 +8602,7 @@ version = "1.1.10"
8251 8602 source = "registry+https://github.com/rust-lang/crates.io-index"
8252 8603 checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
8253 8604 dependencies = [
8254 "cfg-if",
8605 "cfg-if 1.0.5",
8255 8606 ]
8256 8607
8257 8608 [[package]]
@@ -8305,7 +8656,7 @@ dependencies = [
8305 8656 "arrayref",
8306 8657 "arrayvec",
8307 8658 "bytemuck",
8308 "cfg-if",
8659 "cfg-if 1.0.5",
8309 8660 "log",
8310 8661 "png 0.17.16",
8311 8662 "tiny-skia-path",
@@ -8914,6 +9265,26 @@ dependencies = [
8914 9265 "wasm-bindgen",
8915 9266 ]
8916 9267
9268 [[package]]
9269 name = "v4l"
9270 version = "0.14.0"
9271 source = "registry+https://github.com/rust-lang/crates.io-index"
9272 checksum = "d8fbfea44a46799d62c55323f3c55d06df722fbe577851d848d328a1041c3403"
9273 dependencies = [
9274 "bitflags 1.3.2",
9275 "libc",
9276 "v4l2-sys-mit",
9277 ]
9278
9279 [[package]]
9280 name = "v4l2-sys-mit"
9281 version = "0.3.0"
9282 source = "registry+https://github.com/rust-lang/crates.io-index"
9283 checksum = "6779878362b9bacadc7893eac76abe69612e8837ef746573c4a5239daf11990b"
9284 dependencies = [
9285 "bindgen 0.65.1",
9286 ]
9287
8917 9288 [[package]]
8918 9289 name = "v_frame"
8919 9290 version = "0.3.9"
@@ -9060,7 +9431,7 @@ version = "0.2.129"
9060 9431 source = "registry+https://github.com/rust-lang/crates.io-index"
9061 9432 checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
9062 9433 dependencies = [
9063 "cfg-if",
9434 "cfg-if 1.0.5",
9064 9435 "once_cell",
9065 9436 "rustversion",
9066 9437 "wasm-bindgen-macro",
@@ -9144,7 +9515,7 @@ dependencies = [
9144 9515 "cc",
9145 9516 "downcast-rs",
9146 9517 "log",
9147 "rustix",
9518 "rustix 1.1.5",
9148 9519 "scoped-tls",
9149 9520 "smallvec",
9150 9521 "wayland-sys",
@@ -9157,7 +9528,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
9157 9528 checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073"
9158 9529 dependencies = [
9159 9530 "bitflags 2.13.2",
9160 "rustix",
9531 "rustix 1.1.5",
9161 9532 "wayland-backend",
9162 9533 "wayland-scanner",
9163 9534 ]
@@ -9168,7 +9539,7 @@ version = "0.31.14"
9168 9539 source = "registry+https://github.com/rust-lang/crates.io-index"
9169 9540 checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d"
9170 9541 dependencies = [
9171 "rustix",
9542 "rustix 1.1.5",
9172 9543 "wayland-client",
9173 9544 "xcursor",
9174 9545 ]
@@ -9363,7 +9734,7 @@ dependencies = [
9363 9734 "arrayvec",
9364 9735 "bitflags 2.13.2",
9365 9736 "bytemuck",
9366 "cfg-if",
9737 "cfg-if 1.0.5",
9367 9738 "cfg_aliases",
9368 9739 "document-features",
9369 9740 "hashbrown 0.16.1",
@@ -9467,7 +9838,7 @@ dependencies = [
9467 9838 "bitflags 2.13.2",
9468 9839 "block2 0.6.2",
9469 9840 "bytemuck",
9470 "cfg-if",
9841 "cfg-if 1.0.5",
9471 9842 "cfg_aliases",
9472 9843 "glow",
9473 9844 "glutin_wgl_sys",
@@ -9532,6 +9903,18 @@ dependencies = [
9532 9903 "web-sys",
9533 9904 ]
9534 9905
9906 [[package]]
9907 name = "which"
9908 version = "4.4.2"
9909 source = "registry+https://github.com/rust-lang/crates.io-index"
9910 checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
9911 dependencies = [
9912 "either",
9913 "home",
9914 "once_cell",
9915 "rustix 0.38.44",
9916 ]
9917
9535 9918 [[package]]
9536 9919 name = "which"
9537 9920 version = "8.0.6"
@@ -10262,7 +10645,7 @@ version = "0.56.0"
10262 10645 source = "registry+https://github.com/rust-lang/crates.io-index"
10263 10646 checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10"
10264 10647 dependencies = [
10265 "cfg-if",
10648 "cfg-if 1.0.5",
10266 10649 "windows-sys 0.61.2",
10267 10650 ]
10268 10651
@@ -10306,7 +10689,7 @@ dependencies = [
10306 10689 "as-raw-xcb-connection",
10307 10690 "gethostname",
10308 10691 "libc",
10309 "rustix",
10692 "rustix 1.1.5",
10310 10693 "x11rb-protocol",
10311 10694 "xcursor",
10312 10695 ]
@@ -10462,7 +10845,7 @@ dependencies = [
10462 10845 "hex",
10463 10846 "libc",
10464 10847 "ordered-stream",
10465 "rustix",
10848 "rustix 1.1.5",
10466 10849 "serde",
10467 10850 "serde_repr",
10468 10851 "tracing",
@@ -103,7 +103,7 @@ version = "0.8.4"
103source = "registry+https://github.com/rust-lang/crates.io-index"
103source = "registry+https://github.com/rust-lang/crates.io-index"
104checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
104checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
105dependencies = [
105dependencies = [
106 "cfg-if",
106 "cfg-if 1.0.5",
107 "cipher",
107 "cipher",
108 "cpufeatures 0.2.17",
108 "cpufeatures 0.2.17",
109 "zeroize",
109 "zeroize",
@@ -115,7 +115,7 @@ version = "0.8.12"
115source = "registry+https://github.com/rust-lang/crates.io-index"
115source = "registry+https://github.com/rust-lang/crates.io-index"
116checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
116checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75"
117dependencies = [
117dependencies = [
118 "cfg-if",
118 "cfg-if 1.0.5",
119 "const-random",
119 "const-random",
120 "once_cell",
120 "once_cell",
121 "version_check",
121 "version_check",
@@ -163,7 +163,7 @@ checksum = "812947049edcd670a82cd5c73c3661d2e58468577ba8489de58e1a73c04cbd5d"
163dependencies = [
163dependencies = [
164 "alsa-sys",
164 "alsa-sys",
165 "bitflags 2.13.2",
165 "bitflags 2.13.2",
166 "cfg-if",
166 "cfg-if 1.0.5",
167 "libc",
167 "libc",
168]
168]
169
169
@@ -436,13 +436,13 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
436checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
436checksum = "456b8a8feb6f42d237746d4b3e9a178494627745c3c56c6ea55d92ba50d026fc"
437dependencies = [
437dependencies = [
438 "autocfg",
438 "autocfg",
439 "cfg-if",
439 "cfg-if 1.0.5",
440 "concurrent-queue",
440 "concurrent-queue",
441 "futures-io",
441 "futures-io",
442 "futures-lite",
442 "futures-lite",
443 "parking",
443 "parking",
444 "polling",
444 "polling",
445 "rustix",
445 "rustix 1.1.5",
446 "slab",
446 "slab",
447 "windows-sys 0.61.2",
447 "windows-sys 0.61.2",
448]
448]
@@ -481,10 +481,10 @@ dependencies = [
481 "async-signal",
481 "async-signal",
482 "async-task",
482 "async-task",
483 "blocking",
483 "blocking",
484 "cfg-if",
484 "cfg-if 1.0.5",
485 "event-listener",
485 "event-listener",
486 "futures-lite",
486 "futures-lite",
487 "rustix",
487 "rustix 1.1.5",
488]
488]
489
489
490[[package]]
490[[package]]
@@ -507,10 +507,10 @@ dependencies = [
507 "async-io",
507 "async-io",
508 "async-lock",
508 "async-lock",
509 "atomic-waker",
509 "atomic-waker",
510 "cfg-if",
510 "cfg-if 1.0.5",
511 "futures-core",
511 "futures-core",
512 "futures-io",
512 "futures-io",
513 "rustix",
513 "rustix 1.1.5",
514 "signal-hook-registry",
514 "signal-hook-registry",
515 "slab",
515 "slab",
516 "windows-sys 0.61.2",
516 "windows-sys 0.61.2",
@@ -540,7 +540,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
540checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"
540checksum = "241b621213072e993be4f6f3a9e4b45f65b7e6faad43001be957184b7bb1824b"
541dependencies = [
541dependencies = [
542 "atk-sys",
542 "atk-sys",
543 "glib",
543 "glib 0.18.5",
544 "libc",
544 "libc",
545]
545]
546
546
@@ -550,10 +550,10 @@ version = "0.18.2"
550source = "registry+https://github.com/rust-lang/crates.io-index"
550source = "registry+https://github.com/rust-lang/crates.io-index"
551checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"
551checksum = "c5e48b684b0ca77d2bbadeef17424c2ea3c897d44d566a1617e7e8f30614d086"
552dependencies = [
552dependencies = [
553 "glib-sys",
553 "glib-sys 0.18.1",
554 "gobject-sys",
554 "gobject-sys 0.18.0",
555 "libc",
555 "libc",
556 "system-deps",
556 "system-deps 6.2.2",
557]
557]
558
558
559[[package]]
559[[package]]
@@ -684,7 +684,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
684checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"
684checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"
685dependencies = [
685dependencies = [
686 "addr2line",
686 "addr2line",
687 "cfg-if",
687 "cfg-if 1.0.5",
688 "libc",
688 "libc",
689 "miniz_oxide 0.8.9",
689 "miniz_oxide 0.8.9",
690 "object",
690 "object",
@@ -710,6 +710,29 @@ version = "0.23.1"
710source = "registry+https://github.com/rust-lang/crates.io-index"
710source = "registry+https://github.com/rust-lang/crates.io-index"
711checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
711checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
712
712
713[[package]]
714name = "bindgen"
715version = "0.65.1"
716source = "registry+https://github.com/rust-lang/crates.io-index"
717checksum = "cfdf7b466f9a4903edc73f95d6d2bcd5baf8ae620638762244d3f60143643cc5"
718dependencies = [
719 "bitflags 1.3.2",
720 "cexpr",
721 "clang-sys",
722 "lazy_static",
723 "lazycell",
724 "log",
725 "peeking_take_while",
726 "prettyplease",
727 "proc-macro2",
728 "quote",
729 "regex",
730 "rustc-hash 1.1.0",
731 "shlex 1.3.0",
732 "syn 2.0.119",
733 "which 4.4.2",
734]
735
713[[package]]
736[[package]]
714name = "bindgen"
737name = "bindgen"
715version = "0.72.1"
738version = "0.72.1"
@@ -946,7 +969,7 @@ checksum = "8ca26ef0159422fb77631dc9d17b102f253b876fe1586b03b803e63a309b4ee2"
946dependencies = [
969dependencies = [
947 "bitflags 2.13.2",
970 "bitflags 2.13.2",
948 "cairo-sys-rs",
971 "cairo-sys-rs",
949 "glib",
972 "glib 0.18.5",
950 "libc",
973 "libc",
951 "once_cell",
974 "once_cell",
952 "thiserror 1.0.69",
975 "thiserror 1.0.69",
@@ -958,9 +981,9 @@ version = "0.18.2"
958source = "registry+https://github.com/rust-lang/crates.io-index"
981source = "registry+https://github.com/rust-lang/crates.io-index"
959checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"
982checksum = "685c9fa8e590b8b3d678873528d83411db17242a73fccaed827770ea0fedda51"
960dependencies = [
983dependencies = [
961 "glib-sys",
984 "glib-sys 0.18.1",
962 "libc",
985 "libc",
963 "system-deps",
986 "system-deps 6.2.2",
964]
987]
965
988
966[[package]]
989[[package]]
@@ -972,6 +995,7 @@ dependencies = [
972 "flate2",
995 "flate2",
973 "futures-util",
996 "futures-util",
974 "libwebrtc",
997 "libwebrtc",
998 "nokhwa",
975 "serde",
999 "serde",
976 "serde_json",
1000 "serde_json",
977 "session",
1001 "session",
@@ -989,7 +1013,7 @@ checksum = "43b32313e937c8721c9d17ee9bf60699a6402b4b7c2cb6ac1bee0ffcaa4b4e5e"
989dependencies = [
1013dependencies = [
990 "bitflags 2.13.2",
1014 "bitflags 2.13.2",
991 "polling",
1015 "polling",
992 "rustix",
1016 "rustix 1.1.5",
993 "tracing",
1017 "tracing",
994]
1018]
995
1019
@@ -1000,7 +1024,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1000checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa"
1024checksum = "138efcf0940a02ebf0cc8d1eff41a1682a46b431630f4c52450d6265876021fa"
1001dependencies = [
1025dependencies = [
1002 "calloop",
1026 "calloop",
1003 "rustix",
1027 "rustix 1.1.5",
1004 "wayland-backend",
1028 "wayland-backend",
1005 "wayland-client",
1029 "wayland-client",
1006]
1030]
@@ -1066,9 +1090,25 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1066checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
1090checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
1067dependencies = [
1091dependencies = [
1068 "smallvec",
1092 "smallvec",
1069 "target-lexicon",
1093 "target-lexicon 0.12.16",
1094]
1095
1096[[package]]
1097name = "cfg-expr"
1098version = "0.20.10"
1099source = "registry+https://github.com/rust-lang/crates.io-index"
1100checksum = "9ba9e9ec16c447027685b1f897b720e18e9a8afd00bd7332c483537e38086c9f"
1101dependencies = [
1102 "smallvec",
1103 "target-lexicon 0.13.5",
1070]
1104]
1071
1105
1106[[package]]
1107name = "cfg-if"
1108version = "0.1.10"
1109source = "registry+https://github.com/rust-lang/crates.io-index"
1110checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
1111
1072[[package]]
1112[[package]]
1073name = "cfg-if"
1113name = "cfg-if"
1074version = "1.0.5"
1114version = "1.0.5"
@@ -1096,7 +1136,7 @@ version = "0.10.2"
1096source = "registry+https://github.com/rust-lang/crates.io-index"
1136source = "registry+https://github.com/rust-lang/crates.io-index"
1097checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
1137checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"
1098dependencies = [
1138dependencies = [
1099 "cfg-if",
1139 "cfg-if 1.0.5",
1100 "cpufeatures 0.3.1",
1140 "cpufeatures 0.3.1",
1101 "rand_core 0.10.1",
1141 "rand_core 0.10.1",
1102]
1142]
@@ -1216,6 +1256,21 @@ dependencies = [
1216 "cc",
1256 "cc",
1217]
1257]
1218
1258
1259[[package]]
1260name = "cocoa"
1261version = "0.20.2"
1262source = "registry+https://github.com/rust-lang/crates.io-index"
1263checksum = "0c49e86fc36d5704151f5996b7b3795385f50ce09e3be0f47a0cfde869681cf8"
1264dependencies = [
1265 "bitflags 1.3.2",
1266 "block",
1267 "core-foundation 0.7.0",
1268 "core-graphics 0.19.2",
1269 "foreign-types 0.3.2",
1270 "libc",
1271 "objc",
1272]
1273
1219[[package]]
1274[[package]]
1220name = "cocoa"
1275name = "cocoa"
1221version = "0.25.0"
1276version = "0.25.0"
@@ -1227,7 +1282,7 @@ dependencies = [
1227 "cocoa-foundation 0.1.2",
1282 "cocoa-foundation 0.1.2",
1228 "core-foundation 0.9.4",
1283 "core-foundation 0.9.4",
1229 "core-graphics 0.23.2",
1284 "core-graphics 0.23.2",
1230 "foreign-types",
1285 "foreign-types 0.5.0",
1231 "libc",
1286 "libc",
1232 "objc",
1287 "objc",
1233]
1288]
@@ -1243,7 +1298,7 @@ dependencies = [
1243 "cocoa-foundation 0.2.1",
1298 "cocoa-foundation 0.2.1",
1244 "core-foundation 0.10.1",
1299 "core-foundation 0.10.1",
1245 "core-graphics 0.24.0",
1300 "core-graphics 0.24.0",
1246 "foreign-types",
1301 "foreign-types 0.5.0",
1247 "libc",
1302 "libc",
1248 "objc",
1303 "objc",
1249]
1304]
@@ -1341,7 +1396,7 @@ version = "0.1.7"
1341source = "registry+https://github.com/rust-lang/crates.io-index"
1396source = "registry+https://github.com/rust-lang/crates.io-index"
1342checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
1397checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
1343dependencies = [
1398dependencies = [
1344 "cfg-if",
1399 "cfg-if 1.0.5",
1345 "wasm-bindgen",
1400 "wasm-bindgen",
1346]
1401]
1347
1402
@@ -1389,13 +1444,23 @@ dependencies = [
1389 "unicode-segmentation",
1444 "unicode-segmentation",
1390]
1445]
1391
1446
1447[[package]]
1448name = "core-foundation"
1449version = "0.7.0"
1450source = "registry+https://github.com/rust-lang/crates.io-index"
1451checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171"
1452dependencies = [
1453 "core-foundation-sys 0.7.0",
1454 "libc",
1455]
1456
1392[[package]]
1457[[package]]
1393name = "core-foundation"
1458name = "core-foundation"
1394version = "0.9.4"
1459version = "0.9.4"
1395source = "registry+https://github.com/rust-lang/crates.io-index"
1460source = "registry+https://github.com/rust-lang/crates.io-index"
1396checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
1461checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"
1397dependencies = [
1462dependencies = [
1398 "core-foundation-sys",
1463 "core-foundation-sys 0.8.7",
1399 "libc",
1464 "libc",
1400]
1465]
1401
1466
@@ -1405,16 +1470,34 @@ version = "0.10.1"
1405source = "registry+https://github.com/rust-lang/crates.io-index"
1470source = "registry+https://github.com/rust-lang/crates.io-index"
1406checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
1471checksum = "b2a6cd9ae233e7f62ba4e9353e81a88df7fc8a5987b8d445b4d90c879bd156f6"
1407dependencies = [
1472dependencies = [
1408 "core-foundation-sys",
1473 "core-foundation-sys 0.8.7",
1409 "libc",
1474 "libc",
1410]
1475]
1411
1476
1477[[package]]
1478name = "core-foundation-sys"
1479version = "0.7.0"
1480source = "registry+https://github.com/rust-lang/crates.io-index"
1481checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac"
1482
1412[[package]]
1483[[package]]
1413name = "core-foundation-sys"
1484name = "core-foundation-sys"
1414version = "0.8.7"
1485version = "0.8.7"
1415source = "registry+https://github.com/rust-lang/crates.io-index"
1486source = "registry+https://github.com/rust-lang/crates.io-index"
1416checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
1487checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
1417
1488
1489[[package]]
1490name = "core-graphics"
1491version = "0.19.2"
1492source = "registry+https://github.com/rust-lang/crates.io-index"
1493checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923"
1494dependencies = [
1495 "bitflags 1.3.2",
1496 "core-foundation 0.7.0",
1497 "foreign-types 0.3.2",
1498 "libc",
1499]
1500
1418[[package]]
1501[[package]]
1419name = "core-graphics"
1502name = "core-graphics"
1420version = "0.23.2"
1503version = "0.23.2"
@@ -1424,7 +1507,7 @@ dependencies = [
1424 "bitflags 1.3.2",
1507 "bitflags 1.3.2",
1425 "core-foundation 0.9.4",
1508 "core-foundation 0.9.4",
1426 "core-graphics-types 0.1.3",
1509 "core-graphics-types 0.1.3",
1427 "foreign-types",
1510 "foreign-types 0.5.0",
1428 "libc",
1511 "libc",
1429]
1512]
1430
1513
@@ -1437,7 +1520,7 @@ dependencies = [
1437 "bitflags 2.13.2",
1520 "bitflags 2.13.2",
1438 "core-foundation 0.10.1",
1521 "core-foundation 0.10.1",
1439 "core-graphics-types 0.2.0",
1522 "core-graphics-types 0.2.0",
1440 "foreign-types",
1523 "foreign-types 0.5.0",
1441 "libc",
1524 "libc",
1442]
1525]
1443
1526
@@ -1450,7 +1533,7 @@ dependencies = [
1450 "bitflags 2.13.2",
1533 "bitflags 2.13.2",
1451 "core-foundation 0.9.4",
1534 "core-foundation 0.9.4",
1452 "core-graphics-types 0.1.3",
1535 "core-graphics-types 0.1.3",
1453 "foreign-types",
1536 "foreign-types 0.5.0",
1454 "libc",
1537 "libc",
1455]
1538]
1456
1539
@@ -1484,11 +1567,22 @@ checksum = "4416167a69126e617f8d0a214af0e3c1dbdeffcb100ddf72dcd1a1ac9893c146"
1484dependencies = [
1567dependencies = [
1485 "bitflags 2.13.2",
1568 "bitflags 2.13.2",
1486 "block",
1569 "block",
1487 "cfg-if",
1570 "cfg-if 1.0.5",
1488 "core-foundation 0.10.1",
1571 "core-foundation 0.10.1",
1489 "libc",
1572 "libc",
1490]
1573]
1491
1574
1575[[package]]
1576name = "core-media-sys"
1577version = "0.1.2"
1578source = "registry+https://github.com/rust-lang/crates.io-index"
1579checksum = "273bf3fc5bf51fd06a7766a84788c1540b6527130a0bce39e00567d6ab9f31f1"
1580dependencies = [
1581 "cfg-if 0.1.10",
1582 "core-foundation-sys 0.7.0",
1583 "libc",
1584]
1585
1492[[package]]
1586[[package]]
1493name = "core-text"
1587name = "core-text"
1494version = "21.0.0"
1588version = "21.0.0"
@@ -1497,7 +1591,7 @@ checksum = "a593227b66cbd4007b2a050dfdd9e1d1318311409c8d600dc82ba1b15ca9c130"
1497dependencies = [
1591dependencies = [
1498 "core-foundation 0.10.1",
1592 "core-foundation 0.10.1",
1499 "core-graphics 0.24.0",
1593 "core-graphics 0.24.0",
1500 "foreign-types",
1594 "foreign-types 0.5.0",
1501 "libc",
1595 "libc",
1502]
1596]
1503
1597
@@ -1512,7 +1606,21 @@ dependencies = [
1512 "core-graphics2",
1606 "core-graphics2",
1513 "io-surface",
1607 "io-surface",
1514 "libc",
1608 "libc",
1515 "metal",
1609 "metal 0.33.0",
1610]
1611
1612[[package]]
1613name = "core-video-sys"
1614version = "0.1.4"
1615source = "registry+https://github.com/rust-lang/crates.io-index"
1616checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828"
1617dependencies = [
1618 "cfg-if 0.1.10",
1619 "core-foundation-sys 0.7.0",
1620 "core-graphics 0.19.2",
1621 "libc",
1622 "metal 0.18.0",
1623 "objc",
1516]
1624]
1517
1625
1518[[package]]
1626[[package]]
@@ -1622,7 +1730,7 @@ version = "1.5.2"
1622source = "registry+https://github.com/rust-lang/crates.io-index"
1730source = "registry+https://github.com/rust-lang/crates.io-index"
1623checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
1731checksum = "01a7799fd6b852db0e61728dde9a204c423b44d689dbd432522543614b490e78"
1624dependencies = [
1732dependencies = [
1625 "cfg-if",
1733 "cfg-if 1.0.5",
1626]
1734]
1627
1735
1628[[package]]
1736[[package]]
@@ -2049,7 +2157,7 @@ version = "0.8.42"
2049source = "registry+https://github.com/rust-lang/crates.io-index"
2157source = "registry+https://github.com/rust-lang/crates.io-index"
2050checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"
2158checksum = "8e985e0451871ad22fb8d2b6b076e2028a502a0d3950998c2c5c0a4f9b5d9679"
2051dependencies = [
2159dependencies = [
2052 "cfg-if",
2160 "cfg-if 1.0.5",
2053 "core_detect",
2161 "core_detect",
2054 "multiversion_no_op",
2162 "multiversion_no_op",
2055 "rustversion",
2163 "rustversion",
@@ -2334,6 +2442,18 @@ dependencies = [
2334 "bitflags 1.3.2",
2442 "bitflags 1.3.2",
2335]
2443]
2336
2444
2445[[package]]
2446name = "flume"
2447version = "0.11.1"
2448source = "registry+https://github.com/rust-lang/crates.io-index"
2449checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095"
2450dependencies = [
2451 "futures-core",
2452 "futures-sink",
2453 "nanorand",
2454 "spin 0.9.9",
2455]
2456
2337[[package]]
2457[[package]]
2338name = "flume"
2458name = "flume"
2339version = "0.12.0"
2459version = "0.12.0"
@@ -2405,6 +2525,15 @@ dependencies = [
2405 "ttf-parser",
2525 "ttf-parser",
2406]
2526]
2407
2527
2528[[package]]
2529name = "foreign-types"
2530version = "0.3.2"
2531source = "registry+https://github.com/rust-lang/crates.io-index"
2532checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
2533dependencies = [
2534 "foreign-types-shared 0.1.1",
2535]
2536
2408[[package]]
2537[[package]]
2409name = "foreign-types"
2538name = "foreign-types"
2410version = "0.5.0"
2539version = "0.5.0"
@@ -2412,7 +2541,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2412checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
2541checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
2413dependencies = [
2542dependencies = [
2414 "foreign-types-macros",
2543 "foreign-types-macros",
2415 "foreign-types-shared",
2544 "foreign-types-shared 0.3.1",
2416]
2545]
2417
2546
2418[[package]]
2547[[package]]
@@ -2426,6 +2555,12 @@ dependencies = [
2426 "syn 3.0.6",
2555 "syn 3.0.6",
2427]
2556]
2428
2557
2558[[package]]
2559name = "foreign-types-shared"
2560version = "0.1.1"
2561source = "registry+https://github.com/rust-lang/crates.io-index"
2562checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
2563
2429[[package]]
2564[[package]]
2430name = "foreign-types-shared"
2565name = "foreign-types-shared"
2431version = "0.3.1"
2566version = "0.3.1"
@@ -2620,7 +2755,7 @@ dependencies = [
2620 "gdk-pixbuf",
2755 "gdk-pixbuf",
2621 "gdk-sys",
2756 "gdk-sys",
2622 "gio",
2757 "gio",
2623 "glib",
2758 "glib 0.18.5",
2624 "libc",
2759 "libc",
2625 "pango",
2760 "pango",
2626]
2761]
@@ -2633,7 +2768,7 @@ checksum = "50e1f5f1b0bfb830d6ccc8066d18db35c487b1b2b1e8589b5dfe9f07e8defaec"
2633dependencies = [
2768dependencies = [
2634 "gdk-pixbuf-sys",
2769 "gdk-pixbuf-sys",
2635 "gio",
2770 "gio",
2636 "glib",
2771 "glib 0.18.5",
2637 "libc",
2772 "libc",
2638 "once_cell",
2773 "once_cell",
2639]
2774]
@@ -2644,11 +2779,11 @@ version = "0.18.0"
2644source = "registry+https://github.com/rust-lang/crates.io-index"
2779source = "registry+https://github.com/rust-lang/crates.io-index"
2645checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"
2780checksum = "3f9839ea644ed9c97a34d129ad56d38a25e6756f99f3a88e15cd39c20629caf7"
2646dependencies = [
2781dependencies = [
2647 "gio-sys",
2782 "gio-sys 0.18.1",
2648 "glib-sys",
2783 "glib-sys 0.18.1",
2649 "gobject-sys",
2784 "gobject-sys 0.18.0",
2650 "libc",
2785 "libc",
2651 "system-deps",
2786 "system-deps 6.2.2",
2652]
2787]
2653
2788
2654[[package]]
2789[[package]]
@@ -2659,13 +2794,13 @@ checksum = "5c2d13f38594ac1e66619e188c6d5a1adb98d11b2fcf7894fc416ad76aa2f3f7"
2659dependencies = [
2794dependencies = [
2660 "cairo-sys-rs",
2795 "cairo-sys-rs",
2661 "gdk-pixbuf-sys",
2796 "gdk-pixbuf-sys",
2662 "gio-sys",
2797 "gio-sys 0.18.1",
2663 "glib-sys",
2798 "glib-sys 0.18.1",
2664 "gobject-sys",
2799 "gobject-sys 0.18.0",
2665 "libc",
2800 "libc",
2666 "pango-sys",
2801 "pango-sys",
2667 "pkg-config",
2802 "pkg-config",
2668 "system-deps",
2803 "system-deps 6.2.2",
2669]
2804]
2670
2805
2671[[package]]
2806[[package]]
@@ -2684,7 +2819,7 @@ version = "1.1.0"
2684source = "registry+https://github.com/rust-lang/crates.io-index"
2819source = "registry+https://github.com/rust-lang/crates.io-index"
2685checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
2820checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8"
2686dependencies = [
2821dependencies = [
2687 "rustix",
2822 "rustix 1.1.5",
2688 "windows-link 0.2.1",
2823 "windows-link 0.2.1",
2689]
2824]
2690
2825
@@ -2703,7 +2838,7 @@ version = "0.2.17"
2703source = "registry+https://github.com/rust-lang/crates.io-index"
2838source = "registry+https://github.com/rust-lang/crates.io-index"
2704checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
2839checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"
2705dependencies = [
2840dependencies = [
2706 "cfg-if",
2841 "cfg-if 1.0.5",
2707 "js-sys",
2842 "js-sys",
2708 "libc",
2843 "libc",
2709 "wasi",
2844 "wasi",
@@ -2716,7 +2851,7 @@ version = "0.3.4"
2716source = "registry+https://github.com/rust-lang/crates.io-index"
2851source = "registry+https://github.com/rust-lang/crates.io-index"
2717checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
2852checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
2718dependencies = [
2853dependencies = [
2719 "cfg-if",
2854 "cfg-if 1.0.5",
2720 "js-sys",
2855 "js-sys",
2721 "libc",
2856 "libc",
2722 "r-efi 5.3.0",
2857 "r-efi 5.3.0",
@@ -2730,7 +2865,7 @@ version = "0.4.3"
2730source = "registry+https://github.com/rust-lang/crates.io-index"
2865source = "registry+https://github.com/rust-lang/crates.io-index"
2731checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
2866checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
2732dependencies = [
2867dependencies = [
2733 "cfg-if",
2868 "cfg-if 1.0.5",
2734 "js-sys",
2869 "js-sys",
2735 "libc",
2870 "libc",
2736 "r-efi 6.0.0",
2871 "r-efi 6.0.0",
@@ -2774,8 +2909,8 @@ dependencies = [
2774 "futures-core",
2909 "futures-core",
2775 "futures-io",
2910 "futures-io",
2776 "futures-util",
2911 "futures-util",
2777 "gio-sys",
2912 "gio-sys 0.18.1",
2778 "glib",
2913 "glib 0.18.5",
2779 "libc",
2914 "libc",
2780 "once_cell",
2915 "once_cell",
2781 "pin-project-lite",
2916 "pin-project-lite",
@@ -2789,13 +2924,26 @@ version = "0.18.1"
2789source = "registry+https://github.com/rust-lang/crates.io-index"
2924source = "registry+https://github.com/rust-lang/crates.io-index"
2790checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"
2925checksum = "37566df850baf5e4cb0dfb78af2e4b9898d817ed9263d1090a2df958c64737d2"
2791dependencies = [
2926dependencies = [
2792 "glib-sys",
2927 "glib-sys 0.18.1",
2793 "gobject-sys",
2928 "gobject-sys 0.18.0",
2794 "libc",
2929 "libc",
2795 "system-deps",
2930 "system-deps 6.2.2",
2796 "winapi",
2931 "winapi",
2797]
2932]
2798
2933
2934[[package]]
2935name = "gio-sys"
2936version = "0.21.5"
2937source = "registry+https://github.com/rust-lang/crates.io-index"
2938checksum = "0071fe88dba8e40086c8ff9bbb62622999f49628344b1d1bf490a48a29d80f22"
2939dependencies = [
2940 "glib-sys 0.21.5",
2941 "gobject-sys 0.21.5",
2942 "libc",
2943 "system-deps 7.0.8",
2944 "windows-sys 0.52.0",
2945]
2946
2799[[package]]
2947[[package]]
2800name = "gl_generator"
2948name = "gl_generator"
2801version = "0.14.0"
2949version = "0.14.0"
@@ -2819,10 +2967,10 @@ dependencies = [
2819 "futures-executor",
2967 "futures-executor",
2820 "futures-task",
2968 "futures-task",
2821 "futures-util",
2969 "futures-util",
2822 "gio-sys",
2970 "gio-sys 0.18.1",
2823 "glib-macros",
2971 "glib-macros 0.18.5",
2824 "glib-sys",
2972 "glib-sys 0.18.1",
2825 "gobject-sys",
2973 "gobject-sys 0.18.0",
2826 "libc",
2974 "libc",
2827 "memchr",
2975 "memchr",
2828 "once_cell",
2976 "once_cell",
@@ -2830,6 +2978,27 @@ dependencies = [
2830 "thiserror 1.0.69",
2978 "thiserror 1.0.69",
2831]
2979]
2832
2980
2981[[package]]
2982name = "glib"
2983version = "0.21.5"
2984source = "registry+https://github.com/rust-lang/crates.io-index"
2985checksum = "16de123c2e6c90ce3b573b7330de19be649080ec612033d397d72da265f1bd8b"
2986dependencies = [
2987 "bitflags 2.13.2",
2988 "futures-channel",
2989 "futures-core",
2990 "futures-executor",
2991 "futures-task",
2992 "futures-util",
2993 "gio-sys 0.21.5",
2994 "glib-macros 0.21.5",
2995 "glib-sys 0.21.5",
2996 "gobject-sys 0.21.5",
2997 "libc",
2998 "memchr",
2999 "smallvec",
3000]
3001
2833[[package]]
3002[[package]]
2834name = "glib-macros"
3003name = "glib-macros"
2835version = "0.18.5"
3004version = "0.18.5"
@@ -2844,6 +3013,19 @@ dependencies = [
2844 "syn 2.0.119",
3013 "syn 2.0.119",
2845]
3014]
2846
3015
3016[[package]]
3017name = "glib-macros"
3018version = "0.21.5"
3019source = "registry+https://github.com/rust-lang/crates.io-index"
3020checksum = "cf59b675301228a696fe01c3073974643365080a76cc3ed5bc2cbc466ad87f17"
3021dependencies = [
3022 "heck 0.5.0",
3023 "proc-macro-crate 3.5.0",
3024 "proc-macro2",
3025 "quote",
3026 "syn 2.0.119",
3027]
3028
2847[[package]]
3029[[package]]
2848name = "glib-sys"
3030name = "glib-sys"
2849version = "0.18.1"
3031version = "0.18.1"
@@ -2851,7 +3033,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
2851checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898"
3033checksum = "063ce2eb6a8d0ea93d2bf8ba1957e78dbab6be1c2220dd3daca57d5a9d869898"
2852dependencies = [
3034dependencies = [
2853 "libc",
3035 "libc",
2854 "system-deps",
3036 "system-deps 6.2.2",
3037]
3038
3039[[package]]
3040name = "glib-sys"
3041version = "0.21.5"
3042source = "registry+https://github.com/rust-lang/crates.io-index"
3043checksum = "2d95e1a3a19ae464a7286e14af9a90683c64d70c02532d88d87ce95056af3e6c"
3044dependencies = [
3045 "libc",
3046 "system-deps 7.0.8",
2855]
3047]
2856
3048
2857[[package]]
3049[[package]]
@@ -2911,9 +3103,20 @@ version = "0.18.0"
2911source = "registry+https://github.com/rust-lang/crates.io-index"
3103source = "registry+https://github.com/rust-lang/crates.io-index"
2912checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"
3104checksum = "0850127b514d1c4a4654ead6dedadb18198999985908e6ffe4436f53c785ce44"
2913dependencies = [
3105dependencies = [
2914 "glib-sys",
3106 "glib-sys 0.18.1",
3107 "libc",
3108 "system-deps 6.2.2",
3109]
3110
3111[[package]]
3112name = "gobject-sys"
3113version = "0.21.5"
3114source = "registry+https://github.com/rust-lang/crates.io-index"
3115checksum = "2dca35da0d19a18f4575f3cb99fe1c9e029a2941af5662f326f738a21edaf294"
3116dependencies = [
3117 "glib-sys 0.21.5",
2915 "libc",
3118 "libc",
2916 "system-deps",
3119 "system-deps 7.0.8",
2917]
3120]
2918
3121
2919[[package]]
3122[[package]]
@@ -3085,7 +3288,7 @@ dependencies = [
3085 "async-channel",
3288 "async-channel",
3086 "async-task",
3289 "async-task",
3087 "backtrace",
3290 "backtrace",
3088 "bindgen",
3291 "bindgen 0.72.1",
3089 "bitflags 2.13.2",
3292 "bitflags 2.13.2",
3090 "chrono",
3293 "chrono",
3091 "core-video",
3294 "core-video",
@@ -3163,14 +3366,14 @@ dependencies = [
3163 "derive_more 2.1.1",
3366 "derive_more 2.1.1",
3164 "dispatch2",
3367 "dispatch2",
3165 "etagere",
3368 "etagere",
3166 "foreign-types",
3369 "foreign-types 0.5.0",
3167 "gpui-pre",
3370 "gpui-pre",
3168 "gpui-pre-util",
3371 "gpui-pre-util",
3169 "image",
3372 "image",
3170 "libc",
3373 "libc",
3171 "log",
3374 "log",
3172 "mach2",
3375 "mach2",
3173 "metal",
3376 "metal 0.33.0",
3174 "objc2 0.6.5",
3377 "objc2 0.6.5",
3175 "objc2-foundation 0.3.2",
3378 "objc2-foundation 0.3.2",
3176 "objc2-quartz-core 0.3.2",
3379 "objc2-quartz-core 0.3.2",
@@ -3289,13 +3492,13 @@ dependencies = [
3289 "block2 0.6.2",
3492 "block2 0.6.2",
3290 "cocoa 0.26.1",
3493 "cocoa 0.26.1",
3291 "core-foundation 0.10.1",
3494 "core-foundation 0.10.1",
3292 "core-foundation-sys",
3495 "core-foundation-sys 0.8.7",
3293 "core-graphics 0.24.0",
3496 "core-graphics 0.24.0",
3294 "core-text",
3497 "core-text",
3295 "core-video",
3498 "core-video",
3296 "ctor",
3499 "ctor",
3297 "dispatch2",
3500 "dispatch2",
3298 "foreign-types",
3501 "foreign-types 0.5.0",
3299 "futures",
3502 "futures",
3300 "gpui-pre",
3503 "gpui-pre",
3301 "gpui-pre-apple",
3504 "gpui-pre-apple",
@@ -3449,7 +3652,7 @@ dependencies = [
3449 "async-task",
3652 "async-task",
3450 "backtrace",
3653 "backtrace",
3451 "chrono",
3654 "chrono",
3452 "flume",
3655 "flume 0.12.0",
3453 "futures",
3656 "futures",
3454 "parking_lot",
3657 "parking_lot",
3455 "rand 0.9.5",
3658 "rand 0.9.5",
@@ -3489,7 +3692,7 @@ checksum = "e1635ae7d0b05400bfa211ddef6c67dc8d9f223c463022c2b3bf2c1c14c6044f"
3489dependencies = [
3692dependencies = [
3490 "anyhow",
3693 "anyhow",
3491 "log",
3694 "log",
3492 "which",
3695 "which 8.0.6",
3493]
3696]
3494
3697
3495[[package]]
3698[[package]]
@@ -3563,8 +3766,6 @@ dependencies = [
3563[[package]]
3766[[package]]
3564name = "gpui-pre-windows"
3767name = "gpui-pre-windows"
3565version = "0.3.8"
3768version = "0.3.8"
3566source = "registry+https://github.com/rust-lang/crates.io-index"
3567checksum = "371f9bb13f97e3bea2f8b8e5e81232bb74d735153c244ae67f7400e743925b1c"
3568dependencies = [
3769dependencies = [
3569 "accesskit",
3770 "accesskit",
3570 "accesskit_windows",
3771 "accesskit_windows",
@@ -3658,7 +3859,7 @@ dependencies = [
3658 "gdk",
3859 "gdk",
3659 "gdk-pixbuf",
3860 "gdk-pixbuf",
3660 "gio",
3861 "gio",
3661 "glib",
3862 "glib 0.18.5",
3662 "gtk-sys",
3863 "gtk-sys",
3663 "gtk3-macros",
3864 "gtk3-macros",
3664 "libc",
3865 "libc",
@@ -3676,12 +3877,12 @@ dependencies = [
3676 "cairo-sys-rs",
3877 "cairo-sys-rs",
3677 "gdk-pixbuf-sys",
3878 "gdk-pixbuf-sys",
3678 "gdk-sys",
3879 "gdk-sys",
3679 "gio-sys",
3880 "gio-sys 0.18.1",
3680 "glib-sys",
3881 "glib-sys 0.18.1",
3681 "gobject-sys",
3882 "gobject-sys 0.18.0",
3682 "libc",
3883 "libc",
3683 "pango-sys",
3884 "pango-sys",
3684 "system-deps",
3885 "system-deps 6.2.2",
3685]
3886]
3686
3887
3687[[package]]
3888[[package]]
@@ -3722,7 +3923,7 @@ version = "2.7.1"
3722source = "registry+https://github.com/rust-lang/crates.io-index"
3923source = "registry+https://github.com/rust-lang/crates.io-index"
3723checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
3924checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b"
3724dependencies = [
3925dependencies = [
3725 "cfg-if",
3926 "cfg-if 1.0.5",
3726 "crunchy",
3927 "crunchy",
3727 "num-traits",
3928 "num-traits",
3728 "zerocopy",
3929 "zerocopy",
@@ -3849,6 +4050,15 @@ dependencies = [
3849 "digest 0.10.7",
4050 "digest 0.10.7",
3850]
4051]
3851
4052
4053[[package]]
4054name = "home"
4055version = "0.5.12"
4056source = "registry+https://github.com/rust-lang/crates.io-index"
4057checksum = "cc627f471c528ff0c4a49e1d5e60450c8f6461dd6d10ba9dcd3a61d3dff7728d"
4058dependencies = [
4059 "windows-sys 0.61.2",
4060]
4061
3852[[package]]
4062[[package]]
3853name = "html5ever"
4063name = "html5ever"
3854version = "0.27.0"
4064version = "0.27.0"
@@ -3991,7 +4201,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
3991checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
4201checksum = "e31bc9ad994ba00e440a8aa5c9ef0ec67d5cb5e5cb0cc7f8b744a35b389cc470"
3992dependencies = [
4202dependencies = [
3993 "android_system_properties",
4203 "android_system_properties",
3994 "core-foundation-sys",
4204 "core-foundation-sys 0.8.7",
3995 "iana-time-zone-haiku",
4205 "iana-time-zone-haiku",
3996 "js-sys",
4206 "js-sys",
3997 "log",
4207 "log",
@@ -4227,7 +4437,7 @@ version = "0.1.13"
4227source = "registry+https://github.com/rust-lang/crates.io-index"
4437source = "registry+https://github.com/rust-lang/crates.io-index"
4228checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
4438checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222"
4229dependencies = [
4439dependencies = [
4230 "cfg-if",
4440 "cfg-if 1.0.5",
4231 "js-sys",
4441 "js-sys",
4232 "wasm-bindgen",
4442 "wasm-bindgen",
4233 "web-sys",
4443 "web-sys",
@@ -4261,7 +4471,7 @@ checksum = "554b8c5d64ec09a3a520fe58e4d48a73e00ff32899cdcbe32a4877afd4968b8e"
4261dependencies = [
4471dependencies = [
4262 "cgl",
4472 "cgl",
4263 "core-foundation 0.10.1",
4473 "core-foundation 0.10.1",
4264 "core-foundation-sys",
4474 "core-foundation-sys 0.8.7",
4265 "leaky-cow",
4475 "leaky-cow",
4266]
4476]
4267
4477
@@ -4336,7 +4546,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
4336checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
4546checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97"
4337dependencies = [
4547dependencies = [
4338 "cesu8",
4548 "cesu8",
4339 "cfg-if",
4549 "cfg-if 1.0.5",
4340 "combine",
4550 "combine",
4341 "jni-sys 0.3.1",
4551 "jni-sys 0.3.1",
4342 "log",
4552 "log",
@@ -4351,7 +4561,7 @@ version = "0.22.4"
4351source = "registry+https://github.com/rust-lang/crates.io-index"
4561source = "registry+https://github.com/rust-lang/crates.io-index"
4352checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498"
4562checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498"
4353dependencies = [
4563dependencies = [
4354 "cfg-if",
4564 "cfg-if 1.0.5",
4355 "combine",
4565 "combine",
4356 "jni-macros",
4566 "jni-macros",
4357 "jni-sys 0.4.1",
4567 "jni-sys 0.4.1",
@@ -4419,7 +4629,7 @@ version = "0.3.106"
4419source = "registry+https://github.com/rust-lang/crates.io-index"
4629source = "registry+https://github.com/rust-lang/crates.io-index"
4420checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
4630checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"
4421dependencies = [
4631dependencies = [
4422 "cfg-if",
4632 "cfg-if 1.0.5",
4423 "futures-util",
4633 "futures-util",
4424 "wasm-bindgen",
4634 "wasm-bindgen",
4425]
4635]
@@ -4501,6 +4711,12 @@ version = "1.5.1"
4501source = "registry+https://github.com/rust-lang/crates.io-index"
4711source = "registry+https://github.com/rust-lang/crates.io-index"
4502checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
4712checksum = "20870f649af7073d53e38067b2a84312175d56ea15217e1b15bc83506ec50afb"
4503
4713
4714[[package]]
4715name = "lazycell"
4716version = "1.3.0"
4717source = "registry+https://github.com/rust-lang/crates.io-index"
4718checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
4719
4504[[package]]
4720[[package]]
4505name = "leak"
4721name = "leak"
4506version = "0.1.2"
4722version = "0.1.2"
@@ -4528,7 +4744,7 @@ version = "0.9.0"
4528source = "registry+https://github.com/rust-lang/crates.io-index"
4744source = "registry+https://github.com/rust-lang/crates.io-index"
4529checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"
4745checksum = "03589b9607c868cc7ae54c0b2a22c8dc03dd41692d48f2d7df73615c6a95dc0a"
4530dependencies = [
4746dependencies = [
4531 "glib",
4747 "glib 0.18.5",
4532 "gtk",
4748 "gtk",
4533 "gtk-sys",
4749 "gtk-sys",
4534 "libappindicator-sys",
4750 "libappindicator-sys",
@@ -4574,7 +4790,7 @@ version = "0.7.4"
4574source = "registry+https://github.com/rust-lang/crates.io-index"
4790source = "registry+https://github.com/rust-lang/crates.io-index"
4575checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
4791checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f"
4576dependencies = [
4792dependencies = [
4577 "cfg-if",
4793 "cfg-if 1.0.5",
4578 "winapi",
4794 "winapi",
4579]
4795]
4580
4796
@@ -4584,7 +4800,7 @@ version = "0.8.9"
4584source = "registry+https://github.com/rust-lang/crates.io-index"
4800source = "registry+https://github.com/rust-lang/crates.io-index"
4585checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
4801checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55"
4586dependencies = [
4802dependencies = [
4587 "cfg-if",
4803 "cfg-if 1.0.5",
4588 "windows-link 0.2.1",
4804 "windows-link 0.2.1",
4589]
4805]
4590
4806
@@ -4621,6 +4837,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
4621checksum = "14f9145a63a8439508a9b5b51dffa4b1c12f812f49fcc4310ebae3d467f639ab"
4837checksum = "14f9145a63a8439508a9b5b51dffa4b1c12f812f49fcc4310ebae3d467f639ab"
4622dependencies = [
4838dependencies = [
4623 "cxx",
4839 "cxx",
4840 "glib 0.21.5",
4624 "jni 0.21.1",
4841 "jni 0.21.1",
4625 "js-sys",
4842 "js-sys",
4626 "lazy_static",
4843 "lazy_static",
@@ -4665,6 +4882,12 @@ version = "0.2.3"
4665source = "registry+https://github.com/rust-lang/crates.io-index"
4882source = "registry+https://github.com/rust-lang/crates.io-index"
4666checksum = "7e57c38c1e860fd37c604281cdfb1dd2216977fd76a50f85ba2f388ef3219616"
4883checksum = "7e57c38c1e860fd37c604281cdfb1dd2216977fd76a50f85ba2f388ef3219616"
4667
4884
4885[[package]]
4886name = "linux-raw-sys"
4887version = "0.4.15"
4888source = "registry+https://github.com/rust-lang/crates.io-index"
4889checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
4890
4668[[package]]
4891[[package]]
4669name = "linux-raw-sys"
4892name = "linux-raw-sys"
4670version = "0.12.1"
4893version = "0.12.1"
@@ -4887,7 +5110,7 @@ version = "0.1.1"
4887source = "registry+https://github.com/rust-lang/crates.io-index"
5110source = "registry+https://github.com/rust-lang/crates.io-index"
4888checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519"
5111checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519"
4889dependencies = [
5112dependencies = [
4890 "cfg-if",
5113 "cfg-if 1.0.5",
4891 "rayon",
5114 "rayon",
4892]
5115]
4893
5116
@@ -4897,7 +5120,7 @@ version = "0.10.6"
4897source = "registry+https://github.com/rust-lang/crates.io-index"
5120source = "registry+https://github.com/rust-lang/crates.io-index"
4898checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
5121checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
4899dependencies = [
5122dependencies = [
4900 "cfg-if",
5123 "cfg-if 1.0.5",
4901 "digest 0.10.7",
5124 "digest 0.10.7",
4902]
5125]
4903
5126
@@ -4925,6 +5148,21 @@ dependencies = [
4925 "autocfg",
5148 "autocfg",
4926]
5149]
4927
5150
5151[[package]]
5152name = "metal"
5153version = "0.18.0"
5154source = "registry+https://github.com/rust-lang/crates.io-index"
5155checksum = "e198a0ee42bdbe9ef2c09d0b9426f3b2b47d90d93a4a9b0395c4cea605e92dc0"
5156dependencies = [
5157 "bitflags 1.3.2",
5158 "block",
5159 "cocoa 0.20.2",
5160 "core-graphics 0.19.2",
5161 "foreign-types 0.3.2",
5162 "log",
5163 "objc",
5164]
5165
4928[[package]]
5166[[package]]
4929name = "metal"
5167name = "metal"
4930version = "0.33.0"
5168version = "0.33.0"
@@ -4934,7 +5172,7 @@ dependencies = [
4934 "bitflags 2.13.2",
5172 "bitflags 2.13.2",
4935 "block",
5173 "block",
4936 "core-graphics-types 0.2.0",
5174 "core-graphics-types 0.2.0",
4937 "foreign-types",
5175 "foreign-types 0.5.0",
4938 "log",
5176 "log",
4939 "objc",
5177 "objc",
4940 "paste",
5178 "paste",
@@ -5039,7 +5277,7 @@ dependencies = [
5039 "arrayvec",
5277 "arrayvec",
5040 "bit-set 0.9.1",
5278 "bit-set 0.9.1",
5041 "bitflags 2.13.2",
5279 "bitflags 2.13.2",
5042 "cfg-if",
5280 "cfg-if 1.0.5",
5043 "cfg_aliases",
5281 "cfg_aliases",
5044 "codespan-reporting",
5282 "codespan-reporting",
5045 "half",
5283 "half",
@@ -5056,6 +5294,15 @@ dependencies = [
5056 "unicode-ident",
5294 "unicode-ident",
5057]
5295]
5058
5296
5297[[package]]
5298name = "nanorand"
5299version = "0.7.0"
5300source = "registry+https://github.com/rust-lang/crates.io-index"
5301checksum = "6a51313c5820b0b02bd422f4b44776fbf47961755c74ce64afc73bfad10226c3"
5302dependencies = [
5303 "getrandom 0.2.17",
5304]
5305
5059[[package]]
5306[[package]]
5060name = "ndk"
5307name = "ndk"
5061version = "0.9.0"
5308version = "0.9.0"
@@ -5106,6 +5353,72 @@ version = "0.2.0"
5106source = "registry+https://github.com/rust-lang/crates.io-index"
5353source = "registry+https://github.com/rust-lang/crates.io-index"
5107checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
5354checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451"
5108
5355
5356[[package]]
5357name = "nokhwa"
5358version = "0.10.11"
5359source = "registry+https://github.com/rust-lang/crates.io-index"
5360checksum = "9d63f10b450319a0ace7aa8e0e25477d1fdb345313a97e220e886175539a1dbb"
5361dependencies = [
5362 "flume 0.11.1",
5363 "image",
5364 "nokhwa-bindings-linux",
5365 "nokhwa-bindings-macos",
5366 "nokhwa-bindings-windows",
5367 "nokhwa-core",
5368 "paste",
5369 "thiserror 2.0.21",
5370]
5371
5372[[package]]
5373name = "nokhwa-bindings-linux"
5374version = "0.1.4"
5375source = "registry+https://github.com/rust-lang/crates.io-index"
5376checksum = "bb67e22201a53322291740ca064b20eaaade7222ef0349f312d9b37b004e1984"
5377dependencies = [
5378 "libc",
5379 "nokhwa-core",
5380 "v4l",
5381]
5382
5383[[package]]
5384name = "nokhwa-bindings-macos"
5385version = "0.2.4"
5386source = "registry+https://github.com/rust-lang/crates.io-index"
5387checksum = "f70d3908ea68324e44a6b3a0f885aa59e433fb1f6678839d09e0df7d226fb42d"
5388dependencies = [
5389 "block",
5390 "cocoa-foundation 0.2.1",
5391 "core-foundation 0.10.1",
5392 "core-media-sys",
5393 "core-video-sys",
5394 "flume 0.11.1",
5395 "nokhwa-core",
5396 "objc",
5397 "once_cell",
5398]
5399
5400[[package]]
5401name = "nokhwa-bindings-windows"
5402version = "0.4.6"
5403source = "registry+https://github.com/rust-lang/crates.io-index"
5404checksum = "5be28886bad8abcec3655c1f24b965b4cb596a72b23164c910c54439ce55d2a4"
5405dependencies = [
5406 "nokhwa-core",
5407 "once_cell",
5408 "windows 0.62.2",
5409]
5410
5411[[package]]
5412name = "nokhwa-core"
5413version = "0.1.9"
5414source = "registry+https://github.com/rust-lang/crates.io-index"
5415checksum = "b1cba20bebd3bd9ae22f9273ade5bbe49da3e047c8512b53fbaf8b4b9c80d496"
5416dependencies = [
5417 "bytes",
5418 "image",
5419 "thiserror 2.0.21",
5420]
5421
5109[[package]]
5422[[package]]
5110name = "nom"
5423name = "nom"
5111version = "7.1.3"
5424version = "7.1.3"
@@ -5843,7 +6156,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
5843checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
6156checksum = "7ca27ec1eb0457ab26f3036ea52229edbdb74dee1edd29063f5b9b010e7ebee4"
5844dependencies = [
6157dependencies = [
5845 "gio",
6158 "gio",
5846 "glib",
6159 "glib 0.18.5",
5847 "libc",
6160 "libc",
5848 "once_cell",
6161 "once_cell",
5849 "pango-sys",
6162 "pango-sys",
@@ -5855,10 +6168,10 @@ version = "0.18.0"
5855source = "registry+https://github.com/rust-lang/crates.io-index"
6168source = "registry+https://github.com/rust-lang/crates.io-index"
5856checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"
6169checksum = "436737e391a843e5933d6d9aa102cb126d501e815b83601365a948a518555dc5"
5857dependencies = [
6170dependencies = [
5858 "glib-sys",
6171 "glib-sys 0.18.1",
5859 "gobject-sys",
6172 "gobject-sys 0.18.0",
5860 "libc",
6173 "libc",
5861 "system-deps",
6174 "system-deps 6.2.2",
5862]
6175]
5863
6176
5864[[package]]
6177[[package]]
@@ -5883,7 +6196,7 @@ version = "0.9.12"
5883source = "registry+https://github.com/rust-lang/crates.io-index"
6196source = "registry+https://github.com/rust-lang/crates.io-index"
5884checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
6197checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
5885dependencies = [
6198dependencies = [
5886 "cfg-if",
6199 "cfg-if 1.0.5",
5887 "libc",
6200 "libc",
5888 "redox_syscall",
6201 "redox_syscall",
5889 "smallvec",
6202 "smallvec",
@@ -5931,6 +6244,12 @@ dependencies = [
5931 "hmac",
6244 "hmac",
5932]
6245]
5933
6246
6247[[package]]
6248name = "peeking_take_while"
6249version = "0.1.2"
6250source = "registry+https://github.com/rust-lang/crates.io-index"
6251checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
6252
5934[[package]]
6253[[package]]
5935name = "percent-encoding"
6254name = "percent-encoding"
5936version = "2.3.2"
6255version = "2.3.2"
@@ -6113,11 +6432,11 @@ version = "3.11.0"
6113source = "registry+https://github.com/rust-lang/crates.io-index"
6432source = "registry+https://github.com/rust-lang/crates.io-index"
6114checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"
6433checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218"
6115dependencies = [
6434dependencies = [
6116 "cfg-if",
6435 "cfg-if 1.0.5",
6117 "concurrent-queue",
6436 "concurrent-queue",
6118 "hermit-abi",
6437 "hermit-abi",
6119 "pin-project-lite",
6438 "pin-project-lite",
6120 "rustix",
6439 "rustix 1.1.5",
6121 "windows-sys 0.61.2",
6440 "windows-sys 0.61.2",
6122]
6441]
6123
6442
@@ -6339,7 +6658,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
6339checksum = "046aa45b989642ec2e4717c8e72d677b13edd831a4d3b6cf37d9a3e54912496a"
6658checksum = "046aa45b989642ec2e4717c8e72d677b13edd831a4d3b6cf37d9a3e54912496a"
6340dependencies = [
6659dependencies = [
6341 "bytemuck",
6660 "bytemuck",
6342 "cfg-if",
6661 "cfg-if 1.0.5",
6343 "libm",
6662 "libm",
6344 "num-complex",
6663 "num-complex",
6345 "paste",
6664 "paste",
@@ -6588,7 +6907,7 @@ dependencies = [
6588 "av1-grain",
6907 "av1-grain",
6589 "bitstream-io",
6908 "bitstream-io",
6590 "built",
6909 "built",
6591 "cfg-if",
6910 "cfg-if 1.0.5",
6592 "interpolate_name",
6911 "interpolate_name",
6593 "itertools 0.14.0",
6912 "itertools 0.14.0",
6594 "libc",
6913 "libc",
@@ -6874,7 +7193,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
6874checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
7193checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"
6875dependencies = [
7194dependencies = [
6876 "cc",
7195 "cc",
6877 "cfg-if",
7196 "cfg-if 1.0.5",
6878 "getrandom 0.2.17",
7197 "getrandom 0.2.17",
6879 "libc",
7198 "libc",
6880 "untrusted",
7199 "untrusted",
@@ -7050,6 +7369,19 @@ dependencies = [
7050 "semver",
7369 "semver",
7051]
7370]
7052
7371
7372[[package]]
7373name = "rustix"
7374version = "0.38.44"
7375source = "registry+https://github.com/rust-lang/crates.io-index"
7376checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
7377dependencies = [
7378 "bitflags 2.13.2",
7379 "errno",
7380 "libc",
7381 "linux-raw-sys 0.4.15",
7382 "windows-sys 0.52.0",
7383]
7384
7053[[package]]
7385[[package]]
7054name = "rustix"
7386name = "rustix"
7055version = "1.1.5"
7387version = "1.1.5"
@@ -7059,7 +7391,7 @@ dependencies = [
7059 "bitflags 2.13.2",
7391 "bitflags 2.13.2",
7060 "errno",
7392 "errno",
7061 "libc",
7393 "libc",
7062 "linux-raw-sys",
7394 "linux-raw-sys 0.12.1",
7063 "windows-sys 0.61.2",
7395 "windows-sys 0.61.2",
7064]
7396]
7065
7397
@@ -7117,7 +7449,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
7117checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98"
7449checksum = "1167586491e2b18b8bfbb293e8180ec17c201c4f076d7cb3070ca964e7598f98"
7118dependencies = [
7450dependencies = [
7119 "core-foundation 0.10.1",
7451 "core-foundation 0.10.1",
7120 "core-foundation-sys",
7452 "core-foundation-sys 0.8.7",
7121 "jni 0.22.4",
7453 "jni 0.22.4",
7122 "log",
7454 "log",
7123 "once_cell",
7455 "once_cell",
@@ -7305,7 +7637,7 @@ checksum = "b7f4bc775c73d9a02cde8bf7b2ec4c9d12743edf609006c7facc23998404cd1d"
7305dependencies = [
7637dependencies = [
7306 "bitflags 2.13.2",
7638 "bitflags 2.13.2",
7307 "core-foundation 0.10.1",
7639 "core-foundation 0.10.1",
7308 "core-foundation-sys",
7640 "core-foundation-sys 0.8.7",
7309 "libc",
7641 "libc",
7310 "security-framework-sys",
7642 "security-framework-sys",
7311]
7643]
@@ -7316,7 +7648,7 @@ version = "2.17.0"
7316source = "registry+https://github.com/rust-lang/crates.io-index"
7648source = "registry+https://github.com/rust-lang/crates.io-index"
7317checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3"
7649checksum = "6ce2691df843ecc5d231c0b14ece2acc3efb62c0a398c7e1d875f3983ce020e3"
7318dependencies = [
7650dependencies = [
7319 "core-foundation-sys",
7651 "core-foundation-sys 0.8.7",
7320 "libc",
7652 "libc",
7321]
7653]
7322
7654
@@ -7515,7 +7847,7 @@ version = "0.10.7"
7515source = "registry+https://github.com/rust-lang/crates.io-index"
7847source = "registry+https://github.com/rust-lang/crates.io-index"
7516checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8"
7848checksum = "a978451301f4db1d02937a4ab3ccce137717b81826e79b7d49ffe3244a13c3b8"
7517dependencies = [
7849dependencies = [
7518 "cfg-if",
7850 "cfg-if 1.0.5",
7519 "cpufeatures 0.2.17",
7851 "cpufeatures 0.2.17",
7520 "digest 0.10.7",
7852 "digest 0.10.7",
7521]
7853]
@@ -7532,7 +7864,7 @@ version = "0.10.9"
7532source = "registry+https://github.com/rust-lang/crates.io-index"
7864source = "registry+https://github.com/rust-lang/crates.io-index"
7533checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
7865checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
7534dependencies = [
7866dependencies = [
7535 "cfg-if",
7867 "cfg-if 1.0.5",
7536 "cpufeatures 0.2.17",
7868 "cpufeatures 0.2.17",
7537 "digest 0.10.7",
7869 "digest 0.10.7",
7538]
7870]
@@ -7543,7 +7875,7 @@ version = "0.11.0"
7543source = "registry+https://github.com/rust-lang/crates.io-index"
7875source = "registry+https://github.com/rust-lang/crates.io-index"
7544checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
7876checksum = "446ba717509524cb3f22f17ecc096f10f4822d76ab5c0b9822c5f9c284e825f4"
7545dependencies = [
7877dependencies = [
7546 "cfg-if",
7878 "cfg-if 1.0.5",
7547 "cpufeatures 0.3.1",
7879 "cpufeatures 0.3.1",
7548 "digest 0.11.3",
7880 "digest 0.11.3",
7549]
7881]
@@ -8068,7 +8400,7 @@ version = "0.31.4"
8068source = "registry+https://github.com/rust-lang/crates.io-index"
8400source = "registry+https://github.com/rust-lang/crates.io-index"
8069checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be"
8401checksum = "355dbe4f8799b304b05e1b0f05fc59b2a18d36645cf169607da45bde2f69a1be"
8070dependencies = [
8402dependencies = [
8071 "core-foundation-sys",
8403 "core-foundation-sys 0.8.7",
8072 "libc",
8404 "libc",
8073 "memchr",
8405 "memchr",
8074 "ntapi",
8406 "ntapi",
@@ -8093,7 +8425,7 @@ version = "0.6.0"
8093source = "registry+https://github.com/rust-lang/crates.io-index"
8425source = "registry+https://github.com/rust-lang/crates.io-index"
8094checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
8426checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
8095dependencies = [
8427dependencies = [
8096 "core-foundation-sys",
8428 "core-foundation-sys 0.8.7",
8097 "libc",
8429 "libc",
8098]
8430]
8099
8431
@@ -8103,13 +8435,26 @@ version = "6.2.2"
8103source = "registry+https://github.com/rust-lang/crates.io-index"
8435source = "registry+https://github.com/rust-lang/crates.io-index"
8104checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
8436checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
8105dependencies = [
8437dependencies = [
8106 "cfg-expr",
8438 "cfg-expr 0.15.8",
8107 "heck 0.5.0",
8439 "heck 0.5.0",
8108 "pkg-config",
8440 "pkg-config",
8109 "toml 0.8.23",
8441 "toml 0.8.23",
8110 "version-compare",
8442 "version-compare",
8111]
8443]
8112
8444
8445[[package]]
8446name = "system-deps"
8447version = "7.0.8"
8448source = "registry+https://github.com/rust-lang/crates.io-index"
8449checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7"
8450dependencies = [
8451 "cfg-expr 0.20.10",
8452 "heck 0.5.0",
8453 "pkg-config",
8454 "toml 1.1.6+spec-1.1.0",
8455 "version-compare",
8456]
8457
8113[[package]]
8458[[package]]
8114name = "taffy"
8459name = "taffy"
8115version = "0.13.0"
8460version = "0.13.0"
@@ -8128,8 +8473,8 @@ version = "0.2.0"
8128source = "registry+https://github.com/rust-lang/crates.io-index"
8473source = "registry+https://github.com/rust-lang/crates.io-index"
8129checksum = "271450eb289cb4d8d0720c6ce70c72c8c858c93dd61fc625881616752e6b98f6"
8474checksum = "271450eb289cb4d8d0720c6ce70c72c8c858c93dd61fc625881616752e6b98f6"
8130dependencies = [
8475dependencies = [
8131 "cfg-if",
8476 "cfg-if 1.0.5",
8132 "core-foundation-sys",
8477 "core-foundation-sys 0.8.7",
8133 "libc",
8478 "libc",
8134 "objc",
8479 "objc",
8135]
8480]
@@ -8140,6 +8485,12 @@ version = "0.12.16"
8140source = "registry+https://github.com/rust-lang/crates.io-index"
8485source = "registry+https://github.com/rust-lang/crates.io-index"
8141checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
8486checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
8142
8487
8488[[package]]
8489name = "target-lexicon"
8490version = "0.13.5"
8491source = "registry+https://github.com/rust-lang/crates.io-index"
8492checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
8493
8143[[package]]
8494[[package]]
8144name = "tauri-winrt-notification"
8495name = "tauri-winrt-notification"
8145version = "0.8.1"
8496version = "0.8.1"
@@ -8181,7 +8532,7 @@ dependencies = [
8181 "fastrand",
8532 "fastrand",
8182 "getrandom 0.4.3",
8533 "getrandom 0.4.3",
8183 "once_cell",
8534 "once_cell",
8184 "rustix",
8535 "rustix 1.1.5",
8185 "windows-sys 0.61.2",
8536 "windows-sys 0.61.2",
8186]
8537]
8187
8538
@@ -8251,7 +8602,7 @@ version = "1.1.10"
8251source = "registry+https://github.com/rust-lang/crates.io-index"
8602source = "registry+https://github.com/rust-lang/crates.io-index"
8252checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
8603checksum = "1ad99c4c6d32803332c548b1af0540b357b3f5fc0be8f6c6bfe8b2e6ae784070"
8253dependencies = [
8604dependencies = [
8254 "cfg-if",
8605 "cfg-if 1.0.5",
8255]
8606]
8256
8607
8257[[package]]
8608[[package]]
@@ -8305,7 +8656,7 @@ dependencies = [
8305 "arrayref",
8656 "arrayref",
8306 "arrayvec",
8657 "arrayvec",
8307 "bytemuck",
8658 "bytemuck",
8308 "cfg-if",
8659 "cfg-if 1.0.5",
8309 "log",
8660 "log",
8310 "png 0.17.16",
8661 "png 0.17.16",
8311 "tiny-skia-path",
8662 "tiny-skia-path",
@@ -8914,6 +9265,26 @@ dependencies = [
8914 "wasm-bindgen",
9265 "wasm-bindgen",
8915]
9266]
8916
9267
9268[[package]]
9269name = "v4l"
9270version = "0.14.0"
9271source = "registry+https://github.com/rust-lang/crates.io-index"
9272checksum = "d8fbfea44a46799d62c55323f3c55d06df722fbe577851d848d328a1041c3403"
9273dependencies = [
9274 "bitflags 1.3.2",
9275 "libc",
9276 "v4l2-sys-mit",
9277]
9278
9279[[package]]
9280name = "v4l2-sys-mit"
9281version = "0.3.0"
9282source = "registry+https://github.com/rust-lang/crates.io-index"
9283checksum = "6779878362b9bacadc7893eac76abe69612e8837ef746573c4a5239daf11990b"
9284dependencies = [
9285 "bindgen 0.65.1",
9286]
9287
8917[[package]]
9288[[package]]
8918name = "v_frame"
9289name = "v_frame"
8919version = "0.3.9"
9290version = "0.3.9"
@@ -9060,7 +9431,7 @@ version = "0.2.129"
9060source = "registry+https://github.com/rust-lang/crates.io-index"
9431source = "registry+https://github.com/rust-lang/crates.io-index"
9061checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
9432checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"
9062dependencies = [
9433dependencies = [
9063 "cfg-if",
9434 "cfg-if 1.0.5",
9064 "once_cell",
9435 "once_cell",
9065 "rustversion",
9436 "rustversion",
9066 "wasm-bindgen-macro",
9437 "wasm-bindgen-macro",
@@ -9144,7 +9515,7 @@ dependencies = [
9144 "cc",
9515 "cc",
9145 "downcast-rs",
9516 "downcast-rs",
9146 "log",
9517 "log",
9147 "rustix",
9518 "rustix 1.1.5",
9148 "scoped-tls",
9519 "scoped-tls",
9149 "smallvec",
9520 "smallvec",
9150 "wayland-sys",
9521 "wayland-sys",
@@ -9157,7 +9528,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
9157checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073"
9528checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073"
9158dependencies = [
9529dependencies = [
9159 "bitflags 2.13.2",
9530 "bitflags 2.13.2",
9160 "rustix",
9531 "rustix 1.1.5",
9161 "wayland-backend",
9532 "wayland-backend",
9162 "wayland-scanner",
9533 "wayland-scanner",
9163]
9534]
@@ -9168,7 +9539,7 @@ version = "0.31.14"
9168source = "registry+https://github.com/rust-lang/crates.io-index"
9539source = "registry+https://github.com/rust-lang/crates.io-index"
9169checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d"
9540checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d"
9170dependencies = [
9541dependencies = [
9171 "rustix",
9542 "rustix 1.1.5",
9172 "wayland-client",
9543 "wayland-client",
9173 "xcursor",
9544 "xcursor",
9174]
9545]
@@ -9363,7 +9734,7 @@ dependencies = [
9363 "arrayvec",
9734 "arrayvec",
9364 "bitflags 2.13.2",
9735 "bitflags 2.13.2",
9365 "bytemuck",
9736 "bytemuck",
9366 "cfg-if",
9737 "cfg-if 1.0.5",
9367 "cfg_aliases",
9738 "cfg_aliases",
9368 "document-features",
9739 "document-features",
9369 "hashbrown 0.16.1",
9740 "hashbrown 0.16.1",
@@ -9467,7 +9838,7 @@ dependencies = [
9467 "bitflags 2.13.2",
9838 "bitflags 2.13.2",
9468 "block2 0.6.2",
9839 "block2 0.6.2",
9469 "bytemuck",
9840 "bytemuck",
9470 "cfg-if",
9841 "cfg-if 1.0.5",
9471 "cfg_aliases",
9842 "cfg_aliases",
9472 "glow",
9843 "glow",
9473 "glutin_wgl_sys",
9844 "glutin_wgl_sys",
@@ -9532,6 +9903,18 @@ dependencies = [
9532 "web-sys",
9903 "web-sys",
9533]
9904]
9534
9905
9906[[package]]
9907name = "which"
9908version = "4.4.2"
9909source = "registry+https://github.com/rust-lang/crates.io-index"
9910checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
9911dependencies = [
9912 "either",
9913 "home",
9914 "once_cell",
9915 "rustix 0.38.44",
9916]
9917
9535[[package]]
9918[[package]]
9536name = "which"
9919name = "which"
9537version = "8.0.6"
9920version = "8.0.6"
@@ -10262,7 +10645,7 @@ version = "0.56.0"
10262source = "registry+https://github.com/rust-lang/crates.io-index"
10645source = "registry+https://github.com/rust-lang/crates.io-index"
10263checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10"
10646checksum = "7d6f32a0ff4a9f6f01231eb2059cc85479330739333e0e58cadf03b6af2cca10"
10264dependencies = [
10647dependencies = [
10265 "cfg-if",
10648 "cfg-if 1.0.5",
10266 "windows-sys 0.61.2",
10649 "windows-sys 0.61.2",
10267]
10650]
10268
10651
@@ -10306,7 +10689,7 @@ dependencies = [
10306 "as-raw-xcb-connection",
10689 "as-raw-xcb-connection",
10307 "gethostname",
10690 "gethostname",
10308 "libc",
10691 "libc",
10309 "rustix",
10692 "rustix 1.1.5",
10310 "x11rb-protocol",
10693 "x11rb-protocol",
10311 "xcursor",
10694 "xcursor",
10312]
10695]
@@ -10462,7 +10845,7 @@ dependencies = [
10462 "hex",
10845 "hex",
10463 "libc",
10846 "libc",
10464 "ordered-stream",
10847 "ordered-stream",
10465 "rustix",
10848 "rustix 1.1.5",
10466 "serde",
10849 "serde",
10467 "serde_repr",
10850 "serde_repr",
10468 "tracing",
10851 "tracing",
README.md +3 −2
@@ -60,6 +60,7 @@
60 60 **Calls**
61 61 - Test call to the Teams Echo bot from the avatar menu: native WebRTC audio, mute (`Ctrl+Shift+M`), device switching, mini window while you read other chats
62 62 - Phone button in 1:1 and group chat headers: callee tiles show Calling and Ringing, Cancel while ringing, notices like "Bea declined" or "No answer"
63 - Video and screen sharing: H264 tiles, shared screen on a stage (double click for full window, Esc back), camera and screen share buttons with a "You are sharing" banner. Linux needs glib at run time
63 64 - Incoming calls: topmost ring toast with Decline and Accept, ring tone, missed calls in Activity
64 65 - Join a running meeting from its chat (audio): roster tiles, speaking ring, lobby state, Leave or End meeting for the organizer
65 66
@@ -75,7 +76,7 @@
75 76 | 🪟 Windows | Main target. Login through an embedded WebView2 |
76 77 | 🐧 Linux | Connects to a Chrome started with `--remote-debugging-port=9222`. Built-in login is planned |
77 78
78 Video, screen sharing and the remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
79 The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
79 80
80 81 ## Quick start
81 82
@@ -148,7 +149,7 @@ It signs you in through a real Teams web page and lets that page make the API ca
148 149 | `store` | SQLite cache, migrations, search, image file cache |
149 150 | `graph` | Typed Microsoft Graph client with batching and paging |
150 151 | `chatsvc` | Teams chat service: Trouter realtime, pins, folders, receipts |
151 | `calling` | Native calls: Teams signaling, SDP translation, libwebrtc audio |
152 | `calling` | Native calls: Teams signaling, SDP translation, libwebrtc audio and video |
152 153 | `session` | `Transport` trait, CDP session, in-page fetch |
153 154 | `webview` | Hidden WebView2 host (Windows only) |
154 155 | `browser` | Chrome lifecycle and watchdog for the CDP transport |
@@ -60,6 +60,7 @@
60**Calls**
60**Calls**
61- Test call to the Teams Echo bot from the avatar menu: native WebRTC audio, mute (`Ctrl+Shift+M`), device switching, mini window while you read other chats
61- Test call to the Teams Echo bot from the avatar menu: native WebRTC audio, mute (`Ctrl+Shift+M`), device switching, mini window while you read other chats
62- Phone button in 1:1 and group chat headers: callee tiles show Calling and Ringing, Cancel while ringing, notices like "Bea declined" or "No answer"
62- Phone button in 1:1 and group chat headers: callee tiles show Calling and Ringing, Cancel while ringing, notices like "Bea declined" or "No answer"
63- Video and screen sharing: H264 tiles, shared screen on a stage (double click for full window, Esc back), camera and screen share buttons with a "You are sharing" banner. Linux needs glib at run time
63- Incoming calls: topmost ring toast with Decline and Accept, ring tone, missed calls in Activity
64- Incoming calls: topmost ring toast with Decline and Accept, ring tone, missed calls in Activity
64- Join a running meeting from its chat (audio): roster tiles, speaking ring, lobby state, Leave or End meeting for the organizer
65- Join a running meeting from its chat (audio): roster tiles, speaking ring, lobby state, Leave or End meeting for the organizer
65
66
@@ -75,7 +76,7 @@
75| 🪟 Windows | Main target. Login through an embedded WebView2 |
76| 🪟 Windows | Main target. Login through an embedded WebView2 |
76| 🐧 Linux | Connects to a Chrome started with `--remote-debugging-port=9222`. Built-in login is planned |
77| 🐧 Linux | Connects to a Chrome started with `--remote-debugging-port=9222`. Built-in login is planned |
77
78
78Video, screen sharing and the remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
79The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
79
80
80## Quick start
81## Quick start
81
82
@@ -148,7 +149,7 @@ It signs you in through a real Teams web page and lets that page make the API ca
148| `store` | SQLite cache, migrations, search, image file cache |
149| `store` | SQLite cache, migrations, search, image file cache |
149| `graph` | Typed Microsoft Graph client with batching and paging |
150| `graph` | Typed Microsoft Graph client with batching and paging |
150| `chatsvc` | Teams chat service: Trouter realtime, pins, folders, receipts |
151| `chatsvc` | Teams chat service: Trouter realtime, pins, folders, receipts |
151| `calling` | Native calls: Teams signaling, SDP translation, libwebrtc audio |
152| `calling` | Native calls: Teams signaling, SDP translation, libwebrtc audio and video |
152| `session` | `Transport` trait, CDP session, in-page fetch |
153| `session` | `Transport` trait, CDP session, in-page fetch |
153| `webview` | Hidden WebView2 host (Windows only) |
154| `webview` | Hidden WebView2 host (Windows only) |
154| `browser` | Chrome lifecycle and watchdog for the CDP transport |
155| `browser` | Chrome lifecycle and watchdog for the CDP transport |
ROADMAP.md +1 −1
@@ -167,7 +167,7 @@ Feature parity with the Microsoft Teams desktop client.
167 167 | Incoming call: ring, accept, decline | Partial | Ring toast, ring tone, missed call in Activity, registrar endpoint, attach + accept. Built from the Teams code, not yet rung by a second person |
168 168 | 1:1 and group calls | Partial | Phone button, Calling and Ringing tiles, end notices, direct to mixer renegotiation. Not yet tried with a second person |
169 169 | Join a meeting from a chat | Partial | Join button from the live meeting state, joins muted, roster tiles, lobby, Leave and End meeting. Audio only. Verified with a meeting of one; not yet with other participants |
170 | Screen sharing | Missing | |
170 | Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person. Incoming calls stay audio-only |
171 171 | In a call shown in presence | Missing | |
172 172
173 173 ## Agents
@@ -167,7 +167,7 @@ Feature parity with the Microsoft Teams desktop client.
167| Incoming call: ring, accept, decline | Partial | Ring toast, ring tone, missed call in Activity, registrar endpoint, attach + accept. Built from the Teams code, not yet rung by a second person |
167| Incoming call: ring, accept, decline | Partial | Ring toast, ring tone, missed call in Activity, registrar endpoint, attach + accept. Built from the Teams code, not yet rung by a second person |
168| 1:1 and group calls | Partial | Phone button, Calling and Ringing tiles, end notices, direct to mixer renegotiation. Not yet tried with a second person |
168| 1:1 and group calls | Partial | Phone button, Calling and Ringing tiles, end notices, direct to mixer renegotiation. Not yet tried with a second person |
169| Join a meeting from a chat | Partial | Join button from the live meeting state, joins muted, roster tiles, lobby, Leave and End meeting. Audio only. Verified with a meeting of one; not yet with other participants |
169| Join a meeting from a chat | Partial | Join button from the live meeting state, joins muted, roster tiles, lobby, Leave and End meeting. Audio only. Verified with a meeting of one; not yet with other participants |
170| Screen sharing | Missing | |
170| Video and screen sharing | Partial | Send and receive over libwebrtc H264, source requests through `applyChannelParameters`, stage, strip, self view, share banner. Sent frames acknowledged by the mixer; receive only checked by a local loopback, not with a second person. Incoming calls stay audio-only |
171| In a call shown in presence | Missing | |
171| In a call shown in presence | Missing | |
172
172
173## Agents
173## Agents
crates/app/src/call/actions.rs +109 −3
@@ -1,17 +1,21 @@
1 1 use std::time::{Duration, Instant};
2 2
3 3 use calling::meeting::LiveMeeting;
4 use calling::{CallCommand, CallHandle, CallSpec, CallUpdate, Callee, DeviceChoice, EngineEvent, MuteCommand, RingSignal};
4 use calling::{
5 CallCommand, CallHandle, CallSpec, CallUpdate, Callee, DeviceChoice, EngineEvent, MuteCommand, RingSignal, ShareSource, VideoKey,
6 };
5 7 use gpui_kit::*;
6 8
7 9 use super::demo::{DemoCall, demo_caller, demo_guests, demo_ring, start_demo_call};
8 10 use super::model::{ActiveCall, CallModel, ended_notice};
11 use super::pictures::CallPictures;
9 12 use super::ring::{MissedCall, RingOutcome};
10 13 use super::target::{is_organizer, plan_for_chat};
11 14 use crate::app_state::{AppEvent, AppState, Selection, chat_title};
12 15 use crate::notify::selection_for;
13 16
14 17 const TIMER_REFRESH: Duration = Duration::from_millis(500);
18 const SHARE_SOURCES_EVERY_TICKS: u32 = 10;
15 19 const NOT_CONNECTED_NOTICE: &str = "Not connected to Teams yet";
16 20 const READ_ONLY_NOTICE: &str = "Calls are off in read-only mode";
17 21 const NOT_CALLABLE_NOTICE: &str = "This chat cannot be called";
@@ -133,13 +137,16 @@ impl AppState {
133 137 ) {
134 138 self.call_count += 1;
135 139 let call_id = self.call_count;
136 let CallHandle { commands, updates } = handle;
140 let CallHandle { commands, updates, video } = handle;
137 141 self.call = Some(ActiveCall {
138 142 id: call_id,
139 143 model,
140 144 commands,
141 145 viewing: true,
142 146 conversation_id,
147 video,
148 pictures: CallPictures::default(),
149 stage_fullscreen: false,
143 150 });
144 151 self.new_chat = false;
145 152 self.follow_call(call_id, updates, cx);
@@ -163,11 +170,16 @@ impl AppState {
163 170 })
164 171 .detach();
165 172 cx.spawn(async move |this, cx| {
173 let mut ticks = 0u32;
166 174 loop {
167 175 cx.background_executor().timer(TIMER_REFRESH).await;
176 ticks += 1;
168 177 let running = this.update(cx, |state, cx| {
169 178 let running = state.call.as_ref().is_some_and(|call| call.id == call_id);
170 179 if running {
180 if ticks.is_multiple_of(SHARE_SOURCES_EVERY_TICKS) {
181 state.refresh_share_sources();
182 }
171 183 cx.notify();
172 184 }
173 185 running
@@ -184,7 +196,26 @@ impl AppState {
184 196 let Some(call) = self.call.as_mut().filter(|call| call.id == call_id) else {
185 197 return;
186 198 };
199 match update {
200 CallUpdate::VideoReady => {
201 call.pictures.apply(&call.video, cx);
202 cx.notify();
203 return;
204 }
205 CallUpdate::Notice(text) => {
206 self.raise_notice(text, None, cx);
207 return;
208 }
209 _ => {}
210 }
187 211 call.model.apply(update);
212 if call.model.screen_sharer.is_none() {
213 call.stage_fullscreen = false;
214 call.pictures.forget(&VideoKey::Screen, cx);
215 }
216 if !call.model.camera_on {
217 call.pictures.forget(&VideoKey::LocalCamera, cx);
218 }
188 219 let Some(reason) = call.model.ended_reason().cloned() else {
189 220 cx.emit(AppEvent::Call);
190 221 cx.notify();
@@ -192,6 +223,7 @@ impl AppState {
192 223 };
193 224 let elapsed = call.model.elapsed(Instant::now());
194 225 let notice = ended_notice(&reason, elapsed, &call.model.peer_name);
226 call.pictures.clear(cx);
195 227 self.call = None;
196 228 self.raise_notice(notice, None, cx);
197 229 cx.emit(AppEvent::Call);
@@ -211,6 +243,36 @@ impl AppState {
211 243 }
212 244 }
213 245
246 pub fn toggle_call_camera(&mut self, _cx: &mut Context<Self>) {
247 let Some(call) = self.call.as_ref().filter(|call| call.model.can_use_camera()) else {
248 return;
249 };
250 let on = !call.model.camera_on;
251 self.send_call_command(CallCommand::SetCamera(on));
252 }
253
254 pub fn select_call_camera(&mut self, choice: DeviceChoice, _cx: &mut Context<Self>) {
255 if let Some(call) = self.call.as_mut() {
256 call.model.camera = choice.clone();
257 }
258 self.send_call_command(CallCommand::SelectCamera(choice));
259 }
260
261 pub fn start_call_share(&mut self, source: ShareSource, _cx: &mut Context<Self>) {
262 self.send_call_command(CallCommand::StartShare(source));
263 }
264
265 pub fn stop_call_share(&mut self, _cx: &mut Context<Self>) {
266 self.send_call_command(CallCommand::StopShare);
267 }
268
269 pub fn refresh_share_sources(&self) {
270 let idle = self.call.as_ref().is_some_and(|call| call.model.local_share.is_none());
271 if idle {
272 self.send_call_command(CallCommand::RefreshShareSources);
273 }
274 }
275
214 276 pub fn leave_call(&mut self, _cx: &mut Context<Self>) {
215 277 self.send_call_command(CallCommand::Hangup);
216 278 }
@@ -251,6 +313,28 @@ impl AppState {
251 313 }
252 314 }
253 315
316 pub fn toggle_stage_fullscreen(&mut self, cx: &mut Context<Self>) {
317 let Some(call) = self.call.as_mut().filter(|call| call.model.screen_sharer.is_some()) else {
318 return;
319 };
320 call.stage_fullscreen = !call.stage_fullscreen;
321 cx.emit(AppEvent::Call);
322 cx.notify();
323 }
324
325 pub fn leave_stage_fullscreen(&mut self, cx: &mut Context<Self>) {
326 let Some(call) = self.call.as_mut().filter(|call| call.stage_fullscreen) else {
327 return;
328 };
329 call.stage_fullscreen = false;
330 cx.emit(AppEvent::Call);
331 cx.notify();
332 }
333
334 pub fn stage_fullscreen(&self) -> bool {
335 self.call.as_ref().is_some_and(|call| call.stage_fullscreen && call.model.screen_sharer.is_some())
336 }
337
254 338 pub fn viewing_call(&self) -> bool {
255 339 self.call.as_ref().is_some_and(|call| call.viewing)
256 340 }
@@ -449,7 +533,7 @@ mod tests {
449 533 use gpui_kit::{AppContext as _, Entity, TestAppContext};
450 534 use store::{ChatRecord, MemberRecord, Store};
451 535
452 use super::{ActiveCall, CallModel};
536 use super::{ActiveCall, CallModel, CallPictures};
453 537 use crate::app_state::{AppState, Mode, Selection};
454 538 use crate::call::demo::demo_ring;
455 539 use crate::data::Person;
@@ -467,6 +551,9 @@ mod tests {
467 551 commands: handle.commands,
468 552 viewing: true,
469 553 conversation_id: None,
554 video: handle.video,
555 pictures: CallPictures::default(),
556 stage_fullscreen: false,
470 557 });
471 558 })
472 559 });
@@ -541,6 +628,25 @@ mod tests {
541 628 });
542 629 }
543 630
631 #[gpui_kit::test]
632 fn full_window_exists_only_while_someone_shares_and_escape_leaves_it(cx: &mut TestAppContext) {
633 let app = app_with_call(cx);
634 cx.update(|cx| {
635 app.update(cx, |state, cx| {
636 state.toggle_stage_fullscreen(cx);
637 assert!(!state.stage_fullscreen());
638 state.apply_call_update(7, CallUpdate::ScreenShare(Some("8:orgid:a".into())), cx);
639 state.toggle_stage_fullscreen(cx);
640 assert!(state.stage_fullscreen());
641 state.leave_stage_fullscreen(cx);
642 assert!(!state.stage_fullscreen());
643 state.toggle_stage_fullscreen(cx);
644 state.apply_call_update(7, CallUpdate::ScreenShare(None), cx);
645 assert!(!state.stage_fullscreen());
646 })
647 });
648 }
649
544 650 #[gpui_kit::test]
545 651 fn a_declined_call_names_who_declined(cx: &mut TestAppContext) {
546 652 let app = app_with_call(cx);
@@ -1,17 +1,21 @@
1use std::time::{Duration, Instant};
1use std::time::{Duration, Instant};
2
2
3use calling::meeting::LiveMeeting;
3use calling::meeting::LiveMeeting;
4use calling::{CallCommand, CallHandle, CallSpec, CallUpdate, Callee, DeviceChoice, EngineEvent, MuteCommand, RingSignal};
4use calling::{
5 CallCommand, CallHandle, CallSpec, CallUpdate, Callee, DeviceChoice, EngineEvent, MuteCommand, RingSignal, ShareSource, VideoKey,
6};
5use gpui_kit::*;
7use gpui_kit::*;
6
8
7use super::demo::{DemoCall, demo_caller, demo_guests, demo_ring, start_demo_call};
9use super::demo::{DemoCall, demo_caller, demo_guests, demo_ring, start_demo_call};
8use super::model::{ActiveCall, CallModel, ended_notice};
10use super::model::{ActiveCall, CallModel, ended_notice};
11use super::pictures::CallPictures;
9use super::ring::{MissedCall, RingOutcome};
12use super::ring::{MissedCall, RingOutcome};
10use super::target::{is_organizer, plan_for_chat};
13use super::target::{is_organizer, plan_for_chat};
11use crate::app_state::{AppEvent, AppState, Selection, chat_title};
14use crate::app_state::{AppEvent, AppState, Selection, chat_title};
12use crate::notify::selection_for;
15use crate::notify::selection_for;
13
16
14const TIMER_REFRESH: Duration = Duration::from_millis(500);
17const TIMER_REFRESH: Duration = Duration::from_millis(500);
18const SHARE_SOURCES_EVERY_TICKS: u32 = 10;
15const NOT_CONNECTED_NOTICE: &str = "Not connected to Teams yet";
19const NOT_CONNECTED_NOTICE: &str = "Not connected to Teams yet";
16const READ_ONLY_NOTICE: &str = "Calls are off in read-only mode";
20const READ_ONLY_NOTICE: &str = "Calls are off in read-only mode";
17const NOT_CALLABLE_NOTICE: &str = "This chat cannot be called";
21const NOT_CALLABLE_NOTICE: &str = "This chat cannot be called";
@@ -133,13 +137,16 @@ impl AppState {
133 ) {
137 ) {
134 self.call_count += 1;
138 self.call_count += 1;
135 let call_id = self.call_count;
139 let call_id = self.call_count;
136 let CallHandle { commands, updates } = handle;
140 let CallHandle { commands, updates, video } = handle;
137 self.call = Some(ActiveCall {
141 self.call = Some(ActiveCall {
138 id: call_id,
142 id: call_id,
139 model,
143 model,
140 commands,
144 commands,
141 viewing: true,
145 viewing: true,
142 conversation_id,
146 conversation_id,
147 video,
148 pictures: CallPictures::default(),
149 stage_fullscreen: false,
143 });
150 });
144 self.new_chat = false;
151 self.new_chat = false;
145 self.follow_call(call_id, updates, cx);
152 self.follow_call(call_id, updates, cx);
@@ -163,11 +170,16 @@ impl AppState {
163 })
170 })
164 .detach();
171 .detach();
165 cx.spawn(async move |this, cx| {
172 cx.spawn(async move |this, cx| {
173 let mut ticks = 0u32;
166 loop {
174 loop {
167 cx.background_executor().timer(TIMER_REFRESH).await;
175 cx.background_executor().timer(TIMER_REFRESH).await;
176 ticks += 1;
168 let running = this.update(cx, |state, cx| {
177 let running = this.update(cx, |state, cx| {
169 let running = state.call.as_ref().is_some_and(|call| call.id == call_id);
178 let running = state.call.as_ref().is_some_and(|call| call.id == call_id);
170 if running {
179 if running {
180 if ticks.is_multiple_of(SHARE_SOURCES_EVERY_TICKS) {
181 state.refresh_share_sources();
182 }
171 cx.notify();
183 cx.notify();
172 }
184 }
173 running
185 running
@@ -184,7 +196,26 @@ impl AppState {
184 let Some(call) = self.call.as_mut().filter(|call| call.id == call_id) else {
196 let Some(call) = self.call.as_mut().filter(|call| call.id == call_id) else {
185 return;
197 return;
186 };
198 };
199 match update {
200 CallUpdate::VideoReady => {
201 call.pictures.apply(&call.video, cx);
202 cx.notify();
203 return;
204 }
205 CallUpdate::Notice(text) => {
206 self.raise_notice(text, None, cx);
207 return;
208 }
209 _ => {}
210 }
187 call.model.apply(update);
211 call.model.apply(update);
212 if call.model.screen_sharer.is_none() {
213 call.stage_fullscreen = false;
214 call.pictures.forget(&VideoKey::Screen, cx);
215 }
216 if !call.model.camera_on {
217 call.pictures.forget(&VideoKey::LocalCamera, cx);
218 }
188 let Some(reason) = call.model.ended_reason().cloned() else {
219 let Some(reason) = call.model.ended_reason().cloned() else {
189 cx.emit(AppEvent::Call);
220 cx.emit(AppEvent::Call);
190 cx.notify();
221 cx.notify();
@@ -192,6 +223,7 @@ impl AppState {
192 };
223 };
193 let elapsed = call.model.elapsed(Instant::now());
224 let elapsed = call.model.elapsed(Instant::now());
194 let notice = ended_notice(&reason, elapsed, &call.model.peer_name);
225 let notice = ended_notice(&reason, elapsed, &call.model.peer_name);
226 call.pictures.clear(cx);
195 self.call = None;
227 self.call = None;
196 self.raise_notice(notice, None, cx);
228 self.raise_notice(notice, None, cx);
197 cx.emit(AppEvent::Call);
229 cx.emit(AppEvent::Call);
@@ -211,6 +243,36 @@ impl AppState {
211 }
243 }
212 }
244 }
213
245
246 pub fn toggle_call_camera(&mut self, _cx: &mut Context<Self>) {
247 let Some(call) = self.call.as_ref().filter(|call| call.model.can_use_camera()) else {
248 return;
249 };
250 let on = !call.model.camera_on;
251 self.send_call_command(CallCommand::SetCamera(on));
252 }
253
254 pub fn select_call_camera(&mut self, choice: DeviceChoice, _cx: &mut Context<Self>) {
255 if let Some(call) = self.call.as_mut() {
256 call.model.camera = choice.clone();
257 }
258 self.send_call_command(CallCommand::SelectCamera(choice));
259 }
260
261 pub fn start_call_share(&mut self, source: ShareSource, _cx: &mut Context<Self>) {
262 self.send_call_command(CallCommand::StartShare(source));
263 }
264
265 pub fn stop_call_share(&mut self, _cx: &mut Context<Self>) {
266 self.send_call_command(CallCommand::StopShare);
267 }
268
269 pub fn refresh_share_sources(&self) {
270 let idle = self.call.as_ref().is_some_and(|call| call.model.local_share.is_none());
271 if idle {
272 self.send_call_command(CallCommand::RefreshShareSources);
273 }
274 }
275
214 pub fn leave_call(&mut self, _cx: &mut Context<Self>) {
276 pub fn leave_call(&mut self, _cx: &mut Context<Self>) {
215 self.send_call_command(CallCommand::Hangup);
277 self.send_call_command(CallCommand::Hangup);
216 }
278 }
@@ -251,6 +313,28 @@ impl AppState {
251 }
313 }
252 }
314 }
253
315
316 pub fn toggle_stage_fullscreen(&mut self, cx: &mut Context<Self>) {
317 let Some(call) = self.call.as_mut().filter(|call| call.model.screen_sharer.is_some()) else {
318 return;
319 };
320 call.stage_fullscreen = !call.stage_fullscreen;
321 cx.emit(AppEvent::Call);
322 cx.notify();
323 }
324
325 pub fn leave_stage_fullscreen(&mut self, cx: &mut Context<Self>) {
326 let Some(call) = self.call.as_mut().filter(|call| call.stage_fullscreen) else {
327 return;
328 };
329 call.stage_fullscreen = false;
330 cx.emit(AppEvent::Call);
331 cx.notify();
332 }
333
334 pub fn stage_fullscreen(&self) -> bool {
335 self.call.as_ref().is_some_and(|call| call.stage_fullscreen && call.model.screen_sharer.is_some())
336 }
337
254 pub fn viewing_call(&self) -> bool {
338 pub fn viewing_call(&self) -> bool {
255 self.call.as_ref().is_some_and(|call| call.viewing)
339 self.call.as_ref().is_some_and(|call| call.viewing)
256 }
340 }
@@ -449,7 +533,7 @@ mod tests {
449 use gpui_kit::{AppContext as _, Entity, TestAppContext};
533 use gpui_kit::{AppContext as _, Entity, TestAppContext};
450 use store::{ChatRecord, MemberRecord, Store};
534 use store::{ChatRecord, MemberRecord, Store};
451
535
452 use super::{ActiveCall, CallModel};
536 use super::{ActiveCall, CallModel, CallPictures};
453 use crate::app_state::{AppState, Mode, Selection};
537 use crate::app_state::{AppState, Mode, Selection};
454 use crate::call::demo::demo_ring;
538 use crate::call::demo::demo_ring;
455 use crate::data::Person;
539 use crate::data::Person;
@@ -467,6 +551,9 @@ mod tests {
467 commands: handle.commands,
551 commands: handle.commands,
468 viewing: true,
552 viewing: true,
469 conversation_id: None,
553 conversation_id: None,
554 video: handle.video,
555 pictures: CallPictures::default(),
556 stage_fullscreen: false,
470 });
557 });
471 })
558 })
472 });
559 });
@@ -541,6 +628,25 @@ mod tests {
541 });
628 });
542 }
629 }
543
630
631 #[gpui_kit::test]
632 fn full_window_exists_only_while_someone_shares_and_escape_leaves_it(cx: &mut TestAppContext) {
633 let app = app_with_call(cx);
634 cx.update(|cx| {
635 app.update(cx, |state, cx| {
636 state.toggle_stage_fullscreen(cx);
637 assert!(!state.stage_fullscreen());
638 state.apply_call_update(7, CallUpdate::ScreenShare(Some("8:orgid:a".into())), cx);
639 state.toggle_stage_fullscreen(cx);
640 assert!(state.stage_fullscreen());
641 state.leave_stage_fullscreen(cx);
642 assert!(!state.stage_fullscreen());
643 state.toggle_stage_fullscreen(cx);
644 state.apply_call_update(7, CallUpdate::ScreenShare(None), cx);
645 assert!(!state.stage_fullscreen());
646 })
647 });
648 }
649
544 #[gpui_kit::test]
650 #[gpui_kit::test]
545 fn a_declined_call_names_who_declined(cx: &mut TestAppContext) {
651 fn a_declined_call_names_who_declined(cx: &mut TestAppContext) {
546 let app = app_with_call(cx);
652 let app = app_with_call(cx);
crates/app/src/call/demo.rs +72 −3
@@ -1,9 +1,12 @@
1 1 use std::time::{Duration, Instant};
2 2
3 use calling::video_frame::bgra_from_i420;
4 use calling::video_pattern::{PatternKind, pattern_frame};
3 5 use calling::{
4 6 AudioDevice, CallCommand, CallControl, CallHandle, CallState, CallUpdate, Caller, DeviceChoice, DeviceLists, EndReason,
5 IncomingRing, Progress, RosterEntry, call_channel,
7 IncomingRing, Progress, RosterEntry, ShareKind, ShareSource, VideoKey, call_channel,
6 8 };
9 use calling::CameraDevice;
7 10 use tokio::time::{interval, sleep};
8 11
9 12 use super::model::{ECHO_MRI, ECHO_NAME};
@@ -19,6 +22,13 @@ const REMOTE_SPEAKS: std::ops::Range<u32> = 0..18;
19 22 const LOCAL_SPEAKS: std::ops::Range<u32> = 24..32;
20 23 const SPEAKING_LEVEL: f32 = 0.3;
21 24 const SPEAKER_TICKS: u32 = 10;
25 const VIDEO_PERIOD: Duration = Duration::from_millis(125);
26 const DEMO_CAMERAS: usize = 4;
27 const SCREEN_EVERY_TICKS: u32 = 4;
28 const SHARE_START: Duration = Duration::from_secs(10);
29 const SHARE_END: Duration = Duration::from_secs(45);
30 const GUEST_PHASE: u32 = 37;
31 const SELF_PHASE: u32 = 211;
22 32 pub const DEMO_OWN_MRI: &str = "8:orgid:demo-me";
23 33 pub const DEMO_RING_ID: u64 = 9001;
24 34 const DEMO_CALLER: (&str, &str) = ("8:orgid:demo-mara", "Mara Lindqvist");
@@ -78,6 +88,23 @@ fn device(index: u16, name: &str) -> AudioDevice {
78 88 }
79 89 }
80 90
91 fn demo_cameras() -> Vec<CameraDevice> {
92 vec![
93 CameraDevice { key: "0".into(), name: "Integrated Camera".into() },
94 CameraDevice { key: "1".into(), name: "Studio Webcam".into() },
95 ]
96 }
97
98 fn demo_share_sources() -> Vec<ShareSource> {
99 let window = |id: u64, title: &str| ShareSource { id, kind: ShareKind::Window, title: title.to_owned() };
100 vec![
101 ShareSource { id: 1, kind: ShareKind::Screen, title: String::new() },
102 window(2, "Release notes - Docs"),
103 window(3, "Standup board"),
104 window(4, "Terminal"),
105 ]
106 }
107
81 108 fn demo_devices() -> DeviceLists {
82 109 DeviceLists {
83 110 inputs: vec![device(0, "Headset Microphone"), device(1, "Built-in Microphone")],
@@ -100,6 +127,8 @@ fn roster_of(people: &[Person]) -> Vec<RosterEntry> {
100 127 display_name: name.clone(),
101 128 muted: index % 3 == 1,
102 129 in_lobby: false,
130 has_video: index < DEMO_CAMERAS,
131 sharing: false,
103 132 })
104 133 .collect()
105 134 }
@@ -122,6 +151,8 @@ async fn run_demo_call(mut control: CallControl, script: DemoCall) {
122 151 }
123 152 control.send(CallUpdate::ListenOnly(false));
124 153 control.send(CallUpdate::Devices(demo_devices()));
154 control.send(CallUpdate::Cameras(demo_cameras()));
155 control.send(CallUpdate::ShareSources(demo_share_sources()));
125 156 control.send(CallUpdate::Selected {
126 157 input: DeviceChoice::SystemDefault,
127 158 output: DeviceChoice::SystemDefault,
@@ -138,7 +169,9 @@ async fn run_demo_call(mut control: CallControl, script: DemoCall) {
138 169 control.send(CallUpdate::Lobby(false));
139 170 }
140 171 control.send(CallUpdate::Roster(roster_of(&people)));
141 speak_until_hangup(control, people).await;
172 let video = !matches!(script, DemoCall::Test);
173 let sharer = matches!(script, DemoCall::Meeting { .. }).then(|| people.get(1).map(|person| person.0.clone())).flatten();
174 speak_until_hangup(control, people, video, sharer).await;
142 175 }
143 176
144 177 async fn ring_until_answered(control: &mut CallControl, script: &DemoCall) -> bool {
@@ -161,7 +194,25 @@ async fn ring_until_answered(control: &mut CallControl, script: &DemoCall) -> bo
161 194 true
162 195 }
163 196
164 async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>) {
197 fn publish_demo_video(control: &CallControl, people: &[Person], tick: u32, sharing: bool, sharer: Option<&str>, camera_on: bool) {
198 if camera_on {
199 control.video.publish(VideoKey::LocalCamera, bgra_from_i420(pattern_frame(PatternKind::Camera, tick + SELF_PHASE)));
200 }
201 for (index, (mri, _)) in people.iter().take(DEMO_CAMERAS).enumerate() {
202 let frame = pattern_frame(PatternKind::Camera, tick + index as u32 * GUEST_PHASE);
203 control.video.publish(VideoKey::Person(mri.clone()), bgra_from_i420(frame));
204 }
205 if sharing && sharer.is_some() && tick.is_multiple_of(SCREEN_EVERY_TICKS) {
206 control.video.publish(VideoKey::Screen, bgra_from_i420(pattern_frame(PatternKind::Screen, tick)));
207 }
208 }
209
210 async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>, video: bool, sharer: Option<String>) {
211 let started = Instant::now();
212 let mut video_ticks = 0u32;
213 let mut sharing = false;
214 let mut camera_on = false;
215 let mut video_tick = interval(VIDEO_PERIOD);
165 216 let mut muted = false;
166 217 let mut input = DeviceChoice::SystemDefault;
167 218 let mut output = DeviceChoice::SystemDefault;
@@ -169,6 +220,16 @@ async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>) {
169 220 let mut tick = interval(LEVEL_PERIOD);
170 221 loop {
171 222 tokio::select! {
223 _ = video_tick.tick(), if video || camera_on => {
224 let elapsed = started.elapsed();
225 let share_now = sharer.is_some() && (SHARE_START..SHARE_END).contains(&elapsed);
226 if share_now != sharing {
227 sharing = share_now;
228 control.send(CallUpdate::ScreenShare(sharer.clone().filter(|_| sharing)));
229 }
230 publish_demo_video(&control, &people, video_ticks, sharing, sharer.as_deref(), camera_on);
231 video_ticks += 1;
232 }
172 233 _ = tick.tick() => {
173 234 let phase = ticks % CYCLE_TICKS;
174 235 let remote_speaks = REMOTE_SPEAKS.contains(&phase);
@@ -196,6 +257,14 @@ async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>) {
196 257 control.send(CallUpdate::Selected { input: input.clone(), output: output.clone() });
197 258 }
198 259 Some(CallCommand::RefreshDevices) => control.send(CallUpdate::Devices(demo_devices())),
260 Some(CallCommand::SetCamera(on)) => {
261 camera_on = on;
262 control.send(CallUpdate::Camera(on));
263 }
264 Some(CallCommand::SelectCamera(_)) => {}
265 Some(CallCommand::StartShare(source)) => control.send(CallUpdate::LocalShare(Some(source.label()))),
266 Some(CallCommand::StopShare) => control.send(CallUpdate::LocalShare(None)),
267 Some(CallCommand::RefreshShareSources) => control.send(CallUpdate::ShareSources(demo_share_sources())),
199 268 Some(CallCommand::Hangup | CallCommand::EndMeeting) | None => {
200 269 end(&control, EndReason::LocalHangup);
201 270 return;
@@ -1,9 +1,12 @@
1use std::time::{Duration, Instant};
1use std::time::{Duration, Instant};
2
2
3use calling::video_frame::bgra_from_i420;
4use calling::video_pattern::{PatternKind, pattern_frame};
3use calling::{
5use calling::{
4 AudioDevice, CallCommand, CallControl, CallHandle, CallState, CallUpdate, Caller, DeviceChoice, DeviceLists, EndReason,
6 AudioDevice, CallCommand, CallControl, CallHandle, CallState, CallUpdate, Caller, DeviceChoice, DeviceLists, EndReason,
5 IncomingRing, Progress, RosterEntry, call_channel,
7 IncomingRing, Progress, RosterEntry, ShareKind, ShareSource, VideoKey, call_channel,
6};
8};
9use calling::CameraDevice;
7use tokio::time::{interval, sleep};
10use tokio::time::{interval, sleep};
8
11
9use super::model::{ECHO_MRI, ECHO_NAME};
12use super::model::{ECHO_MRI, ECHO_NAME};
@@ -19,6 +22,13 @@ const REMOTE_SPEAKS: std::ops::Range<u32> = 0..18;
19const LOCAL_SPEAKS: std::ops::Range<u32> = 24..32;
22const LOCAL_SPEAKS: std::ops::Range<u32> = 24..32;
20const SPEAKING_LEVEL: f32 = 0.3;
23const SPEAKING_LEVEL: f32 = 0.3;
21const SPEAKER_TICKS: u32 = 10;
24const SPEAKER_TICKS: u32 = 10;
25const VIDEO_PERIOD: Duration = Duration::from_millis(125);
26const DEMO_CAMERAS: usize = 4;
27const SCREEN_EVERY_TICKS: u32 = 4;
28const SHARE_START: Duration = Duration::from_secs(10);
29const SHARE_END: Duration = Duration::from_secs(45);
30const GUEST_PHASE: u32 = 37;
31const SELF_PHASE: u32 = 211;
22pub const DEMO_OWN_MRI: &str = "8:orgid:demo-me";
32pub const DEMO_OWN_MRI: &str = "8:orgid:demo-me";
23pub const DEMO_RING_ID: u64 = 9001;
33pub const DEMO_RING_ID: u64 = 9001;
24const DEMO_CALLER: (&str, &str) = ("8:orgid:demo-mara", "Mara Lindqvist");
34const DEMO_CALLER: (&str, &str) = ("8:orgid:demo-mara", "Mara Lindqvist");
@@ -78,6 +88,23 @@ fn device(index: u16, name: &str) -> AudioDevice {
78 }
88 }
79}
89}
80
90
91fn demo_cameras() -> Vec<CameraDevice> {
92 vec![
93 CameraDevice { key: "0".into(), name: "Integrated Camera".into() },
94 CameraDevice { key: "1".into(), name: "Studio Webcam".into() },
95 ]
96}
97
98fn demo_share_sources() -> Vec<ShareSource> {
99 let window = |id: u64, title: &str| ShareSource { id, kind: ShareKind::Window, title: title.to_owned() };
100 vec![
101 ShareSource { id: 1, kind: ShareKind::Screen, title: String::new() },
102 window(2, "Release notes - Docs"),
103 window(3, "Standup board"),
104 window(4, "Terminal"),
105 ]
106}
107
81fn demo_devices() -> DeviceLists {
108fn demo_devices() -> DeviceLists {
82 DeviceLists {
109 DeviceLists {
83 inputs: vec![device(0, "Headset Microphone"), device(1, "Built-in Microphone")],
110 inputs: vec![device(0, "Headset Microphone"), device(1, "Built-in Microphone")],
@@ -100,6 +127,8 @@ fn roster_of(people: &[Person]) -> Vec<RosterEntry> {
100 display_name: name.clone(),
127 display_name: name.clone(),
101 muted: index % 3 == 1,
128 muted: index % 3 == 1,
102 in_lobby: false,
129 in_lobby: false,
130 has_video: index < DEMO_CAMERAS,
131 sharing: false,
103 })
132 })
104 .collect()
133 .collect()
105}
134}
@@ -122,6 +151,8 @@ async fn run_demo_call(mut control: CallControl, script: DemoCall) {
122 }
151 }
123 control.send(CallUpdate::ListenOnly(false));
152 control.send(CallUpdate::ListenOnly(false));
124 control.send(CallUpdate::Devices(demo_devices()));
153 control.send(CallUpdate::Devices(demo_devices()));
154 control.send(CallUpdate::Cameras(demo_cameras()));
155 control.send(CallUpdate::ShareSources(demo_share_sources()));
125 control.send(CallUpdate::Selected {
156 control.send(CallUpdate::Selected {
126 input: DeviceChoice::SystemDefault,
157 input: DeviceChoice::SystemDefault,
127 output: DeviceChoice::SystemDefault,
158 output: DeviceChoice::SystemDefault,
@@ -138,7 +169,9 @@ async fn run_demo_call(mut control: CallControl, script: DemoCall) {
138 control.send(CallUpdate::Lobby(false));
169 control.send(CallUpdate::Lobby(false));
139 }
170 }
140 control.send(CallUpdate::Roster(roster_of(&people)));
171 control.send(CallUpdate::Roster(roster_of(&people)));
141 speak_until_hangup(control, people).await;
172 let video = !matches!(script, DemoCall::Test);
173 let sharer = matches!(script, DemoCall::Meeting { .. }).then(|| people.get(1).map(|person| person.0.clone())).flatten();
174 speak_until_hangup(control, people, video, sharer).await;
142}
175}
143
176
144async fn ring_until_answered(control: &mut CallControl, script: &DemoCall) -> bool {
177async fn ring_until_answered(control: &mut CallControl, script: &DemoCall) -> bool {
@@ -161,7 +194,25 @@ async fn ring_until_answered(control: &mut CallControl, script: &DemoCall) -> bo
161 true
194 true
162}
195}
163
196
164async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>) {
197fn publish_demo_video(control: &CallControl, people: &[Person], tick: u32, sharing: bool, sharer: Option<&str>, camera_on: bool) {
198 if camera_on {
199 control.video.publish(VideoKey::LocalCamera, bgra_from_i420(pattern_frame(PatternKind::Camera, tick + SELF_PHASE)));
200 }
201 for (index, (mri, _)) in people.iter().take(DEMO_CAMERAS).enumerate() {
202 let frame = pattern_frame(PatternKind::Camera, tick + index as u32 * GUEST_PHASE);
203 control.video.publish(VideoKey::Person(mri.clone()), bgra_from_i420(frame));
204 }
205 if sharing && sharer.is_some() && tick.is_multiple_of(SCREEN_EVERY_TICKS) {
206 control.video.publish(VideoKey::Screen, bgra_from_i420(pattern_frame(PatternKind::Screen, tick)));
207 }
208}
209
210async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>, video: bool, sharer: Option<String>) {
211 let started = Instant::now();
212 let mut video_ticks = 0u32;
213 let mut sharing = false;
214 let mut camera_on = false;
215 let mut video_tick = interval(VIDEO_PERIOD);
165 let mut muted = false;
216 let mut muted = false;
166 let mut input = DeviceChoice::SystemDefault;
217 let mut input = DeviceChoice::SystemDefault;
167 let mut output = DeviceChoice::SystemDefault;
218 let mut output = DeviceChoice::SystemDefault;
@@ -169,6 +220,16 @@ async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>) {
169 let mut tick = interval(LEVEL_PERIOD);
220 let mut tick = interval(LEVEL_PERIOD);
170 loop {
221 loop {
171 tokio::select! {
222 tokio::select! {
223 _ = video_tick.tick(), if video || camera_on => {
224 let elapsed = started.elapsed();
225 let share_now = sharer.is_some() && (SHARE_START..SHARE_END).contains(&elapsed);
226 if share_now != sharing {
227 sharing = share_now;
228 control.send(CallUpdate::ScreenShare(sharer.clone().filter(|_| sharing)));
229 }
230 publish_demo_video(&control, &people, video_ticks, sharing, sharer.as_deref(), camera_on);
231 video_ticks += 1;
232 }
172 _ = tick.tick() => {
233 _ = tick.tick() => {
173 let phase = ticks % CYCLE_TICKS;
234 let phase = ticks % CYCLE_TICKS;
174 let remote_speaks = REMOTE_SPEAKS.contains(&phase);
235 let remote_speaks = REMOTE_SPEAKS.contains(&phase);
@@ -196,6 +257,14 @@ async fn speak_until_hangup(mut control: CallControl, people: Vec<Person>) {
196 control.send(CallUpdate::Selected { input: input.clone(), output: output.clone() });
257 control.send(CallUpdate::Selected { input: input.clone(), output: output.clone() });
197 }
258 }
198 Some(CallCommand::RefreshDevices) => control.send(CallUpdate::Devices(demo_devices())),
259 Some(CallCommand::RefreshDevices) => control.send(CallUpdate::Devices(demo_devices())),
260 Some(CallCommand::SetCamera(on)) => {
261 camera_on = on;
262 control.send(CallUpdate::Camera(on));
263 }
264 Some(CallCommand::SelectCamera(_)) => {}
265 Some(CallCommand::StartShare(source)) => control.send(CallUpdate::LocalShare(Some(source.label()))),
266 Some(CallCommand::StopShare) => control.send(CallUpdate::LocalShare(None)),
267 Some(CallCommand::RefreshShareSources) => control.send(CallUpdate::ShareSources(demo_share_sources())),
199 Some(CallCommand::Hangup | CallCommand::EndMeeting) | None => {
268 Some(CallCommand::Hangup | CallCommand::EndMeeting) | None => {
200 end(&control, EndReason::LocalHangup);
269 end(&control, EndReason::LocalHangup);
201 return;
270 return;
crates/app/src/call/mod.rs +2 −1
@@ -2,10 +2,11 @@ mod actions;
2 2 mod demo;
3 3 mod launcher;
4 4 mod model;
5 mod pictures;
5 6 mod ring;
6 7 mod target;
7 8
8 9 pub use launcher::CallLauncher;
9 pub use model::{ActiveCall, CallKind, CallModel, GridLayout, TileSize, TileState, grid_layout, tile_size};
10 pub use model::{ActiveCall, CallKind, CallModel, GridLayout, Tile, TileSize, TileState, grid_layout, tile_size};
10 11 pub use ring::{MissedCall, RingEntry, Rings};
11 12 pub use target::plan_for_chat;
@@ -2,10 +2,11 @@ mod actions;
2mod demo;
2mod demo;
3mod launcher;
3mod launcher;
4mod model;
4mod model;
5mod pictures;
5mod ring;
6mod ring;
6mod target;
7mod target;
7
8
8pub use launcher::CallLauncher;
9pub use launcher::CallLauncher;
9pub use model::{ActiveCall, CallKind, CallModel, GridLayout, TileSize, TileState, grid_layout, tile_size};
10pub use model::{ActiveCall, CallKind, CallModel, GridLayout, Tile, TileSize, TileState, grid_layout, tile_size};
10pub use ring::{MissedCall, RingEntry, Rings};
11pub use ring::{MissedCall, RingEntry, Rings};
11pub use target::plan_for_chat;
12pub use target::plan_for_chat;
crates/app/src/call/model.rs +99 −2
@@ -1,11 +1,14 @@
1 use std::sync::Arc;
1 2 use std::time::{Duration, Instant};
2 3
3 4 use calling::{
4 CallCommand, CallState, CallUpdate, DeviceChoice, DeviceLists, EndKind, EndReason, Progress, RosterEntry,
5 SpeakingDetector,
5 CallCommand, CallState, CallUpdate, CameraDevice, DeviceChoice, DeviceLists, EndKind, EndReason, Progress, RosterEntry,
6 ShareKind, ShareSource, SpeakingDetector, VideoHub,
6 7 };
7 8 use tokio::sync::mpsc::UnboundedSender;
8 9
10 use super::pictures::CallPictures;
11
9 12 pub const TEST_CALL_TITLE: &str = "Test call";
10 13 pub const ECHO_NAME: &str = "Teams echo";
11 14 pub const ECHO_MRI: &str = calling::signaling::ECHO_BOT_MRI;
@@ -20,6 +23,9 @@ pub struct ActiveCall {
20 23 pub commands: UnboundedSender<CallCommand>,
21 24 pub viewing: bool,
22 25 pub conversation_id: Option<String>,
26 pub video: Arc<VideoHub>,
27 pub pictures: CallPictures,
28 pub stage_fullscreen: bool,
23 29 }
24 30
25 31 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -46,6 +52,7 @@ pub struct Tile {
46 52 pub muted: bool,
47 53 pub state: TileState,
48 54 pub invited: bool,
55 pub has_video: bool,
49 56 }
50 57
51 58 impl Tile {
@@ -57,6 +64,7 @@ impl Tile {
57 64 muted: false,
58 65 state: TileState::Invited,
59 66 invited: true,
67 has_video: false,
60 68 }
61 69 }
62 70 }
@@ -132,6 +140,12 @@ pub struct CallModel {
132 140 pub connected_since: Option<Instant>,
133 141 pub own_mri: Option<String>,
134 142 pub tiles: Vec<Tile>,
143 pub screen_sharer: Option<String>,
144 pub camera_on: bool,
145 pub cameras: Vec<CameraDevice>,
146 pub camera: DeviceChoice,
147 pub local_share: Option<String>,
148 pub share_sources: Vec<ShareSource>,
135 149 local_detector: SpeakingDetector,
136 150 remote_detector: SpeakingDetector,
137 151 }
@@ -158,6 +172,12 @@ impl CallModel {
158 172 connected_since: None,
159 173 own_mri: None,
160 174 tiles,
175 screen_sharer: None,
176 camera_on: false,
177 cameras: Vec::new(),
178 camera: DeviceChoice::SystemDefault,
179 local_share: None,
180 share_sources: Vec::new(),
161 181 local_detector: SpeakingDetector::default(),
162 182 remote_detector: SpeakingDetector::default(),
163 183 }
@@ -236,6 +256,12 @@ impl CallModel {
236 256 CallUpdate::Speakers(mris) => self.speaking_mris = mris,
237 257 CallUpdate::Lobby(lobby) => self.lobby = lobby,
238 258 CallUpdate::OwnIdentity { mri } => self.own_mri = Some(mri),
259 CallUpdate::ScreenShare(sharer) => self.screen_sharer = sharer,
260 CallUpdate::VideoReady | CallUpdate::Notice(_) => {}
261 CallUpdate::Camera(on) => self.camera_on = on,
262 CallUpdate::Cameras(cameras) => self.cameras = cameras,
263 CallUpdate::LocalShare(label) => self.local_share = label,
264 CallUpdate::ShareSources(sources) => self.share_sources = sources,
239 265 }
240 266 }
241 267
@@ -254,6 +280,7 @@ impl CallModel {
254 280 Some(tile) => {
255 281 tile.state = state;
256 282 tile.muted = entry.muted;
283 tile.has_video = entry.has_video;
257 284 if tile.name.is_empty() {
258 285 tile.name = entry.display_name.clone();
259 286 }
@@ -265,6 +292,7 @@ impl CallModel {
265 292 muted: entry.muted,
266 293 state,
267 294 invited: false,
295 has_video: entry.has_video,
268 296 }),
269 297 }
270 298 }
@@ -295,6 +323,24 @@ impl CallModel {
295 323 tiles
296 324 }
297 325
326 pub fn strip_tiles(&self) -> Vec<&Tile> {
327 let mut tiles = self.visible_tiles();
328 tiles.sort_by_key(|tile| !self.tile_speaking(tile));
329 tiles
330 }
331
332 pub fn sharing_label(&self) -> Option<String> {
333 let sharer = self.screen_sharer.as_ref()?;
334 let name = self
335 .tiles
336 .iter()
337 .find(|tile| &tile.mri == sharer)
338 .map(|tile| tile.name.as_str())
339 .filter(|name| !name.is_empty())
340 .unwrap_or("Someone");
341 Some(format!("{name} is sharing"))
342 }
343
298 344 pub fn tile_speaking(&self, tile: &Tile) -> bool {
299 345 if self.speaking_mris.contains(&tile.mri) {
300 346 return true;
@@ -347,6 +393,26 @@ impl CallModel {
347 393 self.elapsed(now).map(format_elapsed).unwrap_or_default()
348 394 }
349 395
396 pub fn can_use_camera(&self) -> bool {
397 !self.cameras.is_empty()
398 }
399
400 pub fn can_share(&self) -> bool {
401 !self.share_sources.is_empty() && self.is_live()
402 }
403
404 fn is_live(&self) -> bool {
405 matches!(self.state, CallState::Connected { .. } | CallState::Reconnecting { .. })
406 }
407
408 pub fn screens(&self) -> Vec<&ShareSource> {
409 self.share_sources.iter().filter(|source| source.kind == ShareKind::Screen).collect()
410 }
411
412 pub fn windows(&self) -> Vec<&ShareSource> {
413 self.share_sources.iter().filter(|source| source.kind == ShareKind::Window).collect()
414 }
415
350 416 pub fn can_unmute(&self) -> bool {
351 417 !self.listen_only
352 418 }
@@ -397,6 +463,8 @@ mod tests {
397 463 display_name: name.into(),
398 464 muted,
399 465 in_lobby,
466 has_video: false,
467 sharing: false,
400 468 }
401 469 }
402 470
@@ -598,6 +666,35 @@ mod tests {
598 666 assert_eq!(tile_size(9).avatar, 56.);
599 667 }
600 668
669 #[test]
670 fn the_stage_label_names_the_sharer_and_the_strip_puts_the_speaker_first() {
671 let mut model = meeting_with_me();
672 model.apply(CallUpdate::Roster(vec![
673 entry("8:orgid:a", "Ana", false, false),
674 entry("8:orgid:b", "Bo", false, false),
675 ]));
676 assert_eq!(model.sharing_label(), None);
677 model.apply(CallUpdate::ScreenShare(Some("8:orgid:b".into())));
678 assert_eq!(model.sharing_label().as_deref(), Some("Bo is sharing"));
679 model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));
680 model.apply(CallUpdate::Speakers(vec!["8:orgid:b".into()]));
681 let names: Vec<&str> = model.strip_tiles().iter().map(|tile| tile.name.as_str()).collect();
682 assert_eq!(names, vec!["Bo", "Ana"]);
683 model.apply(CallUpdate::ScreenShare(None));
684 assert_eq!(model.sharing_label(), None);
685 }
686
687 #[test]
688 fn roster_entries_carry_the_camera_flag_to_the_tile() {
689 let mut model = meeting_with_me();
690 let mut with_camera = entry("8:orgid:a", "Ana", false, false);
691 with_camera.has_video = true;
692 model.apply(CallUpdate::Roster(vec![with_camera]));
693 assert!(model.tiles[0].has_video);
694 model.apply(CallUpdate::Roster(vec![entry("8:orgid:a", "Ana", false, false)]));
695 assert!(!model.tiles[0].has_video);
696 }
697
601 698 #[test]
602 699 fn present_guests_sort_before_waiting_ones() {
603 700 let mut model = CallModel::people(
@@ -1,11 +1,14 @@
1use std::sync::Arc;
1use std::time::{Duration, Instant};
2use std::time::{Duration, Instant};
2
3
3use calling::{
4use calling::{
4 CallCommand, CallState, CallUpdate, DeviceChoice, DeviceLists, EndKind, EndReason, Progress, RosterEntry,
5 CallCommand, CallState, CallUpdate, CameraDevice, DeviceChoice, DeviceLists, EndKind, EndReason, Progress, RosterEntry,
5 SpeakingDetector,
6 ShareKind, ShareSource, SpeakingDetector, VideoHub,
6};
7};
7use tokio::sync::mpsc::UnboundedSender;
8use tokio::sync::mpsc::UnboundedSender;
8
9
10use super::pictures::CallPictures;
11
9pub const TEST_CALL_TITLE: &str = "Test call";
12pub const TEST_CALL_TITLE: &str = "Test call";
10pub const ECHO_NAME: &str = "Teams echo";
13pub const ECHO_NAME: &str = "Teams echo";
11pub const ECHO_MRI: &str = calling::signaling::ECHO_BOT_MRI;
14pub const ECHO_MRI: &str = calling::signaling::ECHO_BOT_MRI;
@@ -20,6 +23,9 @@ pub struct ActiveCall {
20 pub commands: UnboundedSender<CallCommand>,
23 pub commands: UnboundedSender<CallCommand>,
21 pub viewing: bool,
24 pub viewing: bool,
22 pub conversation_id: Option<String>,
25 pub conversation_id: Option<String>,
26 pub video: Arc<VideoHub>,
27 pub pictures: CallPictures,
28 pub stage_fullscreen: bool,
23}
29}
24
30
25#[derive(Debug, Clone, Copy, PartialEq, Eq)]
31#[derive(Debug, Clone, Copy, PartialEq, Eq)]
@@ -46,6 +52,7 @@ pub struct Tile {
46 pub muted: bool,
52 pub muted: bool,
47 pub state: TileState,
53 pub state: TileState,
48 pub invited: bool,
54 pub invited: bool,
55 pub has_video: bool,
49}
56}
50
57
51impl Tile {
58impl Tile {
@@ -57,6 +64,7 @@ impl Tile {
57 muted: false,
64 muted: false,
58 state: TileState::Invited,
65 state: TileState::Invited,
59 invited: true,
66 invited: true,
67 has_video: false,
60 }
68 }
61 }
69 }
62}
70}
@@ -132,6 +140,12 @@ pub struct CallModel {
132 pub connected_since: Option<Instant>,
140 pub connected_since: Option<Instant>,
133 pub own_mri: Option<String>,
141 pub own_mri: Option<String>,
134 pub tiles: Vec<Tile>,
142 pub tiles: Vec<Tile>,
143 pub screen_sharer: Option<String>,
144 pub camera_on: bool,
145 pub cameras: Vec<CameraDevice>,
146 pub camera: DeviceChoice,
147 pub local_share: Option<String>,
148 pub share_sources: Vec<ShareSource>,
135 local_detector: SpeakingDetector,
149 local_detector: SpeakingDetector,
136 remote_detector: SpeakingDetector,
150 remote_detector: SpeakingDetector,
137}
151}
@@ -158,6 +172,12 @@ impl CallModel {
158 connected_since: None,
172 connected_since: None,
159 own_mri: None,
173 own_mri: None,
160 tiles,
174 tiles,
175 screen_sharer: None,
176 camera_on: false,
177 cameras: Vec::new(),
178 camera: DeviceChoice::SystemDefault,
179 local_share: None,
180 share_sources: Vec::new(),
161 local_detector: SpeakingDetector::default(),
181 local_detector: SpeakingDetector::default(),
162 remote_detector: SpeakingDetector::default(),
182 remote_detector: SpeakingDetector::default(),
163 }
183 }
@@ -236,6 +256,12 @@ impl CallModel {
236 CallUpdate::Speakers(mris) => self.speaking_mris = mris,
256 CallUpdate::Speakers(mris) => self.speaking_mris = mris,
237 CallUpdate::Lobby(lobby) => self.lobby = lobby,
257 CallUpdate::Lobby(lobby) => self.lobby = lobby,
238 CallUpdate::OwnIdentity { mri } => self.own_mri = Some(mri),
258 CallUpdate::OwnIdentity { mri } => self.own_mri = Some(mri),
259 CallUpdate::ScreenShare(sharer) => self.screen_sharer = sharer,
260 CallUpdate::VideoReady | CallUpdate::Notice(_) => {}
261 CallUpdate::Camera(on) => self.camera_on = on,
262 CallUpdate::Cameras(cameras) => self.cameras = cameras,
263 CallUpdate::LocalShare(label) => self.local_share = label,
264 CallUpdate::ShareSources(sources) => self.share_sources = sources,
239 }
265 }
240 }
266 }
241
267
@@ -254,6 +280,7 @@ impl CallModel {
254 Some(tile) => {
280 Some(tile) => {
255 tile.state = state;
281 tile.state = state;
256 tile.muted = entry.muted;
282 tile.muted = entry.muted;
283 tile.has_video = entry.has_video;
257 if tile.name.is_empty() {
284 if tile.name.is_empty() {
258 tile.name = entry.display_name.clone();
285 tile.name = entry.display_name.clone();
259 }
286 }
@@ -265,6 +292,7 @@ impl CallModel {
265 muted: entry.muted,
292 muted: entry.muted,
266 state,
293 state,
267 invited: false,
294 invited: false,
295 has_video: entry.has_video,
268 }),
296 }),
269 }
297 }
270 }
298 }
@@ -295,6 +323,24 @@ impl CallModel {
295 tiles
323 tiles
296 }
324 }
297
325
326 pub fn strip_tiles(&self) -> Vec<&Tile> {
327 let mut tiles = self.visible_tiles();
328 tiles.sort_by_key(|tile| !self.tile_speaking(tile));
329 tiles
330 }
331
332 pub fn sharing_label(&self) -> Option<String> {
333 let sharer = self.screen_sharer.as_ref()?;
334 let name = self
335 .tiles
336 .iter()
337 .find(|tile| &tile.mri == sharer)
338 .map(|tile| tile.name.as_str())
339 .filter(|name| !name.is_empty())
340 .unwrap_or("Someone");
341 Some(format!("{name} is sharing"))
342 }
343
298 pub fn tile_speaking(&self, tile: &Tile) -> bool {
344 pub fn tile_speaking(&self, tile: &Tile) -> bool {
299 if self.speaking_mris.contains(&tile.mri) {
345 if self.speaking_mris.contains(&tile.mri) {
300 return true;
346 return true;
@@ -347,6 +393,26 @@ impl CallModel {
347 self.elapsed(now).map(format_elapsed).unwrap_or_default()
393 self.elapsed(now).map(format_elapsed).unwrap_or_default()
348 }
394 }
349
395
396 pub fn can_use_camera(&self) -> bool {
397 !self.cameras.is_empty()
398 }
399
400 pub fn can_share(&self) -> bool {
401 !self.share_sources.is_empty() && self.is_live()
402 }
403
404 fn is_live(&self) -> bool {
405 matches!(self.state, CallState::Connected { .. } | CallState::Reconnecting { .. })
406 }
407
408 pub fn screens(&self) -> Vec<&ShareSource> {
409 self.share_sources.iter().filter(|source| source.kind == ShareKind::Screen).collect()
410 }
411
412 pub fn windows(&self) -> Vec<&ShareSource> {
413 self.share_sources.iter().filter(|source| source.kind == ShareKind::Window).collect()
414 }
415
350 pub fn can_unmute(&self) -> bool {
416 pub fn can_unmute(&self) -> bool {
351 !self.listen_only
417 !self.listen_only
352 }
418 }
@@ -397,6 +463,8 @@ mod tests {
397 display_name: name.into(),
463 display_name: name.into(),
398 muted,
464 muted,
399 in_lobby,
465 in_lobby,
466 has_video: false,
467 sharing: false,
400 }
468 }
401 }
469 }
402
470
@@ -598,6 +666,35 @@ mod tests {
598 assert_eq!(tile_size(9).avatar, 56.);
666 assert_eq!(tile_size(9).avatar, 56.);
599 }
667 }
600
668
669 #[test]
670 fn the_stage_label_names_the_sharer_and_the_strip_puts_the_speaker_first() {
671 let mut model = meeting_with_me();
672 model.apply(CallUpdate::Roster(vec![
673 entry("8:orgid:a", "Ana", false, false),
674 entry("8:orgid:b", "Bo", false, false),
675 ]));
676 assert_eq!(model.sharing_label(), None);
677 model.apply(CallUpdate::ScreenShare(Some("8:orgid:b".into())));
678 assert_eq!(model.sharing_label().as_deref(), Some("Bo is sharing"));
679 model.apply(CallUpdate::State(CallState::Connected { since: Instant::now() }));
680 model.apply(CallUpdate::Speakers(vec!["8:orgid:b".into()]));
681 let names: Vec<&str> = model.strip_tiles().iter().map(|tile| tile.name.as_str()).collect();
682 assert_eq!(names, vec!["Bo", "Ana"]);
683 model.apply(CallUpdate::ScreenShare(None));
684 assert_eq!(model.sharing_label(), None);
685 }
686
687 #[test]
688 fn roster_entries_carry_the_camera_flag_to_the_tile() {
689 let mut model = meeting_with_me();
690 let mut with_camera = entry("8:orgid:a", "Ana", false, false);
691 with_camera.has_video = true;
692 model.apply(CallUpdate::Roster(vec![with_camera]));
693 assert!(model.tiles[0].has_video);
694 model.apply(CallUpdate::Roster(vec![entry("8:orgid:a", "Ana", false, false)]));
695 assert!(!model.tiles[0].has_video);
696 }
697
601 #[test]
698 #[test]
602 fn present_guests_sort_before_waiting_ones() {
699 fn present_guests_sort_before_waiting_ones() {
603 let mut model = CallModel::people(
700 let mut model = CallModel::people(
crates/app/src/call/pictures.rs added +56 −0
@@ -0,0 +1,56 @@
1 use std::collections::HashMap;
2 use std::sync::Arc;
3 use std::time::{Duration, Instant};
4
5 use calling::{VideoHub, VideoKey, VideoPicture};
6 use gpui_kit::*;
7 use image::{Frame, RgbaImage};
8
9 const STALE_AFTER: Duration = Duration::from_millis(2500);
10
11 struct Shown {
12 image: Arc<RenderImage>,
13 updated: Instant,
14 }
15
16 #[derive(Default)]
17 pub struct CallPictures {
18 shown: HashMap<VideoKey, Shown>,
19 }
20
21 fn render_image(picture: VideoPicture) -> Option<Arc<RenderImage>> {
22 let bytes = RgbaImage::from_raw(picture.width, picture.height, picture.bgra)?;
23 Some(Arc::new(RenderImage::new(vec![Frame::new(bytes)])))
24 }
25
26 impl CallPictures {
27 pub fn apply(&mut self, hub: &VideoHub, cx: &mut App) {
28 let now = Instant::now();
29 for (key, picture) in hub.drain() {
30 let picture = Arc::try_unwrap(picture).unwrap_or_else(|shared| (*shared).clone());
31 let Some(image) = render_image(picture) else { continue };
32 if let Some(previous) = self.shown.insert(key, Shown { image, updated: now }) {
33 cx.drop_image(previous.image, None);
34 }
35 }
36 }
37
38 pub fn live(&self, key: &VideoKey, now: Instant) -> Option<Arc<RenderImage>> {
39 self.shown
40 .get(key)
41 .filter(|shown| now.saturating_duration_since(shown.updated) < STALE_AFTER)
42 .map(|shown| shown.image.clone())
43 }
44
45 pub fn forget(&mut self, key: &VideoKey, cx: &mut App) {
46 if let Some(previous) = self.shown.remove(key) {
47 cx.drop_image(previous.image, None);
48 }
49 }
50
51 pub fn clear(&mut self, cx: &mut App) {
52 for (_, previous) in self.shown.drain() {
53 cx.drop_image(previous.image, None);
54 }
55 }
56 }
@@ -0,0 +1,56 @@
1use std::collections::HashMap;
2use std::sync::Arc;
3use std::time::{Duration, Instant};
4
5use calling::{VideoHub, VideoKey, VideoPicture};
6use gpui_kit::*;
7use image::{Frame, RgbaImage};
8
9const STALE_AFTER: Duration = Duration::from_millis(2500);
10
11struct Shown {
12 image: Arc<RenderImage>,
13 updated: Instant,
14}
15
16#[derive(Default)]
17pub struct CallPictures {
18 shown: HashMap<VideoKey, Shown>,
19}
20
21fn render_image(picture: VideoPicture) -> Option<Arc<RenderImage>> {
22 let bytes = RgbaImage::from_raw(picture.width, picture.height, picture.bgra)?;
23 Some(Arc::new(RenderImage::new(vec![Frame::new(bytes)])))
24}
25
26impl CallPictures {
27 pub fn apply(&mut self, hub: &VideoHub, cx: &mut App) {
28 let now = Instant::now();
29 for (key, picture) in hub.drain() {
30 let picture = Arc::try_unwrap(picture).unwrap_or_else(|shared| (*shared).clone());
31 let Some(image) = render_image(picture) else { continue };
32 if let Some(previous) = self.shown.insert(key, Shown { image, updated: now }) {
33 cx.drop_image(previous.image, None);
34 }
35 }
36 }
37
38 pub fn live(&self, key: &VideoKey, now: Instant) -> Option<Arc<RenderImage>> {
39 self.shown
40 .get(key)
41 .filter(|shown| now.saturating_duration_since(shown.updated) < STALE_AFTER)
42 .map(|shown| shown.image.clone())
43 }
44
45 pub fn forget(&mut self, key: &VideoKey, cx: &mut App) {
46 if let Some(previous) = self.shown.remove(key) {
47 cx.drop_image(previous.image, None);
48 }
49 }
50
51 pub fn clear(&mut self, cx: &mut App) {
52 for (_, previous) in self.shown.drain() {
53 cx.drop_image(previous.image, None);
54 }
55 }
56}
crates/app/src/views/call_stage.rs added +126 −0
@@ -0,0 +1,126 @@
1 use std::sync::Arc;
2 use std::time::Instant;
3
4 use calling::VideoKey;
5 use gpui_kit::assets::IconName;
6 use gpui_kit::component::{h_flex, v_flex};
7 use gpui_kit::prelude::FluentBuilder as _;
8 use gpui_kit::*;
9
10 use super::widgets::icon;
11 use crate::app_state::AppState;
12 use crate::theme;
13
14 const STAGE_RADIUS: f32 = 12.;
15 const LABEL_OFFSET: f32 = 14.;
16 const STAGE_BACKGROUND: f32 = 0.04;
17 const LABEL_BACKGROUND: f32 = 0.6;
18 pub const WAITING_TEXT: &str = "Loading the shared screen...";
19 pub const FULL_WINDOW_HINT: &str = "Double-click or press Esc to leave full window";
20
21 fn stage_black() -> Hsla {
22 hsla(0., 0., STAGE_BACKGROUND, 1.)
23 }
24
25 fn label_chip(text: String) -> Div {
26 h_flex()
27 .absolute()
28 .top(px(LABEL_OFFSET))
29 .left(px(LABEL_OFFSET))
30 .h(px(30.))
31 .px(px(12.))
32 .gap(px(8.))
33 .items_center()
34 .rounded_full()
35 .bg(hsla(0., 0., 0., LABEL_BACKGROUND))
36 .text_color(theme::white())
37 .text_size(px(13.))
38 .font_weight(FontWeight::SEMIBOLD)
39 .child(icon(IconName::ScreenShare, 15., theme::white()))
40 .child(text)
41 }
42
43 fn picture(image: Option<Arc<RenderImage>>) -> AnyElement {
44 match image {
45 Some(image) => img(ImageSource::Render(image))
46 .size_full()
47 .object_fit(ObjectFit::Contain)
48 .into_any_element(),
49 None => div()
50 .size_full()
51 .flex()
52 .items_center()
53 .justify_center()
54 .text_size(px(14.))
55 .text_color(theme::text_muted())
56 .child(WAITING_TEXT)
57 .into_any_element(),
58 }
59 }
60
61 pub fn render_stage(app: &Entity<AppState>, state: &AppState, fullscreen: bool) -> Option<AnyElement> {
62 let call = state.call.as_ref()?;
63 let label = call.model.sharing_label()?;
64 let image = call.pictures.live(&VideoKey::Screen, Instant::now());
65 let toggle_app = app.clone();
66 Some(
67 div()
68 .id(if fullscreen { "call-stage-full" } else { "call-stage" })
69 .relative()
70 .flex_1()
71 .min_w_0()
72 .h_full()
73 .overflow_hidden()
74 .bg(stage_black())
75 .when(!fullscreen, |stage| stage.rounded(px(STAGE_RADIUS)))
76 .cursor_pointer()
77 .on_click(move |event, _, cx| {
78 if event.click_count() >= 2 {
79 toggle_app.update(cx, |state, cx| state.toggle_stage_fullscreen(cx));
80 }
81 })
82 .child(picture(image))
83 .child(label_chip(label))
84 .when(fullscreen, |stage| {
85 stage.child(
86 div()
87 .absolute()
88 .bottom(px(LABEL_OFFSET))
89 .left_0()
90 .right_0()
91 .flex()
92 .justify_center()
93 .child(
94 div()
95 .px(px(12.))
96 .py(px(6.))
97 .rounded_full()
98 .bg(hsla(0., 0., 0., LABEL_BACKGROUND))
99 .text_size(px(12.))
100 .text_color(theme::white())
101 .child(FULL_WINDOW_HINT),
102 ),
103 )
104 })
105 .into_any_element(),
106 )
107 }
108
109 pub fn render_stage_overlay(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
110 if !state.stage_fullscreen() {
111 return None;
112 }
113 let stage = render_stage(app, state, true)?;
114 Some(
115 v_flex()
116 .id("call-stage-overlay")
117 .occlude()
118 .absolute()
119 .top_0()
120 .left_0()
121 .size_full()
122 .bg(stage_black())
123 .child(stage)
124 .into_any_element(),
125 )
126 }
@@ -0,0 +1,126 @@
1use std::sync::Arc;
2use std::time::Instant;
3
4use calling::VideoKey;
5use gpui_kit::assets::IconName;
6use gpui_kit::component::{h_flex, v_flex};
7use gpui_kit::prelude::FluentBuilder as _;
8use gpui_kit::*;
9
10use super::widgets::icon;
11use crate::app_state::AppState;
12use crate::theme;
13
14const STAGE_RADIUS: f32 = 12.;
15const LABEL_OFFSET: f32 = 14.;
16const STAGE_BACKGROUND: f32 = 0.04;
17const LABEL_BACKGROUND: f32 = 0.6;
18pub const WAITING_TEXT: &str = "Loading the shared screen...";
19pub const FULL_WINDOW_HINT: &str = "Double-click or press Esc to leave full window";
20
21fn stage_black() -> Hsla {
22 hsla(0., 0., STAGE_BACKGROUND, 1.)
23}
24
25fn label_chip(text: String) -> Div {
26 h_flex()
27 .absolute()
28 .top(px(LABEL_OFFSET))
29 .left(px(LABEL_OFFSET))
30 .h(px(30.))
31 .px(px(12.))
32 .gap(px(8.))
33 .items_center()
34 .rounded_full()
35 .bg(hsla(0., 0., 0., LABEL_BACKGROUND))
36 .text_color(theme::white())
37 .text_size(px(13.))
38 .font_weight(FontWeight::SEMIBOLD)
39 .child(icon(IconName::ScreenShare, 15., theme::white()))
40 .child(text)
41}
42
43fn picture(image: Option<Arc<RenderImage>>) -> AnyElement {
44 match image {
45 Some(image) => img(ImageSource::Render(image))
46 .size_full()
47 .object_fit(ObjectFit::Contain)
48 .into_any_element(),
49 None => div()
50 .size_full()
51 .flex()
52 .items_center()
53 .justify_center()
54 .text_size(px(14.))
55 .text_color(theme::text_muted())
56 .child(WAITING_TEXT)
57 .into_any_element(),
58 }
59}
60
61pub fn render_stage(app: &Entity<AppState>, state: &AppState, fullscreen: bool) -> Option<AnyElement> {
62 let call = state.call.as_ref()?;
63 let label = call.model.sharing_label()?;
64 let image = call.pictures.live(&VideoKey::Screen, Instant::now());
65 let toggle_app = app.clone();
66 Some(
67 div()
68 .id(if fullscreen { "call-stage-full" } else { "call-stage" })
69 .relative()
70 .flex_1()
71 .min_w_0()
72 .h_full()
73 .overflow_hidden()
74 .bg(stage_black())
75 .when(!fullscreen, |stage| stage.rounded(px(STAGE_RADIUS)))
76 .cursor_pointer()
77 .on_click(move |event, _, cx| {
78 if event.click_count() >= 2 {
79 toggle_app.update(cx, |state, cx| state.toggle_stage_fullscreen(cx));
80 }
81 })
82 .child(picture(image))
83 .child(label_chip(label))
84 .when(fullscreen, |stage| {
85 stage.child(
86 div()
87 .absolute()
88 .bottom(px(LABEL_OFFSET))
89 .left_0()
90 .right_0()
91 .flex()
92 .justify_center()
93 .child(
94 div()
95 .px(px(12.))
96 .py(px(6.))
97 .rounded_full()
98 .bg(hsla(0., 0., 0., LABEL_BACKGROUND))
99 .text_size(px(12.))
100 .text_color(theme::white())
101 .child(FULL_WINDOW_HINT),
102 ),
103 )
104 })
105 .into_any_element(),
106 )
107}
108
109pub fn render_stage_overlay(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
110 if !state.stage_fullscreen() {
111 return None;
112 }
113 let stage = render_stage(app, state, true)?;
114 Some(
115 v_flex()
116 .id("call-stage-overlay")
117 .occlude()
118 .absolute()
119 .top_0()
120 .left_0()
121 .size_full()
122 .bg(stage_black())
123 .child(stage)
124 .into_any_element(),
125 )
126}
crates/app/src/views/call_view.rs +275 −27
@@ -1,6 +1,7 @@
1 use std::sync::Arc;
1 2 use std::time::{Duration, Instant};
2 3
3 use calling::DeviceEntry;
4 use calling::{DeviceEntry, VideoKey};
4 5 use gpui_kit::assets::IconName;
5 6 use gpui_kit::component::{
6 7 button::{Button, ButtonVariants as _},
@@ -13,10 +14,11 @@ use gpui_kit::prelude::FluentBuilder as _;
13 14 use gpui_kit::*;
14 15
15 16 use super::avatar::person_avatar;
17 use super::call_stage::render_stage;
16 18 use super::widgets::icon;
17 19 use crate::app_state::AppState;
18 use crate::call::{CallKind, CallModel, GridLayout, TileState, grid_layout, tile_size};
19 20 use crate::call::TileSize;
21 use crate::call::{CallKind, CallModel, GridLayout, Tile, TileState, grid_layout, tile_size};
20 22 use crate::theme;
21 23
22 24 const HEADER_HEIGHT: f32 = 60.;
@@ -29,7 +31,21 @@ const PULSE_PERIOD: Duration = Duration::from_millis(1400);
29 31 const DISABLED_OPACITY: f32 = 0.4;
30 32 const TILE_GAP: f32 = 20.;
31 33 const GRID_PADDING: f32 = 24.;
34 const STRIP_TILE: TileSize = TileSize {
35 width: 232.,
36 height: 131.,
37 avatar: 56.,
38 };
39 const STRIP_GAP: f32 = 10.;
40 const STRIP_VISIBLE: f32 = 4.;
41 const TILE_RADIUS: f32 = 12.;
42 const NAME_PLATE_BACKGROUND: f32 = 0.6;
32 43 pub const NO_MICROPHONE_HINT: &str = "No microphone found";
44 pub const NO_CAMERA_HINT: &str = "No camera found";
45 pub const NO_SHARE_HINT: &str = "Sharing starts once the call is connected";
46 pub const NO_WINDOWS_HINT: &str = "No windows found";
47 const BANNER_HEIGHT: f32 = 40.;
48 const MAX_WINDOW_ITEMS: usize = 12;
33 49 pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
34 50
35 51 pub fn status_line(model: &CallModel, now: Instant) -> (String, Hsla) {
@@ -71,6 +87,56 @@ fn speaking_ring(avatar: AnyElement, speaking: bool) -> Div {
71 87 .child(avatar)
72 88 }
73 89
90 fn mute_badge() -> Div {
91 div()
92 .absolute()
93 .top(px(10.))
94 .right(px(10.))
95 .size(px(24.))
96 .flex()
97 .items_center()
98 .justify_center()
99 .rounded_full()
100 .bg(theme::red())
101 .child(icon(IconName::MicOff, 13., theme::white()))
102 }
103
104 fn video_tile(size: TileSize, image: Arc<RenderImage>, name: &str, speaking: bool, muted: bool) -> Div {
105 div()
106 .relative()
107 .w(px(size.width))
108 .h(px(size.height))
109 .flex_none()
110 .overflow_hidden()
111 .rounded(px(TILE_RADIUS))
112 .bg(theme::surface())
113 .border_2()
114 .border_color(if speaking { theme::green() } else { transparent_black() })
115 .child(
116 img(ImageSource::Render(image))
117 .size_full()
118 .object_fit(ObjectFit::Cover)
119 .rounded(px(TILE_RADIUS)),
120 )
121 .child(
122 div()
123 .absolute()
124 .left(px(8.))
125 .bottom(px(8.))
126 .max_w(px(size.width - 24.))
127 .truncate()
128 .px(px(8.))
129 .py(px(3.))
130 .rounded(px(6.))
131 .bg(hsla(0., 0., 0., NAME_PLATE_BACKGROUND))
132 .text_size(px(12.))
133 .font_weight(FontWeight::SEMIBOLD)
134 .text_color(theme::white())
135 .child(name.to_owned()),
136 )
137 .when(muted, |tile| tile.child(mute_badge()))
138 }
139
74 140 fn tile(
75 141 size: TileSize,
76 142 avatar: AnyElement,
@@ -200,6 +266,127 @@ pub fn leave_button(app: &Entity<AppState>, model: &CallModel, id: &'static str,
200 266 })
201 267 }
202 268
269 fn camera_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
270 let (glyph, background, foreground) = if model.camera_on {
271 (IconName::Video, theme::accent(), theme::on_accent())
272 } else {
273 (IconName::VideoOff, theme::surface_raised(), theme::text())
274 };
275 let button = round_control("call-camera", glyph, background, foreground);
276 if !model.can_use_camera() {
277 return button
278 .opacity(DISABLED_OPACITY)
279 .cursor_default()
280 .tooltip(|window, cx| Tooltip::new(NO_CAMERA_HINT).build(window, cx));
281 }
282 let app = app.clone();
283 button.on_click(move |_, _, cx| {
284 cx.stop_propagation();
285 app.update(cx, |state, cx| state.toggle_call_camera(cx));
286 })
287 }
288
289 fn share_items(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
290 let screens = model.screens();
291 let single_screen = screens.len() == 1;
292 let mut popup = popup.min_w(px(MENU_WIDTH));
293 for (index, source) in screens.into_iter().enumerate() {
294 let label = if single_screen { "Share entire screen".to_owned() } else { format!("Share screen {}", index + 1) };
295 let source = source.clone();
296 let app = app.clone();
297 popup = popup.item(
298 PopupMenuItem::new(label)
299 .icon(IconName::Monitor)
300 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx))),
301 );
302 }
303 popup = popup.separator().item(PopupMenuItem::label("Share a window..."));
304 let windows = model.windows();
305 if windows.is_empty() {
306 return popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true));
307 }
308 for source in windows.into_iter().take(MAX_WINDOW_ITEMS) {
309 let label = source.label();
310 let source = source.clone();
311 let app = app.clone();
312 popup = popup.item(
313 PopupMenuItem::new(label)
314 .icon(IconName::AppWindow)
315 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx))),
316 );
317 }
318 popup
319 }
320
321 fn share_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
322 if model.local_share.is_some() {
323 let app = app.clone();
324 return round_control("call-share-stop", IconName::ScreenShareOff, theme::accent(), theme::on_accent())
325 .tooltip(|window, cx| Tooltip::new("Stop sharing").build(window, cx))
326 .on_click(move |_, _, cx| {
327 cx.stop_propagation();
328 app.update(cx, |state, cx| state.stop_call_share(cx));
329 })
330 .into_any_element();
331 }
332 let face = round_control("call-share-face", IconName::ScreenShare, theme::surface_raised(), theme::text());
333 if !model.can_share() {
334 return face
335 .opacity(DISABLED_OPACITY)
336 .cursor_default()
337 .tooltip(|window, cx| Tooltip::new(NO_SHARE_HINT).build(window, cx))
338 .into_any_element();
339 }
340 let app = app.clone();
341 let model = model.clone();
342 Button::new("call-share")
343 .ghost()
344 .p_0()
345 .size(px(CONTROL_SIZE))
346 .rounded_full()
347 .child(face)
348 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| share_items(popup, &app, &model))
349 .into_any_element()
350 }
351
352 fn sharing_banner(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {
353 let label = model.local_share.as_ref()?;
354 let app = app.clone();
355 Some(
356 h_flex()
357 .id("call-sharing-banner")
358 .w_full()
359 .h(px(BANNER_HEIGHT))
360 .flex_none()
361 .px(px(20.))
362 .gap(px(12.))
363 .items_center()
364 .justify_center()
365 .bg(theme::accent())
366 .text_color(theme::on_accent())
367 .text_size(px(13.))
368 .font_weight(FontWeight::SEMIBOLD)
369 .child(icon(IconName::ScreenShare, 16., theme::on_accent()))
370 .child(format!("You are sharing: {label}"))
371 .child(
372 div()
373 .id("call-sharing-stop")
374 .h(px(26.))
375 .px(px(12.))
376 .flex()
377 .items_center()
378 .rounded_full()
379 .bg(theme::on_accent())
380 .text_color(theme::accent())
381 .cursor_pointer()
382 .hover(|button| button.opacity(0.9))
383 .child("Stop sharing")
384 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.stop_call_share(cx))),
385 )
386 .into_any_element(),
387 )
388 }
389
203 390 fn chat_button(app: &Entity<AppState>) -> Stateful<Div> {
204 391 let app = app.clone();
205 392 round_control("call-chat", IconName::MessageCircle, theme::surface_raised(), theme::text())
@@ -282,6 +469,16 @@ fn devices_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) ->
282 469 for item in outputs {
283 470 popup = popup.item(item);
284 471 }
472 if model.can_use_camera() {
473 let camera_app = app.clone();
474 let cameras = device_items(calling::camera_entries(&model.cameras), &model.camera, move |choice, cx| {
475 camera_app.update(cx, |state, cx| state.select_call_camera(choice, cx));
476 });
477 popup = popup.separator().item(PopupMenuItem::label("Camera"));
478 for item in cameras {
479 popup = popup.item(item);
480 }
481 }
285 482 popup
286 483 }
287 484
@@ -304,21 +501,49 @@ fn devices_button(app: &Entity<AppState>, model: &CallModel) -> impl IntoElement
304 501 })
305 502 }
306 503
307 fn remote_tiles(state: &AppState, model: &CallModel, size: TileSize, hidden_cap: GridLayout) -> Vec<AnyElement> {
504 fn person_tile(state: &AppState, model: &CallModel, remote: &Tile, size: TileSize, now: Instant) -> AnyElement {
505 let video = state
506 .call
507 .as_ref()
508 .filter(|_| remote.has_video)
509 .and_then(|call| call.pictures.live(&VideoKey::Person(remote.mri.clone()), now));
510 if let Some(image) = video {
511 return video_tile(size, image, &remote.name, model.tile_speaking(remote), remote.muted).into_any_element();
512 }
513 let waiting = remote.state == TileState::Invited;
514 let avatar = person_avatar(&state.directory, remote.user_id.as_deref(), &remote.name, size.avatar);
515 let avatar = if waiting { pulsing(avatar, "call-invited-pulse") } else { avatar };
516 let caption = model.tile_caption(remote).map(|text| {
517 let label = div().text_size(px(12.)).text_color(theme::text_muted()).child(text);
518 if waiting { pulsing(label, "call-invited-caption") } else { label.into_any_element() }
519 });
520 tile(size, avatar, &remote.name, model.tile_speaking(remote), remote.muted, caption).into_any_element()
521 }
522
523 fn own_tile(state: &AppState, model: &CallModel, size: TileSize, now: Instant) -> AnyElement {
524 let me = state.directory.me.as_ref();
525 let self_view = state
526 .call
527 .as_ref()
528 .and_then(|call| call.pictures.live(&VideoKey::LocalCamera, now));
529 if let Some(image) = self_view {
530 return video_tile(size, image, "You", model.local_speaking, model.muted).into_any_element();
531 }
532 let avatar = person_avatar(
533 &state.directory,
534 me.map(|person| person.user_id.as_str()),
535 me.map_or("You", |person| person.display_name.as_str()),
536 size.avatar,
537 );
538 tile(size, avatar, "You", model.local_speaking, model.muted, None).into_any_element()
539 }
540
541 fn remote_tiles(state: &AppState, model: &CallModel, size: TileSize, hidden_cap: GridLayout, now: Instant) -> Vec<AnyElement> {
308 542 let visible = model.visible_tiles();
309 543 let mut cells: Vec<AnyElement> = visible
310 544 .iter()
311 545 .take(hidden_cap.shown_others)
312 .map(|remote| {
313 let waiting = remote.state == TileState::Invited;
314 let avatar = person_avatar(&state.directory, remote.user_id.as_deref(), &remote.name, size.avatar);
315 let avatar = if waiting { pulsing(avatar, "call-invited-pulse") } else { avatar };
316 let caption = model.tile_caption(remote).map(|text| {
317 let label = div().text_size(px(12.)).text_color(theme::text_muted()).child(text);
318 if waiting { pulsing(label, "call-invited-caption") } else { label.into_any_element() }
319 });
320 tile(size, avatar, &remote.name, model.tile_speaking(remote), remote.muted, caption).into_any_element()
321 })
546 .map(|remote| person_tile(state, model, remote, size, now))
322 547 .collect();
323 548 if hidden_cap.hidden > 0 {
324 549 cells.push(overflow_tile(size, hidden_cap.hidden).into_any_element());
@@ -326,12 +551,28 @@ fn remote_tiles(state: &AppState, model: &CallModel, size: TileSize, hidden_cap:
326 551 cells
327 552 }
328 553
554 fn people_strip(state: &AppState, model: &CallModel, now: Instant) -> Stateful<Div> {
555 let mut cells: Vec<AnyElement> = model
556 .strip_tiles()
557 .into_iter()
558 .map(|remote| person_tile(state, model, remote, STRIP_TILE, now))
559 .collect();
560 cells.push(own_tile(state, model, STRIP_TILE, now));
561 v_flex()
562 .id("call-strip")
563 .flex_none()
564 .w(px(STRIP_TILE.width))
565 .max_h(px(STRIP_VISIBLE * (STRIP_TILE.height + STRIP_GAP) - STRIP_GAP))
566 .gap(px(STRIP_GAP))
567 .overflow_y_scroll()
568 .children(cells)
569 }
570
329 571 pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
330 572 let call = state.call.as_ref()?;
331 573 let model = &call.model;
332 574 let now = Instant::now();
333 575 let (status, status_color) = status_line(model, now);
334 let me = state.directory.me.as_ref();
335 576 let header = h_flex()
336 577 .w_full()
337 578 .h(px(HEADER_HEIGHT))
@@ -354,15 +595,9 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
354 595
355 596 let layout = grid_layout(model.visible_tiles().len());
356 597 let size = tile_size(layout.shown_others + usize::from(layout.hidden > 0) + 1);
357 let own_avatar = person_avatar(
358 &state.directory,
359 me.map(|person| person.user_id.as_str()),
360 me.map_or("You", |person| person.display_name.as_str()),
361 size.avatar,
362 );
363 let own_tile = tile(size, own_avatar, "You", model.local_speaking, model.muted, None);
364 let mut cells = remote_tiles(state, model, size, layout);
365 cells.push(own_tile.into_any_element());
598 let mut cells = remote_tiles(state, model, size, layout, now);
599 cells.push(own_tile(state, model, size, now));
600 let stage = render_stage(app, state, false);
366 601
367 602 let controls = h_flex()
368 603 .w_full()
@@ -374,6 +609,8 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
374 609 .border_t_1()
375 610 .border_color(theme::border())
376 611 .child(mute_button(app, model, "call-mute", CONTROL_SIZE))
612 .child(camera_button(app, model))
613 .child(share_button(app, model))
377 614 .child(devices_button(app, model))
378 615 .when(call.conversation_id.is_some(), |row| row.child(chat_button(app)))
379 616 .child(leave_button(app, model, "call-leave", false))
@@ -386,8 +623,18 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
386 623 .h_full()
387 624 .bg(theme::background())
388 625 .child(header)
389 .child(
390 h_flex()
626 .children(sharing_banner(app, model))
627 .child(match stage {
628 Some(stage) => h_flex()
629 .flex_1()
630 .min_h_0()
631 .p(px(GRID_PADDING))
632 .gap(px(TILE_GAP))
633 .items_center()
634 .child(stage)
635 .child(people_strip(state, model, now))
636 .into_any_element(),
637 None => h_flex()
391 638 .flex_1()
392 639 .min_h_0()
393 640 .flex_wrap()
@@ -396,8 +643,9 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
396 643 .gap(px(TILE_GAP))
397 644 .items_center()
398 645 .justify_center()
399 .children(cells),
400 )
646 .children(cells)
647 .into_any_element(),
648 })
401 649 .child(controls)
402 650 .into_any_element(),
403 651 )
@@ -1,6 +1,7 @@
1use std::sync::Arc;
1use std::time::{Duration, Instant};
2use std::time::{Duration, Instant};
2
3
3use calling::DeviceEntry;
4use calling::{DeviceEntry, VideoKey};
4use gpui_kit::assets::IconName;
5use gpui_kit::assets::IconName;
5use gpui_kit::component::{
6use gpui_kit::component::{
6 button::{Button, ButtonVariants as _},
7 button::{Button, ButtonVariants as _},
@@ -13,10 +14,11 @@ use gpui_kit::prelude::FluentBuilder as _;
13use gpui_kit::*;
14use gpui_kit::*;
14
15
15use super::avatar::person_avatar;
16use super::avatar::person_avatar;
17use super::call_stage::render_stage;
16use super::widgets::icon;
18use super::widgets::icon;
17use crate::app_state::AppState;
19use crate::app_state::AppState;
18use crate::call::{CallKind, CallModel, GridLayout, TileState, grid_layout, tile_size};
19use crate::call::TileSize;
20use crate::call::TileSize;
21use crate::call::{CallKind, CallModel, GridLayout, Tile, TileState, grid_layout, tile_size};
20use crate::theme;
22use crate::theme;
21
23
22const HEADER_HEIGHT: f32 = 60.;
24const HEADER_HEIGHT: f32 = 60.;
@@ -29,7 +31,21 @@ const PULSE_PERIOD: Duration = Duration::from_millis(1400);
29const DISABLED_OPACITY: f32 = 0.4;
31const DISABLED_OPACITY: f32 = 0.4;
30const TILE_GAP: f32 = 20.;
32const TILE_GAP: f32 = 20.;
31const GRID_PADDING: f32 = 24.;
33const GRID_PADDING: f32 = 24.;
34const STRIP_TILE: TileSize = TileSize {
35 width: 232.,
36 height: 131.,
37 avatar: 56.,
38};
39const STRIP_GAP: f32 = 10.;
40const STRIP_VISIBLE: f32 = 4.;
41const TILE_RADIUS: f32 = 12.;
42const NAME_PLATE_BACKGROUND: f32 = 0.6;
32pub const NO_MICROPHONE_HINT: &str = "No microphone found";
43pub const NO_MICROPHONE_HINT: &str = "No microphone found";
44pub const NO_CAMERA_HINT: &str = "No camera found";
45pub const NO_SHARE_HINT: &str = "Sharing starts once the call is connected";
46pub const NO_WINDOWS_HINT: &str = "No windows found";
47const BANNER_HEIGHT: f32 = 40.;
48const MAX_WINDOW_ITEMS: usize = 12;
33pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
49pub const LOBBY_TEXT: &str = "Waiting in the lobby...";
34
50
35pub fn status_line(model: &CallModel, now: Instant) -> (String, Hsla) {
51pub fn status_line(model: &CallModel, now: Instant) -> (String, Hsla) {
@@ -71,6 +87,56 @@ fn speaking_ring(avatar: AnyElement, speaking: bool) -> Div {
71 .child(avatar)
87 .child(avatar)
72}
88}
73
89
90fn mute_badge() -> Div {
91 div()
92 .absolute()
93 .top(px(10.))
94 .right(px(10.))
95 .size(px(24.))
96 .flex()
97 .items_center()
98 .justify_center()
99 .rounded_full()
100 .bg(theme::red())
101 .child(icon(IconName::MicOff, 13., theme::white()))
102}
103
104fn video_tile(size: TileSize, image: Arc<RenderImage>, name: &str, speaking: bool, muted: bool) -> Div {
105 div()
106 .relative()
107 .w(px(size.width))
108 .h(px(size.height))
109 .flex_none()
110 .overflow_hidden()
111 .rounded(px(TILE_RADIUS))
112 .bg(theme::surface())
113 .border_2()
114 .border_color(if speaking { theme::green() } else { transparent_black() })
115 .child(
116 img(ImageSource::Render(image))
117 .size_full()
118 .object_fit(ObjectFit::Cover)
119 .rounded(px(TILE_RADIUS)),
120 )
121 .child(
122 div()
123 .absolute()
124 .left(px(8.))
125 .bottom(px(8.))
126 .max_w(px(size.width - 24.))
127 .truncate()
128 .px(px(8.))
129 .py(px(3.))
130 .rounded(px(6.))
131 .bg(hsla(0., 0., 0., NAME_PLATE_BACKGROUND))
132 .text_size(px(12.))
133 .font_weight(FontWeight::SEMIBOLD)
134 .text_color(theme::white())
135 .child(name.to_owned()),
136 )
137 .when(muted, |tile| tile.child(mute_badge()))
138}
139
74fn tile(
140fn tile(
75 size: TileSize,
141 size: TileSize,
76 avatar: AnyElement,
142 avatar: AnyElement,
@@ -200,6 +266,127 @@ pub fn leave_button(app: &Entity<AppState>, model: &CallModel, id: &'static str,
200 })
266 })
201}
267}
202
268
269fn camera_button(app: &Entity<AppState>, model: &CallModel) -> Stateful<Div> {
270 let (glyph, background, foreground) = if model.camera_on {
271 (IconName::Video, theme::accent(), theme::on_accent())
272 } else {
273 (IconName::VideoOff, theme::surface_raised(), theme::text())
274 };
275 let button = round_control("call-camera", glyph, background, foreground);
276 if !model.can_use_camera() {
277 return button
278 .opacity(DISABLED_OPACITY)
279 .cursor_default()
280 .tooltip(|window, cx| Tooltip::new(NO_CAMERA_HINT).build(window, cx));
281 }
282 let app = app.clone();
283 button.on_click(move |_, _, cx| {
284 cx.stop_propagation();
285 app.update(cx, |state, cx| state.toggle_call_camera(cx));
286 })
287}
288
289fn share_items(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) -> PopupMenu {
290 let screens = model.screens();
291 let single_screen = screens.len() == 1;
292 let mut popup = popup.min_w(px(MENU_WIDTH));
293 for (index, source) in screens.into_iter().enumerate() {
294 let label = if single_screen { "Share entire screen".to_owned() } else { format!("Share screen {}", index + 1) };
295 let source = source.clone();
296 let app = app.clone();
297 popup = popup.item(
298 PopupMenuItem::new(label)
299 .icon(IconName::Monitor)
300 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx))),
301 );
302 }
303 popup = popup.separator().item(PopupMenuItem::label("Share a window..."));
304 let windows = model.windows();
305 if windows.is_empty() {
306 return popup.item(PopupMenuItem::new(NO_WINDOWS_HINT).disabled(true));
307 }
308 for source in windows.into_iter().take(MAX_WINDOW_ITEMS) {
309 let label = source.label();
310 let source = source.clone();
311 let app = app.clone();
312 popup = popup.item(
313 PopupMenuItem::new(label)
314 .icon(IconName::AppWindow)
315 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.start_call_share(source.clone(), cx))),
316 );
317 }
318 popup
319}
320
321fn share_button(app: &Entity<AppState>, model: &CallModel) -> AnyElement {
322 if model.local_share.is_some() {
323 let app = app.clone();
324 return round_control("call-share-stop", IconName::ScreenShareOff, theme::accent(), theme::on_accent())
325 .tooltip(|window, cx| Tooltip::new("Stop sharing").build(window, cx))
326 .on_click(move |_, _, cx| {
327 cx.stop_propagation();
328 app.update(cx, |state, cx| state.stop_call_share(cx));
329 })
330 .into_any_element();
331 }
332 let face = round_control("call-share-face", IconName::ScreenShare, theme::surface_raised(), theme::text());
333 if !model.can_share() {
334 return face
335 .opacity(DISABLED_OPACITY)
336 .cursor_default()
337 .tooltip(|window, cx| Tooltip::new(NO_SHARE_HINT).build(window, cx))
338 .into_any_element();
339 }
340 let app = app.clone();
341 let model = model.clone();
342 Button::new("call-share")
343 .ghost()
344 .p_0()
345 .size(px(CONTROL_SIZE))
346 .rounded_full()
347 .child(face)
348 .dropdown_menu_with_anchor(Anchor::BottomLeft, move |popup, _, _| share_items(popup, &app, &model))
349 .into_any_element()
350}
351
352fn sharing_banner(app: &Entity<AppState>, model: &CallModel) -> Option<AnyElement> {
353 let label = model.local_share.as_ref()?;
354 let app = app.clone();
355 Some(
356 h_flex()
357 .id("call-sharing-banner")
358 .w_full()
359 .h(px(BANNER_HEIGHT))
360 .flex_none()
361 .px(px(20.))
362 .gap(px(12.))
363 .items_center()
364 .justify_center()
365 .bg(theme::accent())
366 .text_color(theme::on_accent())
367 .text_size(px(13.))
368 .font_weight(FontWeight::SEMIBOLD)
369 .child(icon(IconName::ScreenShare, 16., theme::on_accent()))
370 .child(format!("You are sharing: {label}"))
371 .child(
372 div()
373 .id("call-sharing-stop")
374 .h(px(26.))
375 .px(px(12.))
376 .flex()
377 .items_center()
378 .rounded_full()
379 .bg(theme::on_accent())
380 .text_color(theme::accent())
381 .cursor_pointer()
382 .hover(|button| button.opacity(0.9))
383 .child("Stop sharing")
384 .on_click(move |_, _, cx| app.update(cx, |state, cx| state.stop_call_share(cx))),
385 )
386 .into_any_element(),
387 )
388}
389
203fn chat_button(app: &Entity<AppState>) -> Stateful<Div> {
390fn chat_button(app: &Entity<AppState>) -> Stateful<Div> {
204 let app = app.clone();
391 let app = app.clone();
205 round_control("call-chat", IconName::MessageCircle, theme::surface_raised(), theme::text())
392 round_control("call-chat", IconName::MessageCircle, theme::surface_raised(), theme::text())
@@ -282,6 +469,16 @@ fn devices_menu(popup: PopupMenu, app: &Entity<AppState>, model: &CallModel) ->
282 for item in outputs {
469 for item in outputs {
283 popup = popup.item(item);
470 popup = popup.item(item);
284 }
471 }
472 if model.can_use_camera() {
473 let camera_app = app.clone();
474 let cameras = device_items(calling::camera_entries(&model.cameras), &model.camera, move |choice, cx| {
475 camera_app.update(cx, |state, cx| state.select_call_camera(choice, cx));
476 });
477 popup = popup.separator().item(PopupMenuItem::label("Camera"));
478 for item in cameras {
479 popup = popup.item(item);
480 }
481 }
285 popup
482 popup
286}
483}
287
484
@@ -304,21 +501,49 @@ fn devices_button(app: &Entity<AppState>, model: &CallModel) -> impl IntoElement
304 })
501 })
305}
502}
306
503
307fn remote_tiles(state: &AppState, model: &CallModel, size: TileSize, hidden_cap: GridLayout) -> Vec<AnyElement> {
504fn person_tile(state: &AppState, model: &CallModel, remote: &Tile, size: TileSize, now: Instant) -> AnyElement {
505 let video = state
506 .call
507 .as_ref()
508 .filter(|_| remote.has_video)
509 .and_then(|call| call.pictures.live(&VideoKey::Person(remote.mri.clone()), now));
510 if let Some(image) = video {
511 return video_tile(size, image, &remote.name, model.tile_speaking(remote), remote.muted).into_any_element();
512 }
513 let waiting = remote.state == TileState::Invited;
514 let avatar = person_avatar(&state.directory, remote.user_id.as_deref(), &remote.name, size.avatar);
515 let avatar = if waiting { pulsing(avatar, "call-invited-pulse") } else { avatar };
516 let caption = model.tile_caption(remote).map(|text| {
517 let label = div().text_size(px(12.)).text_color(theme::text_muted()).child(text);
518 if waiting { pulsing(label, "call-invited-caption") } else { label.into_any_element() }
519 });
520 tile(size, avatar, &remote.name, model.tile_speaking(remote), remote.muted, caption).into_any_element()
521}
522
523fn own_tile(state: &AppState, model: &CallModel, size: TileSize, now: Instant) -> AnyElement {
524 let me = state.directory.me.as_ref();
525 let self_view = state
526 .call
527 .as_ref()
528 .and_then(|call| call.pictures.live(&VideoKey::LocalCamera, now));
529 if let Some(image) = self_view {
530 return video_tile(size, image, "You", model.local_speaking, model.muted).into_any_element();
531 }
532 let avatar = person_avatar(
533 &state.directory,
534 me.map(|person| person.user_id.as_str()),
535 me.map_or("You", |person| person.display_name.as_str()),
536 size.avatar,
537 );
538 tile(size, avatar, "You", model.local_speaking, model.muted, None).into_any_element()
539}
540
541fn remote_tiles(state: &AppState, model: &CallModel, size: TileSize, hidden_cap: GridLayout, now: Instant) -> Vec<AnyElement> {
308 let visible = model.visible_tiles();
542 let visible = model.visible_tiles();
309 let mut cells: Vec<AnyElement> = visible
543 let mut cells: Vec<AnyElement> = visible
310 .iter()
544 .iter()
311 .take(hidden_cap.shown_others)
545 .take(hidden_cap.shown_others)
312 .map(|remote| {
546 .map(|remote| person_tile(state, model, remote, size, now))
313 let waiting = remote.state == TileState::Invited;
314 let avatar = person_avatar(&state.directory, remote.user_id.as_deref(), &remote.name, size.avatar);
315 let avatar = if waiting { pulsing(avatar, "call-invited-pulse") } else { avatar };
316 let caption = model.tile_caption(remote).map(|text| {
317 let label = div().text_size(px(12.)).text_color(theme::text_muted()).child(text);
318 if waiting { pulsing(label, "call-invited-caption") } else { label.into_any_element() }
319 });
320 tile(size, avatar, &remote.name, model.tile_speaking(remote), remote.muted, caption).into_any_element()
321 })
322 .collect();
547 .collect();
323 if hidden_cap.hidden > 0 {
548 if hidden_cap.hidden > 0 {
324 cells.push(overflow_tile(size, hidden_cap.hidden).into_any_element());
549 cells.push(overflow_tile(size, hidden_cap.hidden).into_any_element());
@@ -326,12 +551,28 @@ fn remote_tiles(state: &AppState, model: &CallModel, size: TileSize, hidden_cap:
326 cells
551 cells
327}
552}
328
553
554fn people_strip(state: &AppState, model: &CallModel, now: Instant) -> Stateful<Div> {
555 let mut cells: Vec<AnyElement> = model
556 .strip_tiles()
557 .into_iter()
558 .map(|remote| person_tile(state, model, remote, STRIP_TILE, now))
559 .collect();
560 cells.push(own_tile(state, model, STRIP_TILE, now));
561 v_flex()
562 .id("call-strip")
563 .flex_none()
564 .w(px(STRIP_TILE.width))
565 .max_h(px(STRIP_VISIBLE * (STRIP_TILE.height + STRIP_GAP) - STRIP_GAP))
566 .gap(px(STRIP_GAP))
567 .overflow_y_scroll()
568 .children(cells)
569}
570
329pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
571pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyElement> {
330 let call = state.call.as_ref()?;
572 let call = state.call.as_ref()?;
331 let model = &call.model;
573 let model = &call.model;
332 let now = Instant::now();
574 let now = Instant::now();
333 let (status, status_color) = status_line(model, now);
575 let (status, status_color) = status_line(model, now);
334 let me = state.directory.me.as_ref();
335 let header = h_flex()
576 let header = h_flex()
336 .w_full()
577 .w_full()
337 .h(px(HEADER_HEIGHT))
578 .h(px(HEADER_HEIGHT))
@@ -354,15 +595,9 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
354
595
355 let layout = grid_layout(model.visible_tiles().len());
596 let layout = grid_layout(model.visible_tiles().len());
356 let size = tile_size(layout.shown_others + usize::from(layout.hidden > 0) + 1);
597 let size = tile_size(layout.shown_others + usize::from(layout.hidden > 0) + 1);
357 let own_avatar = person_avatar(
598 let mut cells = remote_tiles(state, model, size, layout, now);
358 &state.directory,
599 cells.push(own_tile(state, model, size, now));
359 me.map(|person| person.user_id.as_str()),
600 let stage = render_stage(app, state, false);
360 me.map_or("You", |person| person.display_name.as_str()),
361 size.avatar,
362 );
363 let own_tile = tile(size, own_avatar, "You", model.local_speaking, model.muted, None);
364 let mut cells = remote_tiles(state, model, size, layout);
365 cells.push(own_tile.into_any_element());
366
601
367 let controls = h_flex()
602 let controls = h_flex()
368 .w_full()
603 .w_full()
@@ -374,6 +609,8 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
374 .border_t_1()
609 .border_t_1()
375 .border_color(theme::border())
610 .border_color(theme::border())
376 .child(mute_button(app, model, "call-mute", CONTROL_SIZE))
611 .child(mute_button(app, model, "call-mute", CONTROL_SIZE))
612 .child(camera_button(app, model))
613 .child(share_button(app, model))
377 .child(devices_button(app, model))
614 .child(devices_button(app, model))
378 .when(call.conversation_id.is_some(), |row| row.child(chat_button(app)))
615 .when(call.conversation_id.is_some(), |row| row.child(chat_button(app)))
379 .child(leave_button(app, model, "call-leave", false))
616 .child(leave_button(app, model, "call-leave", false))
@@ -386,8 +623,18 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
386 .h_full()
623 .h_full()
387 .bg(theme::background())
624 .bg(theme::background())
388 .child(header)
625 .child(header)
389 .child(
626 .children(sharing_banner(app, model))
390 h_flex()
627 .child(match stage {
628 Some(stage) => h_flex()
629 .flex_1()
630 .min_h_0()
631 .p(px(GRID_PADDING))
632 .gap(px(TILE_GAP))
633 .items_center()
634 .child(stage)
635 .child(people_strip(state, model, now))
636 .into_any_element(),
637 None => h_flex()
391 .flex_1()
638 .flex_1()
392 .min_h_0()
639 .min_h_0()
393 .flex_wrap()
640 .flex_wrap()
@@ -396,8 +643,9 @@ pub fn render_call_view(app: &Entity<AppState>, state: &AppState) -> Option<AnyE
396 .gap(px(TILE_GAP))
643 .gap(px(TILE_GAP))
397 .items_center()
644 .items_center()
398 .justify_center()
645 .justify_center()
399 .children(cells),
646 .children(cells)
400 )
647 .into_any_element(),
648 })
401 .child(controls)
649 .child(controls)
402 .into_any_element(),
650 .into_any_element(),
403 )
651 )
crates/app/src/views/mod.rs +1 −0
@@ -5,6 +5,7 @@ pub mod attachments;
5 5 pub mod avatar;
6 6 pub mod call_controls;
7 7 pub mod call_mini;
8 pub mod call_stage;
8 9 pub mod call_view;
9 10 pub mod card_carousel;
10 11 pub mod card_chart;
@@ -5,6 +5,7 @@ pub mod attachments;
5pub mod avatar;
5pub mod avatar;
6pub mod call_controls;
6pub mod call_controls;
7pub mod call_mini;
7pub mod call_mini;
8pub mod call_stage;
8pub mod call_view;
9pub mod call_view;
9pub mod card_carousel;
10pub mod card_carousel;
10pub mod card_chart;
11pub mod card_chart;
crates/app/src/views/shell.rs +10 −0
@@ -3,6 +3,7 @@ use gpui_kit::*;
3 3
4 4 use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
5 5 use super::call_mini::render_call_mini;
6 use super::call_stage::render_stage_overlay;
6 7 use super::call_view::render_call_view;
7 8 use super::conversation::{ConversationView, ReplyToHovered};
8 9 use super::dialog_overlay::render_task_dialog;
@@ -69,6 +70,7 @@ pub struct AppShell {
69 70 update: UpdateStatus,
70 71 _subscription: Subscription,
71 72 _activity_observation: Subscription,
73 _escape_observation: Subscription,
72 74 }
73 75
74 76 impl AppShell {
@@ -107,6 +109,11 @@ impl AppShell {
107 109 let notifications = cx.new(|cx| NotificationCenter::new(state.clone(), window, cx));
108 110 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
109 111 let activity_observation = cx.observe(&activity, |_, _, cx| cx.notify());
112 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
113 if event.keystroke.key == "escape" {
114 this.state.update(cx, |state, cx| state.leave_stage_fullscreen(cx));
115 }
116 });
110 117 let closing = notifications.clone();
111 118 window.on_window_should_close(cx, move |_, cx| !closing.read(cx).intercept_close(cx));
112 119 let mut shell = AppShell {
@@ -126,6 +133,7 @@ impl AppShell {
126 133 update: UpdateStatus::UpToDate,
127 134 _subscription: subscription,
128 135 _activity_observation: activity_observation,
136 _escape_observation: escape_observation,
129 137 };
130 138 shell.apply_open_target(cx);
131 139 let Startup {
@@ -483,6 +491,7 @@ impl Render for AppShell {
483 491 let state = self.state.read(cx);
484 492 let call_view = render_call_view(&self.state, state).filter(|_| state.viewing_call());
485 493 let call_mini = render_call_mini(&self.state, state);
494 let stage_overlay = render_stage_overlay(&self.state, state);
486 495 let status = render_status_bar(
487 496 state,
488 497 &self.update,
@@ -541,6 +550,7 @@ impl Render for AppShell {
541 550 .child(status),
542 551 )
543 552 .children(call_mini)
553 .children(stage_overlay)
544 554 .children(self.activity_panel.clone())
545 555 .children(self.saved_panel.clone())
546 556 .children(self.switcher.clone())
@@ -3,6 +3,7 @@ use gpui_kit::*;
3
3
4use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
4use super::activity_panel::{ActivityPanel, ActivityPanelEvent};
5use super::call_mini::render_call_mini;
5use super::call_mini::render_call_mini;
6use super::call_stage::render_stage_overlay;
6use super::call_view::render_call_view;
7use super::call_view::render_call_view;
7use super::conversation::{ConversationView, ReplyToHovered};
8use super::conversation::{ConversationView, ReplyToHovered};
8use super::dialog_overlay::render_task_dialog;
9use super::dialog_overlay::render_task_dialog;
@@ -69,6 +70,7 @@ pub struct AppShell {
69 update: UpdateStatus,
70 update: UpdateStatus,
70 _subscription: Subscription,
71 _subscription: Subscription,
71 _activity_observation: Subscription,
72 _activity_observation: Subscription,
73 _escape_observation: Subscription,
72}
74}
73
75
74impl AppShell {
76impl AppShell {
@@ -107,6 +109,11 @@ impl AppShell {
107 let notifications = cx.new(|cx| NotificationCenter::new(state.clone(), window, cx));
109 let notifications = cx.new(|cx| NotificationCenter::new(state.clone(), window, cx));
108 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
110 let activity = cx.new(|cx| ActivityCenter::new(state.clone(), window, cx));
109 let activity_observation = cx.observe(&activity, |_, _, cx| cx.notify());
111 let activity_observation = cx.observe(&activity, |_, _, cx| cx.notify());
112 let escape_observation = cx.observe_keystrokes(|this, event, _, cx| {
113 if event.keystroke.key == "escape" {
114 this.state.update(cx, |state, cx| state.leave_stage_fullscreen(cx));
115 }
116 });
110 let closing = notifications.clone();
117 let closing = notifications.clone();
111 window.on_window_should_close(cx, move |_, cx| !closing.read(cx).intercept_close(cx));
118 window.on_window_should_close(cx, move |_, cx| !closing.read(cx).intercept_close(cx));
112 let mut shell = AppShell {
119 let mut shell = AppShell {
@@ -126,6 +133,7 @@ impl AppShell {
126 update: UpdateStatus::UpToDate,
133 update: UpdateStatus::UpToDate,
127 _subscription: subscription,
134 _subscription: subscription,
128 _activity_observation: activity_observation,
135 _activity_observation: activity_observation,
136 _escape_observation: escape_observation,
129 };
137 };
130 shell.apply_open_target(cx);
138 shell.apply_open_target(cx);
131 let Startup {
139 let Startup {
@@ -483,6 +491,7 @@ impl Render for AppShell {
483 let state = self.state.read(cx);
491 let state = self.state.read(cx);
484 let call_view = render_call_view(&self.state, state).filter(|_| state.viewing_call());
492 let call_view = render_call_view(&self.state, state).filter(|_| state.viewing_call());
485 let call_mini = render_call_mini(&self.state, state);
493 let call_mini = render_call_mini(&self.state, state);
494 let stage_overlay = render_stage_overlay(&self.state, state);
486 let status = render_status_bar(
495 let status = render_status_bar(
487 state,
496 state,
488 &self.update,
497 &self.update,
@@ -541,6 +550,7 @@ impl Render for AppShell {
541 .child(status),
550 .child(status),
542 )
551 )
543 .children(call_mini)
552 .children(call_mini)
553 .children(stage_overlay)
544 .children(self.activity_panel.clone())
554 .children(self.activity_panel.clone())
545 .children(self.saved_panel.clone())
555 .children(self.saved_panel.clone())
546 .children(self.switcher.clone())
556 .children(self.switcher.clone())
crates/calling/Cargo.toml +2 −1
@@ -10,7 +10,8 @@ base64.workspace = true
10 10 chatsvc.workspace = true
11 11 flate2 = "1"
12 12 futures-util.workspace = true
13 libwebrtc = "0.3.51"
13 libwebrtc = { version = "0.3.51", features = ["glib-main-loop"] }
14 nokhwa = { version = "0.10", default-features = false, features = ["input-native"] }
14 15 serde.workspace = true
15 16 serde_json.workspace = true
16 17 session.workspace = true
@@ -10,7 +10,8 @@ base64.workspace = true
10chatsvc.workspace = true
10chatsvc.workspace = true
11flate2 = "1"
11flate2 = "1"
12futures-util.workspace = true
12futures-util.workspace = true
13libwebrtc = "0.3.51"
13libwebrtc = { version = "0.3.51", features = ["glib-main-loop"] }
14nokhwa = { version = "0.10", default-features = false, features = ["input-native"] }
14serde.workspace = true
15serde.workspace = true
15serde_json.workspace = true
16serde_json.workspace = true
16session.workspace = true
17session.workspace = true
crates/calling/examples/capture_probe.rs added +18 −0
@@ -0,0 +1,18 @@
1 use calling::camera::list_cameras;
2 use calling::screen::{ShareKind, list_share_sources};
3
4 fn main() {
5 let cameras = list_cameras();
6 println!("cameras: {}", cameras.len());
7 for (index, camera) in cameras.iter().enumerate() {
8 println!(" camera {index}: key {:?}, name {} chars", camera.key, camera.name.chars().count());
9 }
10 let sources = list_share_sources();
11 for kind in [ShareKind::Screen, ShareKind::Window] {
12 let of_kind: Vec<_> = sources.iter().filter(|source| source.kind == kind).collect();
13 println!("{kind:?} sources: {}", of_kind.len());
14 for (index, source) in of_kind.iter().enumerate() {
15 println!(" {kind:?} {index}: id {}, title {} chars", source.id, source.title.chars().count());
16 }
17 }
18 }
@@ -0,0 +1,18 @@
1use calling::camera::list_cameras;
2use calling::screen::{ShareKind, list_share_sources};
3
4fn main() {
5 let cameras = list_cameras();
6 println!("cameras: {}", cameras.len());
7 for (index, camera) in cameras.iter().enumerate() {
8 println!(" camera {index}: key {:?}, name {} chars", camera.key, camera.name.chars().count());
9 }
10 let sources = list_share_sources();
11 for kind in [ShareKind::Screen, ShareKind::Window] {
12 let of_kind: Vec<_> = sources.iter().filter(|source| source.kind == kind).collect();
13 println!("{kind:?} sources: {}", of_kind.len());
14 for (index, source) in of_kind.iter().enumerate() {
15 println!(" {kind:?} {index}: id {}, title {} chars", source.id, source.title.chars().count());
16 }
17 }
18}
crates/calling/examples/echo_call.rs +6 −0
@@ -16,6 +16,12 @@ fn print_report(report: &CallReport) {
16 16 "# inbound audio: {} packets, {} bytes, {} s with new packets; outbound {} packets",
17 17 report.inbound_packets, report.inbound_bytes, report.seconds_with_inbound_audio, report.outbound_packets
18 18 );
19 let video = &report.video;
20 println!(
21 "# video: inbound {} packets, {} frames decoded ({}x{}), {} frames to the UI hub; outbound {} packets, {} frames encoded ({}x{})",
22 video.inbound_packets, video.inbound_frames_decoded, video.inbound_width, video.inbound_height, video.frames_published,
23 video.outbound_packets, video.outbound_frames_encoded, video.outbound_width, video.outbound_height
24 );
19 25 for second in &report.seconds {
20 26 println!(
21 27 "# t+{:>2}s packets={:>5} level={:.3} rms={:.3} tone440={:.2}",
@@ -16,6 +16,12 @@ fn print_report(report: &CallReport) {
16 "# inbound audio: {} packets, {} bytes, {} s with new packets; outbound {} packets",
16 "# inbound audio: {} packets, {} bytes, {} s with new packets; outbound {} packets",
17 report.inbound_packets, report.inbound_bytes, report.seconds_with_inbound_audio, report.outbound_packets
17 report.inbound_packets, report.inbound_bytes, report.seconds_with_inbound_audio, report.outbound_packets
18 );
18 );
19 let video = &report.video;
20 println!(
21 "# video: inbound {} packets, {} frames decoded ({}x{}), {} frames to the UI hub; outbound {} packets, {} frames encoded ({}x{})",
22 video.inbound_packets, video.inbound_frames_decoded, video.inbound_width, video.inbound_height, video.frames_published,
23 video.outbound_packets, video.outbound_frames_encoded, video.outbound_width, video.outbound_height
24 );
19 for second in &report.seconds {
25 for second in &report.seconds {
20 println!(
26 println!(
21 "# t+{:>2}s packets={:>5} level={:.3} rms={:.3} tone440={:.2}",
27 "# t+{:>2}s packets={:>5} level={:.3} rms={:.3} tone440={:.2}",
crates/calling/examples/meet_now.rs +45 −3
@@ -4,7 +4,7 @@ use std::time::{Duration, Instant};
4 4 use calling::meeting::fetch_live_meeting;
5 5 use calling::relay::ic3_scope;
6 6 use calling::signaling::{CHATSVC_REGION, fetch_self};
7 use calling::{CallCommand, CallEngine, CallSpec, CallState, CallUpdate, EngineConfig, MeetingTarget};
7 use calling::{CallCommand, CallEngine, CallSpec, CallState, CallUpdate, EngineConfig, MeetingTarget, ShareKind, ShareSource};
8 8 use chatsvc::InstanceNames;
9 9 use serde_json::{Value, json};
10 10 use session::{DEFAULT_ENDPOINT, Method, Request, Scope, Session, SPACES};
@@ -18,8 +18,13 @@ const WAIT_FILE_LIMIT: Duration = Duration::from_secs(300);
18 18 const END_LIMIT: Duration = Duration::from_secs(20);
19 19 const GONE_LIMIT: Duration = Duration::from_secs(90);
20 20 const POLL: Duration = Duration::from_secs(2);
21 const MEDIA_DELAY: Duration = Duration::from_secs(3);
22 const THREAD_PROPERTY_RETRIES: usize = 8;
21 23
22 24 struct Arguments {
25 camera: bool,
26 share: bool,
27 stop_media_after: Option<Duration>,
23 28 hold: Duration,
24 29 thread_out: Option<PathBuf>,
25 30 wait_file: Option<PathBuf>,
@@ -27,6 +32,9 @@ struct Arguments {
27 32
28 33 fn arguments() -> Arguments {
29 34 let mut parsed = Arguments {
35 camera: false,
36 share: false,
37 stop_media_after: None,
30 38 hold: Duration::from_secs(10),
31 39 thread_out: None,
32 40 wait_file: None,
@@ -34,6 +42,9 @@ fn arguments() -> Arguments {
34 42 let mut input = std::env::args().skip(1);
35 43 while let Some(flag) = input.next() {
36 44 match flag.as_str() {
45 "--camera" => parsed.camera = true,
46 "--share" => parsed.share = true,
47 "--stop-media-after" => parsed.stop_media_after = input.next().and_then(|value| value.parse().ok()).map(Duration::from_secs),
37 48 "--hold" => parsed.hold = Duration::from_secs(input.next().and_then(|value| value.parse().ok()).unwrap_or(10)),
38 49 "--thread-out" => parsed.thread_out = input.next().map(PathBuf::from),
39 50 "--wait-file" => parsed.wait_file = input.next().map(PathBuf::from),
@@ -95,7 +106,14 @@ async fn main() {
95 106 std::fs::write(path, &thread_id).expect("thread file");
96 107 }
97 108
98 let (tenant_id, organizer_id) = tenant_and_organizer(&session, &thread_id).await;
109 let (mut tenant_id, mut organizer_id) = tenant_and_organizer(&session, &thread_id).await;
110 for _ in 0..THREAD_PROPERTY_RETRIES {
111 if tenant_id.is_some() {
112 break;
113 }
114 tokio::time::sleep(POLL).await;
115 (tenant_id, organizer_id) = tenant_and_organizer(&session, &thread_id).await;
116 }
99 117 let organizer_id = organizer_id.unwrap_or_else(|| me.object_id.clone());
100 118 println!(
101 119 "# thread: tenant found {}, organizer is me {}",
@@ -131,14 +149,22 @@ async fn main() {
131 149 let mut live_detected_after = None;
132 150 let mut released_at = None;
133 151 let mut end_sent_at = None;
152 let mut media_due: Option<Instant> = None;
153 let mut media_stop_due: Option<Instant> = None;
134 154 let deadline = Instant::now() + CONNECT_LIMIT + LIVE_STATE_LIMIT + WAIT_FILE_LIMIT + arguments.hold + END_LIMIT;
135 155 let mut tick = tokio::time::interval(POLL);
136 156 while ended.is_none() && Instant::now() < deadline {
137 157 tokio::select! {
138 158 update = handle.updates.recv() => match update {
139 159 Some(CallUpdate::State(CallState::Connected { .. })) => {
140 connected_after.get_or_insert(join_started.elapsed());
160 if connected_after.is_none() {
161 connected_after = Some(join_started.elapsed());
162 media_due = Some(Instant::now() + MEDIA_DELAY);
163 }
141 164 }
165 Some(CallUpdate::Camera(on)) => println!("# camera update: {on}"),
166 Some(CallUpdate::LocalShare(label)) => println!("# local share update: {}", label.is_some()),
167 Some(CallUpdate::Notice(text)) => println!("# notice: {text}"),
142 168 Some(CallUpdate::State(CallState::Ended { reason })) => ended = Some(reason),
143 169 Some(CallUpdate::Roster(entries)) => roster_count = Some(entries.len()),
144 170 Some(CallUpdate::Stats { inbound_packets, .. }) => inbound = inbound_packets,
@@ -146,6 +172,22 @@ async fn main() {
146 172 None => break,
147 173 },
148 174 _ = tick.tick() => {
175 if media_stop_due.is_some_and(|due| Instant::now() >= due) {
176 media_stop_due = None;
177 let _ = handle.commands.send(CallCommand::SetCamera(false));
178 let _ = handle.commands.send(CallCommand::StopShare);
179 }
180 if media_due.is_some_and(|due| Instant::now() >= due) {
181 media_due = None;
182 media_stop_due = arguments.stop_media_after.map(|after| Instant::now() + after);
183 if arguments.camera {
184 let _ = handle.commands.send(CallCommand::SetCamera(true));
185 }
186 if arguments.share {
187 let source = ShareSource { id: 0, kind: ShareKind::Screen, title: String::new() };
188 let _ = handle.commands.send(CallCommand::StartShare(source));
189 }
190 }
149 191 if connected_after.is_none() {
150 192 if join_started.elapsed() > CONNECT_LIMIT {
151 193 println!("# not connected within {CONNECT_LIMIT:?}, hanging up");
@@ -4,7 +4,7 @@ use std::time::{Duration, Instant};
4use calling::meeting::fetch_live_meeting;
4use calling::meeting::fetch_live_meeting;
5use calling::relay::ic3_scope;
5use calling::relay::ic3_scope;
6use calling::signaling::{CHATSVC_REGION, fetch_self};
6use calling::signaling::{CHATSVC_REGION, fetch_self};
7use calling::{CallCommand, CallEngine, CallSpec, CallState, CallUpdate, EngineConfig, MeetingTarget};
7use calling::{CallCommand, CallEngine, CallSpec, CallState, CallUpdate, EngineConfig, MeetingTarget, ShareKind, ShareSource};
8use chatsvc::InstanceNames;
8use chatsvc::InstanceNames;
9use serde_json::{Value, json};
9use serde_json::{Value, json};
10use session::{DEFAULT_ENDPOINT, Method, Request, Scope, Session, SPACES};
10use session::{DEFAULT_ENDPOINT, Method, Request, Scope, Session, SPACES};
@@ -18,8 +18,13 @@ const WAIT_FILE_LIMIT: Duration = Duration::from_secs(300);
18const END_LIMIT: Duration = Duration::from_secs(20);
18const END_LIMIT: Duration = Duration::from_secs(20);
19const GONE_LIMIT: Duration = Duration::from_secs(90);
19const GONE_LIMIT: Duration = Duration::from_secs(90);
20const POLL: Duration = Duration::from_secs(2);
20const POLL: Duration = Duration::from_secs(2);
21const MEDIA_DELAY: Duration = Duration::from_secs(3);
22const THREAD_PROPERTY_RETRIES: usize = 8;
21
23
22struct Arguments {
24struct Arguments {
25 camera: bool,
26 share: bool,
27 stop_media_after: Option<Duration>,
23 hold: Duration,
28 hold: Duration,
24 thread_out: Option<PathBuf>,
29 thread_out: Option<PathBuf>,
25 wait_file: Option<PathBuf>,
30 wait_file: Option<PathBuf>,
@@ -27,6 +32,9 @@ struct Arguments {
27
32
28fn arguments() -> Arguments {
33fn arguments() -> Arguments {
29 let mut parsed = Arguments {
34 let mut parsed = Arguments {
35 camera: false,
36 share: false,
37 stop_media_after: None,
30 hold: Duration::from_secs(10),
38 hold: Duration::from_secs(10),
31 thread_out: None,
39 thread_out: None,
32 wait_file: None,
40 wait_file: None,
@@ -34,6 +42,9 @@ fn arguments() -> Arguments {
34 let mut input = std::env::args().skip(1);
42 let mut input = std::env::args().skip(1);
35 while let Some(flag) = input.next() {
43 while let Some(flag) = input.next() {
36 match flag.as_str() {
44 match flag.as_str() {
45 "--camera" => parsed.camera = true,
46 "--share" => parsed.share = true,
47 "--stop-media-after" => parsed.stop_media_after = input.next().and_then(|value| value.parse().ok()).map(Duration::from_secs),
37 "--hold" => parsed.hold = Duration::from_secs(input.next().and_then(|value| value.parse().ok()).unwrap_or(10)),
48 "--hold" => parsed.hold = Duration::from_secs(input.next().and_then(|value| value.parse().ok()).unwrap_or(10)),
38 "--thread-out" => parsed.thread_out = input.next().map(PathBuf::from),
49 "--thread-out" => parsed.thread_out = input.next().map(PathBuf::from),
39 "--wait-file" => parsed.wait_file = input.next().map(PathBuf::from),
50 "--wait-file" => parsed.wait_file = input.next().map(PathBuf::from),
@@ -95,7 +106,14 @@ async fn main() {
95 std::fs::write(path, &thread_id).expect("thread file");
106 std::fs::write(path, &thread_id).expect("thread file");
96 }
107 }
97
108
98 let (tenant_id, organizer_id) = tenant_and_organizer(&session, &thread_id).await;
109 let (mut tenant_id, mut organizer_id) = tenant_and_organizer(&session, &thread_id).await;
110 for _ in 0..THREAD_PROPERTY_RETRIES {
111 if tenant_id.is_some() {
112 break;
113 }
114 tokio::time::sleep(POLL).await;
115 (tenant_id, organizer_id) = tenant_and_organizer(&session, &thread_id).await;
116 }
99 let organizer_id = organizer_id.unwrap_or_else(|| me.object_id.clone());
117 let organizer_id = organizer_id.unwrap_or_else(|| me.object_id.clone());
100 println!(
118 println!(
101 "# thread: tenant found {}, organizer is me {}",
119 "# thread: tenant found {}, organizer is me {}",
@@ -131,14 +149,22 @@ async fn main() {
131 let mut live_detected_after = None;
149 let mut live_detected_after = None;
132 let mut released_at = None;
150 let mut released_at = None;
133 let mut end_sent_at = None;
151 let mut end_sent_at = None;
152 let mut media_due: Option<Instant> = None;
153 let mut media_stop_due: Option<Instant> = None;
134 let deadline = Instant::now() + CONNECT_LIMIT + LIVE_STATE_LIMIT + WAIT_FILE_LIMIT + arguments.hold + END_LIMIT;
154 let deadline = Instant::now() + CONNECT_LIMIT + LIVE_STATE_LIMIT + WAIT_FILE_LIMIT + arguments.hold + END_LIMIT;
135 let mut tick = tokio::time::interval(POLL);
155 let mut tick = tokio::time::interval(POLL);
136 while ended.is_none() && Instant::now() < deadline {
156 while ended.is_none() && Instant::now() < deadline {
137 tokio::select! {
157 tokio::select! {
138 update = handle.updates.recv() => match update {
158 update = handle.updates.recv() => match update {
139 Some(CallUpdate::State(CallState::Connected { .. })) => {
159 Some(CallUpdate::State(CallState::Connected { .. })) => {
140 connected_after.get_or_insert(join_started.elapsed());
160 if connected_after.is_none() {
161 connected_after = Some(join_started.elapsed());
162 media_due = Some(Instant::now() + MEDIA_DELAY);
163 }
141 }
164 }
165 Some(CallUpdate::Camera(on)) => println!("# camera update: {on}"),
166 Some(CallUpdate::LocalShare(label)) => println!("# local share update: {}", label.is_some()),
167 Some(CallUpdate::Notice(text)) => println!("# notice: {text}"),
142 Some(CallUpdate::State(CallState::Ended { reason })) => ended = Some(reason),
168 Some(CallUpdate::State(CallState::Ended { reason })) => ended = Some(reason),
143 Some(CallUpdate::Roster(entries)) => roster_count = Some(entries.len()),
169 Some(CallUpdate::Roster(entries)) => roster_count = Some(entries.len()),
144 Some(CallUpdate::Stats { inbound_packets, .. }) => inbound = inbound_packets,
170 Some(CallUpdate::Stats { inbound_packets, .. }) => inbound = inbound_packets,
@@ -146,6 +172,22 @@ async fn main() {
146 None => break,
172 None => break,
147 },
173 },
148 _ = tick.tick() => {
174 _ = tick.tick() => {
175 if media_stop_due.is_some_and(|due| Instant::now() >= due) {
176 media_stop_due = None;
177 let _ = handle.commands.send(CallCommand::SetCamera(false));
178 let _ = handle.commands.send(CallCommand::StopShare);
179 }
180 if media_due.is_some_and(|due| Instant::now() >= due) {
181 media_due = None;
182 media_stop_due = arguments.stop_media_after.map(|after| Instant::now() + after);
183 if arguments.camera {
184 let _ = handle.commands.send(CallCommand::SetCamera(true));
185 }
186 if arguments.share {
187 let source = ShareSource { id: 0, kind: ShareKind::Screen, title: String::new() };
188 let _ = handle.commands.send(CallCommand::StartShare(source));
189 }
190 }
149 if connected_after.is_none() {
191 if connected_after.is_none() {
150 if join_started.elapsed() > CONNECT_LIMIT {
192 if join_started.elapsed() > CONNECT_LIMIT {
151 println!("# not connected within {CONNECT_LIMIT:?}, hanging up");
193 println!("# not connected within {CONNECT_LIMIT:?}, hanging up");
crates/calling/src/call.rs +251 −11
@@ -28,13 +28,18 @@ use crate::push::CallNotification;
28 28 use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};
29 29 use crate::renegotiation::{MediaAction, MediaNegotiator};
30 30 use crate::roster::Roster;
31 use crate::sdp::{OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, to_browser_answer, to_teams_answer, to_teams_offer};
31 use crate::sdp::{RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};
32 32 use crate::signaling::{
33 33 Answer, Attached, Callee, Conversation, Invitation, InviteTarget, LeaveReason, MeetingTarget, Participant, Signaling,
34 34 TenantRouting, find_echo_bot_thread, escalation_answer_body, renegotiation_body,
35 35 };
36 36 use crate::state::{CallSignal, CallState};
37 37 use crate::timeline::{Timeline, TimelineEntry};
38 use crate::video_layout::{MediaDescription, SlotTable, VideoLines, VideoRouter, add_video_lines, offer_plan};
39 use crate::video_send::{LocalVideo, VideoMode};
40 use crate::camera::{CameraDevice, list_cameras};
41 use crate::screen::{ShareKind, ShareSource, list_share_sources};
42 use crate::video_receive::{ReceiveChange, SourceRequester, VideoCounters, VideoReceive, spawn_video_pump};
38 43 use crate::trouter_events::{
39 44 CallEnd, CallEvent, CallbackLinks, ProgressStatus, acceptance_acknowledgement, classify, decode_body,
40 45 };
@@ -56,6 +61,8 @@ pub struct CallOptions {
56 61 pub hard_limit: Option<Duration>,
57 62 pub reconnect_window: Duration,
58 63 pub audio: AudioMode,
64 pub video: VideoMode,
65 pub camera: DeviceChoice,
59 66 pub tone_hz: f32,
60 67 pub input: DeviceChoice,
61 68 pub output: DeviceChoice,
@@ -74,6 +81,8 @@ impl Default for CallOptions {
74 81 hard_limit: None,
75 82 reconnect_window: RECONNECT_WINDOW,
76 83 audio: AudioMode::from_env(),
84 video: VideoMode::from_env(),
85 camera: DeviceChoice::SystemDefault,
77 86 tone_hz: 440.0,
78 87 input: DeviceChoice::SystemDefault,
79 88 output: DeviceChoice::SystemDefault,
@@ -97,6 +106,22 @@ pub struct AudioSecond {
97 106 pub tone_ratio: f32,
98 107 }
99 108
109 #[derive(Debug, Clone, Default, PartialEq)]
110 pub struct VideoReport {
111 pub inbound_packets: u64,
112 pub inbound_frames_decoded: u64,
113 pub inbound_width: u32,
114 pub inbound_height: u32,
115 pub frames_received: u64,
116 pub frames_published: u64,
117 pub outbound_packets: u64,
118 pub outbound_frames_encoded: u64,
119 pub outbound_width: u32,
120 pub outbound_height: u32,
121 pub remote_reports: u64,
122 pub remote_round_trip_ms: f64,
123 }
124
100 125 #[derive(Debug, Clone, Default)]
101 126 pub struct CallReport {
102 127 pub timeline: Vec<TimelineEntry>,
@@ -109,6 +134,8 @@ pub struct CallReport {
109 134 pub inbound_packets: u64,
110 135 pub inbound_bytes: u64,
111 136 pub outbound_packets: u64,
137 pub video: VideoReport,
138 pub own_streams: Vec<String>,
112 139 pub seconds_with_inbound_audio: u32,
113 140 pub seconds: Vec<AudioSecond>,
114 141 pub end: Option<CallEnd>,
@@ -178,6 +205,7 @@ enum PeerEvent {
178 205 Ice(IceConnectionState),
179 206 Connection(PeerConnectionState),
180 207 Track(RtcAudioTrack),
208 VideoTrack { mid: String, track: RtcVideoTrack },
181 209 }
182 210
183 211 struct PeerSession {
@@ -188,6 +216,7 @@ struct PeerSession {
188 216 struct OfferedMedia {
189 217 browser_offer: String,
190 218 signaled: SignaledOffer,
219 video: VideoLines,
191 220 }
192 221
193 222 struct NextPeer {
@@ -218,6 +247,8 @@ struct Live {
218 247 route_id: Option<String>,
219 248 skip_leave: bool,
220 249 cancel_leave: bool,
250 video_tasks: Vec<JoinHandle<()>>,
251 video_counters: Arc<VideoCounters>,
221 252 }
222 253
223 254 fn advance(state: &mut CallState, signal: CallSignal, control: &CallControl) -> bool {
@@ -317,15 +348,19 @@ fn open_peer(factory: &PeerConnectionFactory, grant: &RelayGrant, relay_host: &s
317 348 peer.on_connection_state_change(Some(Box::new(move |state| {
318 349 let _ = connection_sender.send(PeerEvent::Connection(state));
319 350 })));
320 peer.on_track(Some(Box::new(move |event| {
321 if let MediaStreamTrack::Audio(track) = event.track {
351 peer.on_track(Some(Box::new(move |event| match event.track {
352 MediaStreamTrack::Audio(track) => {
322 353 let _ = sender.send(PeerEvent::Track(track));
323 354 }
355 MediaStreamTrack::Video(track) => {
356 let mid = event.transceiver.mid().unwrap_or_default();
357 let _ = sender.send(PeerEvent::VideoTrack { mid, track });
358 }
324 359 })));
325 360 Ok(PeerSession { peer, events })
326 361 }
327 362
328 async fn create_offer(peer: &PeerConnection, track: &RtcAudioTrack) -> Result<OfferedMedia> {
363 async fn create_offer(peer: &PeerConnection, factory: &PeerConnectionFactory, track: &RtcAudioTrack) -> Result<OfferedMedia> {
329 364 let transceiver_init = RtpTransceiverInit {
330 365 direction: RtpTransceiverDirection::SendRecv,
331 366 stream_ids: vec![MIC_STREAM.into()],
@@ -333,9 +368,11 @@ async fn create_offer(peer: &PeerConnection, track: &RtcAudioTrack) -> Result<Of
333 368 };
334 369 peer.add_transceiver(MediaStreamTrack::Audio(track.clone()), transceiver_init)
335 370 .map_err(|error| Error::Webrtc(error.to_string()))?;
371 let video = add_video_lines(peer, factory)?;
336 372 let offer = peer
337 373 .create_offer(OfferOptions {
338 374 offer_to_receive_audio: true,
375 offer_to_receive_video: true,
339 376 ..OfferOptions::default()
340 377 })
341 378 .await
@@ -345,8 +382,8 @@ async fn create_offer(peer: &PeerConnection, track: &RtcAudioTrack) -> Result<Of
345 382 .map_err(|error| Error::Webrtc(error.to_string()))?;
346 383 let browser_offer = offer.to_string();
347 384 let mut numbers = random_u32;
348 let signaled = to_teams_offer(&browser_offer, &OfferPlan::default(), &mut numbers)?;
349 Ok(OfferedMedia { browser_offer, signaled })
385 let signaled = to_teams_offer(&browser_offer, &offer_plan(), &mut numbers)?;
386 Ok(OfferedMedia { browser_offer, signaled, video })
350 387 }
351 388
352 389 /// Video lines of a Teams offer are stopped so the answer rejects them; audio is all this client does.
@@ -456,6 +493,11 @@ async fn drive(
456 493 });
457 494 let track = audio.track.clone();
458 495 live.audio = Some(audio);
496 let mut local_video = LocalVideo::new(&factory, options.video, control.video.clone(), control.updates());
497 let mut camera_choice = options.camera.clone();
498 let mut media_description_request = 1u32;
499 control.send(CallUpdate::Cameras(camera_devices(options.video).await));
500 refresh_share_sources(control.updates(), options.video);
459 501
460 502 let mut current = open_peer(&factory, &grant, &options.relay_host)?;
461 503 live.peers.push(current.peer.clone());
@@ -475,7 +517,7 @@ async fn drive(
475 517
476 518 let conversation = match (spec, incoming_media) {
477 519 (Some(spec), None) => {
478 let media = create_offer(&current.peer, &track).await?;
520 let media = create_offer(&current.peer, &factory, &track).await?;
479 521 timeline.record("setLocalDescription", format!("{} m-line(s) signaled", media.signaled.lines.len()));
480 522 dump_sdp(options, "1-browser-offer.sdp", &media.browser_offer);
481 523 dump_sdp(options, "2-teams-offer.sdp", &media.signaled.sdp);
@@ -500,6 +542,9 @@ async fn drive(
500 542 control.send(CallUpdate::Progress(Progress::Calling));
501 543 outgoing_deadline = Some(Instant::now() + OUTGOING_TIMEOUT);
502 544 }
545 if let Err(error) = local_video.set_lines(media.video.clone()) {
546 timeline.record("video lines not attached", error.to_string());
547 }
503 548 offered = Some(media);
504 549 live.remote = Some(RemoteCall {
505 550 signaling: signaling.clone(),
@@ -581,6 +626,8 @@ async fn drive(
581 626 let mut ticks = 0u32;
582 627 let mut second = 0u32;
583 628 let echo_thread = thread_id;
629 let mut video = VideoReceive::new(own_mri.clone(), VideoRouter::default());
630 let mut media_links: BTreeMap<String, String> = BTreeMap::new();
584 631 loop {
585 632 tokio::select! {
586 633 Some(callback) = callbacks.recv() => {
@@ -599,6 +646,8 @@ async fn drive(
599 646 .await
600 647 .inspect_err(|error| timeline.record("answer rejected", error.to_string()))?;
601 648 remote_set = true;
649 media_links.extend(acceptance.links.clone());
650 negotiate_video(&mut video, &signaling, control, timeline, &acceptance.sdp, media, acceptance.from_mixer, &media_links, &roster);
602 651 outgoing_deadline = None;
603 652 let directions: Vec<String> = current
604 653 .peer
@@ -649,6 +698,10 @@ async fn drive(
649 698 };
650 699 match applied {
651 700 Ok(()) => {
701 if let Some(media) = next.as_ref().and_then(|pending| pending.offered.as_ref()) {
702 media_links.extend(answer.links.clone());
703 negotiate_video(&mut video, &signaling, control, timeline, &answer.sdp, media, true, &media_links, &roster);
704 }
652 705 if let Some(url) = answer.links.get("mediaAcknowledgement") {
653 706 let _ = remote.signaling.post_empty("POST mediaAcknowledgement", url).await;
654 707 }
@@ -694,6 +747,12 @@ async fn drive(
694 747 let entries = roster.entries();
695 748 timeline.record("roster", format!("{} participant(s)", entries.len()));
696 749 control.send(CallUpdate::Roster(entries));
750 let own_streams = roster.stream_summaries(&own_mri);
751 if own_streams != report.own_streams {
752 timeline.record("own media streams", own_streams.join("; "));
753 report.own_streams = own_streams;
754 }
755 send_receive_change(control, video.reselect(&roster));
697 756 if let Some(in_lobby) = roster.is_in_lobby(&own_mri)
698 757 && in_lobby != lobby
699 758 {
@@ -710,7 +769,11 @@ async fn drive(
710 769 }
711 770 Ok(CallEvent::Speakers(sources)) => {
712 771 replier.reply(request_id, 200, "");
713 control.send(CallUpdate::Speakers(roster.mris_for_sources(&sources)));
772 let speakers = roster.mris_for_sources(&sources);
773 if video.note_speakers(&speakers) {
774 send_receive_change(control, video.reselect(&roster));
775 }
776 control.send(CallUpdate::Speakers(speakers));
714 777 }
715 778 Ok(CallEvent::End(end)) => {
716 779 replier.reply(request_id, 200, "");
@@ -765,6 +828,10 @@ async fn drive(
765 828 tokio::spawn(record_track(remote_track, recording.clone(), options.tone_hz));
766 829 }
767 830 }
831 PeerEvent::VideoTrack { mid, track } => {
832 timeline.record("remote video track", format!("mid {mid}"));
833 live.video_tasks.push(spawn_video_pump(track, mid, video.router().clone(), control.video.clone(), live.video_counters.clone()));
834 }
768 835 },
769 836 Some(event) = next_peer_event(&mut next) => match event {
770 837 PeerEvent::Connection(PeerConnectionState::Connected) => {
@@ -773,9 +840,18 @@ async fn drive(
773 840 let old = std::mem::replace(&mut current, pending.session);
774 841 old.peer.close();
775 842 offered = pending.offered;
843 if let Some(media) = &offered
844 && let Err(error) = local_video.set_lines(media.video.clone())
845 {
846 timeline.record("video lines not attached", error.to_string());
847 }
776 848 remote_set = true;
777 849 }
778 850 }
851 PeerEvent::VideoTrack { mid, track } => {
852 timeline.record("remote video track", format!("mid {mid} (new peer)"));
853 live.video_tasks.push(spawn_video_pump(track, mid, video.router().clone(), control.video.clone(), live.video_counters.clone()));
854 }
779 855 PeerEvent::Connection(PeerConnectionState::Failed) => {
780 856 negotiator.escalation_failed();
781 857 if let Some(pending) = next.take() {
@@ -806,6 +882,52 @@ async fn drive(
806 882 Some(CallCommand::RefreshDevices) => {
807 883 control.send(CallUpdate::Devices(devices::list_devices(&factory)));
808 884 }
885 Some(CallCommand::SetCamera(on)) => {
886 if !remote_set {
887 control.send(CallUpdate::Notice(NOT_CONNECTED_FOR_VIDEO.into()));
888 } else if on {
889 match local_video.start_camera(&camera_choice) {
890 Ok(()) => {
891 control.send(CallUpdate::Camera(true));
892 tell_media_descriptions(&remote, &media_links, MediaDescription::camera(true), &mut media_description_request, timeline);
893 }
894 Err(error) => control.send(CallUpdate::Notice(format!("Camera could not start: {error}"))),
895 }
896 } else {
897 local_video.stop_camera();
898 control.send(CallUpdate::Camera(false));
899 tell_media_descriptions(&remote, &media_links, MediaDescription::camera(false), &mut media_description_request, timeline);
900 }
901 }
902 Some(CallCommand::SelectCamera(choice)) => {
903 camera_choice = choice;
904 if local_video.camera_on()
905 && let Err(error) = local_video.start_camera(&camera_choice)
906 {
907 control.send(CallUpdate::Notice(format!("Camera could not start: {error}")));
908 }
909 }
910 Some(CallCommand::StartShare(source)) => {
911 if !remote_set {
912 control.send(CallUpdate::Notice(NOT_CONNECTED_FOR_VIDEO.into()));
913 } else {
914 match local_video.start_share(&source) {
915 Ok(()) => {
916 control.send(CallUpdate::LocalShare(Some(source.label())));
917 tell_media_descriptions(&remote, &media_links, MediaDescription::share(true), &mut media_description_request, timeline);
918 }
919 Err(error) => control.send(CallUpdate::Notice(format!("Sharing could not start: {error}"))),
920 }
921 }
922 }
923 Some(CallCommand::StopShare) => {
924 if local_video.sharing() {
925 local_video.stop_share();
926 control.send(CallUpdate::LocalShare(None));
927 tell_media_descriptions(&remote, &media_links, MediaDescription::share(false), &mut media_description_request, timeline);
928 }
929 }
930 Some(CallCommand::RefreshShareSources) => refresh_share_sources(control.updates(), options.video),
809 931 Some(CallCommand::EndMeeting) => {
810 932 if is_meeting {
811 933 match remote.signaling.end_for_all(&remote.conversation, &remote.participant).await {
@@ -838,6 +960,11 @@ async fn drive(
838 960 report.inbound_packets = snapshot.inbound_packets;
839 961 report.inbound_bytes = snapshot.inbound_bytes;
840 962 report.outbound_packets = snapshot.outbound_packets;
963 report.video = VideoReport {
964 frames_received: live.video_counters.received.load(Ordering::Relaxed),
965 frames_published: live.video_counters.published.load(Ordering::Relaxed),
966 ..snapshot.video.clone()
967 };
841 968 if ticks.is_multiple_of(TICKS_PER_SECOND) {
842 969 second += 1;
843 970 let (decoded_rms, ratio) = {
@@ -863,8 +990,11 @@ async fn drive(
863 990 timeline.record(
864 991 "stats",
865 992 format!(
866 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={}",
867 snapshot.inbound_packets, snapshot.inbound_bytes, snapshot.audio_level, snapshot.outbound_packets, snapshot.local_level, snapshot.echo_return_loss_enhancement, snapshot.dtls_state
993 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={} video in packets={} decoded={} {}x{} out packets={} encoded={} {}x{} mixer reports {} (rtt {:.0} ms)",
994 snapshot.inbound_packets, snapshot.inbound_bytes, snapshot.audio_level, snapshot.outbound_packets, snapshot.local_level, snapshot.echo_return_loss_enhancement, snapshot.dtls_state,
995 snapshot.video.inbound_packets, snapshot.video.inbound_frames_decoded, snapshot.video.inbound_width, snapshot.video.inbound_height,
996 snapshot.video.outbound_packets, snapshot.video.outbound_frames_encoded, snapshot.video.outbound_width, snapshot.video.outbound_height,
997 snapshot.video.remote_reports, snapshot.video.remote_round_trip_ms
868 998 ),
869 999 );
870 1000 }
@@ -916,7 +1046,7 @@ async fn start_escalation(
916 1046 .get("mediaRenegotiation")
917 1047 .ok_or_else(|| Error::Signaling("acceptance without a mediaRenegotiation link".into()))?;
918 1048 let session = open_peer(factory, grant, &options.relay_host)?;
919 let media = create_offer(&session.peer, track).await?;
1049 let media = create_offer(&session.peer, factory, track).await?;
920 1050 let body = renegotiation_body(&remote.participant, links, &media.signaled.sdp, media_leg_id);
921 1051 remote.signaling.post_json("POST mediaRenegotiation", url, body).await?;
922 1052 Ok(NextPeer {
@@ -951,6 +1081,96 @@ async fn send_media_answer(
951 1081 remote.signaling.post_json("POST mediaAnswer", url, body).await
952 1082 }
953 1083
1084 #[allow(clippy::too_many_arguments)]
1085 fn negotiate_video(
1086 video: &mut VideoReceive,
1087 signaling: &Arc<Signaling>,
1088 control: &CallControl,
1089 timeline: &Timeline,
1090 answer_sdp: &str,
1091 media: &OfferedMedia,
1092 from_mixer: bool,
1093 links: &BTreeMap<String, String>,
1094 roster: &Roster,
1095 ) {
1096 let streams = match stream_lines(answer_sdp, &media.signaled.lines) {
1097 Ok(streams) => streams,
1098 Err(error) => {
1099 timeline.record("video slots unknown", error.to_string());
1100 return;
1101 }
1102 };
1103 let table = SlotTable::from_streams(&streams);
1104 let link = links.get("applyChannelParameters").or_else(|| links.get("controlVideoStreaming"));
1105 timeline.record(
1106 "video slots",
1107 format!(
1108 "{} receive slot(s), screen {}, fromMixer={from_mixer}, request link {}",
1109 table.people.len(),
1110 table.screen.is_some(),
1111 link.is_some()
1112 ),
1113 );
1114 let requester = link
1115 .filter(|_| from_mixer)
1116 .map(|url| SourceRequester::start(signaling.clone(), url.clone(), video.router().clone(), control.video.clone(), timeline.clone()));
1117 video.negotiated(table, requester);
1118 send_receive_change(control, video.reselect(roster));
1119 }
1120
1121 const NOT_CONNECTED_FOR_VIDEO: &str = "Video starts once the call is connected";
1122
1123 async fn camera_devices(mode: VideoMode) -> Vec<CameraDevice> {
1124 match mode {
1125 VideoMode::Pattern => vec![CameraDevice { key: "pattern".into(), name: "Test pattern".into() }],
1126 VideoMode::Off => Vec::new(),
1127 VideoMode::Platform => tokio::task::spawn_blocking(list_cameras).await.unwrap_or_default(),
1128 }
1129 }
1130
1131 fn refresh_share_sources(updates: mpsc::UnboundedSender<CallUpdate>, mode: VideoMode) {
1132 tokio::spawn(async move {
1133 let sources = match mode {
1134 VideoMode::Pattern => vec![
1135 ShareSource { id: 1, kind: ShareKind::Screen, title: "Test screen".into() },
1136 ShareSource { id: 2, kind: ShareKind::Window, title: "Test window".into() },
1137 ],
1138 VideoMode::Off => Vec::new(),
1139 VideoMode::Platform => tokio::task::spawn_blocking(list_share_sources).await.unwrap_or_default(),
1140 };
1141 let _ = updates.send(CallUpdate::ShareSources(sources));
1142 });
1143 }
1144
1145 fn tell_media_descriptions(
1146 remote: &RemoteCall,
1147 links: &BTreeMap<String, String>,
1148 description: MediaDescription,
1149 request_id: &mut u32,
1150 timeline: &Timeline,
1151 ) {
1152 let Some(url) = links.get("updateMediaDescriptions").cloned() else {
1153 timeline.record("updateMediaDescriptions skipped", "no link from the mixer");
1154 return;
1155 };
1156 *request_id += 1;
1157 let request_id = *request_id;
1158 let signaling = remote.signaling.clone();
1159 let timeline = timeline.clone();
1160 tokio::spawn(async move {
1161 let sent = format!("{} {} request {request_id}", description.mid, description.direction);
1162 if let Err(error) = signaling.update_media_descriptions(&url, &[description], request_id).await {
1163 timeline.record("updateMediaDescriptions failed", format!("{sent}: {error}"));
1164 }
1165 });
1166 }
1167
1168 fn send_receive_change(control: &CallControl, change: ReceiveChange) {
1169 if let Some(sharer) = change.screen_sharer {
1170 control.send(CallUpdate::ScreenShare(sharer));
1171 }
1172 }
1173
954 1174 fn far_future() -> Instant {
955 1175 Instant::now() + FAR_FUTURE
956 1176 }
@@ -1010,6 +1230,9 @@ async fn tear_down(mut live: Live, inner: &Inner, timeline: &Timeline, report: &
1010 1230 if let Some(broker) = live.broker.take() {
1011 1231 broker.abort();
1012 1232 }
1233 for task in live.video_tasks.drain(..) {
1234 task.abort();
1235 }
1013 1236 if let Some(route_id) = &live.route_id {
1014 1237 inner.unregister_route(route_id);
1015 1238 }
@@ -1105,6 +1328,7 @@ struct StatsSnapshot {
1105 1328 audio_level: f64,
1106 1329 local_level: f64,
1107 1330 echo_return_loss_enhancement: f64,
1331 video: VideoReport,
1108 1332 dtls_state: String,
1109 1333 tls_version: String,
1110 1334 dtls_cipher: String,
@@ -1132,6 +1356,22 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
1132 1356 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "audio" => {
1133 1357 snapshot.outbound_packets += outbound.sent.packets_sent;
1134 1358 }
1359 RtcStats::InboundRtp(inbound) if inbound.stream.kind == "video" => {
1360 snapshot.video.inbound_packets += inbound.received.packets_received;
1361 snapshot.video.inbound_frames_decoded += u64::from(inbound.inbound.frames_decoded);
1362 snapshot.video.inbound_width = snapshot.video.inbound_width.max(inbound.inbound.frame_width);
1363 snapshot.video.inbound_height = snapshot.video.inbound_height.max(inbound.inbound.frame_height);
1364 }
1365 RtcStats::RemoteInboundRtp(remote) if remote.stream.kind == "video" => {
1366 snapshot.video.remote_reports += remote.remote_inbound.round_trip_time_measurements;
1367 snapshot.video.remote_round_trip_ms = snapshot.video.remote_round_trip_ms.max(remote.remote_inbound.round_trip_time * 1000.0);
1368 }
1369 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "video" => {
1370 snapshot.video.outbound_packets += outbound.sent.packets_sent;
1371 snapshot.video.outbound_frames_encoded += u64::from(outbound.outbound.frames_encoded);
1372 snapshot.video.outbound_width = snapshot.video.outbound_width.max(outbound.outbound.frame_width);
1373 snapshot.video.outbound_height = snapshot.video.outbound_height.max(outbound.outbound.frame_height);
1374 }
1135 1375 RtcStats::Transport(transport) => {
1136 1376 snapshot.dtls_state = format!("{:?}", transport.transport.dtls_state);
1137 1377 snapshot.tls_version = transport.transport.tls_version.clone();
@@ -28,13 +28,18 @@ use crate::push::CallNotification;
28use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};
28use crate::relay::{DEFAULT_RELAY_HOST, RelayGrant, fetch_relay_grant};
29use crate::renegotiation::{MediaAction, MediaNegotiator};
29use crate::renegotiation::{MediaAction, MediaNegotiator};
30use crate::roster::Roster;
30use crate::roster::Roster;
31use crate::sdp::{OfferPlan, RemoteOffer, SignaledOffer, from_teams_offer, to_browser_answer, to_teams_answer, to_teams_offer};
31use crate::sdp::{RemoteOffer, SignaledOffer, from_teams_offer, stream_lines, to_browser_answer, to_teams_answer, to_teams_offer};
32use crate::signaling::{
32use crate::signaling::{
33 Answer, Attached, Callee, Conversation, Invitation, InviteTarget, LeaveReason, MeetingTarget, Participant, Signaling,
33 Answer, Attached, Callee, Conversation, Invitation, InviteTarget, LeaveReason, MeetingTarget, Participant, Signaling,
34 TenantRouting, find_echo_bot_thread, escalation_answer_body, renegotiation_body,
34 TenantRouting, find_echo_bot_thread, escalation_answer_body, renegotiation_body,
35};
35};
36use crate::state::{CallSignal, CallState};
36use crate::state::{CallSignal, CallState};
37use crate::timeline::{Timeline, TimelineEntry};
37use crate::timeline::{Timeline, TimelineEntry};
38use crate::video_layout::{MediaDescription, SlotTable, VideoLines, VideoRouter, add_video_lines, offer_plan};
39use crate::video_send::{LocalVideo, VideoMode};
40use crate::camera::{CameraDevice, list_cameras};
41use crate::screen::{ShareKind, ShareSource, list_share_sources};
42use crate::video_receive::{ReceiveChange, SourceRequester, VideoCounters, VideoReceive, spawn_video_pump};
38use crate::trouter_events::{
43use crate::trouter_events::{
39 CallEnd, CallEvent, CallbackLinks, ProgressStatus, acceptance_acknowledgement, classify, decode_body,
44 CallEnd, CallEvent, CallbackLinks, ProgressStatus, acceptance_acknowledgement, classify, decode_body,
40};
45};
@@ -56,6 +61,8 @@ pub struct CallOptions {
56 pub hard_limit: Option<Duration>,
61 pub hard_limit: Option<Duration>,
57 pub reconnect_window: Duration,
62 pub reconnect_window: Duration,
58 pub audio: AudioMode,
63 pub audio: AudioMode,
64 pub video: VideoMode,
65 pub camera: DeviceChoice,
59 pub tone_hz: f32,
66 pub tone_hz: f32,
60 pub input: DeviceChoice,
67 pub input: DeviceChoice,
61 pub output: DeviceChoice,
68 pub output: DeviceChoice,
@@ -74,6 +81,8 @@ impl Default for CallOptions {
74 hard_limit: None,
81 hard_limit: None,
75 reconnect_window: RECONNECT_WINDOW,
82 reconnect_window: RECONNECT_WINDOW,
76 audio: AudioMode::from_env(),
83 audio: AudioMode::from_env(),
84 video: VideoMode::from_env(),
85 camera: DeviceChoice::SystemDefault,
77 tone_hz: 440.0,
86 tone_hz: 440.0,
78 input: DeviceChoice::SystemDefault,
87 input: DeviceChoice::SystemDefault,
79 output: DeviceChoice::SystemDefault,
88 output: DeviceChoice::SystemDefault,
@@ -97,6 +106,22 @@ pub struct AudioSecond {
97 pub tone_ratio: f32,
106 pub tone_ratio: f32,
98}
107}
99
108
109#[derive(Debug, Clone, Default, PartialEq)]
110pub struct VideoReport {
111 pub inbound_packets: u64,
112 pub inbound_frames_decoded: u64,
113 pub inbound_width: u32,
114 pub inbound_height: u32,
115 pub frames_received: u64,
116 pub frames_published: u64,
117 pub outbound_packets: u64,
118 pub outbound_frames_encoded: u64,
119 pub outbound_width: u32,
120 pub outbound_height: u32,
121 pub remote_reports: u64,
122 pub remote_round_trip_ms: f64,
123}
124
100#[derive(Debug, Clone, Default)]
125#[derive(Debug, Clone, Default)]
101pub struct CallReport {
126pub struct CallReport {
102 pub timeline: Vec<TimelineEntry>,
127 pub timeline: Vec<TimelineEntry>,
@@ -109,6 +134,8 @@ pub struct CallReport {
109 pub inbound_packets: u64,
134 pub inbound_packets: u64,
110 pub inbound_bytes: u64,
135 pub inbound_bytes: u64,
111 pub outbound_packets: u64,
136 pub outbound_packets: u64,
137 pub video: VideoReport,
138 pub own_streams: Vec<String>,
112 pub seconds_with_inbound_audio: u32,
139 pub seconds_with_inbound_audio: u32,
113 pub seconds: Vec<AudioSecond>,
140 pub seconds: Vec<AudioSecond>,
114 pub end: Option<CallEnd>,
141 pub end: Option<CallEnd>,
@@ -178,6 +205,7 @@ enum PeerEvent {
178 Ice(IceConnectionState),
205 Ice(IceConnectionState),
179 Connection(PeerConnectionState),
206 Connection(PeerConnectionState),
180 Track(RtcAudioTrack),
207 Track(RtcAudioTrack),
208 VideoTrack { mid: String, track: RtcVideoTrack },
181}
209}
182
210
183struct PeerSession {
211struct PeerSession {
@@ -188,6 +216,7 @@ struct PeerSession {
188struct OfferedMedia {
216struct OfferedMedia {
189 browser_offer: String,
217 browser_offer: String,
190 signaled: SignaledOffer,
218 signaled: SignaledOffer,
219 video: VideoLines,
191}
220}
192
221
193struct NextPeer {
222struct NextPeer {
@@ -218,6 +247,8 @@ struct Live {
218 route_id: Option<String>,
247 route_id: Option<String>,
219 skip_leave: bool,
248 skip_leave: bool,
220 cancel_leave: bool,
249 cancel_leave: bool,
250 video_tasks: Vec<JoinHandle<()>>,
251 video_counters: Arc<VideoCounters>,
221}
252}
222
253
223fn advance(state: &mut CallState, signal: CallSignal, control: &CallControl) -> bool {
254fn advance(state: &mut CallState, signal: CallSignal, control: &CallControl) -> bool {
@@ -317,15 +348,19 @@ fn open_peer(factory: &PeerConnectionFactory, grant: &RelayGrant, relay_host: &s
317 peer.on_connection_state_change(Some(Box::new(move |state| {
348 peer.on_connection_state_change(Some(Box::new(move |state| {
318 let _ = connection_sender.send(PeerEvent::Connection(state));
349 let _ = connection_sender.send(PeerEvent::Connection(state));
319 })));
350 })));
320 peer.on_track(Some(Box::new(move |event| {
351 peer.on_track(Some(Box::new(move |event| match event.track {
321 if let MediaStreamTrack::Audio(track) = event.track {
352 MediaStreamTrack::Audio(track) => {
322 let _ = sender.send(PeerEvent::Track(track));
353 let _ = sender.send(PeerEvent::Track(track));
323 }
354 }
355 MediaStreamTrack::Video(track) => {
356 let mid = event.transceiver.mid().unwrap_or_default();
357 let _ = sender.send(PeerEvent::VideoTrack { mid, track });
358 }
324 })));
359 })));
325 Ok(PeerSession { peer, events })
360 Ok(PeerSession { peer, events })
326}
361}
327
362
328async fn create_offer(peer: &PeerConnection, track: &RtcAudioTrack) -> Result<OfferedMedia> {
363async fn create_offer(peer: &PeerConnection, factory: &PeerConnectionFactory, track: &RtcAudioTrack) -> Result<OfferedMedia> {
329 let transceiver_init = RtpTransceiverInit {
364 let transceiver_init = RtpTransceiverInit {
330 direction: RtpTransceiverDirection::SendRecv,
365 direction: RtpTransceiverDirection::SendRecv,
331 stream_ids: vec![MIC_STREAM.into()],
366 stream_ids: vec![MIC_STREAM.into()],
@@ -333,9 +368,11 @@ async fn create_offer(peer: &PeerConnection, track: &RtcAudioTrack) -> Result<Of
333 };
368 };
334 peer.add_transceiver(MediaStreamTrack::Audio(track.clone()), transceiver_init)
369 peer.add_transceiver(MediaStreamTrack::Audio(track.clone()), transceiver_init)
335 .map_err(|error| Error::Webrtc(error.to_string()))?;
370 .map_err(|error| Error::Webrtc(error.to_string()))?;
371 let video = add_video_lines(peer, factory)?;
336 let offer = peer
372 let offer = peer
337 .create_offer(OfferOptions {
373 .create_offer(OfferOptions {
338 offer_to_receive_audio: true,
374 offer_to_receive_audio: true,
375 offer_to_receive_video: true,
339 ..OfferOptions::default()
376 ..OfferOptions::default()
340 })
377 })
341 .await
378 .await
@@ -345,8 +382,8 @@ async fn create_offer(peer: &PeerConnection, track: &RtcAudioTrack) -> Result<Of
345 .map_err(|error| Error::Webrtc(error.to_string()))?;
382 .map_err(|error| Error::Webrtc(error.to_string()))?;
346 let browser_offer = offer.to_string();
383 let browser_offer = offer.to_string();
347 let mut numbers = random_u32;
384 let mut numbers = random_u32;
348 let signaled = to_teams_offer(&browser_offer, &OfferPlan::default(), &mut numbers)?;
385 let signaled = to_teams_offer(&browser_offer, &offer_plan(), &mut numbers)?;
349 Ok(OfferedMedia { browser_offer, signaled })
386 Ok(OfferedMedia { browser_offer, signaled, video })
350}
387}
351
388
352/// Video lines of a Teams offer are stopped so the answer rejects them; audio is all this client does.
389/// Video lines of a Teams offer are stopped so the answer rejects them; audio is all this client does.
@@ -456,6 +493,11 @@ async fn drive(
456 });
493 });
457 let track = audio.track.clone();
494 let track = audio.track.clone();
458 live.audio = Some(audio);
495 live.audio = Some(audio);
496 let mut local_video = LocalVideo::new(&factory, options.video, control.video.clone(), control.updates());
497 let mut camera_choice = options.camera.clone();
498 let mut media_description_request = 1u32;
499 control.send(CallUpdate::Cameras(camera_devices(options.video).await));
500 refresh_share_sources(control.updates(), options.video);
459
501
460 let mut current = open_peer(&factory, &grant, &options.relay_host)?;
502 let mut current = open_peer(&factory, &grant, &options.relay_host)?;
461 live.peers.push(current.peer.clone());
503 live.peers.push(current.peer.clone());
@@ -475,7 +517,7 @@ async fn drive(
475
517
476 let conversation = match (spec, incoming_media) {
518 let conversation = match (spec, incoming_media) {
477 (Some(spec), None) => {
519 (Some(spec), None) => {
478 let media = create_offer(&current.peer, &track).await?;
520 let media = create_offer(&current.peer, &factory, &track).await?;
479 timeline.record("setLocalDescription", format!("{} m-line(s) signaled", media.signaled.lines.len()));
521 timeline.record("setLocalDescription", format!("{} m-line(s) signaled", media.signaled.lines.len()));
480 dump_sdp(options, "1-browser-offer.sdp", &media.browser_offer);
522 dump_sdp(options, "1-browser-offer.sdp", &media.browser_offer);
481 dump_sdp(options, "2-teams-offer.sdp", &media.signaled.sdp);
523 dump_sdp(options, "2-teams-offer.sdp", &media.signaled.sdp);
@@ -500,6 +542,9 @@ async fn drive(
500 control.send(CallUpdate::Progress(Progress::Calling));
542 control.send(CallUpdate::Progress(Progress::Calling));
501 outgoing_deadline = Some(Instant::now() + OUTGOING_TIMEOUT);
543 outgoing_deadline = Some(Instant::now() + OUTGOING_TIMEOUT);
502 }
544 }
545 if let Err(error) = local_video.set_lines(media.video.clone()) {
546 timeline.record("video lines not attached", error.to_string());
547 }
503 offered = Some(media);
548 offered = Some(media);
504 live.remote = Some(RemoteCall {
549 live.remote = Some(RemoteCall {
505 signaling: signaling.clone(),
550 signaling: signaling.clone(),
@@ -581,6 +626,8 @@ async fn drive(
581 let mut ticks = 0u32;
626 let mut ticks = 0u32;
582 let mut second = 0u32;
627 let mut second = 0u32;
583 let echo_thread = thread_id;
628 let echo_thread = thread_id;
629 let mut video = VideoReceive::new(own_mri.clone(), VideoRouter::default());
630 let mut media_links: BTreeMap<String, String> = BTreeMap::new();
584 loop {
631 loop {
585 tokio::select! {
632 tokio::select! {
586 Some(callback) = callbacks.recv() => {
633 Some(callback) = callbacks.recv() => {
@@ -599,6 +646,8 @@ async fn drive(
599 .await
646 .await
600 .inspect_err(|error| timeline.record("answer rejected", error.to_string()))?;
647 .inspect_err(|error| timeline.record("answer rejected", error.to_string()))?;
601 remote_set = true;
648 remote_set = true;
649 media_links.extend(acceptance.links.clone());
650 negotiate_video(&mut video, &signaling, control, timeline, &acceptance.sdp, media, acceptance.from_mixer, &media_links, &roster);
602 outgoing_deadline = None;
651 outgoing_deadline = None;
603 let directions: Vec<String> = current
652 let directions: Vec<String> = current
604 .peer
653 .peer
@@ -649,6 +698,10 @@ async fn drive(
649 };
698 };
650 match applied {
699 match applied {
651 Ok(()) => {
700 Ok(()) => {
701 if let Some(media) = next.as_ref().and_then(|pending| pending.offered.as_ref()) {
702 media_links.extend(answer.links.clone());
703 negotiate_video(&mut video, &signaling, control, timeline, &answer.sdp, media, true, &media_links, &roster);
704 }
652 if let Some(url) = answer.links.get("mediaAcknowledgement") {
705 if let Some(url) = answer.links.get("mediaAcknowledgement") {
653 let _ = remote.signaling.post_empty("POST mediaAcknowledgement", url).await;
706 let _ = remote.signaling.post_empty("POST mediaAcknowledgement", url).await;
654 }
707 }
@@ -694,6 +747,12 @@ async fn drive(
694 let entries = roster.entries();
747 let entries = roster.entries();
695 timeline.record("roster", format!("{} participant(s)", entries.len()));
748 timeline.record("roster", format!("{} participant(s)", entries.len()));
696 control.send(CallUpdate::Roster(entries));
749 control.send(CallUpdate::Roster(entries));
750 let own_streams = roster.stream_summaries(&own_mri);
751 if own_streams != report.own_streams {
752 timeline.record("own media streams", own_streams.join("; "));
753 report.own_streams = own_streams;
754 }
755 send_receive_change(control, video.reselect(&roster));
697 if let Some(in_lobby) = roster.is_in_lobby(&own_mri)
756 if let Some(in_lobby) = roster.is_in_lobby(&own_mri)
698 && in_lobby != lobby
757 && in_lobby != lobby
699 {
758 {
@@ -710,7 +769,11 @@ async fn drive(
710 }
769 }
711 Ok(CallEvent::Speakers(sources)) => {
770 Ok(CallEvent::Speakers(sources)) => {
712 replier.reply(request_id, 200, "");
771 replier.reply(request_id, 200, "");
713 control.send(CallUpdate::Speakers(roster.mris_for_sources(&sources)));
772 let speakers = roster.mris_for_sources(&sources);
773 if video.note_speakers(&speakers) {
774 send_receive_change(control, video.reselect(&roster));
775 }
776 control.send(CallUpdate::Speakers(speakers));
714 }
777 }
715 Ok(CallEvent::End(end)) => {
778 Ok(CallEvent::End(end)) => {
716 replier.reply(request_id, 200, "");
779 replier.reply(request_id, 200, "");
@@ -765,6 +828,10 @@ async fn drive(
765 tokio::spawn(record_track(remote_track, recording.clone(), options.tone_hz));
828 tokio::spawn(record_track(remote_track, recording.clone(), options.tone_hz));
766 }
829 }
767 }
830 }
831 PeerEvent::VideoTrack { mid, track } => {
832 timeline.record("remote video track", format!("mid {mid}"));
833 live.video_tasks.push(spawn_video_pump(track, mid, video.router().clone(), control.video.clone(), live.video_counters.clone()));
834 }
768 },
835 },
769 Some(event) = next_peer_event(&mut next) => match event {
836 Some(event) = next_peer_event(&mut next) => match event {
770 PeerEvent::Connection(PeerConnectionState::Connected) => {
837 PeerEvent::Connection(PeerConnectionState::Connected) => {
@@ -773,9 +840,18 @@ async fn drive(
773 let old = std::mem::replace(&mut current, pending.session);
840 let old = std::mem::replace(&mut current, pending.session);
774 old.peer.close();
841 old.peer.close();
775 offered = pending.offered;
842 offered = pending.offered;
843 if let Some(media) = &offered
844 && let Err(error) = local_video.set_lines(media.video.clone())
845 {
846 timeline.record("video lines not attached", error.to_string());
847 }
776 remote_set = true;
848 remote_set = true;
777 }
849 }
778 }
850 }
851 PeerEvent::VideoTrack { mid, track } => {
852 timeline.record("remote video track", format!("mid {mid} (new peer)"));
853 live.video_tasks.push(spawn_video_pump(track, mid, video.router().clone(), control.video.clone(), live.video_counters.clone()));
854 }
779 PeerEvent::Connection(PeerConnectionState::Failed) => {
855 PeerEvent::Connection(PeerConnectionState::Failed) => {
780 negotiator.escalation_failed();
856 negotiator.escalation_failed();
781 if let Some(pending) = next.take() {
857 if let Some(pending) = next.take() {
@@ -806,6 +882,52 @@ async fn drive(
806 Some(CallCommand::RefreshDevices) => {
882 Some(CallCommand::RefreshDevices) => {
807 control.send(CallUpdate::Devices(devices::list_devices(&factory)));
883 control.send(CallUpdate::Devices(devices::list_devices(&factory)));
808 }
884 }
885 Some(CallCommand::SetCamera(on)) => {
886 if !remote_set {
887 control.send(CallUpdate::Notice(NOT_CONNECTED_FOR_VIDEO.into()));
888 } else if on {
889 match local_video.start_camera(&camera_choice) {
890 Ok(()) => {
891 control.send(CallUpdate::Camera(true));
892 tell_media_descriptions(&remote, &media_links, MediaDescription::camera(true), &mut media_description_request, timeline);
893 }
894 Err(error) => control.send(CallUpdate::Notice(format!("Camera could not start: {error}"))),
895 }
896 } else {
897 local_video.stop_camera();
898 control.send(CallUpdate::Camera(false));
899 tell_media_descriptions(&remote, &media_links, MediaDescription::camera(false), &mut media_description_request, timeline);
900 }
901 }
902 Some(CallCommand::SelectCamera(choice)) => {
903 camera_choice = choice;
904 if local_video.camera_on()
905 && let Err(error) = local_video.start_camera(&camera_choice)
906 {
907 control.send(CallUpdate::Notice(format!("Camera could not start: {error}")));
908 }
909 }
910 Some(CallCommand::StartShare(source)) => {
911 if !remote_set {
912 control.send(CallUpdate::Notice(NOT_CONNECTED_FOR_VIDEO.into()));
913 } else {
914 match local_video.start_share(&source) {
915 Ok(()) => {
916 control.send(CallUpdate::LocalShare(Some(source.label())));
917 tell_media_descriptions(&remote, &media_links, MediaDescription::share(true), &mut media_description_request, timeline);
918 }
919 Err(error) => control.send(CallUpdate::Notice(format!("Sharing could not start: {error}"))),
920 }
921 }
922 }
923 Some(CallCommand::StopShare) => {
924 if local_video.sharing() {
925 local_video.stop_share();
926 control.send(CallUpdate::LocalShare(None));
927 tell_media_descriptions(&remote, &media_links, MediaDescription::share(false), &mut media_description_request, timeline);
928 }
929 }
930 Some(CallCommand::RefreshShareSources) => refresh_share_sources(control.updates(), options.video),
809 Some(CallCommand::EndMeeting) => {
931 Some(CallCommand::EndMeeting) => {
810 if is_meeting {
932 if is_meeting {
811 match remote.signaling.end_for_all(&remote.conversation, &remote.participant).await {
933 match remote.signaling.end_for_all(&remote.conversation, &remote.participant).await {
@@ -838,6 +960,11 @@ async fn drive(
838 report.inbound_packets = snapshot.inbound_packets;
960 report.inbound_packets = snapshot.inbound_packets;
839 report.inbound_bytes = snapshot.inbound_bytes;
961 report.inbound_bytes = snapshot.inbound_bytes;
840 report.outbound_packets = snapshot.outbound_packets;
962 report.outbound_packets = snapshot.outbound_packets;
963 report.video = VideoReport {
964 frames_received: live.video_counters.received.load(Ordering::Relaxed),
965 frames_published: live.video_counters.published.load(Ordering::Relaxed),
966 ..snapshot.video.clone()
967 };
841 if ticks.is_multiple_of(TICKS_PER_SECOND) {
968 if ticks.is_multiple_of(TICKS_PER_SECOND) {
842 second += 1;
969 second += 1;
843 let (decoded_rms, ratio) = {
970 let (decoded_rms, ratio) = {
@@ -863,8 +990,11 @@ async fn drive(
863 timeline.record(
990 timeline.record(
864 "stats",
991 "stats",
865 format!(
992 format!(
866 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={}",
993 "in packets={} bytes={} level={:.3} rms={decoded_rms:.3} tone={ratio:.2} out packets={} mic={:.3} erle={:.1} dtls={} video in packets={} decoded={} {}x{} out packets={} encoded={} {}x{} mixer reports {} (rtt {:.0} ms)",
867 snapshot.inbound_packets, snapshot.inbound_bytes, snapshot.audio_level, snapshot.outbound_packets, snapshot.local_level, snapshot.echo_return_loss_enhancement, snapshot.dtls_state
994 snapshot.inbound_packets, snapshot.inbound_bytes, snapshot.audio_level, snapshot.outbound_packets, snapshot.local_level, snapshot.echo_return_loss_enhancement, snapshot.dtls_state,
995 snapshot.video.inbound_packets, snapshot.video.inbound_frames_decoded, snapshot.video.inbound_width, snapshot.video.inbound_height,
996 snapshot.video.outbound_packets, snapshot.video.outbound_frames_encoded, snapshot.video.outbound_width, snapshot.video.outbound_height,
997 snapshot.video.remote_reports, snapshot.video.remote_round_trip_ms
868 ),
998 ),
869 );
999 );
870 }
1000 }
@@ -916,7 +1046,7 @@ async fn start_escalation(
916 .get("mediaRenegotiation")
1046 .get("mediaRenegotiation")
917 .ok_or_else(|| Error::Signaling("acceptance without a mediaRenegotiation link".into()))?;
1047 .ok_or_else(|| Error::Signaling("acceptance without a mediaRenegotiation link".into()))?;
918 let session = open_peer(factory, grant, &options.relay_host)?;
1048 let session = open_peer(factory, grant, &options.relay_host)?;
919 let media = create_offer(&session.peer, track).await?;
1049 let media = create_offer(&session.peer, factory, track).await?;
920 let body = renegotiation_body(&remote.participant, links, &media.signaled.sdp, media_leg_id);
1050 let body = renegotiation_body(&remote.participant, links, &media.signaled.sdp, media_leg_id);
921 remote.signaling.post_json("POST mediaRenegotiation", url, body).await?;
1051 remote.signaling.post_json("POST mediaRenegotiation", url, body).await?;
922 Ok(NextPeer {
1052 Ok(NextPeer {
@@ -951,6 +1081,96 @@ async fn send_media_answer(
951 remote.signaling.post_json("POST mediaAnswer", url, body).await
1081 remote.signaling.post_json("POST mediaAnswer", url, body).await
952}
1082}
953
1083
1084#[allow(clippy::too_many_arguments)]
1085fn negotiate_video(
1086 video: &mut VideoReceive,
1087 signaling: &Arc<Signaling>,
1088 control: &CallControl,
1089 timeline: &Timeline,
1090 answer_sdp: &str,
1091 media: &OfferedMedia,
1092 from_mixer: bool,
1093 links: &BTreeMap<String, String>,
1094 roster: &Roster,
1095) {
1096 let streams = match stream_lines(answer_sdp, &media.signaled.lines) {
1097 Ok(streams) => streams,
1098 Err(error) => {
1099 timeline.record("video slots unknown", error.to_string());
1100 return;
1101 }
1102 };
1103 let table = SlotTable::from_streams(&streams);
1104 let link = links.get("applyChannelParameters").or_else(|| links.get("controlVideoStreaming"));
1105 timeline.record(
1106 "video slots",
1107 format!(
1108 "{} receive slot(s), screen {}, fromMixer={from_mixer}, request link {}",
1109 table.people.len(),
1110 table.screen.is_some(),
1111 link.is_some()
1112 ),
1113 );
1114 let requester = link
1115 .filter(|_| from_mixer)
1116 .map(|url| SourceRequester::start(signaling.clone(), url.clone(), video.router().clone(), control.video.clone(), timeline.clone()));
1117 video.negotiated(table, requester);
1118 send_receive_change(control, video.reselect(roster));
1119}
1120
1121const NOT_CONNECTED_FOR_VIDEO: &str = "Video starts once the call is connected";
1122
1123async fn camera_devices(mode: VideoMode) -> Vec<CameraDevice> {
1124 match mode {
1125 VideoMode::Pattern => vec![CameraDevice { key: "pattern".into(), name: "Test pattern".into() }],
1126 VideoMode::Off => Vec::new(),
1127 VideoMode::Platform => tokio::task::spawn_blocking(list_cameras).await.unwrap_or_default(),
1128 }
1129}
1130
1131fn refresh_share_sources(updates: mpsc::UnboundedSender<CallUpdate>, mode: VideoMode) {
1132 tokio::spawn(async move {
1133 let sources = match mode {
1134 VideoMode::Pattern => vec![
1135 ShareSource { id: 1, kind: ShareKind::Screen, title: "Test screen".into() },
1136 ShareSource { id: 2, kind: ShareKind::Window, title: "Test window".into() },
1137 ],
1138 VideoMode::Off => Vec::new(),
1139 VideoMode::Platform => tokio::task::spawn_blocking(list_share_sources).await.unwrap_or_default(),
1140 };
1141 let _ = updates.send(CallUpdate::ShareSources(sources));
1142 });
1143}
1144
1145fn tell_media_descriptions(
1146 remote: &RemoteCall,
1147 links: &BTreeMap<String, String>,
1148 description: MediaDescription,
1149 request_id: &mut u32,
1150 timeline: &Timeline,
1151) {
1152 let Some(url) = links.get("updateMediaDescriptions").cloned() else {
1153 timeline.record("updateMediaDescriptions skipped", "no link from the mixer");
1154 return;
1155 };
1156 *request_id += 1;
1157 let request_id = *request_id;
1158 let signaling = remote.signaling.clone();
1159 let timeline = timeline.clone();
1160 tokio::spawn(async move {
1161 let sent = format!("{} {} request {request_id}", description.mid, description.direction);
1162 if let Err(error) = signaling.update_media_descriptions(&url, &[description], request_id).await {
1163 timeline.record("updateMediaDescriptions failed", format!("{sent}: {error}"));
1164 }
1165 });
1166}
1167
1168fn send_receive_change(control: &CallControl, change: ReceiveChange) {
1169 if let Some(sharer) = change.screen_sharer {
1170 control.send(CallUpdate::ScreenShare(sharer));
1171 }
1172}
1173
954fn far_future() -> Instant {
1174fn far_future() -> Instant {
955 Instant::now() + FAR_FUTURE
1175 Instant::now() + FAR_FUTURE
956}
1176}
@@ -1010,6 +1230,9 @@ async fn tear_down(mut live: Live, inner: &Inner, timeline: &Timeline, report: &
1010 if let Some(broker) = live.broker.take() {
1230 if let Some(broker) = live.broker.take() {
1011 broker.abort();
1231 broker.abort();
1012 }
1232 }
1233 for task in live.video_tasks.drain(..) {
1234 task.abort();
1235 }
1013 if let Some(route_id) = &live.route_id {
1236 if let Some(route_id) = &live.route_id {
1014 inner.unregister_route(route_id);
1237 inner.unregister_route(route_id);
1015 }
1238 }
@@ -1105,6 +1328,7 @@ struct StatsSnapshot {
1105 audio_level: f64,
1328 audio_level: f64,
1106 local_level: f64,
1329 local_level: f64,
1107 echo_return_loss_enhancement: f64,
1330 echo_return_loss_enhancement: f64,
1331 video: VideoReport,
1108 dtls_state: String,
1332 dtls_state: String,
1109 tls_version: String,
1333 tls_version: String,
1110 dtls_cipher: String,
1334 dtls_cipher: String,
@@ -1132,6 +1356,22 @@ async fn collect_stats(peer: &PeerConnection) -> StatsSnapshot {
1132 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "audio" => {
1356 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "audio" => {
1133 snapshot.outbound_packets += outbound.sent.packets_sent;
1357 snapshot.outbound_packets += outbound.sent.packets_sent;
1134 }
1358 }
1359 RtcStats::InboundRtp(inbound) if inbound.stream.kind == "video" => {
1360 snapshot.video.inbound_packets += inbound.received.packets_received;
1361 snapshot.video.inbound_frames_decoded += u64::from(inbound.inbound.frames_decoded);
1362 snapshot.video.inbound_width = snapshot.video.inbound_width.max(inbound.inbound.frame_width);
1363 snapshot.video.inbound_height = snapshot.video.inbound_height.max(inbound.inbound.frame_height);
1364 }
1365 RtcStats::RemoteInboundRtp(remote) if remote.stream.kind == "video" => {
1366 snapshot.video.remote_reports += remote.remote_inbound.round_trip_time_measurements;
1367 snapshot.video.remote_round_trip_ms = snapshot.video.remote_round_trip_ms.max(remote.remote_inbound.round_trip_time * 1000.0);
1368 }
1369 RtcStats::OutboundRtp(outbound) if outbound.stream.kind == "video" => {
1370 snapshot.video.outbound_packets += outbound.sent.packets_sent;
1371 snapshot.video.outbound_frames_encoded += u64::from(outbound.outbound.frames_encoded);
1372 snapshot.video.outbound_width = snapshot.video.outbound_width.max(outbound.outbound.frame_width);
1373 snapshot.video.outbound_height = snapshot.video.outbound_height.max(outbound.outbound.frame_height);
1374 }
1135 RtcStats::Transport(transport) => {
1375 RtcStats::Transport(transport) => {
1136 snapshot.dtls_state = format!("{:?}", transport.transport.dtls_state);
1376 snapshot.dtls_state = format!("{:?}", transport.transport.dtls_state);
1137 snapshot.tls_version = transport.transport.tls_version.clone();
1377 snapshot.tls_version = transport.transport.tls_version.clone();
crates/calling/src/camera.rs added +130 −0
@@ -0,0 +1,130 @@
1 use std::time::Duration;
2
3 use libwebrtc::native::yuv_helper::abgr_to_i420;
4 use libwebrtc::video_frame::I420Buffer;
5 use nokhwa::pixel_format::RgbAFormat;
6 use nokhwa::utils::{ApiBackend, CameraIndex, RequestedFormat, RequestedFormatType};
7 use nokhwa::{Camera, query};
8 use std::sync::atomic::Ordering;
9
10 use crate::capture::Capture;
11 use crate::devices::{DeviceChoice, DeviceEntry};
12 use crate::error::{Error, Result};
13
14 const RETRY_PAUSE: Duration = Duration::from_millis(20);
15 const BYTES_PER_PIXEL: u32 = 4;
16
17 #[derive(Debug, Clone, PartialEq, Eq)]
18 pub struct CameraDevice {
19 pub key: String,
20 pub name: String,
21 }
22
23 pub fn list_cameras() -> Vec<CameraDevice> {
24 query(ApiBackend::Auto)
25 .unwrap_or_default()
26 .into_iter()
27 .map(|info| CameraDevice {
28 key: match info.index() {
29 CameraIndex::Index(number) => number.to_string(),
30 CameraIndex::String(text) => text.clone(),
31 },
32 name: info.human_name(),
33 })
34 .collect()
35 }
36
37 fn camera_index(choice: &DeviceChoice) -> CameraIndex {
38 match choice {
39 DeviceChoice::SystemDefault => CameraIndex::Index(0),
40 DeviceChoice::Device(key) => key.parse().map_or_else(|_| CameraIndex::String(key.clone()), CameraIndex::Index),
41 }
42 }
43
44 fn i420_from_rgba(rgba: &[u8], width: u32, height: u32) -> I420Buffer {
45 let mut buffer = I420Buffer::new(width, height);
46 let (stride_y, stride_u, stride_v) = buffer.strides();
47 let (plane_y, plane_u, plane_v) = buffer.data_mut();
48 abgr_to_i420(
49 rgba,
50 width * BYTES_PER_PIXEL,
51 plane_y,
52 stride_y,
53 plane_u,
54 stride_u,
55 plane_v,
56 stride_v,
57 width as i32,
58 height as i32,
59 );
60 buffer
61 }
62
63 pub fn start_camera(
64 choice: &DeviceChoice,
65 mut deliver: impl FnMut(I420Buffer) + Send + 'static,
66 failed: impl FnOnce(String) + Send + 'static,
67 ) -> Result<Capture> {
68 let index = camera_index(choice);
69 Capture::spawn_thread("camera", move |stop| {
70 let format = RequestedFormat::new::<RgbAFormat>(RequestedFormatType::AbsoluteHighestFrameRate);
71 let mut camera = match Camera::new(index, format).and_then(|mut camera| camera.open_stream().map(|()| camera)) {
72 Ok(camera) => camera,
73 Err(error) => return failed(error.to_string()),
74 };
75 while !stop.load(Ordering::SeqCst) {
76 let Ok(frame) = camera.frame() else {
77 std::thread::sleep(RETRY_PAUSE);
78 continue;
79 };
80 let Ok(decoded) = frame.decode_image::<RgbAFormat>() else { continue };
81 let (width, height) = (decoded.width(), decoded.height());
82 if width >= 2 && height >= 2 && width % 2 == 0 && height % 2 == 0 {
83 deliver(i420_from_rgba(decoded.as_raw(), width, height));
84 }
85 }
86 let _ = camera.stop_stream();
87 })
88 .map_err(|error| Error::Webrtc(format!("camera thread: {error}")))
89 }
90
91 pub const DEFAULT_CAMERA_LABEL: &str = "Default camera";
92
93 pub fn camera_entries(cameras: &[CameraDevice]) -> Vec<DeviceEntry> {
94 let default_entry = DeviceEntry {
95 choice: DeviceChoice::SystemDefault,
96 label: DEFAULT_CAMERA_LABEL.to_owned(),
97 };
98 let named = cameras
99 .iter()
100 .filter(|camera| !camera.name.trim().is_empty())
101 .map(|camera| DeviceEntry {
102 choice: DeviceChoice::Device(camera.key.clone()),
103 label: camera.name.clone(),
104 });
105 std::iter::once(default_entry).chain(named).collect()
106 }
107
108 #[cfg(test)]
109 mod tests {
110 use super::*;
111
112 #[test]
113 fn the_default_camera_comes_first_and_unnamed_ones_are_hidden() {
114 let cameras = [
115 CameraDevice { key: "0".into(), name: "Integrated Camera".into() },
116 CameraDevice { key: "1".into(), name: " ".into() },
117 ];
118 let entries = camera_entries(&cameras);
119 assert_eq!(entries.len(), 2);
120 assert_eq!(entries[0].choice, DeviceChoice::SystemDefault);
121 assert_eq!(entries[1].choice, DeviceChoice::Device("0".into()));
122 }
123
124 #[test]
125 fn camera_choices_map_to_indices_or_names() {
126 assert!(matches!(camera_index(&DeviceChoice::SystemDefault), CameraIndex::Index(0)));
127 assert!(matches!(camera_index(&DeviceChoice::Device("2".into())), CameraIndex::Index(2)));
128 assert!(matches!(camera_index(&DeviceChoice::Device("video0".into())), CameraIndex::String(_)));
129 }
130 }
@@ -0,0 +1,130 @@
1use std::time::Duration;
2
3use libwebrtc::native::yuv_helper::abgr_to_i420;
4use libwebrtc::video_frame::I420Buffer;
5use nokhwa::pixel_format::RgbAFormat;
6use nokhwa::utils::{ApiBackend, CameraIndex, RequestedFormat, RequestedFormatType};
7use nokhwa::{Camera, query};
8use std::sync::atomic::Ordering;
9
10use crate::capture::Capture;
11use crate::devices::{DeviceChoice, DeviceEntry};
12use crate::error::{Error, Result};
13
14const RETRY_PAUSE: Duration = Duration::from_millis(20);
15const BYTES_PER_PIXEL: u32 = 4;
16
17#[derive(Debug, Clone, PartialEq, Eq)]
18pub struct CameraDevice {
19 pub key: String,
20 pub name: String,
21}
22
23pub fn list_cameras() -> Vec<CameraDevice> {
24 query(ApiBackend::Auto)
25 .unwrap_or_default()
26 .into_iter()
27 .map(|info| CameraDevice {
28 key: match info.index() {
29 CameraIndex::Index(number) => number.to_string(),
30 CameraIndex::String(text) => text.clone(),
31 },
32 name: info.human_name(),
33 })
34 .collect()
35}
36
37fn camera_index(choice: &DeviceChoice) -> CameraIndex {
38 match choice {
39 DeviceChoice::SystemDefault => CameraIndex::Index(0),
40 DeviceChoice::Device(key) => key.parse().map_or_else(|_| CameraIndex::String(key.clone()), CameraIndex::Index),
41 }
42}
43
44fn i420_from_rgba(rgba: &[u8], width: u32, height: u32) -> I420Buffer {
45 let mut buffer = I420Buffer::new(width, height);
46 let (stride_y, stride_u, stride_v) = buffer.strides();
47 let (plane_y, plane_u, plane_v) = buffer.data_mut();
48 abgr_to_i420(
49 rgba,
50 width * BYTES_PER_PIXEL,
51 plane_y,
52 stride_y,
53 plane_u,
54 stride_u,
55 plane_v,
56 stride_v,
57 width as i32,
58 height as i32,
59 );
60 buffer
61}
62
63pub fn start_camera(
64 choice: &DeviceChoice,
65 mut deliver: impl FnMut(I420Buffer) + Send + 'static,
66 failed: impl FnOnce(String) + Send + 'static,
67) -> Result<Capture> {
68 let index = camera_index(choice);
69 Capture::spawn_thread("camera", move |stop| {
70 let format = RequestedFormat::new::<RgbAFormat>(RequestedFormatType::AbsoluteHighestFrameRate);
71 let mut camera = match Camera::new(index, format).and_then(|mut camera| camera.open_stream().map(|()| camera)) {
72 Ok(camera) => camera,
73 Err(error) => return failed(error.to_string()),
74 };
75 while !stop.load(Ordering::SeqCst) {
76 let Ok(frame) = camera.frame() else {
77 std::thread::sleep(RETRY_PAUSE);
78 continue;
79 };
80 let Ok(decoded) = frame.decode_image::<RgbAFormat>() else { continue };
81 let (width, height) = (decoded.width(), decoded.height());
82 if width >= 2 && height >= 2 && width % 2 == 0 && height % 2 == 0 {
83 deliver(i420_from_rgba(decoded.as_raw(), width, height));
84 }
85 }
86 let _ = camera.stop_stream();
87 })
88 .map_err(|error| Error::Webrtc(format!("camera thread: {error}")))
89}
90
91pub const DEFAULT_CAMERA_LABEL: &str = "Default camera";
92
93pub fn camera_entries(cameras: &[CameraDevice]) -> Vec<DeviceEntry> {
94 let default_entry = DeviceEntry {
95 choice: DeviceChoice::SystemDefault,
96 label: DEFAULT_CAMERA_LABEL.to_owned(),
97 };
98 let named = cameras
99 .iter()
100 .filter(|camera| !camera.name.trim().is_empty())
101 .map(|camera| DeviceEntry {
102 choice: DeviceChoice::Device(camera.key.clone()),
103 label: camera.name.clone(),
104 });
105 std::iter::once(default_entry).chain(named).collect()
106}
107
108#[cfg(test)]
109mod tests {
110 use super::*;
111
112 #[test]
113 fn the_default_camera_comes_first_and_unnamed_ones_are_hidden() {
114 let cameras = [
115 CameraDevice { key: "0".into(), name: "Integrated Camera".into() },
116 CameraDevice { key: "1".into(), name: " ".into() },
117 ];
118 let entries = camera_entries(&cameras);
119 assert_eq!(entries.len(), 2);
120 assert_eq!(entries[0].choice, DeviceChoice::SystemDefault);
121 assert_eq!(entries[1].choice, DeviceChoice::Device("0".into()));
122 }
123
124 #[test]
125 fn camera_choices_map_to_indices_or_names() {
126 assert!(matches!(camera_index(&DeviceChoice::SystemDefault), CameraIndex::Index(0)));
127 assert!(matches!(camera_index(&DeviceChoice::Device("2".into())), CameraIndex::Index(2)));
128 assert!(matches!(camera_index(&DeviceChoice::Device("video0".into())), CameraIndex::String(_)));
129 }
130}
crates/calling/src/capture.rs added +34 −0
@@ -0,0 +1,34 @@
1 use std::sync::Arc;
2 use std::sync::atomic::{AtomicBool, Ordering};
3 use std::thread::JoinHandle;
4
5 use tokio::task::JoinHandle as TaskHandle;
6
7 /// A running frame source; dropping it stops the capture.
8 pub enum Capture {
9 Thread { stop: Arc<AtomicBool>, thread: Option<JoinHandle<()>> },
10 Task(TaskHandle<()>),
11 }
12
13 impl Capture {
14 pub fn spawn_thread(name: &str, body: impl FnOnce(Arc<AtomicBool>) + Send + 'static) -> std::io::Result<Self> {
15 let stop = Arc::new(AtomicBool::new(false));
16 let thread_stop = stop.clone();
17 let thread = std::thread::Builder::new().name(name.to_owned()).spawn(move || body(thread_stop))?;
18 Ok(Capture::Thread { stop, thread: Some(thread) })
19 }
20 }
21
22 impl Drop for Capture {
23 fn drop(&mut self) {
24 match self {
25 Capture::Thread { stop, thread } => {
26 stop.store(true, Ordering::SeqCst);
27 if let Some(thread) = thread.take() {
28 let _ = thread.join();
29 }
30 }
31 Capture::Task(task) => task.abort(),
32 }
33 }
34 }
@@ -0,0 +1,34 @@
1use std::sync::Arc;
2use std::sync::atomic::{AtomicBool, Ordering};
3use std::thread::JoinHandle;
4
5use tokio::task::JoinHandle as TaskHandle;
6
7/// A running frame source; dropping it stops the capture.
8pub enum Capture {
9 Thread { stop: Arc<AtomicBool>, thread: Option<JoinHandle<()>> },
10 Task(TaskHandle<()>),
11}
12
13impl Capture {
14 pub fn spawn_thread(name: &str, body: impl FnOnce(Arc<AtomicBool>) + Send + 'static) -> std::io::Result<Self> {
15 let stop = Arc::new(AtomicBool::new(false));
16 let thread_stop = stop.clone();
17 let thread = std::thread::Builder::new().name(name.to_owned()).spawn(move || body(thread_stop))?;
18 Ok(Capture::Thread { stop, thread: Some(thread) })
19 }
20}
21
22impl Drop for Capture {
23 fn drop(&mut self) {
24 match self {
25 Capture::Thread { stop, thread } => {
26 stop.store(true, Ordering::SeqCst);
27 if let Some(thread) = thread.take() {
28 let _ = thread.join();
29 }
30 }
31 Capture::Task(task) => task.abort(),
32 }
33 }
34}
crates/calling/src/control.rs +25 −0
@@ -1,4 +1,5 @@
1 1 use std::future::Future;
2 use std::sync::Arc;
2 3
3 4 use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
4 5
@@ -6,7 +7,10 @@ use crate::devices::{DeviceChoice, DeviceLists};
6 7 use crate::error::{Error, Result};
7 8 use crate::mute::MuteCommand;
8 9 use crate::roster::RosterEntry;
10 use crate::camera::CameraDevice;
11 use crate::screen::ShareSource;
9 12 use crate::state::CallState;
13 use crate::video_frame::VideoHub;
10 14
11 15 #[derive(Debug, Clone, PartialEq, Eq)]
12 16 pub enum CallCommand {
@@ -14,6 +18,11 @@ pub enum CallCommand {
14 18 SelectInput(DeviceChoice),
15 19 SelectOutput(DeviceChoice),
16 20 RefreshDevices,
21 SetCamera(bool),
22 SelectCamera(DeviceChoice),
23 StartShare(ShareSource),
24 StopShare,
25 RefreshShareSources,
17 26 Hangup,
18 27 EndMeeting,
19 28 }
@@ -38,31 +47,43 @@ pub enum CallUpdate {
38 47 Speakers(Vec<String>),
39 48 Lobby(bool),
40 49 OwnIdentity { mri: String },
50 VideoReady,
51 ScreenShare(Option<String>),
52 Camera(bool),
53 Cameras(Vec<CameraDevice>),
54 LocalShare(Option<String>),
55 ShareSources(Vec<ShareSource>),
56 Notice(String),
41 57 }
42 58
43 59 pub struct CallHandle {
44 60 pub commands: UnboundedSender<CallCommand>,
45 61 pub updates: UnboundedReceiver<CallUpdate>,
62 pub video: Arc<VideoHub>,
46 63 }
47 64
48 65 pub struct CallControl {
49 66 commands: UnboundedReceiver<CallCommand>,
50 67 updates: UnboundedSender<CallUpdate>,
51 68 deferred: Vec<CallCommand>,
69 pub video: Arc<VideoHub>,
52 70 }
53 71
54 72 pub fn call_channel() -> (CallHandle, CallControl) {
55 73 let (command_sender, command_receiver) = unbounded_channel();
56 74 let (update_sender, update_receiver) = unbounded_channel();
75 let video = VideoHub::new(update_sender.clone());
57 76 (
58 77 CallHandle {
59 78 commands: command_sender,
60 79 updates: update_receiver,
80 video: video.clone(),
61 81 },
62 82 CallControl {
63 83 commands: command_receiver,
64 84 updates: update_sender,
65 85 deferred: Vec::new(),
86 video,
66 87 },
67 88 )
68 89 }
@@ -72,6 +93,10 @@ impl CallControl {
72 93 let _ = self.updates.send(update);
73 94 }
74 95
96 pub fn updates(&self) -> UnboundedSender<CallUpdate> {
97 self.updates.clone()
98 }
99
75 100 pub async fn recv(&mut self) -> Option<CallCommand> {
76 101 if !self.deferred.is_empty() {
77 102 return Some(self.deferred.remove(0));
@@ -1,4 +1,5 @@
1use std::future::Future;
1use std::future::Future;
2use std::sync::Arc;
2
3
3use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
4use tokio::sync::mpsc::{UnboundedReceiver, UnboundedSender, unbounded_channel};
4
5
@@ -6,7 +7,10 @@ use crate::devices::{DeviceChoice, DeviceLists};
6use crate::error::{Error, Result};
7use crate::error::{Error, Result};
7use crate::mute::MuteCommand;
8use crate::mute::MuteCommand;
8use crate::roster::RosterEntry;
9use crate::roster::RosterEntry;
10use crate::camera::CameraDevice;
11use crate::screen::ShareSource;
9use crate::state::CallState;
12use crate::state::CallState;
13use crate::video_frame::VideoHub;
10
14
11#[derive(Debug, Clone, PartialEq, Eq)]
15#[derive(Debug, Clone, PartialEq, Eq)]
12pub enum CallCommand {
16pub enum CallCommand {
@@ -14,6 +18,11 @@ pub enum CallCommand {
14 SelectInput(DeviceChoice),
18 SelectInput(DeviceChoice),
15 SelectOutput(DeviceChoice),
19 SelectOutput(DeviceChoice),
16 RefreshDevices,
20 RefreshDevices,
21 SetCamera(bool),
22 SelectCamera(DeviceChoice),
23 StartShare(ShareSource),
24 StopShare,
25 RefreshShareSources,
17 Hangup,
26 Hangup,
18 EndMeeting,
27 EndMeeting,
19}
28}
@@ -38,31 +47,43 @@ pub enum CallUpdate {
38 Speakers(Vec<String>),
47 Speakers(Vec<String>),
39 Lobby(bool),
48 Lobby(bool),
40 OwnIdentity { mri: String },
49 OwnIdentity { mri: String },
50 VideoReady,
51 ScreenShare(Option<String>),
52 Camera(bool),
53 Cameras(Vec<CameraDevice>),
54 LocalShare(Option<String>),
55 ShareSources(Vec<ShareSource>),
56 Notice(String),
41}
57}
42
58
43pub struct CallHandle {
59pub struct CallHandle {
44 pub commands: UnboundedSender<CallCommand>,
60 pub commands: UnboundedSender<CallCommand>,
45 pub updates: UnboundedReceiver<CallUpdate>,
61 pub updates: UnboundedReceiver<CallUpdate>,
62 pub video: Arc<VideoHub>,
46}
63}
47
64
48pub struct CallControl {
65pub struct CallControl {
49 commands: UnboundedReceiver<CallCommand>,
66 commands: UnboundedReceiver<CallCommand>,
50 updates: UnboundedSender<CallUpdate>,
67 updates: UnboundedSender<CallUpdate>,
51 deferred: Vec<CallCommand>,
68 deferred: Vec<CallCommand>,
69 pub video: Arc<VideoHub>,
52}
70}
53
71
54pub fn call_channel() -> (CallHandle, CallControl) {
72pub fn call_channel() -> (CallHandle, CallControl) {
55 let (command_sender, command_receiver) = unbounded_channel();
73 let (command_sender, command_receiver) = unbounded_channel();
56 let (update_sender, update_receiver) = unbounded_channel();
74 let (update_sender, update_receiver) = unbounded_channel();
75 let video = VideoHub::new(update_sender.clone());
57 (
76 (
58 CallHandle {
77 CallHandle {
59 commands: command_sender,
78 commands: command_sender,
60 updates: update_receiver,
79 updates: update_receiver,
80 video: video.clone(),
61 },
81 },
62 CallControl {
82 CallControl {
63 commands: command_receiver,
83 commands: command_receiver,
64 updates: update_sender,
84 updates: update_sender,
65 deferred: Vec::new(),
85 deferred: Vec::new(),
86 video,
66 },
87 },
67 )
88 )
68}
89}
@@ -72,6 +93,10 @@ impl CallControl {
72 let _ = self.updates.send(update);
93 let _ = self.updates.send(update);
73 }
94 }
74
95
96 pub fn updates(&self) -> UnboundedSender<CallUpdate> {
97 self.updates.clone()
98 }
99
75 pub async fn recv(&mut self) -> Option<CallCommand> {
100 pub async fn recv(&mut self) -> Option<CallCommand> {
76 if !self.deferred.is_empty() {
101 if !self.deferred.is_empty() {
77 return Some(self.deferred.remove(0));
102 return Some(self.deferred.remove(0));
crates/calling/src/lib.rs +12 −0
@@ -1,6 +1,8 @@
1 1 pub mod audio;
2 2 pub mod audio_io;
3 3 pub mod call;
4 pub mod camera;
5 pub mod capture;
4 6 pub mod control;
5 7 pub mod devices;
6 8 pub mod engine;
@@ -14,11 +16,17 @@ pub mod relay;
14 16 pub mod renegotiation;
15 17 pub mod ring;
16 18 pub mod roster;
19 pub mod screen;
17 20 pub mod sdp;
18 21 pub mod signaling;
19 22 pub mod state;
20 23 pub mod timeline;
21 24 pub mod trouter_events;
25 pub mod video_frame;
26 pub mod video_layout;
27 pub mod video_pattern;
28 pub mod video_receive;
29 pub mod video_send;
22 30
23 31 pub use audio_io::AudioMode;
24 32 pub use call::{CallOptions, CallReport, CallSpec, run_test_call};
@@ -34,3 +42,7 @@ pub use error::{Error, Result};
34 42 pub use level::SpeakingDetector;
35 43 pub use mute::MuteCommand;
36 44 pub use state::{CallSignal, CallState, EndReason};
45 pub use camera::{CameraDevice, camera_entries};
46 pub use screen::{ShareKind, ShareSource};
47 pub use video_frame::{VideoHub, VideoKey, VideoPicture};
48 pub use video_send::VideoMode;
@@ -1,6 +1,8 @@
1pub mod audio;
1pub mod audio;
2pub mod audio_io;
2pub mod audio_io;
3pub mod call;
3pub mod call;
4pub mod camera;
5pub mod capture;
4pub mod control;
6pub mod control;
5pub mod devices;
7pub mod devices;
6pub mod engine;
8pub mod engine;
@@ -14,11 +16,17 @@ pub mod relay;
14pub mod renegotiation;
16pub mod renegotiation;
15pub mod ring;
17pub mod ring;
16pub mod roster;
18pub mod roster;
19pub mod screen;
17pub mod sdp;
20pub mod sdp;
18pub mod signaling;
21pub mod signaling;
19pub mod state;
22pub mod state;
20pub mod timeline;
23pub mod timeline;
21pub mod trouter_events;
24pub mod trouter_events;
25pub mod video_frame;
26pub mod video_layout;
27pub mod video_pattern;
28pub mod video_receive;
29pub mod video_send;
22
30
23pub use audio_io::AudioMode;
31pub use audio_io::AudioMode;
24pub use call::{CallOptions, CallReport, CallSpec, run_test_call};
32pub use call::{CallOptions, CallReport, CallSpec, run_test_call};
@@ -34,3 +42,7 @@ pub use error::{Error, Result};
34pub use level::SpeakingDetector;
42pub use level::SpeakingDetector;
35pub use mute::MuteCommand;
43pub use mute::MuteCommand;
36pub use state::{CallSignal, CallState, EndReason};
44pub use state::{CallSignal, CallState, EndReason};
45pub use camera::{CameraDevice, camera_entries};
46pub use screen::{ShareKind, ShareSource};
47pub use video_frame::{VideoHub, VideoKey, VideoPicture};
48pub use video_send::VideoMode;
crates/calling/src/roster.rs +88 −0
@@ -2,6 +2,9 @@ use serde_json::Value;
2 2
3 3 const ACTIVE: &str = "active";
4 4 const AUDIO: &str = "audio";
5 const VIDEO: &str = "video";
6 const SCREEN: &str = "applicationsharing-video";
7 const SENDING_DIRECTIONS: [&str; 2] = ["sendonly", "sendrecv"];
5 8
6 9 #[derive(Debug, Clone, PartialEq, Eq)]
7 10 pub struct Member {
@@ -10,6 +13,9 @@ pub struct Member {
10 13 pub muted: bool,
11 14 pub in_lobby: bool,
12 15 pub audio_sources: Vec<u32>,
16 pub video_source: Option<u32>,
17 pub screen_source: Option<u32>,
18 pub streams: Vec<String>,
13 19 version: u64,
14 20 }
15 21
@@ -19,6 +25,8 @@ pub struct RosterEntry {
19 25 pub display_name: String,
20 26 pub muted: bool,
21 27 pub in_lobby: bool,
28 pub has_video: bool,
29 pub sharing: bool,
22 30 }
23 31
24 32 #[derive(Debug, Clone, Default, PartialEq, Eq)]
@@ -40,6 +48,8 @@ impl Roster {
40 48 display_name: member.display_name.clone(),
41 49 muted: member.muted,
42 50 in_lobby: member.in_lobby,
51 has_video: member.video_source.is_some(),
52 sharing: member.screen_source.is_some(),
43 53 })
44 54 .collect()
45 55 }
@@ -77,6 +87,29 @@ impl Roster {
77 87 self.members.iter().find(|member| member.mri == mri).map(|member| member.in_lobby)
78 88 }
79 89
90 pub fn stream_summaries(&self, mri: &str) -> Vec<String> {
91 self.members
92 .iter()
93 .find(|member| member.mri == mri)
94 .map(|member| member.streams.clone())
95 .unwrap_or_default()
96 }
97
98 pub fn video_candidates(&self, own_mri: &str) -> Vec<(String, u32)> {
99 self.members
100 .iter()
101 .filter(|member| member.mri != own_mri && !member.in_lobby)
102 .filter_map(|member| Some((member.mri.clone(), member.video_source?)))
103 .collect()
104 }
105
106 pub fn screen_share(&self, own_mri: &str) -> Option<(String, u32)> {
107 self.members
108 .iter()
109 .filter(|member| member.mri != own_mri && !member.in_lobby)
110 .find_map(|member| Some((member.mri.clone(), member.screen_source?)))
111 }
112
80 113 pub fn mris_for_sources(&self, sources: &[u32]) -> Vec<String> {
81 114 self.members
82 115 .iter()
@@ -111,10 +144,38 @@ fn member_from(mri: &str, participant: &Value, version: u64, previous: Option<&M
111 144 muted,
112 145 in_lobby,
113 146 audio_sources,
147 video_source: sending_source(&in_call, VIDEO),
148 screen_source: sending_source(&in_call, SCREEN),
149 streams: stream_summaries(&in_call),
114 150 version,
115 151 }
116 152 }
117 153
154 fn stream_summaries(in_call: &[&&Value]) -> Vec<String> {
155 in_call
156 .iter()
157 .flat_map(|endpoint| endpoint["call"]["mediaStreams"].as_array().into_iter().flatten())
158 .map(|stream| {
159 format!(
160 "{} source {} {} request {}",
161 stream["type"].as_str().unwrap_or("?"),
162 stream["sourceId"],
163 stream["direction"].as_str().unwrap_or("?"),
164 stream["mdRequestId"]
165 )
166 })
167 .collect()
168 }
169
170 fn sending_source(in_call: &[&&Value], stream_type: &str) -> Option<u32> {
171 in_call
172 .iter()
173 .flat_map(|endpoint| endpoint["call"]["mediaStreams"].as_array().into_iter().flatten())
174 .filter(|stream| stream["type"].as_str() == Some(stream_type))
175 .filter(|stream| stream["direction"].as_str().is_some_and(|direction| SENDING_DIRECTIONS.contains(&direction)))
176 .find_map(|stream| source_id(&stream["sourceId"]))
177 }
178
118 179 fn audio_streams(endpoint: &Value) -> impl Iterator<Item = &Value> {
119 180 endpoint["call"]["mediaStreams"]
120 181 .as_array()
@@ -230,6 +291,33 @@ mod tests {
230 291 assert!(roster.mris_for_sources(&[999]).is_empty());
231 292 }
232 293
294 fn sending(mut person: Value, video: Option<u32>, screen: Option<u32>) -> Value {
295 let streams = person["endpoints"]["ep"]["call"]["mediaStreams"].as_array_mut().unwrap();
296 streams.clear();
297 streams.push(json!({"type": "audio", "label": "main-audio", "sourceId": 201, "direction": "sendrecv"}));
298 streams.push(json!({"type": "video", "label": "main-video", "sourceId": video.unwrap_or(202), "direction": if video.is_some() { "sendonly" } else { "inactive" }}));
299 streams.push(json!({"type": "applicationsharing-video", "label": "applicationsharing-video", "sourceId": screen.unwrap_or(212), "direction": if screen.is_some() { "sendrecv" } else { "recvonly" }}));
300 person
301 }
302
303 #[test]
304 fn only_sending_video_streams_are_candidates() {
305 let mut roster = Roster::default();
306 roster.apply(&delta(json!({
307 "8:orgid:me": sending(participant("Me", 1, "active", false, 201), Some(250), None),
308 "8:orgid:a": sending(participant("Ana", 1, "active", false, 301), Some(302), None),
309 "8:orgid:b": sending(participant("Bo", 1, "active", false, 401), None, None),
310 "8:orgid:c": sending(participant("Cy", 1, "active", false, 501), None, Some(512)),
311 })));
312 assert_eq!(roster.video_candidates("8:orgid:me"), vec![("8:orgid:a".to_owned(), 302)]);
313 assert_eq!(roster.screen_share("8:orgid:me"), Some(("8:orgid:c".to_owned(), 512)));
314 assert_eq!(roster.screen_share("8:orgid:c"), None);
315 let entries = roster.entries();
316 assert!(entries.iter().find(|entry| entry.display_name == "Ana").unwrap().has_video);
317 assert!(!entries.iter().find(|entry| entry.display_name == "Bo").unwrap().has_video);
318 assert!(entries.iter().find(|entry| entry.display_name == "Cy").unwrap().sharing);
319 }
320
233 321 #[test]
234 322 fn missing_name_keeps_the_known_one() {
235 323 let mut roster = Roster::default();
@@ -2,6 +2,9 @@ use serde_json::Value;
2
2
3const ACTIVE: &str = "active";
3const ACTIVE: &str = "active";
4const AUDIO: &str = "audio";
4const AUDIO: &str = "audio";
5const VIDEO: &str = "video";
6const SCREEN: &str = "applicationsharing-video";
7const SENDING_DIRECTIONS: [&str; 2] = ["sendonly", "sendrecv"];
5
8
6#[derive(Debug, Clone, PartialEq, Eq)]
9#[derive(Debug, Clone, PartialEq, Eq)]
7pub struct Member {
10pub struct Member {
@@ -10,6 +13,9 @@ pub struct Member {
10 pub muted: bool,
13 pub muted: bool,
11 pub in_lobby: bool,
14 pub in_lobby: bool,
12 pub audio_sources: Vec<u32>,
15 pub audio_sources: Vec<u32>,
16 pub video_source: Option<u32>,
17 pub screen_source: Option<u32>,
18 pub streams: Vec<String>,
13 version: u64,
19 version: u64,
14}
20}
15
21
@@ -19,6 +25,8 @@ pub struct RosterEntry {
19 pub display_name: String,
25 pub display_name: String,
20 pub muted: bool,
26 pub muted: bool,
21 pub in_lobby: bool,
27 pub in_lobby: bool,
28 pub has_video: bool,
29 pub sharing: bool,
22}
30}
23
31
24#[derive(Debug, Clone, Default, PartialEq, Eq)]
32#[derive(Debug, Clone, Default, PartialEq, Eq)]
@@ -40,6 +48,8 @@ impl Roster {
40 display_name: member.display_name.clone(),
48 display_name: member.display_name.clone(),
41 muted: member.muted,
49 muted: member.muted,
42 in_lobby: member.in_lobby,
50 in_lobby: member.in_lobby,
51 has_video: member.video_source.is_some(),
52 sharing: member.screen_source.is_some(),
43 })
53 })
44 .collect()
54 .collect()
45 }
55 }
@@ -77,6 +87,29 @@ impl Roster {
77 self.members.iter().find(|member| member.mri == mri).map(|member| member.in_lobby)
87 self.members.iter().find(|member| member.mri == mri).map(|member| member.in_lobby)
78 }
88 }
79
89
90 pub fn stream_summaries(&self, mri: &str) -> Vec<String> {
91 self.members
92 .iter()
93 .find(|member| member.mri == mri)
94 .map(|member| member.streams.clone())
95 .unwrap_or_default()
96 }
97
98 pub fn video_candidates(&self, own_mri: &str) -> Vec<(String, u32)> {
99 self.members
100 .iter()
101 .filter(|member| member.mri != own_mri && !member.in_lobby)
102 .filter_map(|member| Some((member.mri.clone(), member.video_source?)))
103 .collect()
104 }
105
106 pub fn screen_share(&self, own_mri: &str) -> Option<(String, u32)> {
107 self.members
108 .iter()
109 .filter(|member| member.mri != own_mri && !member.in_lobby)
110 .find_map(|member| Some((member.mri.clone(), member.screen_source?)))
111 }
112
80 pub fn mris_for_sources(&self, sources: &[u32]) -> Vec<String> {
113 pub fn mris_for_sources(&self, sources: &[u32]) -> Vec<String> {
81 self.members
114 self.members
82 .iter()
115 .iter()
@@ -111,10 +144,38 @@ fn member_from(mri: &str, participant: &Value, version: u64, previous: Option<&M
111 muted,
144 muted,
112 in_lobby,
145 in_lobby,
113 audio_sources,
146 audio_sources,
147 video_source: sending_source(&in_call, VIDEO),
148 screen_source: sending_source(&in_call, SCREEN),
149 streams: stream_summaries(&in_call),
114 version,
150 version,
115 }
151 }
116}
152}
117
153
154fn stream_summaries(in_call: &[&&Value]) -> Vec<String> {
155 in_call
156 .iter()
157 .flat_map(|endpoint| endpoint["call"]["mediaStreams"].as_array().into_iter().flatten())
158 .map(|stream| {
159 format!(
160 "{} source {} {} request {}",
161 stream["type"].as_str().unwrap_or("?"),
162 stream["sourceId"],
163 stream["direction"].as_str().unwrap_or("?"),
164 stream["mdRequestId"]
165 )
166 })
167 .collect()
168}
169
170fn sending_source(in_call: &[&&Value], stream_type: &str) -> Option<u32> {
171 in_call
172 .iter()
173 .flat_map(|endpoint| endpoint["call"]["mediaStreams"].as_array().into_iter().flatten())
174 .filter(|stream| stream["type"].as_str() == Some(stream_type))
175 .filter(|stream| stream["direction"].as_str().is_some_and(|direction| SENDING_DIRECTIONS.contains(&direction)))
176 .find_map(|stream| source_id(&stream["sourceId"]))
177}
178
118fn audio_streams(endpoint: &Value) -> impl Iterator<Item = &Value> {
179fn audio_streams(endpoint: &Value) -> impl Iterator<Item = &Value> {
119 endpoint["call"]["mediaStreams"]
180 endpoint["call"]["mediaStreams"]
120 .as_array()
181 .as_array()
@@ -230,6 +291,33 @@ mod tests {
230 assert!(roster.mris_for_sources(&[999]).is_empty());
291 assert!(roster.mris_for_sources(&[999]).is_empty());
231 }
292 }
232
293
294 fn sending(mut person: Value, video: Option<u32>, screen: Option<u32>) -> Value {
295 let streams = person["endpoints"]["ep"]["call"]["mediaStreams"].as_array_mut().unwrap();
296 streams.clear();
297 streams.push(json!({"type": "audio", "label": "main-audio", "sourceId": 201, "direction": "sendrecv"}));
298 streams.push(json!({"type": "video", "label": "main-video", "sourceId": video.unwrap_or(202), "direction": if video.is_some() { "sendonly" } else { "inactive" }}));
299 streams.push(json!({"type": "applicationsharing-video", "label": "applicationsharing-video", "sourceId": screen.unwrap_or(212), "direction": if screen.is_some() { "sendrecv" } else { "recvonly" }}));
300 person
301 }
302
303 #[test]
304 fn only_sending_video_streams_are_candidates() {
305 let mut roster = Roster::default();
306 roster.apply(&delta(json!({
307 "8:orgid:me": sending(participant("Me", 1, "active", false, 201), Some(250), None),
308 "8:orgid:a": sending(participant("Ana", 1, "active", false, 301), Some(302), None),
309 "8:orgid:b": sending(participant("Bo", 1, "active", false, 401), None, None),
310 "8:orgid:c": sending(participant("Cy", 1, "active", false, 501), None, Some(512)),
311 })));
312 assert_eq!(roster.video_candidates("8:orgid:me"), vec![("8:orgid:a".to_owned(), 302)]);
313 assert_eq!(roster.screen_share("8:orgid:me"), Some(("8:orgid:c".to_owned(), 512)));
314 assert_eq!(roster.screen_share("8:orgid:c"), None);
315 let entries = roster.entries();
316 assert!(entries.iter().find(|entry| entry.display_name == "Ana").unwrap().has_video);
317 assert!(!entries.iter().find(|entry| entry.display_name == "Bo").unwrap().has_video);
318 assert!(entries.iter().find(|entry| entry.display_name == "Cy").unwrap().sharing);
319 }
320
233 #[test]
321 #[test]
234 fn missing_name_keeps_the_known_one() {
322 fn missing_name_keeps_the_known_one() {
235 let mut roster = Roster::default();
323 let mut roster = Roster::default();
crates/calling/src/screen.rs added +123 −0
@@ -0,0 +1,123 @@
1 use std::sync::atomic::Ordering;
2 use std::time::Duration;
3
4 use libwebrtc::desktop_capturer::{CaptureSource, DesktopCaptureSourceType, DesktopCapturer, DesktopCapturerOptions};
5 use libwebrtc::native::yuv_helper::argb_to_i420;
6 use libwebrtc::video_frame::I420Buffer;
7
8 use crate::capture::Capture;
9 use crate::error::{Error, Result};
10 use crate::video_pattern::PatternKind;
11
12
13 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
14 pub enum ShareKind {
15 Screen,
16 Window,
17 }
18
19 impl ShareKind {
20 fn source_type(self) -> DesktopCaptureSourceType {
21 match self {
22 ShareKind::Screen => DesktopCaptureSourceType::Screen,
23 ShareKind::Window => DesktopCaptureSourceType::Window,
24 }
25 }
26 }
27
28 #[derive(Debug, Clone, PartialEq, Eq)]
29 pub struct ShareSource {
30 pub id: u64,
31 pub kind: ShareKind,
32 pub title: String,
33 }
34
35 impl ShareSource {
36 pub fn label(&self) -> String {
37 match (self.kind, self.title.trim()) {
38 (ShareKind::Screen, "") => "Entire screen".to_owned(),
39 (_, "") => "Window".to_owned(),
40 (_, title) => title.to_owned(),
41 }
42 }
43 }
44
45 fn capturer(kind: ShareKind) -> Option<DesktopCapturer> {
46 let mut options = DesktopCapturerOptions::new(kind.source_type());
47 options.set_include_cursor(true);
48 DesktopCapturer::new(options)
49 }
50
51 fn sources_of(kind: ShareKind) -> Vec<(ShareSource, CaptureSource)> {
52 let Some(capturer) = capturer(kind) else { return Vec::new() };
53 capturer
54 .get_source_list()
55 .into_iter()
56 .map(|source| {
57 (
58 ShareSource {
59 id: source.id(),
60 kind,
61 title: source.title(),
62 },
63 source,
64 )
65 })
66 .collect()
67 }
68
69 pub fn list_share_sources() -> Vec<ShareSource> {
70 [ShareKind::Screen, ShareKind::Window]
71 .into_iter()
72 .flat_map(|kind| sources_of(kind).into_iter().map(|(source, _)| source))
73 .collect()
74 }
75
76 fn i420_from_bgra(bytes: &[u8], width: u32, height: u32, stride: u32) -> I420Buffer {
77 let mut buffer = I420Buffer::new(width, height);
78 let (stride_y, stride_u, stride_v) = buffer.strides();
79 let (plane_y, plane_u, plane_v) = buffer.data_mut();
80 argb_to_i420(bytes, stride, plane_y, stride_y, plane_u, stride_u, plane_v, stride_v, width as i32, height as i32);
81 buffer
82 }
83
84 pub fn start_screen_capture(
85 wanted: ShareSource,
86 mut deliver: impl FnMut(I420Buffer) + Send + 'static,
87 failed: impl FnOnce(String) + Send + 'static,
88 ) -> Result<Capture> {
89 let period = Duration::from_secs(1) / PatternKind::Screen.fps();
90 Capture::spawn_thread("screen-capture", move |stop| {
91 let Some(source) = sources_of(wanted.kind).into_iter().find(|(source, _)| source.id == wanted.id).map(|(_, raw)| raw) else {
92 return failed("the shared source is gone".to_owned());
93 };
94 let Some(mut capturer) = capturer(wanted.kind) else {
95 return failed("screen capture is not available".to_owned());
96 };
97 capturer.start_capture(Some(source), move |result| {
98 let Ok(frame) = result else { return };
99 let (width, height) = (frame.width() as u32 & !1, frame.height() as u32 & !1);
100 if width >= 2 && height >= 2 {
101 deliver(i420_from_bgra(frame.data(), width, height, frame.stride()));
102 }
103 });
104 while !stop.load(Ordering::SeqCst) {
105 capturer.capture_frame();
106 std::thread::sleep(period);
107 }
108 })
109 .map_err(|error| Error::Webrtc(format!("screen thread: {error}")))
110 }
111
112 #[cfg(test)]
113 mod tests {
114 use super::*;
115
116 #[test]
117 fn sources_get_readable_labels() {
118 let screen = ShareSource { id: 1, kind: ShareKind::Screen, title: String::new() };
119 assert_eq!(screen.label(), "Entire screen");
120 let window = ShareSource { id: 2, kind: ShareKind::Window, title: " Notes ".into() };
121 assert_eq!(window.label(), "Notes");
122 }
123 }
@@ -0,0 +1,123 @@
1use std::sync::atomic::Ordering;
2use std::time::Duration;
3
4use libwebrtc::desktop_capturer::{CaptureSource, DesktopCaptureSourceType, DesktopCapturer, DesktopCapturerOptions};
5use libwebrtc::native::yuv_helper::argb_to_i420;
6use libwebrtc::video_frame::I420Buffer;
7
8use crate::capture::Capture;
9use crate::error::{Error, Result};
10use crate::video_pattern::PatternKind;
11
12
13#[derive(Debug, Clone, Copy, PartialEq, Eq)]
14pub enum ShareKind {
15 Screen,
16 Window,
17}
18
19impl ShareKind {
20 fn source_type(self) -> DesktopCaptureSourceType {
21 match self {
22 ShareKind::Screen => DesktopCaptureSourceType::Screen,
23 ShareKind::Window => DesktopCaptureSourceType::Window,
24 }
25 }
26}
27
28#[derive(Debug, Clone, PartialEq, Eq)]
29pub struct ShareSource {
30 pub id: u64,
31 pub kind: ShareKind,
32 pub title: String,
33}
34
35impl ShareSource {
36 pub fn label(&self) -> String {
37 match (self.kind, self.title.trim()) {
38 (ShareKind::Screen, "") => "Entire screen".to_owned(),
39 (_, "") => "Window".to_owned(),
40 (_, title) => title.to_owned(),
41 }
42 }
43}
44
45fn capturer(kind: ShareKind) -> Option<DesktopCapturer> {
46 let mut options = DesktopCapturerOptions::new(kind.source_type());
47 options.set_include_cursor(true);
48 DesktopCapturer::new(options)
49}
50
51fn sources_of(kind: ShareKind) -> Vec<(ShareSource, CaptureSource)> {
52 let Some(capturer) = capturer(kind) else { return Vec::new() };
53 capturer
54 .get_source_list()
55 .into_iter()
56 .map(|source| {
57 (
58 ShareSource {
59 id: source.id(),
60 kind,
61 title: source.title(),
62 },
63 source,
64 )
65 })
66 .collect()
67}
68
69pub fn list_share_sources() -> Vec<ShareSource> {
70 [ShareKind::Screen, ShareKind::Window]
71 .into_iter()
72 .flat_map(|kind| sources_of(kind).into_iter().map(|(source, _)| source))
73 .collect()
74}
75
76fn i420_from_bgra(bytes: &[u8], width: u32, height: u32, stride: u32) -> I420Buffer {
77 let mut buffer = I420Buffer::new(width, height);
78 let (stride_y, stride_u, stride_v) = buffer.strides();
79 let (plane_y, plane_u, plane_v) = buffer.data_mut();
80 argb_to_i420(bytes, stride, plane_y, stride_y, plane_u, stride_u, plane_v, stride_v, width as i32, height as i32);
81 buffer
82}
83
84pub fn start_screen_capture(
85 wanted: ShareSource,
86 mut deliver: impl FnMut(I420Buffer) + Send + 'static,
87 failed: impl FnOnce(String) + Send + 'static,
88) -> Result<Capture> {
89 let period = Duration::from_secs(1) / PatternKind::Screen.fps();
90 Capture::spawn_thread("screen-capture", move |stop| {
91 let Some(source) = sources_of(wanted.kind).into_iter().find(|(source, _)| source.id == wanted.id).map(|(_, raw)| raw) else {
92 return failed("the shared source is gone".to_owned());
93 };
94 let Some(mut capturer) = capturer(wanted.kind) else {
95 return failed("screen capture is not available".to_owned());
96 };
97 capturer.start_capture(Some(source), move |result| {
98 let Ok(frame) = result else { return };
99 let (width, height) = (frame.width() as u32 & !1, frame.height() as u32 & !1);
100 if width >= 2 && height >= 2 {
101 deliver(i420_from_bgra(frame.data(), width, height, frame.stride()));
102 }
103 });
104 while !stop.load(Ordering::SeqCst) {
105 capturer.capture_frame();
106 std::thread::sleep(period);
107 }
108 })
109 .map_err(|error| Error::Webrtc(format!("screen thread: {error}")))
110}
111
112#[cfg(test)]
113mod tests {
114 use super::*;
115
116 #[test]
117 fn sources_get_readable_labels() {
118 let screen = ShareSource { id: 1, kind: ShareKind::Screen, title: String::new() };
119 assert_eq!(screen.label(), "Entire screen");
120 let window = ShareSource { id: 2, kind: ShareKind::Window, title: " Notes ".into() };
121 assert_eq!(window.label(), "Notes");
122 }
123}
crates/calling/src/sdp.rs +35 −0
@@ -589,6 +589,41 @@ pub fn to_browser_answer(teams_sdp: &str, offer: &SignaledOffer, browser_offer_s
589 589 Ok(write(&SessionDescription { session, media }))
590 590 }
591 591
592 #[derive(Debug, Clone, PartialEq, Eq)]
593 pub struct StreamLine {
594 pub mid: String,
595 pub browser_mid: String,
596 pub role: LineRole,
597 pub source_stream_id: Option<u32>,
598 }
599
600 pub fn stream_lines(teams_sdp: &str, lines: &[SignaledLine]) -> Result<Vec<StreamLine>> {
601 let teams = parse(teams_sdp)?;
602 if teams.media.len() != lines.len() {
603 return Err(Error::Sdp(format!("sdp has {} m-lines, {} were signaled", teams.media.len(), lines.len())));
604 }
605 let mut streams = Vec::new();
606 for (media, line) in teams.media.iter().zip(lines) {
607 let source_stream_id = media.value("x-source-streamid").and_then(|value| value.trim().parse().ok());
608 let mid = media.mid().unwrap_or_default().to_owned();
609 match line.browser_mids.as_slice() {
610 [browser_mid] => streams.push(StreamLine {
611 mid,
612 browser_mid: browser_mid.clone(),
613 role: line.role,
614 source_stream_id,
615 }),
616 folded => streams.extend(folded.iter().map(|browser_mid| StreamLine {
617 mid: mid.clone(),
618 browser_mid: browser_mid.clone(),
619 role: line.role,
620 source_stream_id: None,
621 })),
622 }
623 }
624 Ok(streams)
625 }
626
592 627 fn transport_attributes(teams_line: &Media, session: &Session) -> Vec<Attribute> {
593 628 ["setup", "ice-ufrag", "ice-pwd", "fingerprint"]
594 629 .into_iter()
@@ -589,6 +589,41 @@ pub fn to_browser_answer(teams_sdp: &str, offer: &SignaledOffer, browser_offer_s
589 Ok(write(&SessionDescription { session, media }))
589 Ok(write(&SessionDescription { session, media }))
590}
590}
591
591
592#[derive(Debug, Clone, PartialEq, Eq)]
593pub struct StreamLine {
594 pub mid: String,
595 pub browser_mid: String,
596 pub role: LineRole,
597 pub source_stream_id: Option<u32>,
598}
599
600pub fn stream_lines(teams_sdp: &str, lines: &[SignaledLine]) -> Result<Vec<StreamLine>> {
601 let teams = parse(teams_sdp)?;
602 if teams.media.len() != lines.len() {
603 return Err(Error::Sdp(format!("sdp has {} m-lines, {} were signaled", teams.media.len(), lines.len())));
604 }
605 let mut streams = Vec::new();
606 for (media, line) in teams.media.iter().zip(lines) {
607 let source_stream_id = media.value("x-source-streamid").and_then(|value| value.trim().parse().ok());
608 let mid = media.mid().unwrap_or_default().to_owned();
609 match line.browser_mids.as_slice() {
610 [browser_mid] => streams.push(StreamLine {
611 mid,
612 browser_mid: browser_mid.clone(),
613 role: line.role,
614 source_stream_id,
615 }),
616 folded => streams.extend(folded.iter().map(|browser_mid| StreamLine {
617 mid: mid.clone(),
618 browser_mid: browser_mid.clone(),
619 role: line.role,
620 source_stream_id: None,
621 })),
622 }
623 }
624 Ok(streams)
625}
626
592fn transport_attributes(teams_line: &Media, session: &Session) -> Vec<Attribute> {
627fn transport_attributes(teams_line: &Media, session: &Session) -> Vec<Attribute> {
593 ["setup", "ice-ufrag", "ice-pwd", "fingerprint"]
628 ["setup", "ice-ufrag", "ice-pwd", "fingerprint"]
594 .into_iter()
629 .into_iter()
crates/calling/src/signaling.rs +17 −1
@@ -7,6 +7,7 @@ use crate::error::{Error, Result};
7 7 use crate::relay::ic3_scope;
8 8 use crate::timeline::Timeline;
9 9 use crate::trouter_events::{CallbackLinks, acceptance_links};
10 use crate::video_layout::MediaDescription;
10 11
11 12 pub const EPCONV_URL: &str = "https://api-emea.flightproxy.teams.microsoft.com/api/v2/epconv";
12 13 pub const ECHO_BOT_MRI: &str = "28:cf28171e-fcfd-47e4-a1d6-79460b0b3ca0";
@@ -157,6 +158,8 @@ pub fn routed_url(url: &str) -> Result<String> {
157 158 Ok(format!("{FLIGHTPROXY_EP}/{host}{path}"))
158 159 }
159 160
161 const FAILURE_BODY_CHARS: usize = 240;
162
160 163 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
161 164 pub enum LeaveReason {
162 165 Hangup,
@@ -240,7 +243,8 @@ impl Signaling {
240 243 let response = session.batch(&[request], &ic3_scope()).await?.remove(0);
241 244 self.timeline.record(label, format!("HTTP {}", response.status));
242 245 if !response.is_success() {
243 return Err(Error::Signaling(format!("{label} answered HTTP {}", response.status)));
246 let reason: String = response.body.to_string().chars().take(FAILURE_BODY_CHARS).collect();
247 return Err(Error::Signaling(format!("{label} answered HTTP {} {reason}", response.status)));
244 248 }
245 249 Ok(response)
246 250 }
@@ -307,6 +311,18 @@ impl Signaling {
307 311 self.post_json("POST updateEndpointState", url, body).await
308 312 }
309 313
314 pub async fn update_media_descriptions(&self, url: &str, descriptions: &[MediaDescription], request_id: u32) -> Result<()> {
315 let body = json!({
316 "UpdateMediaDescriptions": {
317 "mediaDescriptions": {
318 "descriptions": descriptions.iter().map(MediaDescription::wire).collect::<Vec<_>>(),
319 "requestId": request_id,
320 },
321 },
322 });
323 self.post_json("POST updateMediaDescriptions", url, body).await
324 }
325
310 326 pub async fn add_echo_bot(
311 327 &self,
312 328 conversation: &Conversation,
@@ -7,6 +7,7 @@ use crate::error::{Error, Result};
7use crate::relay::ic3_scope;
7use crate::relay::ic3_scope;
8use crate::timeline::Timeline;
8use crate::timeline::Timeline;
9use crate::trouter_events::{CallbackLinks, acceptance_links};
9use crate::trouter_events::{CallbackLinks, acceptance_links};
10use crate::video_layout::MediaDescription;
10
11
11pub const EPCONV_URL: &str = "https://api-emea.flightproxy.teams.microsoft.com/api/v2/epconv";
12pub const EPCONV_URL: &str = "https://api-emea.flightproxy.teams.microsoft.com/api/v2/epconv";
12pub const ECHO_BOT_MRI: &str = "28:cf28171e-fcfd-47e4-a1d6-79460b0b3ca0";
13pub const ECHO_BOT_MRI: &str = "28:cf28171e-fcfd-47e4-a1d6-79460b0b3ca0";
@@ -157,6 +158,8 @@ pub fn routed_url(url: &str) -> Result<String> {
157 Ok(format!("{FLIGHTPROXY_EP}/{host}{path}"))
158 Ok(format!("{FLIGHTPROXY_EP}/{host}{path}"))
158}
159}
159
160
161const FAILURE_BODY_CHARS: usize = 240;
162
160#[derive(Debug, Clone, Copy, PartialEq, Eq)]
163#[derive(Debug, Clone, Copy, PartialEq, Eq)]
161pub enum LeaveReason {
164pub enum LeaveReason {
162 Hangup,
165 Hangup,
@@ -240,7 +243,8 @@ impl Signaling {
240 let response = session.batch(&[request], &ic3_scope()).await?.remove(0);
243 let response = session.batch(&[request], &ic3_scope()).await?.remove(0);
241 self.timeline.record(label, format!("HTTP {}", response.status));
244 self.timeline.record(label, format!("HTTP {}", response.status));
242 if !response.is_success() {
245 if !response.is_success() {
243 return Err(Error::Signaling(format!("{label} answered HTTP {}", response.status)));
246 let reason: String = response.body.to_string().chars().take(FAILURE_BODY_CHARS).collect();
247 return Err(Error::Signaling(format!("{label} answered HTTP {} {reason}", response.status)));
244 }
248 }
245 Ok(response)
249 Ok(response)
246 }
250 }
@@ -307,6 +311,18 @@ impl Signaling {
307 self.post_json("POST updateEndpointState", url, body).await
311 self.post_json("POST updateEndpointState", url, body).await
308 }
312 }
309
313
314 pub async fn update_media_descriptions(&self, url: &str, descriptions: &[MediaDescription], request_id: u32) -> Result<()> {
315 let body = json!({
316 "UpdateMediaDescriptions": {
317 "mediaDescriptions": {
318 "descriptions": descriptions.iter().map(MediaDescription::wire).collect::<Vec<_>>(),
319 "requestId": request_id,
320 },
321 },
322 });
323 self.post_json("POST updateMediaDescriptions", url, body).await
324 }
325
310 pub async fn add_echo_bot(
326 pub async fn add_echo_bot(
311 &self,
327 &self,
312 conversation: &Conversation,
328 conversation: &Conversation,
crates/calling/src/video_frame.rs added +209 −0
@@ -0,0 +1,209 @@
1 use std::collections::HashMap;
2 use std::sync::atomic::{AtomicBool, Ordering};
3 use std::sync::{Arc, Mutex};
4 use std::time::{Duration, Instant};
5
6 use libwebrtc::video_frame::{BoxVideoBuffer, BoxVideoFrame, I420Buffer, VideoBuffer, VideoFormatType};
7 use tokio::sync::mpsc::UnboundedSender;
8
9 use crate::control::CallUpdate;
10
11 pub const PERSON_FPS: u32 = 30;
12 pub const SCREEN_FPS: u32 = 15;
13 pub const PERSON_MAX_WIDTH: u32 = 640;
14 pub const SCREEN_MAX_WIDTH: u32 = 1600;
15 const BYTES_PER_PIXEL: usize = 4;
16
17 #[derive(Debug, Clone, PartialEq, Eq, Hash)]
18 pub enum VideoKey {
19 Person(String),
20 Screen,
21 LocalCamera,
22 LocalScreen,
23 }
24
25 impl VideoKey {
26 pub fn max_width(&self) -> u32 {
27 match self {
28 VideoKey::Screen | VideoKey::LocalScreen => SCREEN_MAX_WIDTH,
29 VideoKey::Person(_) | VideoKey::LocalCamera => PERSON_MAX_WIDTH,
30 }
31 }
32
33 pub fn max_fps(&self) -> u32 {
34 match self {
35 VideoKey::Screen | VideoKey::LocalScreen => SCREEN_FPS,
36 VideoKey::Person(_) | VideoKey::LocalCamera => PERSON_FPS,
37 }
38 }
39 }
40
41 /// BGRA, tightly packed, the byte order the GPU atlas of the UI expects.
42 #[derive(Debug, Clone, PartialEq, Eq)]
43 pub struct VideoPicture {
44 pub width: u32,
45 pub height: u32,
46 pub bgra: Vec<u8>,
47 }
48
49 impl VideoPicture {
50 pub fn solid(width: u32, height: u32, blue: u8, green: u8, red: u8) -> Self {
51 let pixel = [blue, green, red, u8::MAX];
52 VideoPicture {
53 width,
54 height,
55 bgra: pixel.iter().copied().cycle().take(width as usize * height as usize * BYTES_PER_PIXEL).collect(),
56 }
57 }
58 }
59
60 pub struct VideoHub {
61 frames: Mutex<HashMap<VideoKey, Arc<VideoPicture>>>,
62 pending: AtomicBool,
63 notify: UnboundedSender<CallUpdate>,
64 }
65
66 impl VideoHub {
67 pub fn new(notify: UnboundedSender<CallUpdate>) -> Arc<Self> {
68 Arc::new(VideoHub {
69 frames: Mutex::default(),
70 pending: AtomicBool::new(false),
71 notify,
72 })
73 }
74
75 pub fn publish(&self, key: VideoKey, picture: VideoPicture) {
76 self.frames.lock().expect("video frames lock").insert(key, Arc::new(picture));
77 if !self.pending.swap(true, Ordering::SeqCst) {
78 let _ = self.notify.send(CallUpdate::VideoReady);
79 }
80 }
81
82 pub fn drain(&self) -> Vec<(VideoKey, Arc<VideoPicture>)> {
83 self.pending.store(false, Ordering::SeqCst);
84 self.frames.lock().expect("video frames lock").drain().collect()
85 }
86
87 pub fn forget(&self, key: &VideoKey) {
88 self.frames.lock().expect("video frames lock").remove(key);
89 }
90 }
91
92 const GATE_SLACK: f64 = 0.8;
93
94 pub struct FrameGate {
95 interval: Duration,
96 last: Option<Instant>,
97 }
98
99 impl FrameGate {
100 pub fn new(frames_per_second: u32) -> Self {
101 FrameGate {
102 interval: Duration::from_secs(1).mul_f64(GATE_SLACK) / frames_per_second.max(1),
103 last: None,
104 }
105 }
106
107 pub fn admit(&mut self, now: Instant) -> bool {
108 let due = self.last.is_none_or(|last| now.duration_since(last) >= self.interval);
109 if due {
110 self.last = Some(now);
111 }
112 due
113 }
114 }
115
116 pub fn fit_width(width: u32, height: u32, max_width: u32) -> (u32, u32) {
117 if width <= max_width || width == 0 {
118 return (width & !1, height & !1);
119 }
120 let scaled_height = (u64::from(height) * u64::from(max_width) / u64::from(width)) as u32;
121 (max_width & !1, scaled_height.max(2) & !1)
122 }
123
124 pub fn picture_from_frame(frame: BoxVideoFrame, max_width: u32) -> Option<VideoPicture> {
125 let buffer: BoxVideoBuffer = frame.buffer;
126 picture_from_i420(buffer.to_i420(), max_width)
127 }
128
129 pub fn picture_from_i420(mut i420: I420Buffer, max_width: u32) -> Option<VideoPicture> {
130 let (width, height) = (i420.width(), i420.height());
131 if width < 2 || height < 2 {
132 return None;
133 }
134 let (target_width, target_height) = fit_width(width, height, max_width);
135 if (target_width, target_height) != (width, height) {
136 i420 = i420.scale(target_width as i32, target_height as i32);
137 }
138 Some(bgra_from_i420(i420))
139 }
140
141 pub fn bgra_from_i420(i420: I420Buffer) -> VideoPicture {
142 let (width, height) = (i420.width(), i420.height());
143 let stride = width as usize * BYTES_PER_PIXEL;
144 let mut bgra = vec![0u8; stride * height as usize];
145 let buffer: BoxVideoBuffer = Box::new(i420);
146 buffer.to_argb(VideoFormatType::ARGB, &mut bgra, stride as u32, width as i32, height as i32);
147 VideoPicture { width, height, bgra }
148 }
149
150 #[cfg(test)]
151 mod tests {
152 use super::*;
153
154 #[test]
155 fn the_gate_caps_a_fast_source_at_thirty_frames_a_second() {
156 let mut gate = FrameGate::new(30);
157 let start = Instant::now();
158 let admitted = (0..120)
159 .filter(|tick| gate.admit(start + Duration::from_millis(tick * 8)))
160 .count();
161 assert!((28..=32).contains(&admitted), "{admitted} frames in a second");
162 }
163
164 #[test]
165 fn the_gate_keeps_every_frame_of_a_steady_thirty_fps_source() {
166 let mut gate = FrameGate::new(30);
167 let start = Instant::now();
168 let admitted = (0..30)
169 .filter(|tick| gate.admit(start + Duration::from_micros(tick * 33_000)))
170 .count();
171 assert_eq!(admitted, 30);
172 }
173
174 #[test]
175 fn wide_frames_shrink_to_the_cap_with_even_sides() {
176 assert_eq!(fit_width(1920, 1080, 640), (640, 360));
177 assert_eq!(fit_width(1280, 720, 640), (640, 360));
178 assert_eq!(fit_width(321, 241, 640), (320, 240));
179 assert_eq!(fit_width(1000, 1001, 500), (500, 500));
180 }
181
182 #[test]
183 fn the_hub_notifies_once_until_it_is_drained() {
184 let (sender, mut receiver) = tokio::sync::mpsc::unbounded_channel();
185 let hub = VideoHub::new(sender);
186 hub.publish(VideoKey::Screen, VideoPicture::solid(2, 2, 0, 0, 0));
187 hub.publish(VideoKey::LocalCamera, VideoPicture::solid(2, 2, 0, 0, 0));
188 hub.publish(VideoKey::Screen, VideoPicture::solid(4, 4, 0, 0, 0));
189 assert!(matches!(receiver.try_recv(), Ok(CallUpdate::VideoReady)));
190 assert!(receiver.try_recv().is_err());
191 let drained = hub.drain();
192 assert_eq!(drained.len(), 2);
193 assert!(drained.iter().any(|(key, picture)| *key == VideoKey::Screen && picture.width == 4));
194 hub.publish(VideoKey::Screen, VideoPicture::solid(2, 2, 0, 0, 0));
195 assert!(matches!(receiver.try_recv(), Ok(CallUpdate::VideoReady)));
196 }
197
198 #[test]
199 fn a_red_i420_frame_becomes_bgra_red() {
200 let mut buffer = I420Buffer::new(4, 4);
201 let (y_plane, u_plane, v_plane) = buffer.data_mut();
202 y_plane.fill(82);
203 u_plane.fill(90);
204 v_plane.fill(240);
205 let picture = bgra_from_i420(buffer);
206 let [blue, green, red, alpha] = [picture.bgra[0], picture.bgra[1], picture.bgra[2], picture.bgra[3]];
207 assert!(red > 200 && green < 60 && blue < 60 && alpha == 255, "{blue} {green} {red} {alpha}");
208 }
209 }
@@ -0,0 +1,209 @@
1use std::collections::HashMap;
2use std::sync::atomic::{AtomicBool, Ordering};
3use std::sync::{Arc, Mutex};
4use std::time::{Duration, Instant};
5
6use libwebrtc::video_frame::{BoxVideoBuffer, BoxVideoFrame, I420Buffer, VideoBuffer, VideoFormatType};
7use tokio::sync::mpsc::UnboundedSender;
8
9use crate::control::CallUpdate;
10
11pub const PERSON_FPS: u32 = 30;
12pub const SCREEN_FPS: u32 = 15;
13pub const PERSON_MAX_WIDTH: u32 = 640;
14pub const SCREEN_MAX_WIDTH: u32 = 1600;
15const BYTES_PER_PIXEL: usize = 4;
16
17#[derive(Debug, Clone, PartialEq, Eq, Hash)]
18pub enum VideoKey {
19 Person(String),
20 Screen,
21 LocalCamera,
22 LocalScreen,
23}
24
25impl VideoKey {
26 pub fn max_width(&self) -> u32 {
27 match self {
28 VideoKey::Screen | VideoKey::LocalScreen => SCREEN_MAX_WIDTH,
29 VideoKey::Person(_) | VideoKey::LocalCamera => PERSON_MAX_WIDTH,
30 }
31 }
32
33 pub fn max_fps(&self) -> u32 {
34 match self {
35 VideoKey::Screen | VideoKey::LocalScreen => SCREEN_FPS,
36 VideoKey::Person(_) | VideoKey::LocalCamera => PERSON_FPS,
37 }
38 }
39}
40
41/// BGRA, tightly packed, the byte order the GPU atlas of the UI expects.
42#[derive(Debug, Clone, PartialEq, Eq)]
43pub struct VideoPicture {
44 pub width: u32,
45 pub height: u32,
46 pub bgra: Vec<u8>,
47}
48
49impl VideoPicture {
50 pub fn solid(width: u32, height: u32, blue: u8, green: u8, red: u8) -> Self {
51 let pixel = [blue, green, red, u8::MAX];
52 VideoPicture {
53 width,
54 height,
55 bgra: pixel.iter().copied().cycle().take(width as usize * height as usize * BYTES_PER_PIXEL).collect(),
56 }
57 }
58}
59
60pub struct VideoHub {
61 frames: Mutex<HashMap<VideoKey, Arc<VideoPicture>>>,
62 pending: AtomicBool,
63 notify: UnboundedSender<CallUpdate>,
64}
65
66impl VideoHub {
67 pub fn new(notify: UnboundedSender<CallUpdate>) -> Arc<Self> {
68 Arc::new(VideoHub {
69 frames: Mutex::default(),
70 pending: AtomicBool::new(false),
71 notify,
72 })
73 }
74
75 pub fn publish(&self, key: VideoKey, picture: VideoPicture) {
76 self.frames.lock().expect("video frames lock").insert(key, Arc::new(picture));
77 if !self.pending.swap(true, Ordering::SeqCst) {
78 let _ = self.notify.send(CallUpdate::VideoReady);
79 }
80 }
81
82 pub fn drain(&self) -> Vec<(VideoKey, Arc<VideoPicture>)> {
83 self.pending.store(false, Ordering::SeqCst);
84 self.frames.lock().expect("video frames lock").drain().collect()
85 }
86
87 pub fn forget(&self, key: &VideoKey) {
88 self.frames.lock().expect("video frames lock").remove(key);
89 }
90}
91
92const GATE_SLACK: f64 = 0.8;
93
94pub struct FrameGate {
95 interval: Duration,
96 last: Option<Instant>,
97}
98
99impl FrameGate {
100 pub fn new(frames_per_second: u32) -> Self {
101 FrameGate {
102 interval: Duration::from_secs(1).mul_f64(GATE_SLACK) / frames_per_second.max(1),
103 last: None,
104 }
105 }
106
107 pub fn admit(&mut self, now: Instant) -> bool {
108 let due = self.last.is_none_or(|last| now.duration_since(last) >= self.interval);
109 if due {
110 self.last = Some(now);
111 }
112 due
113 }
114}
115
116pub fn fit_width(width: u32, height: u32, max_width: u32) -> (u32, u32) {
117 if width <= max_width || width == 0 {
118 return (width & !1, height & !1);
119 }
120 let scaled_height = (u64::from(height) * u64::from(max_width) / u64::from(width)) as u32;
121 (max_width & !1, scaled_height.max(2) & !1)
122}
123
124pub fn picture_from_frame(frame: BoxVideoFrame, max_width: u32) -> Option<VideoPicture> {
125 let buffer: BoxVideoBuffer = frame.buffer;
126 picture_from_i420(buffer.to_i420(), max_width)
127}
128
129pub fn picture_from_i420(mut i420: I420Buffer, max_width: u32) -> Option<VideoPicture> {
130 let (width, height) = (i420.width(), i420.height());
131 if width < 2 || height < 2 {
132 return None;
133 }
134 let (target_width, target_height) = fit_width(width, height, max_width);
135 if (target_width, target_height) != (width, height) {
136 i420 = i420.scale(target_width as i32, target_height as i32);
137 }
138 Some(bgra_from_i420(i420))
139}
140
141pub fn bgra_from_i420(i420: I420Buffer) -> VideoPicture {
142 let (width, height) = (i420.width(), i420.height());
143 let stride = width as usize * BYTES_PER_PIXEL;
144 let mut bgra = vec![0u8; stride * height as usize];
145 let buffer: BoxVideoBuffer = Box::new(i420);
146 buffer.to_argb(VideoFormatType::ARGB, &mut bgra, stride as u32, width as i32, height as i32);
147 VideoPicture { width, height, bgra }
148}
149
150#[cfg(test)]
151mod tests {
152 use super::*;
153
154 #[test]
155 fn the_gate_caps_a_fast_source_at_thirty_frames_a_second() {
156 let mut gate = FrameGate::new(30);
157 let start = Instant::now();
158 let admitted = (0..120)
159 .filter(|tick| gate.admit(start + Duration::from_millis(tick * 8)))
160 .count();
161 assert!((28..=32).contains(&admitted), "{admitted} frames in a second");
162 }
163
164 #[test]
165 fn the_gate_keeps_every_frame_of_a_steady_thirty_fps_source() {
166 let mut gate = FrameGate::new(30);
167 let start = Instant::now();
168 let admitted = (0..30)
169 .filter(|tick| gate.admit(start + Duration::from_micros(tick * 33_000)))
170 .count();
171 assert_eq!(admitted, 30);
172 }
173
174 #[test]
175 fn wide_frames_shrink_to_the_cap_with_even_sides() {
176 assert_eq!(fit_width(1920, 1080, 640), (640, 360));
177 assert_eq!(fit_width(1280, 720, 640), (640, 360));
178 assert_eq!(fit_width(321, 241, 640), (320, 240));
179 assert_eq!(fit_width(1000, 1001, 500), (500, 500));
180 }
181
182 #[test]
183 fn the_hub_notifies_once_until_it_is_drained() {
184 let (sender, mut receiver) = tokio::sync::mpsc::unbounded_channel();
185 let hub = VideoHub::new(sender);
186 hub.publish(VideoKey::Screen, VideoPicture::solid(2, 2, 0, 0, 0));
187 hub.publish(VideoKey::LocalCamera, VideoPicture::solid(2, 2, 0, 0, 0));
188 hub.publish(VideoKey::Screen, VideoPicture::solid(4, 4, 0, 0, 0));
189 assert!(matches!(receiver.try_recv(), Ok(CallUpdate::VideoReady)));
190 assert!(receiver.try_recv().is_err());
191 let drained = hub.drain();
192 assert_eq!(drained.len(), 2);
193 assert!(drained.iter().any(|(key, picture)| *key == VideoKey::Screen && picture.width == 4));
194 hub.publish(VideoKey::Screen, VideoPicture::solid(2, 2, 0, 0, 0));
195 assert!(matches!(receiver.try_recv(), Ok(CallUpdate::VideoReady)));
196 }
197
198 #[test]
199 fn a_red_i420_frame_becomes_bgra_red() {
200 let mut buffer = I420Buffer::new(4, 4);
201 let (y_plane, u_plane, v_plane) = buffer.data_mut();
202 y_plane.fill(82);
203 u_plane.fill(90);
204 v_plane.fill(240);
205 let picture = bgra_from_i420(buffer);
206 let [blue, green, red, alpha] = [picture.bgra[0], picture.bgra[1], picture.bgra[2], picture.bgra[3]];
207 assert!(red > 200 && green < 60 && blue < 60 && alpha == 255, "{blue} {green} {red} {alpha}");
208 }
209}
crates/calling/src/video_layout.rs added +378 −0
@@ -0,0 +1,378 @@
1 use std::collections::HashMap;
2 use std::sync::{Arc, Mutex};
3
4 use libwebrtc::peer_connection::PeerConnection;
5 use libwebrtc::peer_connection_factory::PeerConnectionFactory;
6 use libwebrtc::rtp_parameters::RtpCodecCapability;
7 use libwebrtc::rtp_transceiver::{RtpTransceiver, RtpTransceiverDirection, RtpTransceiverInit};
8 use libwebrtc::MediaType;
9 use serde_json::{Value, json};
10
11 use crate::error::{Error, Result};
12 use crate::sdp::{LineRole, OfferPlan, StreamLine};
13 use crate::video_frame::VideoKey;
14
15 pub const RECEIVE_SLOTS: usize = 4;
16 pub const CAMERA_MID: &str = "1";
17 pub const SHARE_MID: &str = "6";
18 const CAMERA_LINE_LABEL: &str = "main-video";
19 const SHARE_LINE_LABEL: &str = "applicationsharing-video";
20 const CAMERA_STREAM: &str = "camera";
21 const SCREEN_STREAM: &str = "screen";
22 const H264: &str = "video/h264";
23 const RTX: &str = "video/rtx";
24 const NO_SOURCE: i64 = -1;
25 const PERSON_REQUEST: ReceiveLimits = ReceiveLimits { max_fs: 3600, max_fps: 3000, max_mbps: 108_000 };
26 const SCREEN_REQUEST: ReceiveLimits = ReceiveLimits { max_fs: 8160, max_fps: 1500, max_mbps: 135_000 };
27 const SUBSCRIBE_PROFILE: &str = "64001f";
28
29 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
30 struct ReceiveLimits {
31 max_fs: u32,
32 max_fps: u32,
33 max_mbps: u32,
34 }
35
36 pub fn offer_plan() -> OfferPlan {
37 OfferPlan {
38 screen_share_mids: vec![SHARE_MID.to_owned()],
39 gallery_mids: Vec::new(),
40 }
41 }
42
43 /// Offered after the audio line: camera, `RECEIVE_SLOTS` receive-only slots, screen share (mids 1, 2-5, 6).
44 #[derive(Clone)]
45 pub struct VideoLines {
46 pub camera: RtpTransceiver,
47 pub share: RtpTransceiver,
48 }
49
50 fn h264_only(capabilities: Vec<RtpCodecCapability>) -> Vec<RtpCodecCapability> {
51 capabilities
52 .into_iter()
53 .filter(|codec| {
54 let mime = codec.mime_type.to_ascii_lowercase();
55 mime == H264 || mime == RTX
56 })
57 .collect()
58 }
59
60 fn add_line(
61 peer: &PeerConnection,
62 direction: RtpTransceiverDirection,
63 stream: Option<&str>,
64 codecs: Vec<RtpCodecCapability>,
65 ) -> Result<RtpTransceiver> {
66 let init = RtpTransceiverInit {
67 direction,
68 stream_ids: stream.map(str::to_owned).into_iter().collect(),
69 send_encodings: Vec::new(),
70 };
71 let transceiver = peer
72 .add_transceiver_for_media(MediaType::Video, init)
73 .map_err(|error| Error::Webrtc(error.to_string()))?;
74 transceiver
75 .set_codec_preferences(codecs)
76 .map_err(|error| Error::Webrtc(error.to_string()))?;
77 Ok(transceiver)
78 }
79
80 pub fn add_video_lines(peer: &PeerConnection, factory: &PeerConnectionFactory) -> Result<VideoLines> {
81 let sending = h264_only(factory.get_rtp_sender_capabilities(MediaType::Video).codecs);
82 let receiving = h264_only(factory.get_rtp_receiver_capabilities(MediaType::Video).codecs);
83 let camera = add_line(peer, RtpTransceiverDirection::SendRecv, Some(CAMERA_STREAM), sending.clone())?;
84 for _ in 0..RECEIVE_SLOTS {
85 add_line(peer, RtpTransceiverDirection::RecvOnly, None, receiving.clone())?;
86 }
87 let share = add_line(peer, RtpTransceiverDirection::SendRecv, Some(SCREEN_STREAM), sending)?;
88 Ok(VideoLines { camera, share })
89 }
90
91 /// Per-line direction told to the mixer through `updateMediaDescriptions`; no SDP renegotiation.
92 #[derive(Debug, Clone, PartialEq, Eq)]
93 pub struct MediaDescription {
94 pub mid: &'static str,
95 pub direction: &'static str,
96 pub label: Option<&'static str>,
97 }
98
99 impl MediaDescription {
100 pub fn camera(sending: bool) -> Self {
101 Self::line(CAMERA_MID, sending, CAMERA_LINE_LABEL)
102 }
103
104 pub fn share(sending: bool) -> Self {
105 Self::line(SHARE_MID, sending, SHARE_LINE_LABEL)
106 }
107
108 fn line(mid: &'static str, sending: bool, label: &'static str) -> Self {
109 if sending {
110 MediaDescription { mid, direction: "sendrecv", label: Some(label) }
111 } else {
112 MediaDescription { mid, direction: "recvonly", label: None }
113 }
114 }
115
116 pub fn wire(&self) -> Value {
117 let mut description = json!({"mid": self.mid, "direction": self.direction});
118 if let Some(label) = self.label {
119 description["label"] = json!(label);
120 }
121 description
122 }
123 }
124
125 #[derive(Debug, Clone, PartialEq, Eq)]
126 pub struct ReceiveSlot {
127 pub mid: String,
128 pub stream_id: u32,
129 }
130
131 #[derive(Debug, Clone, Default, PartialEq, Eq)]
132 pub struct SlotTable {
133 pub people: Vec<ReceiveSlot>,
134 pub screen: Option<ReceiveSlot>,
135 }
136
137 impl SlotTable {
138 pub fn from_streams(streams: &[StreamLine]) -> Self {
139 let slot = |stream: &StreamLine| {
140 Some(ReceiveSlot {
141 mid: stream.browser_mid.clone(),
142 stream_id: stream.source_stream_id?,
143 })
144 };
145 let people = streams
146 .iter()
147 .filter(|stream| stream.role == LineRole::MainVideo)
148 .skip(1)
149 .filter_map(slot)
150 .take(RECEIVE_SLOTS)
151 .collect();
152 let screen = streams.iter().find(|stream| stream.role == LineRole::ScreenShare).and_then(slot);
153 SlotTable { people, screen }
154 }
155
156 pub fn is_empty(&self) -> bool {
157 self.people.is_empty() && self.screen.is_none()
158 }
159 }
160
161 #[derive(Debug, Clone, PartialEq, Eq)]
162 pub struct Assignment {
163 pub mri: String,
164 pub source: u32,
165 }
166
167 pub fn plan_receive(current: &[Option<Assignment>], candidates: &[Assignment]) -> Vec<Option<Assignment>> {
168 let wanted: Vec<&Assignment> = candidates.iter().take(current.len()).collect();
169 let mut next: Vec<Option<Assignment>> = current
170 .iter()
171 .map(|slot| slot.clone().filter(|held| wanted.contains(&held)))
172 .collect();
173 for assignment in wanted {
174 if next.iter().flatten().any(|held| held == assignment) {
175 continue;
176 }
177 if let Some(free) = next.iter_mut().find(|slot| slot.is_none()) {
178 *free = Some(assignment.clone());
179 }
180 }
181 next
182 }
183
184 pub fn prioritize(candidates: Vec<(String, u32)>, speaker_history: &[String]) -> Vec<Assignment> {
185 let rank = |mri: &str| speaker_history.iter().position(|speaker| speaker == mri).unwrap_or(usize::MAX);
186 let mut ordered: Vec<Assignment> = candidates
187 .into_iter()
188 .map(|(mri, source)| Assignment { mri, source })
189 .collect();
190 ordered.sort_by_key(|assignment| rank(&assignment.mri));
191 ordered
192 }
193
194 #[derive(Debug, Clone, PartialEq, Eq)]
195 pub struct SourceRequest {
196 pub mid: String,
197 pub stream_id: u32,
198 pub source: Option<u32>,
199 pub screen: bool,
200 }
201
202 pub fn requests_for(
203 current: &[Option<Assignment>],
204 next: &[Option<Assignment>],
205 slots: &[ReceiveSlot],
206 ) -> Vec<SourceRequest> {
207 slots
208 .iter()
209 .zip(current.iter().zip(next))
210 .filter(|(_, (before, after))| before != after)
211 .map(|(slot, (_, after))| SourceRequest {
212 mid: slot.mid.clone(),
213 stream_id: slot.stream_id,
214 source: after.as_ref().map(|assignment| assignment.source),
215 screen: false,
216 })
217 .collect()
218 }
219
220 impl SourceRequest {
221 /// Body of the `applyChannelParameters` link, the signaling twin of the data-channel `sr` message.
222 pub fn body(&self, sequence_number: u64) -> Value {
223 let limits = if self.screen { SCREEN_REQUEST } else { PERSON_REQUEST };
224 let control = json!({
225 "controlVideoStreaming": {
226 "sequenceNumber": sequence_number,
227 "controlInfo": {
228 "sourceId": self.source.map_or(NO_SOURCE, i64::from),
229 "streamMsid": self.stream_id,
230 "fmtParams": [{
231 "max-fs": limits.max_fs,
232 "max-mbps": limits.max_mbps,
233 "max-fps": limits.max_fps,
234 "profile-level-id": SUBSCRIBE_PROFILE,
235 }],
236 },
237 },
238 });
239 json!({
240 "applyChannelParameters": {
241 "multiChannelParameter": {
242 "mids": [self.mid],
243 "mediaParameter": control.to_string(),
244 },
245 },
246 })
247 }
248 }
249
250 #[derive(Clone, Default)]
251 pub struct VideoRouter {
252 keys: Arc<Mutex<HashMap<String, VideoKey>>>,
253 }
254
255 impl VideoRouter {
256 pub fn set(&self, mid: &str, key: Option<VideoKey>) {
257 let mut keys = self.keys.lock().expect("router lock");
258 match key {
259 Some(key) => keys.insert(mid.to_owned(), key),
260 None => keys.remove(mid),
261 };
262 }
263
264 pub fn key_for(&self, mid: &str) -> Option<VideoKey> {
265 self.keys.lock().expect("router lock").get(mid).cloned()
266 }
267 }
268
269 #[cfg(test)]
270 mod tests {
271 use super::*;
272
273 fn assignment(name: &str, source: u32) -> Assignment {
274 Assignment { mri: format!("8:orgid:{name}"), source }
275 }
276
277 fn stream(mid: &str, role: LineRole, id: Option<u32>) -> StreamLine {
278 StreamLine { mid: mid.into(), browser_mid: mid.into(), role, source_stream_id: id }
279 }
280
281 #[test]
282 fn slots_are_the_main_video_lines_after_the_camera_line() {
283 let streams = vec![
284 stream("0", LineRole::MainAudio, Some(201)),
285 stream("1", LineRole::MainVideo, Some(202)),
286 stream("2", LineRole::MainVideo, Some(203)),
287 stream("3", LineRole::MainVideo, Some(204)),
288 stream("4", LineRole::MainVideo, None),
289 stream("5", LineRole::MainVideo, Some(206)),
290 stream("6", LineRole::ScreenShare, Some(207)),
291 ];
292 let table = SlotTable::from_streams(&streams);
293 let mids: Vec<&str> = table.people.iter().map(|slot| slot.mid.as_str()).collect();
294 assert_eq!(mids, vec!["2", "3", "5"]);
295 assert_eq!(table.screen, Some(ReceiveSlot { mid: "6".into(), stream_id: 207 }));
296 }
297
298 #[test]
299 fn nobody_is_dropped_while_they_are_still_wanted() {
300 let held = vec![Some(assignment("a", 1)), Some(assignment("b", 2)), None, None];
301 let candidates = vec![assignment("c", 3), assignment("a", 1), assignment("b", 2)];
302 let next = plan_receive(&held, &candidates);
303 assert_eq!(next[0], Some(assignment("a", 1)));
304 assert_eq!(next[1], Some(assignment("b", 2)));
305 assert_eq!(next[2], Some(assignment("c", 3)));
306 assert_eq!(next[3], None);
307 }
308
309 #[test]
310 fn a_new_speaker_replaces_the_least_recent_person() {
311 let held: Vec<Option<Assignment>> = (1..=4).map(|index| Some(assignment(&format!("p{index}"), index))).collect();
312 let history = vec!["8:orgid:p5".to_owned(), "8:orgid:p1".to_owned(), "8:orgid:p2".to_owned(), "8:orgid:p3".to_owned()];
313 let roster = (1..=5).map(|index| (format!("8:orgid:p{index}"), index)).collect();
314 let next = plan_receive(&held, &prioritize(roster, &history));
315 let names: Vec<&str> = next.iter().flatten().map(|held| held.mri.as_str()).collect();
316 assert_eq!(names, vec!["8:orgid:p1", "8:orgid:p2", "8:orgid:p3", "8:orgid:p5"]);
317 }
318
319 #[test]
320 fn people_who_left_free_their_slot() {
321 let held = vec![Some(assignment("a", 1)), Some(assignment("b", 2))];
322 let next = plan_receive(&held, &[assignment("b", 2)]);
323 assert_eq!(next, vec![None, Some(assignment("b", 2))]);
324 let slots = vec![
325 ReceiveSlot { mid: "2".into(), stream_id: 203 },
326 ReceiveSlot { mid: "3".into(), stream_id: 204 },
327 ];
328 let requests = requests_for(&held, &next, &slots);
329 assert_eq!(requests, vec![SourceRequest { mid: "2".into(), stream_id: 203, source: None, screen: false }]);
330 }
331
332 #[test]
333 fn a_source_request_wraps_the_control_message_like_the_web_client() {
334 let request = SourceRequest { mid: "3".into(), stream_id: 204, source: Some(302), screen: false };
335 let body = request.body(7);
336 let channel = &body["applyChannelParameters"]["multiChannelParameter"];
337 assert_eq!(channel["mids"], json!(["3"]));
338 let parameter: Value = serde_json::from_str(channel["mediaParameter"].as_str().unwrap()).unwrap();
339 let info = &parameter["controlVideoStreaming"]["controlInfo"];
340 assert_eq!(parameter["controlVideoStreaming"]["sequenceNumber"], 7);
341 assert_eq!(info["sourceId"], 302);
342 assert_eq!(info["streamMsid"], 204);
343 assert_eq!(info["fmtParams"][0]["max-fs"], 3600);
344 assert_eq!(info["fmtParams"][0]["max-fps"], 3000);
345 assert_eq!(info["fmtParams"][0]["profile-level-id"], "64001f");
346 let cleared = SourceRequest { source: None, ..request.clone() }.body(8);
347 let parameter: Value =
348 serde_json::from_str(cleared["applyChannelParameters"]["multiChannelParameter"]["mediaParameter"].as_str().unwrap()).unwrap();
349 assert_eq!(parameter["controlVideoStreaming"]["controlInfo"]["sourceId"], -1);
350 let screen = SourceRequest { screen: true, ..request }.body(9);
351 let parameter: Value =
352 serde_json::from_str(screen["applyChannelParameters"]["multiChannelParameter"]["mediaParameter"].as_str().unwrap()).unwrap();
353 assert_eq!(parameter["controlVideoStreaming"]["controlInfo"]["fmtParams"][0]["max-fs"], 8160);
354 }
355
356 #[test]
357 fn media_descriptions_tell_the_mixer_what_a_line_does() {
358 assert_eq!(
359 MediaDescription::camera(true).wire(),
360 json!({"mid": "1", "direction": "sendrecv", "label": "main-video"})
361 );
362 assert_eq!(MediaDescription::camera(false).wire(), json!({"mid": "1", "direction": "recvonly"}));
363 assert_eq!(
364 MediaDescription::share(true).wire(),
365 json!({"mid": "6", "direction": "sendrecv", "label": "applicationsharing-video"})
366 );
367 }
368
369 #[test]
370 fn the_router_follows_assignments() {
371 let router = VideoRouter::default();
372 assert_eq!(router.key_for("2"), None);
373 router.set("2", Some(VideoKey::Person("8:orgid:a".into())));
374 assert_eq!(router.key_for("2"), Some(VideoKey::Person("8:orgid:a".into())));
375 router.set("2", None);
376 assert_eq!(router.key_for("2"), None);
377 }
378 }
@@ -0,0 +1,378 @@
1use std::collections::HashMap;
2use std::sync::{Arc, Mutex};
3
4use libwebrtc::peer_connection::PeerConnection;
5use libwebrtc::peer_connection_factory::PeerConnectionFactory;
6use libwebrtc::rtp_parameters::RtpCodecCapability;
7use libwebrtc::rtp_transceiver::{RtpTransceiver, RtpTransceiverDirection, RtpTransceiverInit};
8use libwebrtc::MediaType;
9use serde_json::{Value, json};
10
11use crate::error::{Error, Result};
12use crate::sdp::{LineRole, OfferPlan, StreamLine};
13use crate::video_frame::VideoKey;
14
15pub const RECEIVE_SLOTS: usize = 4;
16pub const CAMERA_MID: &str = "1";
17pub const SHARE_MID: &str = "6";
18const CAMERA_LINE_LABEL: &str = "main-video";
19const SHARE_LINE_LABEL: &str = "applicationsharing-video";
20const CAMERA_STREAM: &str = "camera";
21const SCREEN_STREAM: &str = "screen";
22const H264: &str = "video/h264";
23const RTX: &str = "video/rtx";
24const NO_SOURCE: i64 = -1;
25const PERSON_REQUEST: ReceiveLimits = ReceiveLimits { max_fs: 3600, max_fps: 3000, max_mbps: 108_000 };
26const SCREEN_REQUEST: ReceiveLimits = ReceiveLimits { max_fs: 8160, max_fps: 1500, max_mbps: 135_000 };
27const SUBSCRIBE_PROFILE: &str = "64001f";
28
29#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30struct ReceiveLimits {
31 max_fs: u32,
32 max_fps: u32,
33 max_mbps: u32,
34}
35
36pub fn offer_plan() -> OfferPlan {
37 OfferPlan {
38 screen_share_mids: vec![SHARE_MID.to_owned()],
39 gallery_mids: Vec::new(),
40 }
41}
42
43/// Offered after the audio line: camera, `RECEIVE_SLOTS` receive-only slots, screen share (mids 1, 2-5, 6).
44#[derive(Clone)]
45pub struct VideoLines {
46 pub camera: RtpTransceiver,
47 pub share: RtpTransceiver,
48}
49
50fn h264_only(capabilities: Vec<RtpCodecCapability>) -> Vec<RtpCodecCapability> {
51 capabilities
52 .into_iter()
53 .filter(|codec| {
54 let mime = codec.mime_type.to_ascii_lowercase();
55 mime == H264 || mime == RTX
56 })
57 .collect()
58}
59
60fn add_line(
61 peer: &PeerConnection,
62 direction: RtpTransceiverDirection,
63 stream: Option<&str>,
64 codecs: Vec<RtpCodecCapability>,
65) -> Result<RtpTransceiver> {
66 let init = RtpTransceiverInit {
67 direction,
68 stream_ids: stream.map(str::to_owned).into_iter().collect(),
69 send_encodings: Vec::new(),
70 };
71 let transceiver = peer
72 .add_transceiver_for_media(MediaType::Video, init)
73 .map_err(|error| Error::Webrtc(error.to_string()))?;
74 transceiver
75 .set_codec_preferences(codecs)
76 .map_err(|error| Error::Webrtc(error.to_string()))?;
77 Ok(transceiver)
78}
79
80pub fn add_video_lines(peer: &PeerConnection, factory: &PeerConnectionFactory) -> Result<VideoLines> {
81 let sending = h264_only(factory.get_rtp_sender_capabilities(MediaType::Video).codecs);
82 let receiving = h264_only(factory.get_rtp_receiver_capabilities(MediaType::Video).codecs);
83 let camera = add_line(peer, RtpTransceiverDirection::SendRecv, Some(CAMERA_STREAM), sending.clone())?;
84 for _ in 0..RECEIVE_SLOTS {
85 add_line(peer, RtpTransceiverDirection::RecvOnly, None, receiving.clone())?;
86 }
87 let share = add_line(peer, RtpTransceiverDirection::SendRecv, Some(SCREEN_STREAM), sending)?;
88 Ok(VideoLines { camera, share })
89}
90
91/// Per-line direction told to the mixer through `updateMediaDescriptions`; no SDP renegotiation.
92#[derive(Debug, Clone, PartialEq, Eq)]
93pub struct MediaDescription {
94 pub mid: &'static str,
95 pub direction: &'static str,
96 pub label: Option<&'static str>,
97}
98
99impl MediaDescription {
100 pub fn camera(sending: bool) -> Self {
101 Self::line(CAMERA_MID, sending, CAMERA_LINE_LABEL)
102 }
103
104 pub fn share(sending: bool) -> Self {
105 Self::line(SHARE_MID, sending, SHARE_LINE_LABEL)
106 }
107
108 fn line(mid: &'static str, sending: bool, label: &'static str) -> Self {
109 if sending {
110 MediaDescription { mid, direction: "sendrecv", label: Some(label) }
111 } else {
112 MediaDescription { mid, direction: "recvonly", label: None }
113 }
114 }
115
116 pub fn wire(&self) -> Value {
117 let mut description = json!({"mid": self.mid, "direction": self.direction});
118 if let Some(label) = self.label {
119 description["label"] = json!(label);
120 }
121 description
122 }
123}
124
125#[derive(Debug, Clone, PartialEq, Eq)]
126pub struct ReceiveSlot {
127 pub mid: String,
128 pub stream_id: u32,
129}
130
131#[derive(Debug, Clone, Default, PartialEq, Eq)]
132pub struct SlotTable {
133 pub people: Vec<ReceiveSlot>,
134 pub screen: Option<ReceiveSlot>,
135}
136
137impl SlotTable {
138 pub fn from_streams(streams: &[StreamLine]) -> Self {
139 let slot = |stream: &StreamLine| {
140 Some(ReceiveSlot {
141 mid: stream.browser_mid.clone(),
142 stream_id: stream.source_stream_id?,
143 })
144 };
145 let people = streams
146 .iter()
147 .filter(|stream| stream.role == LineRole::MainVideo)
148 .skip(1)
149 .filter_map(slot)
150 .take(RECEIVE_SLOTS)
151 .collect();
152 let screen = streams.iter().find(|stream| stream.role == LineRole::ScreenShare).and_then(slot);
153 SlotTable { people, screen }
154 }
155
156 pub fn is_empty(&self) -> bool {
157 self.people.is_empty() && self.screen.is_none()
158 }
159}
160
161#[derive(Debug, Clone, PartialEq, Eq)]
162pub struct Assignment {
163 pub mri: String,
164 pub source: u32,
165}
166
167pub fn plan_receive(current: &[Option<Assignment>], candidates: &[Assignment]) -> Vec<Option<Assignment>> {
168 let wanted: Vec<&Assignment> = candidates.iter().take(current.len()).collect();
169 let mut next: Vec<Option<Assignment>> = current
170 .iter()
171 .map(|slot| slot.clone().filter(|held| wanted.contains(&held)))
172 .collect();
173 for assignment in wanted {
174 if next.iter().flatten().any(|held| held == assignment) {
175 continue;
176 }
177 if let Some(free) = next.iter_mut().find(|slot| slot.is_none()) {
178 *free = Some(assignment.clone());
179 }
180 }
181 next
182}
183
184pub fn prioritize(candidates: Vec<(String, u32)>, speaker_history: &[String]) -> Vec<Assignment> {
185 let rank = |mri: &str| speaker_history.iter().position(|speaker| speaker == mri).unwrap_or(usize::MAX);
186 let mut ordered: Vec<Assignment> = candidates
187 .into_iter()
188 .map(|(mri, source)| Assignment { mri, source })
189 .collect();
190 ordered.sort_by_key(|assignment| rank(&assignment.mri));
191 ordered
192}
193
194#[derive(Debug, Clone, PartialEq, Eq)]
195pub struct SourceRequest {
196 pub mid: String,
197 pub stream_id: u32,
198 pub source: Option<u32>,
199 pub screen: bool,
200}
201
202pub fn requests_for(
203 current: &[Option<Assignment>],
204 next: &[Option<Assignment>],
205 slots: &[ReceiveSlot],
206) -> Vec<SourceRequest> {
207 slots
208 .iter()
209 .zip(current.iter().zip(next))
210 .filter(|(_, (before, after))| before != after)
211 .map(|(slot, (_, after))| SourceRequest {
212 mid: slot.mid.clone(),
213 stream_id: slot.stream_id,
214 source: after.as_ref().map(|assignment| assignment.source),
215 screen: false,
216 })
217 .collect()
218}
219
220impl SourceRequest {
221 /// Body of the `applyChannelParameters` link, the signaling twin of the data-channel `sr` message.
222 pub fn body(&self, sequence_number: u64) -> Value {
223 let limits = if self.screen { SCREEN_REQUEST } else { PERSON_REQUEST };
224 let control = json!({
225 "controlVideoStreaming": {
226 "sequenceNumber": sequence_number,
227 "controlInfo": {
228 "sourceId": self.source.map_or(NO_SOURCE, i64::from),
229 "streamMsid": self.stream_id,
230 "fmtParams": [{
231 "max-fs": limits.max_fs,
232 "max-mbps": limits.max_mbps,
233 "max-fps": limits.max_fps,
234 "profile-level-id": SUBSCRIBE_PROFILE,
235 }],
236 },
237 },
238 });
239 json!({
240 "applyChannelParameters": {
241 "multiChannelParameter": {
242 "mids": [self.mid],
243 "mediaParameter": control.to_string(),
244 },
245 },
246 })
247 }
248}
249
250#[derive(Clone, Default)]
251pub struct VideoRouter {
252 keys: Arc<Mutex<HashMap<String, VideoKey>>>,
253}
254
255impl VideoRouter {
256 pub fn set(&self, mid: &str, key: Option<VideoKey>) {
257 let mut keys = self.keys.lock().expect("router lock");
258 match key {
259 Some(key) => keys.insert(mid.to_owned(), key),
260 None => keys.remove(mid),
261 };
262 }
263
264 pub fn key_for(&self, mid: &str) -> Option<VideoKey> {
265 self.keys.lock().expect("router lock").get(mid).cloned()
266 }
267}
268
269#[cfg(test)]
270mod tests {
271 use super::*;
272
273 fn assignment(name: &str, source: u32) -> Assignment {
274 Assignment { mri: format!("8:orgid:{name}"), source }
275 }
276
277 fn stream(mid: &str, role: LineRole, id: Option<u32>) -> StreamLine {
278 StreamLine { mid: mid.into(), browser_mid: mid.into(), role, source_stream_id: id }
279 }
280
281 #[test]
282 fn slots_are_the_main_video_lines_after_the_camera_line() {
283 let streams = vec![
284 stream("0", LineRole::MainAudio, Some(201)),
285 stream("1", LineRole::MainVideo, Some(202)),
286 stream("2", LineRole::MainVideo, Some(203)),
287 stream("3", LineRole::MainVideo, Some(204)),
288 stream("4", LineRole::MainVideo, None),
289 stream("5", LineRole::MainVideo, Some(206)),
290 stream("6", LineRole::ScreenShare, Some(207)),
291 ];
292 let table = SlotTable::from_streams(&streams);
293 let mids: Vec<&str> = table.people.iter().map(|slot| slot.mid.as_str()).collect();
294 assert_eq!(mids, vec!["2", "3", "5"]);
295 assert_eq!(table.screen, Some(ReceiveSlot { mid: "6".into(), stream_id: 207 }));
296 }
297
298 #[test]
299 fn nobody_is_dropped_while_they_are_still_wanted() {
300 let held = vec![Some(assignment("a", 1)), Some(assignment("b", 2)), None, None];
301 let candidates = vec![assignment("c", 3), assignment("a", 1), assignment("b", 2)];
302 let next = plan_receive(&held, &candidates);
303 assert_eq!(next[0], Some(assignment("a", 1)));
304 assert_eq!(next[1], Some(assignment("b", 2)));
305 assert_eq!(next[2], Some(assignment("c", 3)));
306 assert_eq!(next[3], None);
307 }
308
309 #[test]
310 fn a_new_speaker_replaces_the_least_recent_person() {
311 let held: Vec<Option<Assignment>> = (1..=4).map(|index| Some(assignment(&format!("p{index}"), index))).collect();
312 let history = vec!["8:orgid:p5".to_owned(), "8:orgid:p1".to_owned(), "8:orgid:p2".to_owned(), "8:orgid:p3".to_owned()];
313 let roster = (1..=5).map(|index| (format!("8:orgid:p{index}"), index)).collect();
314 let next = plan_receive(&held, &prioritize(roster, &history));
315 let names: Vec<&str> = next.iter().flatten().map(|held| held.mri.as_str()).collect();
316 assert_eq!(names, vec!["8:orgid:p1", "8:orgid:p2", "8:orgid:p3", "8:orgid:p5"]);
317 }
318
319 #[test]
320 fn people_who_left_free_their_slot() {
321 let held = vec![Some(assignment("a", 1)), Some(assignment("b", 2))];
322 let next = plan_receive(&held, &[assignment("b", 2)]);
323 assert_eq!(next, vec![None, Some(assignment("b", 2))]);
324 let slots = vec![
325 ReceiveSlot { mid: "2".into(), stream_id: 203 },
326 ReceiveSlot { mid: "3".into(), stream_id: 204 },
327 ];
328 let requests = requests_for(&held, &next, &slots);
329 assert_eq!(requests, vec![SourceRequest { mid: "2".into(), stream_id: 203, source: None, screen: false }]);
330 }
331
332 #[test]
333 fn a_source_request_wraps_the_control_message_like_the_web_client() {
334 let request = SourceRequest { mid: "3".into(), stream_id: 204, source: Some(302), screen: false };
335 let body = request.body(7);
336 let channel = &body["applyChannelParameters"]["multiChannelParameter"];
337 assert_eq!(channel["mids"], json!(["3"]));
338 let parameter: Value = serde_json::from_str(channel["mediaParameter"].as_str().unwrap()).unwrap();
339 let info = &parameter["controlVideoStreaming"]["controlInfo"];
340 assert_eq!(parameter["controlVideoStreaming"]["sequenceNumber"], 7);
341 assert_eq!(info["sourceId"], 302);
342 assert_eq!(info["streamMsid"], 204);
343 assert_eq!(info["fmtParams"][0]["max-fs"], 3600);
344 assert_eq!(info["fmtParams"][0]["max-fps"], 3000);
345 assert_eq!(info["fmtParams"][0]["profile-level-id"], "64001f");
346 let cleared = SourceRequest { source: None, ..request.clone() }.body(8);
347 let parameter: Value =
348 serde_json::from_str(cleared["applyChannelParameters"]["multiChannelParameter"]["mediaParameter"].as_str().unwrap()).unwrap();
349 assert_eq!(parameter["controlVideoStreaming"]["controlInfo"]["sourceId"], -1);
350 let screen = SourceRequest { screen: true, ..request }.body(9);
351 let parameter: Value =
352 serde_json::from_str(screen["applyChannelParameters"]["multiChannelParameter"]["mediaParameter"].as_str().unwrap()).unwrap();
353 assert_eq!(parameter["controlVideoStreaming"]["controlInfo"]["fmtParams"][0]["max-fs"], 8160);
354 }
355
356 #[test]
357 fn media_descriptions_tell_the_mixer_what_a_line_does() {
358 assert_eq!(
359 MediaDescription::camera(true).wire(),
360 json!({"mid": "1", "direction": "sendrecv", "label": "main-video"})
361 );
362 assert_eq!(MediaDescription::camera(false).wire(), json!({"mid": "1", "direction": "recvonly"}));
363 assert_eq!(
364 MediaDescription::share(true).wire(),
365 json!({"mid": "6", "direction": "sendrecv", "label": "applicationsharing-video"})
366 );
367 }
368
369 #[test]
370 fn the_router_follows_assignments() {
371 let router = VideoRouter::default();
372 assert_eq!(router.key_for("2"), None);
373 router.set("2", Some(VideoKey::Person("8:orgid:a".into())));
374 assert_eq!(router.key_for("2"), Some(VideoKey::Person("8:orgid:a".into())));
375 router.set("2", None);
376 assert_eq!(router.key_for("2"), None);
377 }
378}
crates/calling/src/video_pattern.rs added +140 −0
@@ -0,0 +1,140 @@
1 use std::time::Duration;
2
3 use libwebrtc::video_frame::I420Buffer;
4 use tokio::task::JoinHandle;
5 use tokio::time::interval;
6
7 use crate::video_send::LocalSink;
8
9 pub const CAMERA_WIDTH: u32 = 640;
10 pub const CAMERA_HEIGHT: u32 = 360;
11 pub const SCREEN_WIDTH: u32 = 1280;
12 pub const SCREEN_HEIGHT: u32 = 720;
13 const SQUARE: u32 = 64;
14 const BLOCK_ROWS: u32 = 6;
15
16 #[derive(Debug, Clone, Copy, PartialEq, Eq)]
17 pub enum PatternKind {
18 Camera,
19 Screen,
20 }
21
22 impl PatternKind {
23 pub fn size(self) -> (u32, u32) {
24 match self {
25 PatternKind::Camera => (CAMERA_WIDTH, CAMERA_HEIGHT),
26 PatternKind::Screen => (SCREEN_WIDTH, SCREEN_HEIGHT),
27 }
28 }
29
30 pub fn fps(self) -> u32 {
31 match self {
32 PatternKind::Camera => 30,
33 PatternKind::Screen => 15,
34 }
35 }
36 }
37
38 /// A moving test picture: no real camera or screen is ever read.
39 pub fn pattern_frame(kind: PatternKind, tick: u32) -> I420Buffer {
40 let (width, height) = kind.size();
41 let mut buffer = I420Buffer::new(width, height);
42 let (stride_y, stride_u, stride_v) = buffer.strides();
43 let (y_plane, u_plane, v_plane) = buffer.data_mut();
44 match kind {
45 PatternKind::Camera => paint_camera(y_plane, u_plane, v_plane, (width, height), (stride_y, stride_u, stride_v), tick),
46 PatternKind::Screen => paint_screen(y_plane, u_plane, v_plane, (width, height), (stride_y, stride_u, stride_v), tick),
47 }
48 buffer
49 }
50
51 fn paint_camera(
52 y_plane: &mut [u8],
53 u_plane: &mut [u8],
54 v_plane: &mut [u8],
55 (width, height): (u32, u32),
56 (stride_y, stride_u, stride_v): (u32, u32, u32),
57 tick: u32,
58 ) {
59 let square_x = (tick * 6) % (width - SQUARE);
60 let square_y = (tick * 4) % (height - SQUARE);
61 for row in 0..height {
62 for column in 0..width {
63 let inside = column >= square_x && column < square_x + SQUARE && row >= square_y && row < square_y + SQUARE;
64 let shade = ((column + tick * 3) * 255 / width) as u8;
65 y_plane[(row * stride_y + column) as usize] = if inside { 235 } else { shade / 2 + 24 };
66 }
67 }
68 for row in 0..height / 2 {
69 for column in 0..width / 2 {
70 u_plane[(row * stride_u + column) as usize] = (64 + (column * 128 / (width / 2)) as u8).wrapping_add((tick * 2) as u8 / 4);
71 v_plane[(row * stride_v + column) as usize] = (192 - (row * 128 / (height / 2)) as u8).wrapping_add((tick % 64) as u8);
72 }
73 }
74 }
75
76 fn paint_screen(
77 y_plane: &mut [u8],
78 u_plane: &mut [u8],
79 v_plane: &mut [u8],
80 (width, height): (u32, u32),
81 (stride_y, stride_u, stride_v): (u32, u32, u32),
82 tick: u32,
83 ) {
84 let band = height / BLOCK_ROWS;
85 let cursor_x = (tick * 9) % (width - SQUARE / 2);
86 let cursor_y = (tick * 5) % (height - SQUARE / 2);
87 for row in 0..height {
88 for column in 0..width {
89 let on_cursor = column >= cursor_x && column < cursor_x + SQUARE / 2 && row >= cursor_y && row < cursor_y + SQUARE / 2;
90 let line = (row / 18) % 2 == 0 && column % 11 < 7 && column > 40 && column < width - 40;
91 let title_bar = row < 40;
92 y_plane[(row * stride_y + column) as usize] = match (on_cursor, title_bar, line) {
93 (true, _, _) => 235,
94 (_, true, _) => 60,
95 (_, _, true) => 40,
96 _ => 225 - (row / band * 6) as u8,
97 };
98 }
99 }
100 u_plane[..(stride_u * height / 2) as usize].fill(128);
101 v_plane[..(stride_v * height / 2) as usize].fill(128);
102 }
103
104 pub fn spawn_pattern(mut sink: LocalSink, kind: PatternKind) -> JoinHandle<()> {
105 tokio::spawn(async move {
106 let mut ticker = interval(Duration::from_secs(1) / kind.fps());
107 let mut tick = 0u32;
108 loop {
109 ticker.tick().await;
110 sink.push(pattern_frame(kind, tick));
111 tick = tick.wrapping_add(1);
112 }
113 })
114 }
115
116 #[cfg(test)]
117 mod tests {
118 use super::*;
119
120 fn luma_checksum(kind: PatternKind, tick: u32) -> u64 {
121 let buffer = pattern_frame(kind, tick);
122 buffer.data().0.iter().map(|&value| u64::from(value)).sum()
123 }
124
125 #[test]
126 fn the_camera_pattern_moves_between_frames() {
127 assert_ne!(luma_checksum(PatternKind::Camera, 0), luma_checksum(PatternKind::Camera, 9));
128 }
129
130 #[test]
131 fn the_screen_pattern_moves_between_frames() {
132 assert_ne!(luma_checksum(PatternKind::Screen, 0), luma_checksum(PatternKind::Screen, 4));
133 }
134
135 #[test]
136 fn patterns_have_the_documented_sizes() {
137 assert_eq!(pattern_frame(PatternKind::Camera, 1).strides().0, CAMERA_WIDTH);
138 assert_eq!(PatternKind::Screen.size(), (SCREEN_WIDTH, SCREEN_HEIGHT));
139 }
140 }
@@ -0,0 +1,140 @@
1use std::time::Duration;
2
3use libwebrtc::video_frame::I420Buffer;
4use tokio::task::JoinHandle;
5use tokio::time::interval;
6
7use crate::video_send::LocalSink;
8
9pub const CAMERA_WIDTH: u32 = 640;
10pub const CAMERA_HEIGHT: u32 = 360;
11pub const SCREEN_WIDTH: u32 = 1280;
12pub const SCREEN_HEIGHT: u32 = 720;
13const SQUARE: u32 = 64;
14const BLOCK_ROWS: u32 = 6;
15
16#[derive(Debug, Clone, Copy, PartialEq, Eq)]
17pub enum PatternKind {
18 Camera,
19 Screen,
20}
21
22impl PatternKind {
23 pub fn size(self) -> (u32, u32) {
24 match self {
25 PatternKind::Camera => (CAMERA_WIDTH, CAMERA_HEIGHT),
26 PatternKind::Screen => (SCREEN_WIDTH, SCREEN_HEIGHT),
27 }
28 }
29
30 pub fn fps(self) -> u32 {
31 match self {
32 PatternKind::Camera => 30,
33 PatternKind::Screen => 15,
34 }
35 }
36}
37
38/// A moving test picture: no real camera or screen is ever read.
39pub fn pattern_frame(kind: PatternKind, tick: u32) -> I420Buffer {
40 let (width, height) = kind.size();
41 let mut buffer = I420Buffer::new(width, height);
42 let (stride_y, stride_u, stride_v) = buffer.strides();
43 let (y_plane, u_plane, v_plane) = buffer.data_mut();
44 match kind {
45 PatternKind::Camera => paint_camera(y_plane, u_plane, v_plane, (width, height), (stride_y, stride_u, stride_v), tick),
46 PatternKind::Screen => paint_screen(y_plane, u_plane, v_plane, (width, height), (stride_y, stride_u, stride_v), tick),
47 }
48 buffer
49}
50
51fn paint_camera(
52 y_plane: &mut [u8],
53 u_plane: &mut [u8],
54 v_plane: &mut [u8],
55 (width, height): (u32, u32),
56 (stride_y, stride_u, stride_v): (u32, u32, u32),
57 tick: u32,
58) {
59 let square_x = (tick * 6) % (width - SQUARE);
60 let square_y = (tick * 4) % (height - SQUARE);
61 for row in 0..height {
62 for column in 0..width {
63 let inside = column >= square_x && column < square_x + SQUARE && row >= square_y && row < square_y + SQUARE;
64 let shade = ((column + tick * 3) * 255 / width) as u8;
65 y_plane[(row * stride_y + column) as usize] = if inside { 235 } else { shade / 2 + 24 };
66 }
67 }
68 for row in 0..height / 2 {
69 for column in 0..width / 2 {
70 u_plane[(row * stride_u + column) as usize] = (64 + (column * 128 / (width / 2)) as u8).wrapping_add((tick * 2) as u8 / 4);
71 v_plane[(row * stride_v + column) as usize] = (192 - (row * 128 / (height / 2)) as u8).wrapping_add((tick % 64) as u8);
72 }
73 }
74}
75
76fn paint_screen(
77 y_plane: &mut [u8],
78 u_plane: &mut [u8],
79 v_plane: &mut [u8],
80 (width, height): (u32, u32),
81 (stride_y, stride_u, stride_v): (u32, u32, u32),
82 tick: u32,
83) {
84 let band = height / BLOCK_ROWS;
85 let cursor_x = (tick * 9) % (width - SQUARE / 2);
86 let cursor_y = (tick * 5) % (height - SQUARE / 2);
87 for row in 0..height {
88 for column in 0..width {
89 let on_cursor = column >= cursor_x && column < cursor_x + SQUARE / 2 && row >= cursor_y && row < cursor_y + SQUARE / 2;
90 let line = (row / 18) % 2 == 0 && column % 11 < 7 && column > 40 && column < width - 40;
91 let title_bar = row < 40;
92 y_plane[(row * stride_y + column) as usize] = match (on_cursor, title_bar, line) {
93 (true, _, _) => 235,
94 (_, true, _) => 60,
95 (_, _, true) => 40,
96 _ => 225 - (row / band * 6) as u8,
97 };
98 }
99 }
100 u_plane[..(stride_u * height / 2) as usize].fill(128);
101 v_plane[..(stride_v * height / 2) as usize].fill(128);
102}
103
104pub fn spawn_pattern(mut sink: LocalSink, kind: PatternKind) -> JoinHandle<()> {
105 tokio::spawn(async move {
106 let mut ticker = interval(Duration::from_secs(1) / kind.fps());
107 let mut tick = 0u32;
108 loop {
109 ticker.tick().await;
110 sink.push(pattern_frame(kind, tick));
111 tick = tick.wrapping_add(1);
112 }
113 })
114}
115
116#[cfg(test)]
117mod tests {
118 use super::*;
119
120 fn luma_checksum(kind: PatternKind, tick: u32) -> u64 {
121 let buffer = pattern_frame(kind, tick);
122 buffer.data().0.iter().map(|&value| u64::from(value)).sum()
123 }
124
125 #[test]
126 fn the_camera_pattern_moves_between_frames() {
127 assert_ne!(luma_checksum(PatternKind::Camera, 0), luma_checksum(PatternKind::Camera, 9));
128 }
129
130 #[test]
131 fn the_screen_pattern_moves_between_frames() {
132 assert_ne!(luma_checksum(PatternKind::Screen, 0), luma_checksum(PatternKind::Screen, 4));
133 }
134
135 #[test]
136 fn patterns_have_the_documented_sizes() {
137 assert_eq!(pattern_frame(PatternKind::Camera, 1).strides().0, CAMERA_WIDTH);
138 assert_eq!(PatternKind::Screen.size(), (SCREEN_WIDTH, SCREEN_HEIGHT));
139 }
140}
crates/calling/src/video_receive.rs added +192 −0
@@ -0,0 +1,192 @@
1 use std::collections::HashMap;
2 use std::sync::Arc;
3 use std::sync::atomic::{AtomicU64, Ordering};
4 use std::time::Instant;
5
6 use futures_util::StreamExt;
7 use libwebrtc::video_stream::native::NativeVideoStream;
8 use libwebrtc::video_track::RtcVideoTrack;
9 use tokio::sync::mpsc;
10 use tokio::task::JoinHandle;
11
12 use crate::roster::Roster;
13 use crate::signaling::Signaling;
14 use crate::timeline::Timeline;
15 use crate::video_frame::{FrameGate, VideoHub, VideoKey, picture_from_frame};
16 use crate::video_layout::{
17 Assignment, SlotTable, SourceRequest, VideoRouter, plan_receive, prioritize, requests_for,
18 };
19
20 const HISTORY_LIMIT: usize = 16;
21 const REQUEST_LABEL: &str = "POST applyChannelParameters";
22
23 #[derive(Default)]
24 pub struct VideoCounters {
25 pub received: AtomicU64,
26 pub published: AtomicU64,
27 }
28
29 pub fn spawn_video_pump(
30 track: RtcVideoTrack,
31 mid: String,
32 router: VideoRouter,
33 hub: Arc<VideoHub>,
34 counters: Arc<VideoCounters>,
35 ) -> JoinHandle<()> {
36 tokio::spawn(async move {
37 let mut stream = NativeVideoStream::new(track);
38 let mut gates: HashMap<VideoKey, FrameGate> = HashMap::new();
39 while let Some(frame) = stream.next().await {
40 counters.received.fetch_add(1, Ordering::Relaxed);
41 let Some(key) = router.key_for(&mid) else { continue };
42 let gate = gates.entry(key.clone()).or_insert_with(|| FrameGate::new(key.max_fps()));
43 if !gate.admit(Instant::now()) {
44 continue;
45 }
46 let Some(picture) = picture_from_frame(frame, key.max_width()) else { continue };
47 counters.published.fetch_add(1, Ordering::Relaxed);
48 hub.publish(key, picture);
49 }
50 })
51 }
52
53 struct QueuedRequest {
54 request: SourceRequest,
55 route_after: Option<VideoKey>,
56 }
57
58 /// Sends source requests one at a time so their sequence numbers stay in order.
59 pub struct SourceRequester {
60 queue: mpsc::UnboundedSender<QueuedRequest>,
61 task: JoinHandle<()>,
62 }
63
64 impl SourceRequester {
65 pub fn start(signaling: Arc<Signaling>, url: String, router: VideoRouter, hub: Arc<VideoHub>, timeline: Timeline) -> Self {
66 let (queue, mut requests) = mpsc::unbounded_channel::<QueuedRequest>();
67 let task = tokio::spawn(async move {
68 let mut sequence_number = 0u64;
69 while let Some(queued) = requests.recv().await {
70 sequence_number += 1;
71 let body = queued.request.body(sequence_number);
72 match signaling.post_json(REQUEST_LABEL, &url, body).await {
73 Ok(()) => timeline.record(
74 "video source",
75 format!("mid {} source {:?} accepted", queued.request.mid, queued.request.source),
76 ),
77 Err(error) => timeline.record("video source failed", error.to_string()),
78 }
79 if let Some(key) = &queued.route_after {
80 hub.forget(key);
81 }
82 router.set(&queued.request.mid, queued.route_after);
83 }
84 });
85 SourceRequester { queue, task }
86 }
87
88 fn send(&self, request: SourceRequest, route_after: Option<VideoKey>) {
89 let _ = self.queue.send(QueuedRequest { request, route_after });
90 }
91
92 }
93
94 impl Drop for SourceRequester {
95 fn drop(&mut self) {
96 self.task.abort();
97 }
98 }
99
100 #[derive(Debug, Clone, Default, PartialEq, Eq)]
101 pub struct ReceiveChange {
102 pub screen_sharer: Option<Option<String>>,
103 }
104
105 pub struct VideoReceive {
106 own_mri: String,
107 router: VideoRouter,
108 table: SlotTable,
109 held: Vec<Option<Assignment>>,
110 screen_held: Option<Assignment>,
111 history: Vec<String>,
112 requester: Option<SourceRequester>,
113 }
114
115 impl VideoReceive {
116 pub fn new(own_mri: String, router: VideoRouter) -> Self {
117 VideoReceive {
118 own_mri,
119 router,
120 table: SlotTable::default(),
121 held: Vec::new(),
122 screen_held: None,
123 history: Vec::new(),
124 requester: None,
125 }
126 }
127
128 pub fn router(&self) -> &VideoRouter {
129 &self.router
130 }
131
132 pub fn negotiated(&mut self, table: SlotTable, requester: Option<SourceRequester>) {
133 self.requester = requester;
134 self.held = vec![None; table.people.len()];
135 self.screen_held = None;
136 self.table = table;
137 }
138
139 pub fn is_ready(&self) -> bool {
140 self.requester.is_some() && !self.table.is_empty()
141 }
142
143 pub fn note_speakers(&mut self, speakers: &[String]) -> bool {
144 let Some(first) = speakers.iter().find(|mri| **mri != self.own_mri) else {
145 return false;
146 };
147 if self.history.first() == Some(first) {
148 return false;
149 }
150 self.history.retain(|mri| mri != first);
151 self.history.insert(0, first.clone());
152 self.history.truncate(HISTORY_LIMIT);
153 true
154 }
155
156 pub fn reselect(&mut self, roster: &Roster) -> ReceiveChange {
157 let mut change = ReceiveChange::default();
158 let Some(requester) = &self.requester else { return change };
159 let candidates = prioritize(roster.video_candidates(&self.own_mri), &self.history);
160 let next = plan_receive(&self.held, &candidates);
161 for request in requests_for(&self.held, &next, &self.table.people) {
162 let slot = self.table.people.iter().position(|slot| slot.mid == request.mid);
163 let route_after = slot
164 .and_then(|index| next[index].as_ref())
165 .map(|assignment| VideoKey::Person(assignment.mri.clone()));
166 self.router.set(&request.mid, None);
167 requester.send(request, route_after);
168 }
169 self.held = next;
170 if let Some(slot) = &self.table.screen {
171 let wanted = roster
172 .screen_share(&self.own_mri)
173 .map(|(mri, source)| Assignment { mri, source });
174 if wanted != self.screen_held {
175 let route_after = wanted.as_ref().map(|_| VideoKey::Screen);
176 self.router.set(&slot.mid, None);
177 requester.send(
178 SourceRequest {
179 mid: slot.mid.clone(),
180 stream_id: slot.stream_id,
181 source: wanted.as_ref().map(|assignment| assignment.source),
182 screen: true,
183 },
184 route_after,
185 );
186 change.screen_sharer = Some(wanted.as_ref().map(|assignment| assignment.mri.clone()));
187 self.screen_held = wanted;
188 }
189 }
190 change
191 }
192 }
@@ -0,0 +1,192 @@
1use std::collections::HashMap;
2use std::sync::Arc;
3use std::sync::atomic::{AtomicU64, Ordering};
4use std::time::Instant;
5
6use futures_util::StreamExt;
7use libwebrtc::video_stream::native::NativeVideoStream;
8use libwebrtc::video_track::RtcVideoTrack;
9use tokio::sync::mpsc;
10use tokio::task::JoinHandle;
11
12use crate::roster::Roster;
13use crate::signaling::Signaling;
14use crate::timeline::Timeline;
15use crate::video_frame::{FrameGate, VideoHub, VideoKey, picture_from_frame};
16use crate::video_layout::{
17 Assignment, SlotTable, SourceRequest, VideoRouter, plan_receive, prioritize, requests_for,
18};
19
20const HISTORY_LIMIT: usize = 16;
21const REQUEST_LABEL: &str = "POST applyChannelParameters";
22
23#[derive(Default)]
24pub struct VideoCounters {
25 pub received: AtomicU64,
26 pub published: AtomicU64,
27}
28
29pub fn spawn_video_pump(
30 track: RtcVideoTrack,
31 mid: String,
32 router: VideoRouter,
33 hub: Arc<VideoHub>,
34 counters: Arc<VideoCounters>,
35) -> JoinHandle<()> {
36 tokio::spawn(async move {
37 let mut stream = NativeVideoStream::new(track);
38 let mut gates: HashMap<VideoKey, FrameGate> = HashMap::new();
39 while let Some(frame) = stream.next().await {
40 counters.received.fetch_add(1, Ordering::Relaxed);
41 let Some(key) = router.key_for(&mid) else { continue };
42 let gate = gates.entry(key.clone()).or_insert_with(|| FrameGate::new(key.max_fps()));
43 if !gate.admit(Instant::now()) {
44 continue;
45 }
46 let Some(picture) = picture_from_frame(frame, key.max_width()) else { continue };
47 counters.published.fetch_add(1, Ordering::Relaxed);
48 hub.publish(key, picture);
49 }
50 })
51}
52
53struct QueuedRequest {
54 request: SourceRequest,
55 route_after: Option<VideoKey>,
56}
57
58/// Sends source requests one at a time so their sequence numbers stay in order.
59pub struct SourceRequester {
60 queue: mpsc::UnboundedSender<QueuedRequest>,
61 task: JoinHandle<()>,
62}
63
64impl SourceRequester {
65 pub fn start(signaling: Arc<Signaling>, url: String, router: VideoRouter, hub: Arc<VideoHub>, timeline: Timeline) -> Self {
66 let (queue, mut requests) = mpsc::unbounded_channel::<QueuedRequest>();
67 let task = tokio::spawn(async move {
68 let mut sequence_number = 0u64;
69 while let Some(queued) = requests.recv().await {
70 sequence_number += 1;
71 let body = queued.request.body(sequence_number);
72 match signaling.post_json(REQUEST_LABEL, &url, body).await {
73 Ok(()) => timeline.record(
74 "video source",
75 format!("mid {} source {:?} accepted", queued.request.mid, queued.request.source),
76 ),
77 Err(error) => timeline.record("video source failed", error.to_string()),
78 }
79 if let Some(key) = &queued.route_after {
80 hub.forget(key);
81 }
82 router.set(&queued.request.mid, queued.route_after);
83 }
84 });
85 SourceRequester { queue, task }
86 }
87
88 fn send(&self, request: SourceRequest, route_after: Option<VideoKey>) {
89 let _ = self.queue.send(QueuedRequest { request, route_after });
90 }
91
92}
93
94impl Drop for SourceRequester {
95 fn drop(&mut self) {
96 self.task.abort();
97 }
98}
99
100#[derive(Debug, Clone, Default, PartialEq, Eq)]
101pub struct ReceiveChange {
102 pub screen_sharer: Option<Option<String>>,
103}
104
105pub struct VideoReceive {
106 own_mri: String,
107 router: VideoRouter,
108 table: SlotTable,
109 held: Vec<Option<Assignment>>,
110 screen_held: Option<Assignment>,
111 history: Vec<String>,
112 requester: Option<SourceRequester>,
113}
114
115impl VideoReceive {
116 pub fn new(own_mri: String, router: VideoRouter) -> Self {
117 VideoReceive {
118 own_mri,
119 router,
120 table: SlotTable::default(),
121 held: Vec::new(),
122 screen_held: None,
123 history: Vec::new(),
124 requester: None,
125 }
126 }
127
128 pub fn router(&self) -> &VideoRouter {
129 &self.router
130 }
131
132 pub fn negotiated(&mut self, table: SlotTable, requester: Option<SourceRequester>) {
133 self.requester = requester;
134 self.held = vec![None; table.people.len()];
135 self.screen_held = None;
136 self.table = table;
137 }
138
139 pub fn is_ready(&self) -> bool {
140 self.requester.is_some() && !self.table.is_empty()
141 }
142
143 pub fn note_speakers(&mut self, speakers: &[String]) -> bool {
144 let Some(first) = speakers.iter().find(|mri| **mri != self.own_mri) else {
145 return false;
146 };
147 if self.history.first() == Some(first) {
148 return false;
149 }
150 self.history.retain(|mri| mri != first);
151 self.history.insert(0, first.clone());
152 self.history.truncate(HISTORY_LIMIT);
153 true
154 }
155
156 pub fn reselect(&mut self, roster: &Roster) -> ReceiveChange {
157 let mut change = ReceiveChange::default();
158 let Some(requester) = &self.requester else { return change };
159 let candidates = prioritize(roster.video_candidates(&self.own_mri), &self.history);
160 let next = plan_receive(&self.held, &candidates);
161 for request in requests_for(&self.held, &next, &self.table.people) {
162 let slot = self.table.people.iter().position(|slot| slot.mid == request.mid);
163 let route_after = slot
164 .and_then(|index| next[index].as_ref())
165 .map(|assignment| VideoKey::Person(assignment.mri.clone()));
166 self.router.set(&request.mid, None);
167 requester.send(request, route_after);
168 }
169 self.held = next;
170 if let Some(slot) = &self.table.screen {
171 let wanted = roster
172 .screen_share(&self.own_mri)
173 .map(|(mri, source)| Assignment { mri, source });
174 if wanted != self.screen_held {
175 let route_after = wanted.as_ref().map(|_| VideoKey::Screen);
176 self.router.set(&slot.mid, None);
177 requester.send(
178 SourceRequest {
179 mid: slot.mid.clone(),
180 stream_id: slot.stream_id,
181 source: wanted.as_ref().map(|assignment| assignment.source),
182 screen: true,
183 },
184 route_after,
185 );
186 change.screen_sharer = Some(wanted.as_ref().map(|assignment| assignment.mri.clone()));
187 self.screen_held = wanted;
188 }
189 }
190 change
191 }
192}
crates/calling/src/video_send.rs added +230 −0
@@ -0,0 +1,230 @@
1 use std::sync::Arc;
2 use std::time::{Instant, SystemTime, UNIX_EPOCH};
3
4 use libwebrtc::media_stream_track::MediaStreamTrack;
5 use libwebrtc::peer_connection_factory::PeerConnectionFactory;
6 use libwebrtc::rtp_sender::RtpSender;
7 use libwebrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
8 use libwebrtc::video_frame::{I420Buffer, VideoFrame, VideoRotation};
9 use libwebrtc::video_source::VideoResolution;
10 use libwebrtc::video_source::native::NativeVideoSource;
11 use libwebrtc::video_track::RtcVideoTrack;
12 use tokio::sync::mpsc::UnboundedSender;
13
14 use crate::camera::start_camera;
15 use crate::capture::Capture;
16 use crate::control::CallUpdate;
17 use crate::devices::DeviceChoice;
18 use crate::error::{Error, Result};
19 use crate::screen::{ShareSource, start_screen_capture};
20 use crate::video_frame::{FrameGate, SCREEN_FPS, VideoHub, VideoKey, picture_from_i420};
21 use crate::video_layout::VideoLines;
22 use crate::video_pattern::{PatternKind, spawn_pattern};
23
24 pub const VIDEO_MODE_ENV: &str = "CALLING_VIDEO";
25 const CAMERA_LABEL: &str = "camera";
26 const SCREEN_LABEL: &str = "screen";
27 const SELF_VIEW_FPS: u32 = 15;
28
29 #[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
30 pub enum VideoMode {
31 #[default]
32 Platform,
33 Pattern,
34 Off,
35 }
36
37 impl VideoMode {
38 pub fn from_env() -> Self {
39 Self::parse(std::env::var(VIDEO_MODE_ENV).ok().as_deref())
40 }
41
42 pub fn parse(value: Option<&str>) -> Self {
43 match value.map(str::to_ascii_lowercase).as_deref() {
44 Some("pattern") => VideoMode::Pattern,
45 Some("off") => VideoMode::Off,
46 _ => VideoMode::Platform,
47 }
48 }
49 }
50
51 /// Where a captured frame goes: the encoder source and, for the self view, the UI hub.
52 pub struct LocalSink {
53 source: NativeVideoSource,
54 self_view: Option<(Arc<VideoHub>, VideoKey, FrameGate)>,
55 }
56
57 impl LocalSink {
58 pub fn new(source: NativeVideoSource, hub: Option<(Arc<VideoHub>, VideoKey)>) -> Self {
59 let self_view = hub.map(|(hub, key)| {
60 let fps = if matches!(key, VideoKey::LocalScreen) { SCREEN_FPS } else { SELF_VIEW_FPS };
61 (hub, key, FrameGate::new(fps))
62 });
63 LocalSink { source, self_view }
64 }
65
66 pub fn push(&mut self, buffer: I420Buffer) {
67 let mut frame = VideoFrame::new(VideoRotation::VideoRotation0, buffer);
68 frame.timestamp_us = SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |elapsed| elapsed.as_micros() as i64);
69 self.source.capture_frame(&frame);
70 let Some((hub, key, gate)) = &mut self.self_view else { return };
71 if gate.admit(Instant::now())
72 && let Some(picture) = picture_from_i420(frame.buffer, key.max_width())
73 {
74 hub.publish(key.clone(), picture);
75 }
76 }
77 }
78
79 struct Outgoing {
80 source: NativeVideoSource,
81 track: RtcVideoTrack,
82 capture: Option<Capture>,
83 }
84
85 impl Outgoing {
86 fn new(factory: &PeerConnectionFactory, label: &str, kind: PatternKind, screencast: bool) -> Self {
87 let (width, height) = kind.size();
88 let source = NativeVideoSource::new(VideoResolution { width, height }, screencast);
89 let track = factory.create_video_track(label, source.clone());
90 Outgoing { source, track, capture: None }
91 }
92 }
93
94 /// Camera and screen share of the local user; frames come from devices or a generated pattern.
95 pub struct LocalVideo {
96 mode: VideoMode,
97 hub: Arc<VideoHub>,
98 updates: UnboundedSender<CallUpdate>,
99 camera: Outgoing,
100 screen: Outgoing,
101 lines: Option<VideoLines>,
102 }
103
104 impl LocalVideo {
105 pub fn new(factory: &PeerConnectionFactory, mode: VideoMode, hub: Arc<VideoHub>, updates: UnboundedSender<CallUpdate>) -> Self {
106 LocalVideo {
107 mode,
108 hub,
109 updates,
110 camera: Outgoing::new(factory, CAMERA_LABEL, PatternKind::Camera, false),
111 screen: Outgoing::new(factory, SCREEN_LABEL, PatternKind::Screen, true),
112 lines: None,
113 }
114 }
115
116 pub fn is_available(&self) -> bool {
117 self.mode != VideoMode::Off
118 }
119
120 pub fn camera_on(&self) -> bool {
121 self.camera.capture.is_some()
122 }
123
124 pub fn sharing(&self) -> bool {
125 self.screen.capture.is_some()
126 }
127
128 pub fn set_lines(&mut self, lines: VideoLines) -> Result<()> {
129 if self.camera_on() {
130 Self::begin_sending(&lines.camera.sender(), &self.camera.track)?;
131 }
132 if self.sharing() {
133 Self::begin_sending(&lines.share.sender(), &self.screen.track)?;
134 }
135 self.lines = Some(lines);
136 Ok(())
137 }
138
139 fn begin_sending(sender: &RtpSender, track: &RtcVideoTrack) -> Result<()> {
140 sender
141 .set_track(Some(MediaStreamTrack::Video(track.clone())))
142 .map_err(|error| Error::Webrtc(error.to_string()))?;
143 Self::set_active(sender, true)
144 }
145
146 fn set_active(sender: &RtpSender, active: bool) -> Result<()> {
147 let mut parameters = sender.parameters();
148 for encoding in &mut parameters.encodings {
149 encoding.active = active;
150 }
151 sender.set_parameters(parameters).map_err(|error| Error::Webrtc(error.to_string()))
152 }
153
154 fn sink(&self, outgoing: &Outgoing, key: VideoKey) -> LocalSink {
155 LocalSink::new(outgoing.source.clone(), Some((self.hub.clone(), key)))
156 }
157
158 fn report_failure(&self, what: &'static str) -> impl FnOnce(String) + Send + 'static {
159 let updates = self.updates.clone();
160 move |reason| {
161 let _ = updates.send(CallUpdate::Notice(format!("{what} stopped: {reason}")));
162 }
163 }
164
165 pub fn start_camera(&mut self, choice: &DeviceChoice) -> Result<()> {
166 let lines = self.lines.as_ref().ok_or_else(|| Error::Webrtc("no video line negotiated".into()))?;
167 if !self.is_available() {
168 return Err(Error::Webrtc("video is switched off".into()));
169 }
170 self.camera.capture = None;
171 let mut sink = self.sink(&self.camera, VideoKey::LocalCamera);
172 let capture = match self.mode {
173 VideoMode::Pattern => Capture::Task(spawn_pattern(sink, PatternKind::Camera)),
174 _ => start_camera(choice, move |buffer| sink.push(buffer), self.report_failure("Camera"))?,
175 };
176 Self::begin_sending(&lines.camera.sender(), &self.camera.track)?;
177 self.camera.capture = Some(capture);
178 Ok(())
179 }
180
181 pub fn stop_camera(&mut self) {
182 self.camera.capture = None;
183 if let Some(lines) = &self.lines {
184 let _ = Self::set_active(&lines.camera.sender(), false);
185 }
186 self.hub.forget(&VideoKey::LocalCamera);
187 }
188
189 pub fn start_share(&mut self, source: &ShareSource) -> Result<()> {
190 let lines = self.lines.as_ref().ok_or_else(|| Error::Webrtc("no video line negotiated".into()))?;
191 if !self.is_available() {
192 return Err(Error::Webrtc("video is switched off".into()));
193 }
194 self.screen.capture = None;
195 let mut sink = self.sink(&self.screen, VideoKey::LocalScreen);
196 let capture = match self.mode {
197 VideoMode::Pattern => Capture::Task(spawn_pattern(sink, PatternKind::Screen)),
198 _ => start_screen_capture(source.clone(), move |buffer| sink.push(buffer), self.report_failure("Screen share"))?,
199 };
200 Self::begin_sending(&lines.share.sender(), &self.screen.track)?;
201 self.screen.capture = Some(capture);
202 Ok(())
203 }
204
205 pub fn stop_share(&mut self) {
206 self.screen.capture = None;
207 if let Some(lines) = &self.lines {
208 let _ = Self::set_active(&lines.share.sender(), false);
209 }
210 self.hub.forget(&VideoKey::LocalScreen);
211 }
212
213 pub fn stop_all(&mut self) {
214 self.stop_camera();
215 self.stop_share();
216 }
217 }
218
219 #[cfg(test)]
220 mod tests {
221 use super::*;
222
223 #[test]
224 fn the_video_mode_follows_the_environment_value() {
225 assert_eq!(VideoMode::parse(None), VideoMode::Platform);
226 assert_eq!(VideoMode::parse(Some("Pattern")), VideoMode::Pattern);
227 assert_eq!(VideoMode::parse(Some("off")), VideoMode::Off);
228 assert_eq!(VideoMode::parse(Some("whatever")), VideoMode::Platform);
229 }
230 }
@@ -0,0 +1,230 @@
1use std::sync::Arc;
2use std::time::{Instant, SystemTime, UNIX_EPOCH};
3
4use libwebrtc::media_stream_track::MediaStreamTrack;
5use libwebrtc::peer_connection_factory::PeerConnectionFactory;
6use libwebrtc::rtp_sender::RtpSender;
7use libwebrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
8use libwebrtc::video_frame::{I420Buffer, VideoFrame, VideoRotation};
9use libwebrtc::video_source::VideoResolution;
10use libwebrtc::video_source::native::NativeVideoSource;
11use libwebrtc::video_track::RtcVideoTrack;
12use tokio::sync::mpsc::UnboundedSender;
13
14use crate::camera::start_camera;
15use crate::capture::Capture;
16use crate::control::CallUpdate;
17use crate::devices::DeviceChoice;
18use crate::error::{Error, Result};
19use crate::screen::{ShareSource, start_screen_capture};
20use crate::video_frame::{FrameGate, SCREEN_FPS, VideoHub, VideoKey, picture_from_i420};
21use crate::video_layout::VideoLines;
22use crate::video_pattern::{PatternKind, spawn_pattern};
23
24pub const VIDEO_MODE_ENV: &str = "CALLING_VIDEO";
25const CAMERA_LABEL: &str = "camera";
26const SCREEN_LABEL: &str = "screen";
27const SELF_VIEW_FPS: u32 = 15;
28
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
30pub enum VideoMode {
31 #[default]
32 Platform,
33 Pattern,
34 Off,
35}
36
37impl VideoMode {
38 pub fn from_env() -> Self {
39 Self::parse(std::env::var(VIDEO_MODE_ENV).ok().as_deref())
40 }
41
42 pub fn parse(value: Option<&str>) -> Self {
43 match value.map(str::to_ascii_lowercase).as_deref() {
44 Some("pattern") => VideoMode::Pattern,
45 Some("off") => VideoMode::Off,
46 _ => VideoMode::Platform,
47 }
48 }
49}
50
51/// Where a captured frame goes: the encoder source and, for the self view, the UI hub.
52pub struct LocalSink {
53 source: NativeVideoSource,
54 self_view: Option<(Arc<VideoHub>, VideoKey, FrameGate)>,
55}
56
57impl LocalSink {
58 pub fn new(source: NativeVideoSource, hub: Option<(Arc<VideoHub>, VideoKey)>) -> Self {
59 let self_view = hub.map(|(hub, key)| {
60 let fps = if matches!(key, VideoKey::LocalScreen) { SCREEN_FPS } else { SELF_VIEW_FPS };
61 (hub, key, FrameGate::new(fps))
62 });
63 LocalSink { source, self_view }
64 }
65
66 pub fn push(&mut self, buffer: I420Buffer) {
67 let mut frame = VideoFrame::new(VideoRotation::VideoRotation0, buffer);
68 frame.timestamp_us = SystemTime::now().duration_since(UNIX_EPOCH).map_or(0, |elapsed| elapsed.as_micros() as i64);
69 self.source.capture_frame(&frame);
70 let Some((hub, key, gate)) = &mut self.self_view else { return };
71 if gate.admit(Instant::now())
72 && let Some(picture) = picture_from_i420(frame.buffer, key.max_width())
73 {
74 hub.publish(key.clone(), picture);
75 }
76 }
77}
78
79struct Outgoing {
80 source: NativeVideoSource,
81 track: RtcVideoTrack,
82 capture: Option<Capture>,
83}
84
85impl Outgoing {
86 fn new(factory: &PeerConnectionFactory, label: &str, kind: PatternKind, screencast: bool) -> Self {
87 let (width, height) = kind.size();
88 let source = NativeVideoSource::new(VideoResolution { width, height }, screencast);
89 let track = factory.create_video_track(label, source.clone());
90 Outgoing { source, track, capture: None }
91 }
92}
93
94/// Camera and screen share of the local user; frames come from devices or a generated pattern.
95pub struct LocalVideo {
96 mode: VideoMode,
97 hub: Arc<VideoHub>,
98 updates: UnboundedSender<CallUpdate>,
99 camera: Outgoing,
100 screen: Outgoing,
101 lines: Option<VideoLines>,
102}
103
104impl LocalVideo {
105 pub fn new(factory: &PeerConnectionFactory, mode: VideoMode, hub: Arc<VideoHub>, updates: UnboundedSender<CallUpdate>) -> Self {
106 LocalVideo {
107 mode,
108 hub,
109 updates,
110 camera: Outgoing::new(factory, CAMERA_LABEL, PatternKind::Camera, false),
111 screen: Outgoing::new(factory, SCREEN_LABEL, PatternKind::Screen, true),
112 lines: None,
113 }
114 }
115
116 pub fn is_available(&self) -> bool {
117 self.mode != VideoMode::Off
118 }
119
120 pub fn camera_on(&self) -> bool {
121 self.camera.capture.is_some()
122 }
123
124 pub fn sharing(&self) -> bool {
125 self.screen.capture.is_some()
126 }
127
128 pub fn set_lines(&mut self, lines: VideoLines) -> Result<()> {
129 if self.camera_on() {
130 Self::begin_sending(&lines.camera.sender(), &self.camera.track)?;
131 }
132 if self.sharing() {
133 Self::begin_sending(&lines.share.sender(), &self.screen.track)?;
134 }
135 self.lines = Some(lines);
136 Ok(())
137 }
138
139 fn begin_sending(sender: &RtpSender, track: &RtcVideoTrack) -> Result<()> {
140 sender
141 .set_track(Some(MediaStreamTrack::Video(track.clone())))
142 .map_err(|error| Error::Webrtc(error.to_string()))?;
143 Self::set_active(sender, true)
144 }
145
146 fn set_active(sender: &RtpSender, active: bool) -> Result<()> {
147 let mut parameters = sender.parameters();
148 for encoding in &mut parameters.encodings {
149 encoding.active = active;
150 }
151 sender.set_parameters(parameters).map_err(|error| Error::Webrtc(error.to_string()))
152 }
153
154 fn sink(&self, outgoing: &Outgoing, key: VideoKey) -> LocalSink {
155 LocalSink::new(outgoing.source.clone(), Some((self.hub.clone(), key)))
156 }
157
158 fn report_failure(&self, what: &'static str) -> impl FnOnce(String) + Send + 'static {
159 let updates = self.updates.clone();
160 move |reason| {
161 let _ = updates.send(CallUpdate::Notice(format!("{what} stopped: {reason}")));
162 }
163 }
164
165 pub fn start_camera(&mut self, choice: &DeviceChoice) -> Result<()> {
166 let lines = self.lines.as_ref().ok_or_else(|| Error::Webrtc("no video line negotiated".into()))?;
167 if !self.is_available() {
168 return Err(Error::Webrtc("video is switched off".into()));
169 }
170 self.camera.capture = None;
171 let mut sink = self.sink(&self.camera, VideoKey::LocalCamera);
172 let capture = match self.mode {
173 VideoMode::Pattern => Capture::Task(spawn_pattern(sink, PatternKind::Camera)),
174 _ => start_camera(choice, move |buffer| sink.push(buffer), self.report_failure("Camera"))?,
175 };
176 Self::begin_sending(&lines.camera.sender(), &self.camera.track)?;
177 self.camera.capture = Some(capture);
178 Ok(())
179 }
180
181 pub fn stop_camera(&mut self) {
182 self.camera.capture = None;
183 if let Some(lines) = &self.lines {
184 let _ = Self::set_active(&lines.camera.sender(), false);
185 }
186 self.hub.forget(&VideoKey::LocalCamera);
187 }
188
189 pub fn start_share(&mut self, source: &ShareSource) -> Result<()> {
190 let lines = self.lines.as_ref().ok_or_else(|| Error::Webrtc("no video line negotiated".into()))?;
191 if !self.is_available() {
192 return Err(Error::Webrtc("video is switched off".into()));
193 }
194 self.screen.capture = None;
195 let mut sink = self.sink(&self.screen, VideoKey::LocalScreen);
196 let capture = match self.mode {
197 VideoMode::Pattern => Capture::Task(spawn_pattern(sink, PatternKind::Screen)),
198 _ => start_screen_capture(source.clone(), move |buffer| sink.push(buffer), self.report_failure("Screen share"))?,
199 };
200 Self::begin_sending(&lines.share.sender(), &self.screen.track)?;
201 self.screen.capture = Some(capture);
202 Ok(())
203 }
204
205 pub fn stop_share(&mut self) {
206 self.screen.capture = None;
207 if let Some(lines) = &self.lines {
208 let _ = Self::set_active(&lines.share.sender(), false);
209 }
210 self.hub.forget(&VideoKey::LocalScreen);
211 }
212
213 pub fn stop_all(&mut self) {
214 self.stop_camera();
215 self.stop_share();
216 }
217}
218
219#[cfg(test)]
220mod tests {
221 use super::*;
222
223 #[test]
224 fn the_video_mode_follows_the_environment_value() {
225 assert_eq!(VideoMode::parse(None), VideoMode::Platform);
226 assert_eq!(VideoMode::parse(Some("Pattern")), VideoMode::Pattern);
227 assert_eq!(VideoMode::parse(Some("off")), VideoMode::Off);
228 assert_eq!(VideoMode::parse(Some("whatever")), VideoMode::Platform);
229 }
230}
crates/calling/tests/video_loopback.rs added +113 −0
@@ -0,0 +1,113 @@
1 use std::sync::Arc;
2 use std::time::Duration;
3
4 use calling::video_frame::{VideoHub, VideoKey};
5 use calling::video_layout::VideoRouter;
6 use calling::video_pattern::{PatternKind, spawn_pattern};
7 use calling::video_send::LocalSink;
8 use calling::video_receive::{VideoCounters, spawn_video_pump};
9 use calling::{CallUpdate, devices::shared_factory};
10 use libwebrtc::video_source::native::NativeVideoSource;
11 use libwebrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
12 use libwebrtc::prelude::*;
13 use libwebrtc::rtp_transceiver::{RtpTransceiverDirection, RtpTransceiverInit};
14 use libwebrtc::video_source::VideoResolution;
15 use tokio::sync::mpsc;
16 use tokio::time::{sleep, timeout};
17
18 fn h264_only(capabilities: Vec<RtpCodecCapability>) -> Vec<RtpCodecCapability> {
19 capabilities
20 .into_iter()
21 .filter(|codec| matches!(codec.mime_type.to_ascii_lowercase().as_str(), "video/h264" | "video/rtx"))
22 .collect()
23 }
24
25 #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
26 async fn a_generated_h264_stream_survives_the_pipeline_to_bgra_pictures() {
27 let factory = shared_factory();
28 let sender = factory.create_peer_connection(RtcConfiguration::default()).unwrap();
29 let receiver = factory.create_peer_connection(RtcConfiguration::default()).unwrap();
30
31 let (to_receiver, mut for_receiver) = mpsc::unbounded_channel::<IceCandidate>();
32 let (to_sender, mut for_sender) = mpsc::unbounded_channel::<IceCandidate>();
33 sender.on_ice_candidate(Some(Box::new(move |candidate| {
34 let _ = to_receiver.send(candidate);
35 })));
36 receiver.on_ice_candidate(Some(Box::new(move |candidate| {
37 let _ = to_sender.send(candidate);
38 })));
39 let (track_sender, mut tracks) = mpsc::unbounded_channel::<RtcVideoTrack>();
40 receiver.on_track(Some(Box::new(move |event| {
41 if let MediaStreamTrack::Video(track) = event.track {
42 let _ = track_sender.send(track);
43 }
44 })));
45
46 let (width, height) = PatternKind::Camera.size();
47 let source = NativeVideoSource::new(VideoResolution { width, height }, false);
48 let track = factory.create_video_track("camera", source.clone());
49 let transceiver = sender
50 .add_transceiver(
51 MediaStreamTrack::Video(track),
52 RtpTransceiverInit {
53 direction: RtpTransceiverDirection::SendOnly,
54 stream_ids: vec!["camera".into()],
55 send_encodings: Vec::new(),
56 },
57 )
58 .unwrap();
59 transceiver
60 .set_codec_preferences(h264_only(factory.get_rtp_sender_capabilities(MediaType::Video).codecs))
61 .unwrap();
62 let pattern = spawn_pattern(LocalSink::new(source, None), PatternKind::Camera);
63
64 let offer = sender.create_offer(OfferOptions::default()).await.unwrap();
65 sender.set_local_description(offer.clone()).await.unwrap();
66 receiver.set_remote_description(offer).await.unwrap();
67 let answer = receiver.create_answer(AnswerOptions::default()).await.unwrap();
68 receiver.set_local_description(answer.clone()).await.unwrap();
69 sender.set_remote_description(answer).await.unwrap();
70
71 let relay = tokio::spawn(async move {
72 loop {
73 tokio::select! {
74 Some(candidate) = for_receiver.recv() => { let _ = receiver.add_ice_candidate(candidate).await; }
75 Some(candidate) = for_sender.recv() => { let _ = sender.add_ice_candidate(candidate).await; }
76 else => break,
77 }
78 }
79 (sender, receiver)
80 });
81
82 let remote_track = timeout(Duration::from_secs(15), tracks.recv()).await.expect("video track").expect("track");
83 let (updates, mut ready) = mpsc::unbounded_channel();
84 let hub = VideoHub::new(updates);
85 let router = VideoRouter::default();
86 router.set("0", Some(VideoKey::Person("8:orgid:loopback".into())));
87 let counters = Arc::new(VideoCounters::default());
88 let pump = spawn_video_pump(remote_track, "0".into(), router, hub.clone(), counters.clone());
89
90 let mut pictures = 0;
91 let mut last = None;
92 let collect = async {
93 while pictures < 20 {
94 let Some(CallUpdate::VideoReady) = ready.recv().await else { break };
95 for (key, picture) in hub.drain() {
96 assert_eq!(key, VideoKey::Person("8:orgid:loopback".into()));
97 pictures += 1;
98 last = Some(picture);
99 }
100 }
101 };
102 timeout(Duration::from_secs(20), collect).await.expect("pictures within 20 s");
103 sleep(Duration::from_millis(200)).await;
104 let picture = last.unwrap();
105 assert_eq!((picture.width, picture.height), (width, height));
106 assert_eq!(picture.bgra.len(), (width * height * 4) as usize);
107 let bright = picture.bgra.as_chunks::<4>().0.iter().filter(|pixel| pixel[0] > 150 && pixel[1] > 150 && pixel[2] > 150).count();
108 assert!(bright > 1000, "the moving square is visible ({bright} bright pixels)");
109 assert!(counters.received.load(std::sync::atomic::Ordering::Relaxed) >= 20);
110 pump.abort();
111 pattern.abort();
112 relay.abort();
113 }
@@ -0,0 +1,113 @@
1use std::sync::Arc;
2use std::time::Duration;
3
4use calling::video_frame::{VideoHub, VideoKey};
5use calling::video_layout::VideoRouter;
6use calling::video_pattern::{PatternKind, spawn_pattern};
7use calling::video_send::LocalSink;
8use calling::video_receive::{VideoCounters, spawn_video_pump};
9use calling::{CallUpdate, devices::shared_factory};
10use libwebrtc::video_source::native::NativeVideoSource;
11use libwebrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
12use libwebrtc::prelude::*;
13use libwebrtc::rtp_transceiver::{RtpTransceiverDirection, RtpTransceiverInit};
14use libwebrtc::video_source::VideoResolution;
15use tokio::sync::mpsc;
16use tokio::time::{sleep, timeout};
17
18fn h264_only(capabilities: Vec<RtpCodecCapability>) -> Vec<RtpCodecCapability> {
19 capabilities
20 .into_iter()
21 .filter(|codec| matches!(codec.mime_type.to_ascii_lowercase().as_str(), "video/h264" | "video/rtx"))
22 .collect()
23}
24
25#[tokio::test(flavor = "multi_thread", worker_threads = 4)]
26async fn a_generated_h264_stream_survives_the_pipeline_to_bgra_pictures() {
27 let factory = shared_factory();
28 let sender = factory.create_peer_connection(RtcConfiguration::default()).unwrap();
29 let receiver = factory.create_peer_connection(RtcConfiguration::default()).unwrap();
30
31 let (to_receiver, mut for_receiver) = mpsc::unbounded_channel::<IceCandidate>();
32 let (to_sender, mut for_sender) = mpsc::unbounded_channel::<IceCandidate>();
33 sender.on_ice_candidate(Some(Box::new(move |candidate| {
34 let _ = to_receiver.send(candidate);
35 })));
36 receiver.on_ice_candidate(Some(Box::new(move |candidate| {
37 let _ = to_sender.send(candidate);
38 })));
39 let (track_sender, mut tracks) = mpsc::unbounded_channel::<RtcVideoTrack>();
40 receiver.on_track(Some(Box::new(move |event| {
41 if let MediaStreamTrack::Video(track) = event.track {
42 let _ = track_sender.send(track);
43 }
44 })));
45
46 let (width, height) = PatternKind::Camera.size();
47 let source = NativeVideoSource::new(VideoResolution { width, height }, false);
48 let track = factory.create_video_track("camera", source.clone());
49 let transceiver = sender
50 .add_transceiver(
51 MediaStreamTrack::Video(track),
52 RtpTransceiverInit {
53 direction: RtpTransceiverDirection::SendOnly,
54 stream_ids: vec!["camera".into()],
55 send_encodings: Vec::new(),
56 },
57 )
58 .unwrap();
59 transceiver
60 .set_codec_preferences(h264_only(factory.get_rtp_sender_capabilities(MediaType::Video).codecs))
61 .unwrap();
62 let pattern = spawn_pattern(LocalSink::new(source, None), PatternKind::Camera);
63
64 let offer = sender.create_offer(OfferOptions::default()).await.unwrap();
65 sender.set_local_description(offer.clone()).await.unwrap();
66 receiver.set_remote_description(offer).await.unwrap();
67 let answer = receiver.create_answer(AnswerOptions::default()).await.unwrap();
68 receiver.set_local_description(answer.clone()).await.unwrap();
69 sender.set_remote_description(answer).await.unwrap();
70
71 let relay = tokio::spawn(async move {
72 loop {
73 tokio::select! {
74 Some(candidate) = for_receiver.recv() => { let _ = receiver.add_ice_candidate(candidate).await; }
75 Some(candidate) = for_sender.recv() => { let _ = sender.add_ice_candidate(candidate).await; }
76 else => break,
77 }
78 }
79 (sender, receiver)
80 });
81
82 let remote_track = timeout(Duration::from_secs(15), tracks.recv()).await.expect("video track").expect("track");
83 let (updates, mut ready) = mpsc::unbounded_channel();
84 let hub = VideoHub::new(updates);
85 let router = VideoRouter::default();
86 router.set("0", Some(VideoKey::Person("8:orgid:loopback".into())));
87 let counters = Arc::new(VideoCounters::default());
88 let pump = spawn_video_pump(remote_track, "0".into(), router, hub.clone(), counters.clone());
89
90 let mut pictures = 0;
91 let mut last = None;
92 let collect = async {
93 while pictures < 20 {
94 let Some(CallUpdate::VideoReady) = ready.recv().await else { break };
95 for (key, picture) in hub.drain() {
96 assert_eq!(key, VideoKey::Person("8:orgid:loopback".into()));
97 pictures += 1;
98 last = Some(picture);
99 }
100 }
101 };
102 timeout(Duration::from_secs(20), collect).await.expect("pictures within 20 s");
103 sleep(Duration::from_millis(200)).await;
104 let picture = last.unwrap();
105 assert_eq!((picture.width, picture.height), (width, height));
106 assert_eq!(picture.bgra.len(), (width * height * 4) as usize);
107 let bright = picture.bgra.as_chunks::<4>().0.iter().filter(|pixel| pixel[0] > 150 && pixel[1] > 150 && pixel[2] > 150).count();
108 assert!(bright > 1000, "the moving square is visible ({bright} bright pixels)");
109 assert!(counters.received.load(std::sync::atomic::Ordering::Relaxed) >= 20);
110 pump.abort();
111 pattern.abort();
112 relay.abort();
113}
crates/calling/tests/video_offer.rs added +94 −0
@@ -0,0 +1,94 @@
1 use calling::devices::shared_factory;
2 use calling::sdp::{LineRole, parse, stream_lines, to_teams_offer};
3 use calling::video_layout::{SlotTable, add_video_lines, offer_plan};
4 use libwebrtc::audio_source::native::NativeAudioSource;
5 use libwebrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
6 use libwebrtc::prelude::*;
7 use libwebrtc::rtp_transceiver::{RtpTransceiverDirection, RtpTransceiverInit};
8
9 fn counter() -> impl FnMut() -> u32 {
10 let mut next = 5_000_000u32;
11 move || {
12 next += 1;
13 next
14 }
15 }
16
17 async fn browser_offer() -> String {
18 let factory = shared_factory();
19 let peer = factory.create_peer_connection(RtcConfiguration::default()).unwrap();
20 let source = NativeAudioSource::new(AudioSourceOptions::default(), 48_000, 1, 100);
21 let track = factory.create_audio_track("microphone", source);
22 peer.add_transceiver(
23 MediaStreamTrack::Audio(track),
24 RtpTransceiverInit {
25 direction: RtpTransceiverDirection::SendRecv,
26 stream_ids: vec!["microphone".into()],
27 send_encodings: Vec::new(),
28 },
29 )
30 .unwrap();
31 add_video_lines(&peer, &factory).unwrap();
32 peer.create_offer(OfferOptions {
33 offer_to_receive_audio: true,
34 offer_to_receive_video: true,
35 ..OfferOptions::default()
36 })
37 .await
38 .unwrap()
39 .to_string()
40 }
41
42 #[tokio::test]
43 async fn the_meeting_layout_is_signaled_like_the_web_client_offers_it() {
44 let browser = browser_offer().await;
45 let offer = to_teams_offer(&browser, &offer_plan(), &mut counter()).unwrap();
46 let parsed = parse(&offer.sdp).unwrap();
47 let summary: Vec<(String, String, String)> = parsed
48 .media
49 .iter()
50 .map(|media| {
51 (
52 media.mid().unwrap_or_default().to_owned(),
53 media.value("label").unwrap_or_default().to_owned(),
54 media.direction().unwrap_or_default().to_owned(),
55 )
56 })
57 .collect();
58 let expected: Vec<(&str, &str, &str)> = vec![
59 ("0", "main-audio", "sendrecv"),
60 ("1", "main-video", "sendrecv"),
61 ("2", "main-video", "recvonly"),
62 ("3", "main-video", "recvonly"),
63 ("4", "main-video", "recvonly"),
64 ("5", "main-video", "recvonly"),
65 ("6", "applicationsharing-video", "sendrecv"),
66 ];
67 let actual: Vec<(&str, &str, &str)> = summary.iter().map(|(a, b, c)| (a.as_str(), b.as_str(), c.as_str())).collect();
68 assert_eq!(actual, expected);
69 for receive in &parsed.media[2..6] {
70 assert_eq!(receive.value("x-ssrc-range"), Some("1-1"));
71 assert_eq!(receive.value("x-signaling-fb"), Some("* x-message app send:src recv:src,vc"));
72 assert!(receive.values("rtpmap").all(|mapping| mapping.contains("H264") || mapping.contains("rtx")), "{:?}", receive.values("rtpmap").collect::<Vec<_>>());
73 }
74 assert!(parsed.media[1].value("x-ssrc-range").is_some());
75 let group = parsed.session.attributes.iter().find(|attribute| attribute.name == "group").and_then(|attribute| attribute.value.clone());
76 assert_eq!(group.as_deref(), Some("BUNDLE 0 1 2 3 4 5 6"));
77 assert_eq!(offer.lines.iter().filter(|line| line.role == LineRole::ScreenShare).count(), 1);
78 }
79
80 #[tokio::test]
81 async fn the_slots_come_from_the_source_stream_ids_of_an_answer() {
82 let browser = browser_offer().await;
83 let offer = to_teams_offer(&browser, &offer_plan(), &mut counter()).unwrap();
84 let mut answer = String::from("v=0\r\no=- 1 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n");
85 for (index, role) in ["main-audio", "main-video", "main-video", "main-video", "main-video", "main-video", "applicationsharing-video"].iter().enumerate() {
86 let kind = if index == 0 { "audio" } else { "video" };
87 answer.push_str(&format!("m={kind} 3478 RTP/SAVP 107\r\na=x-source-streamid:{}\r\na=label:{role}\r\na=mid:{index}\r\n", 201 + index));
88 }
89 let streams = stream_lines(&answer, &offer.lines).unwrap();
90 let table = SlotTable::from_streams(&streams);
91 let slots: Vec<(String, u32)> = table.people.iter().map(|slot| (slot.mid.clone(), slot.stream_id)).collect();
92 assert_eq!(slots, vec![("2".to_owned(), 203), ("3".to_owned(), 204), ("4".to_owned(), 205), ("5".to_owned(), 206)]);
93 assert_eq!(table.screen.map(|slot| (slot.mid, slot.stream_id)), Some(("6".to_owned(), 207)));
94 }
@@ -0,0 +1,94 @@
1use calling::devices::shared_factory;
2use calling::sdp::{LineRole, parse, stream_lines, to_teams_offer};
3use calling::video_layout::{SlotTable, add_video_lines, offer_plan};
4use libwebrtc::audio_source::native::NativeAudioSource;
5use libwebrtc::peer_connection_factory::native::PeerConnectionFactoryExt;
6use libwebrtc::prelude::*;
7use libwebrtc::rtp_transceiver::{RtpTransceiverDirection, RtpTransceiverInit};
8
9fn counter() -> impl FnMut() -> u32 {
10 let mut next = 5_000_000u32;
11 move || {
12 next += 1;
13 next
14 }
15}
16
17async fn browser_offer() -> String {
18 let factory = shared_factory();
19 let peer = factory.create_peer_connection(RtcConfiguration::default()).unwrap();
20 let source = NativeAudioSource::new(AudioSourceOptions::default(), 48_000, 1, 100);
21 let track = factory.create_audio_track("microphone", source);
22 peer.add_transceiver(
23 MediaStreamTrack::Audio(track),
24 RtpTransceiverInit {
25 direction: RtpTransceiverDirection::SendRecv,
26 stream_ids: vec!["microphone".into()],
27 send_encodings: Vec::new(),
28 },
29 )
30 .unwrap();
31 add_video_lines(&peer, &factory).unwrap();
32 peer.create_offer(OfferOptions {
33 offer_to_receive_audio: true,
34 offer_to_receive_video: true,
35 ..OfferOptions::default()
36 })
37 .await
38 .unwrap()
39 .to_string()
40}
41
42#[tokio::test]
43async fn the_meeting_layout_is_signaled_like_the_web_client_offers_it() {
44 let browser = browser_offer().await;
45 let offer = to_teams_offer(&browser, &offer_plan(), &mut counter()).unwrap();
46 let parsed = parse(&offer.sdp).unwrap();
47 let summary: Vec<(String, String, String)> = parsed
48 .media
49 .iter()
50 .map(|media| {
51 (
52 media.mid().unwrap_or_default().to_owned(),
53 media.value("label").unwrap_or_default().to_owned(),
54 media.direction().unwrap_or_default().to_owned(),
55 )
56 })
57 .collect();
58 let expected: Vec<(&str, &str, &str)> = vec![
59 ("0", "main-audio", "sendrecv"),
60 ("1", "main-video", "sendrecv"),
61 ("2", "main-video", "recvonly"),
62 ("3", "main-video", "recvonly"),
63 ("4", "main-video", "recvonly"),
64 ("5", "main-video", "recvonly"),
65 ("6", "applicationsharing-video", "sendrecv"),
66 ];
67 let actual: Vec<(&str, &str, &str)> = summary.iter().map(|(a, b, c)| (a.as_str(), b.as_str(), c.as_str())).collect();
68 assert_eq!(actual, expected);
69 for receive in &parsed.media[2..6] {
70 assert_eq!(receive.value("x-ssrc-range"), Some("1-1"));
71 assert_eq!(receive.value("x-signaling-fb"), Some("* x-message app send:src recv:src,vc"));
72 assert!(receive.values("rtpmap").all(|mapping| mapping.contains("H264") || mapping.contains("rtx")), "{:?}", receive.values("rtpmap").collect::<Vec<_>>());
73 }
74 assert!(parsed.media[1].value("x-ssrc-range").is_some());
75 let group = parsed.session.attributes.iter().find(|attribute| attribute.name == "group").and_then(|attribute| attribute.value.clone());
76 assert_eq!(group.as_deref(), Some("BUNDLE 0 1 2 3 4 5 6"));
77 assert_eq!(offer.lines.iter().filter(|line| line.role == LineRole::ScreenShare).count(), 1);
78}
79
80#[tokio::test]
81async fn the_slots_come_from_the_source_stream_ids_of_an_answer() {
82 let browser = browser_offer().await;
83 let offer = to_teams_offer(&browser, &offer_plan(), &mut counter()).unwrap();
84 let mut answer = String::from("v=0\r\no=- 1 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n");
85 for (index, role) in ["main-audio", "main-video", "main-video", "main-video", "main-video", "main-video", "applicationsharing-video"].iter().enumerate() {
86 let kind = if index == 0 { "audio" } else { "video" };
87 answer.push_str(&format!("m={kind} 3478 RTP/SAVP 107\r\na=x-source-streamid:{}\r\na=label:{role}\r\na=mid:{index}\r\n", 201 + index));
88 }
89 let streams = stream_lines(&answer, &offer.lines).unwrap();
90 let table = SlotTable::from_streams(&streams);
91 let slots: Vec<(String, u32)> = table.people.iter().map(|slot| (slot.mid.clone(), slot.stream_id)).collect();
92 assert_eq!(slots, vec![("2".to_owned(), 203), ("3".to_owned(), 204), ("4".to_owned(), 205), ("5".to_owned(), 206)]);
93 assert_eq!(table.screen.map(|slot| (slot.mid, slot.stream_id)), Some(("6".to_owned(), 207)));
94}