apprtc 0.4.0

AppRTC P2P/SFU Server in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
/*
 *  Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license
 *  that can be found in the LICENSE file in the root of the source
 *  tree.
 */

.hidden {
  display: none !important;
}

a {
  color: #4285F4;
  text-decoration: none;
}

a:hover {
  color: #3B78E7;
  text-decoration: underline;
}

#room-link a {
  white-space: nowrap;
}

:root {
  --bg-gradient: radial-gradient(circle at 50% 50%, #1a1a2e 0%, #0d0d15 100%);
  --card-bg: rgba(22, 22, 37, 0.7);
  --border-color: rgba(255, 255, 255, 0.08);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-blue: #3b82f6;
  --accent-blue-glow: rgba(59, 130, 246, 0.5);
  --accent-green: #10b981;
  --accent-green-glow: rgba(16, 185, 129, 0.5);
  --accent-orange: #f59e0b;
  --accent-orange-glow: rgba(245, 158, 11, 0.5);
  --accent-red: #ef4444;
  --accent-red-glow: rgba(239, 68, 68, 0.5);
  --accent-purple: #8b5cf6;
}

body {
  background: var(--bg-gradient);
  color: var(--text-primary);
  font-family: 'Outfit', sans-serif;
  height: 100%;
  margin: 0;
  padding: 0;
  width: 100%;
}

header {
  background: rgba(150, 16, 16, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin: 0;
  padding: 1em 0;
  position: absolute;
  text-align: center;
  top: 0;
  width: 100%;
  z-index: 10;
}

#remote-canvas {
  display: none;
  height: 100%;
  margin: 0 auto;
  width: 100%;
}

div.warning {
  background-color: #a80202;
  color: black;
  font-weight: 400;
  opacity: .9;
}

#container {
  height: 100%;
  position: absolute;
}

#info-div {
  z-index: 3;
}

#room-link {
  margin: 0 0 29px 0;
}

#status {
  z-index: 4;
}

#videos {
  font-size: 0; /* to fix whitespace/scrollbars problem */
  height: 100%;
  pointer-events: none;
  position: absolute;
  transition: all 1s;
  width: 100%;
}

#videos.active {
  -moz-transform: rotateY(180deg);
  -ms-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
}

footer > div {
  background-color: black;
  bottom: 0;
  color: white;
  display: none;
  font-size: .9em;
  font-weight: 300;
  line-height: 2em;
  max-height: 80%;
  opacity: 0;
  overflow-y: auto;
  padding: 10px;
  position: absolute;
  transition: opacity 1s;
  width: calc(100% - 20px);
}

footer > div.active {
  display: block;
  opacity: .8;
}

div#privacy {
  bottom: 7px;
  color: gray;
  position: absolute;
  right: 10px;
}

div#privacy a {
  color: gray;
  font-size: 14px;
}

html {
  height: 100%;
  margin: 0;
  width: 100%;
}

label {
  margin: 0 10px 0 0;
}

#local-video {
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  object-fit: cover;  /* no letterboxing */
  -moz-transform: scale(-1, 1);
  -ms-transform: scale(-1, 1);
  -o-transform: scale(-1, 1);
  -webkit-transform: scale(-1, 1);
  transform: scale(-1, 1);
  transition: opacity 1s;
  width: 100%;
}

#mini-video {
  border: 1px solid gray;
  bottom: 20px;
  left: 20px;
  /* video div is flipped horizontally when active*/
  max-height: 17%;
  max-width: 17%;
  opacity: 0;
  position: absolute;
  transition: opacity 1s;
}

#mini-video.active {
  opacity: 1;
  z-index: 2;
}

#remote-video {
  display: block;
  height: 100%;
  max-height: 100%;
  max-width: 100%;
  object-fit: cover;  /* no letterboxing */
  opacity: 0;
  position: absolute;
  -moz-transform: rotateY(180deg);
  -ms-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
  transition: opacity 1s;
  width: 100%;
}

#remote-video.active {
  opacity: 1;
  z-index: 1;
}

.sfu-grid {
  align-content: start;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  /* Anchor to #videos' top-left so the grid overlays the full window the way the P2P remote-video
     does. Without top/left an absolutely positioned box uses its static position, which sits below
     the full-height (opacity:0 but still in-flow) #local-video and pushes the grid off-screen. */
  top: 0;
  left: 0;
  height: 100%;
  overflow-y: auto;
  padding: 12px;
  position: absolute;
  width: 100%;
  box-sizing: border-box;
  z-index: 1;
}

.sfu-grid.hidden {
  display: none;
}

.sfu-tile {
  /* A fixed 16:9 aspect gives each tile a real height (its columns are width-driven), so the
     grid flows top-down as a responsive grid of cards instead of collapsing. */
  aspect-ratio: 16 / 9;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.sfu-tile video {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.sfu-caption {
  background: rgba(0, 0, 0, 0.55);
  border-radius: 4px;
  bottom: 6px;
  color: #fff;
  font-size: 12px;
  left: 6px;
  padding: 2px 6px;
  position: absolute;
  z-index: 2;
}

/* SFU mode only swaps the full-window peer video for the grid. #videos.active gives P2P its own
   stacking context (via its transform) so the grid — which lives inside #videos — cannot escape
   to cover the self-view or the control buttons (which sit outside #videos). SFU mode drops the
   .active transform, so re-establish that context here with isolation, leaving every other
   element (self-view, #icons) in its P2P position and stacking order. */
#videos.sfu-mode {
  isolation: isolate;
}

/* In P2P the .active transform both mirrors the self-view and (by flipping the whole container)
   makes #mini-video's `left: 20px` land on the right. SFU mode drops that container transform, so
   here we (a) mirror the self-view directly and (b) re-anchor it to the right so it keeps the exact
   P2P bottom-right position. */
#videos.sfu-mode #mini-video {
  transform: rotateY(180deg);
  left: auto;
  right: 20px;
}

#videos.sfu-mode #local-video,
#videos.sfu-mode #remote-video {
  opacity: 0;
  pointer-events: none;
}

#confirm-join-div {
  position: absolute;
  text-align: center;
  top: 80%;
  width: 100%;
  z-index: 5;
}

#confirm-join-div div {
  font-size: 1.5em;
  margin-bottom: 10px;
}

/*////// room selection start ///////////////////*/

/* Glow decoration */
.bg-glow,
.bg-glow-right {
  position: fixed;
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
}

.bg-glow {
  width: 600px;
  height: 600px;
  top: -100px;
  left: -100px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.15) 0%, rgba(59, 130, 246, 0.05) 50%, transparent 100%);
}

.bg-glow-right {
  width: 500px;
  height: 500px;
  bottom: -100px;
  right: -100px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, rgba(59, 130, 246, 0.05) 60%, transparent 100%);
}

/* Glassy card styling */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  padding: 1.5rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
  transition: transform 0.3s ease, border-color 0.3s ease;
  margin-bottom: 2rem;
}

.card:hover {
  transform: translateY(-4px);
  border-color: rgba(255, 255, 255, 0.15);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.75rem;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-icon {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-orange);
  box-shadow: 0 0 10px var(--accent-orange-glow);
  display: inline-block;
  flex-shrink: 0;
}

.card-title.states .card-icon {
  background-color: var(--accent-purple);
  box-shadow: 0 0 10px rgba(139, 92, 246, 0.5);
}

.log-container {
  flex-grow: 1;
  overflow-y: auto;
  max-height: 280px;
}

.controls-row {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

input[type="text"] {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
  width: 100%;
  box-sizing: border-box;
  display: block;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input[type="text"].invalid {
  border-color: var(--accent-red);
}

/* The V2 room link stands in for the room-id field: same box, but a real anchor so it can
   be clicked, hovered to reveal the URL, and opened in a new tab. */
.room-selection-link {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  color: var(--accent-blue);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 0.6rem;
  padding: 0.6rem 0.9rem;
  width: 100%;
  box-sizing: border-box;
  display: block;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.room-selection-link:hover,
.room-selection-link:focus {
  text-decoration: underline;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
  outline: none;
}

label.error-label {
  color: var(--accent-red);
  font-size: 0.85rem;
  font-weight: 400;
  margin-top: 0.5rem;
  display: block;
}

#room-id-input-div {
  margin: 0;
}

.protocol-option {
  align-items: center;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  font-size: 0.9rem;
  gap: 0.65rem;
  margin-left: auto;
  width: fit-content;
}

.protocol-option input {
  accent-color: var(--accent-blue);
  height: 1rem;
  margin: 0;
  width: 1rem;
}

.protocol-badge {
  background: rgba(59, 130, 246, 0.14);
  border: 1px solid rgba(59, 130, 246, 0.32);
  border-radius: 999px;
  color: #93c5fd;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
}

#room-id-input-buttons {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-start;
  margin: 0;
}

button {
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-blue);
  border: none;
  border-radius: 0.6rem;
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease, opacity 0.2s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

button:hover:not(:disabled) {
  background: #2563eb;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: none;
  cursor: not-allowed;
}

h1 {
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff 0%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem 0;
  text-align: center;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 300;
  text-align: center;
  margin: 0 0 2rem 0;
  display: block;
}

div#room-selection {
  margin: 6vh auto 0 auto;
  width: 100%;
  /* Wide enough for a V2 room link to fit on one line. The longest realistic form,
     https://host:port/v2/r/ plus the 22-character token, is ~50 monospace characters
     (~537px including the field and card padding); 45rem leaves room for longer hosts,
     and 92vw keeps the card inside narrow viewports. The link still ellipsizes rather
     than overflowing if a host is longer still.
     min(92vw, 45rem)*/
  max-width: 540px;
  z-index: 1;
}

p {
  color: var(--text-secondary);
  font-weight: 300;
  line-height: 1.6em;
}

#recent-rooms-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

#recent-rooms-list li {
  background: rgba(255, 255, 255, 0.03);
  border-left: 3px solid var(--accent-blue);
  padding: 0.6rem 0.9rem;
  border-radius: 0 0.6rem 0.6rem 0;
  transition: background 0.2s ease, border-left-color 0.2s ease, transform 0.2s ease;
}

#recent-rooms-list li:hover {
  background: rgba(59, 130, 246, 0.08);
  border-left-color: var(--accent-green);
  transform: translateX(4px);
}

#recent-rooms-list li a {
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  text-decoration: none;
  display: block;
}

#recent-rooms-list li a:hover {
  color: #fff;
  text-decoration: none;
}

/*////// room selection end /////////////////////*/

/*////// icons CSS start ////////////////////////*/

#icons {
  bottom: 77px;
  left: 6vw;
  position: absolute;
}

circle {
  fill: #666;
  fill-opacity: 0.6;
}

svg.on circle {
  fill-opacity: 0;
}

/* on icons are hidden by default */
path.on {
  display: none;
}

/* off icons are displayed by default */
path.off {
  display: block;
}

/* on icons are displayed when parent svg has class 'on' */
svg.on path.on {
  display: block;
}

/* off icons are hidden when parent svg has class 'on' */
svg.on path.off {
  display: none;
}

svg {
  border-radius: 48px;
  box-shadow: 2px 2px 24px #444;
  display: block;
  margin: 0 0 3vh 0;
  transform: translateX(calc(-6vw - 96px));
  transition: all .1s;
  transition-timing-function: ease-in-out;
}

svg:hover {
  box-shadow: 4px 4px 48px #666;
}

#icons.active svg {
  transform: translateX(0);
}

#mute-audio {
  transition: 40ms;
}

#mute-audio:hover,
#mute-audio.on {
  background: #407cf7;
}

#mute-audio:hover circle {
  fill: #407cf7;
}

#mute-video {
  transition: 120ms;
}

#mute-video:hover,
#mute-video.on {
  background: #407cf7;
}

#mute-video:hover circle {
  fill: #407cf7;
}

#switch-video {
  transition: 200ms;
}

#switch-video:hover {
  background: #407cf7;
}

#switch-video:hover circle {
  fill: #407cf7;
}

#fullscreen {
  transition: 280ms;
}

#fullscreen:hover,
#fullscreen.on {
  background: #407cf7;
}

#fullscreen:hover circle {
  fill: #407cf7;
}

#hangup {
  transition: 360ms;
}

#hangup:hover {
  background: #dd2c00;
}
#hangup:hover circle {
  fill: #dd2c00;
}

/*////// icons CSS end /////////////////////////*/