@3dsource/angular-unreal-module 0.0.197 → 0.0.199
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2214,10 +2214,16 @@ function iceSnapshot(stats) {
|
|
|
2214
2214
|
};
|
|
2215
2215
|
}
|
|
2216
2216
|
var VideoService = class VideoService extends SubService {
|
|
2217
|
+
get video() {
|
|
2218
|
+
return this.video$.value;
|
|
2219
|
+
}
|
|
2220
|
+
set video(video) {
|
|
2221
|
+
this.video$.next(video);
|
|
2222
|
+
}
|
|
2217
2223
|
constructor() {
|
|
2218
2224
|
super();
|
|
2219
2225
|
this.isVideoPlaying = this.store.selectSignal(unrealFeature.selectIsVideoPlaying);
|
|
2220
|
-
this.video = null;
|
|
2226
|
+
this.video$ = new BehaviorSubject(null);
|
|
2221
2227
|
this.audio = null;
|
|
2222
2228
|
this.container = null;
|
|
2223
2229
|
this.latencyTestTimings = new LatencyTimings();
|
|
@@ -2568,7 +2574,7 @@ var WebRtcPlayerService = class WebRtcPlayerService extends SubService {
|
|
|
2568
2574
|
const pc = this.pcClient;
|
|
2569
2575
|
if (!pc) return;
|
|
2570
2576
|
await this.setupTransceiversAsync(pc);
|
|
2571
|
-
this.
|
|
2577
|
+
this.createDataChannel(pc, "UnrealDcConnection", { ordered: true });
|
|
2572
2578
|
await this.createOffer(pc);
|
|
2573
2579
|
} catch (e) {
|
|
2574
2580
|
Logger.error("Failed to create WebRTC offer", e);
|
|
@@ -2581,15 +2587,17 @@ var WebRtcPlayerService = class WebRtcPlayerService extends SubService {
|
|
|
2581
2587
|
setupPeerConnection(config) {
|
|
2582
2588
|
this.closePC();
|
|
2583
2589
|
Logger.log("Creating new RTCPeerConnection with config");
|
|
2584
|
-
this.
|
|
2585
|
-
|
|
2590
|
+
this.ownPeerConnection(new RTCPeerConnection(config));
|
|
2591
|
+
}
|
|
2592
|
+
ownPeerConnection(pc) {
|
|
2593
|
+
this.pcClient = pc;
|
|
2594
|
+
this.handlePeerConnectionEvents(pc);
|
|
2586
2595
|
this.disconnect$.pipe(take(1), takeUntil$1(this.destroy$)).subscribe(() => {
|
|
2587
2596
|
this.closePC();
|
|
2588
2597
|
});
|
|
2589
2598
|
}
|
|
2590
2599
|
createDataChannel(pc, label, options) {
|
|
2591
|
-
|
|
2592
|
-
return this.setupDataChannelCallbacks(datachannel);
|
|
2600
|
+
this.ownDataChannel(pc.createDataChannel(label, options));
|
|
2593
2601
|
}
|
|
2594
2602
|
handleCandidateFromServer(iceCandidate) {
|
|
2595
2603
|
try {
|
|
@@ -2709,23 +2717,19 @@ var WebRtcPlayerService = class WebRtcPlayerService extends SubService {
|
|
|
2709
2717
|
return true;
|
|
2710
2718
|
}
|
|
2711
2719
|
adopt(pc, dc, stream, config, dcBuffer) {
|
|
2712
|
-
this.closePC();
|
|
2713
|
-
this.pcClient = pc;
|
|
2714
2720
|
this.cfg = config ?? {};
|
|
2715
|
-
this.
|
|
2721
|
+
this.videoService.create();
|
|
2716
2722
|
pc.onicecandidate = null;
|
|
2717
2723
|
pc.ondatachannel = null;
|
|
2718
2724
|
pc.ontrack = null;
|
|
2719
|
-
this.
|
|
2720
|
-
this.
|
|
2725
|
+
this.closePC();
|
|
2726
|
+
this.ownPeerConnection(pc);
|
|
2727
|
+
this.remoteDescriptionSet = true;
|
|
2728
|
+
this.videoService.attachVideoStream(stream, pc);
|
|
2721
2729
|
dc.onmessage = null;
|
|
2722
2730
|
dc.onopen = null;
|
|
2723
2731
|
dc.onclose = null;
|
|
2724
|
-
this.
|
|
2725
|
-
for (const buffered of dcBuffer) this.onDataChannelMessage$.next(buffered);
|
|
2726
|
-
this.onDataChannelConnected();
|
|
2727
|
-
this.videoService.create();
|
|
2728
|
-
this.videoService.attachVideoStream(stream, pc);
|
|
2732
|
+
this.ownDataChannel(dc, dcBuffer);
|
|
2729
2733
|
}
|
|
2730
2734
|
setConfig(parOptions = {}) {
|
|
2731
2735
|
const urlParams = new URLSearchParams(window.location.search);
|
|
@@ -2778,9 +2782,7 @@ var WebRtcPlayerService = class WebRtcPlayerService extends SubService {
|
|
|
2778
2782
|
type: "iceCandidate",
|
|
2779
2783
|
candidate
|
|
2780
2784
|
}));
|
|
2781
|
-
fromEvent(pcClient, "datachannel").pipe(tap((e) => Logger.info(`[DATACHANNEL] Received remote DC: label="${e.channel.label}" id=${e.channel.id} protocol="${e.channel.protocol}" ordered=${e.channel.ordered}`)), map$1((e) => e.channel), takeUntil$1(merge(this.disconnect$, this.destroy$))).subscribe((datachannel) =>
|
|
2782
|
-
this.dcClient = this.setupDataChannelCallbacks(datachannel);
|
|
2783
|
-
});
|
|
2785
|
+
fromEvent(pcClient, "datachannel").pipe(tap((e) => Logger.info(`[DATACHANNEL] Received remote DC: label="${e.channel.label}" id=${e.channel.id} protocol="${e.channel.protocol}" ordered=${e.channel.ordered}`)), map$1((e) => e.channel), takeUntil$1(merge(this.disconnect$, this.destroy$))).subscribe((datachannel) => this.ownDataChannel(datachannel));
|
|
2784
2786
|
const onTrack$ = fromEvent(pcClient, "track").pipe(takeUntil$1(merge(this.disconnect$, this.destroy$)), filter$1((e) => !!e.track), tap((e) => Logger.info("Got track - " + e.track.kind + " id=" + e.track.id + " readyState=" + e.track.readyState)), share());
|
|
2785
2787
|
onTrack$.pipe(filter$1((e) => e.track.kind === "audio"), map$1((e) => e.streams[0])).subscribe((stream) => this.videoService.attachAudioStream(stream));
|
|
2786
2788
|
onTrack$.pipe(filter$1((e) => e.track.kind === "video"), map$1((e) => e.streams[0]), tap(() => Logger.info("Set video source from video track ontrack."))).subscribe((stream) => {
|
|
@@ -2818,7 +2820,8 @@ var WebRtcPlayerService = class WebRtcPlayerService extends SubService {
|
|
|
2818
2820
|
} else pc.addTransceiver("audio", { direction: "recvonly" });
|
|
2819
2821
|
}
|
|
2820
2822
|
}
|
|
2821
|
-
|
|
2823
|
+
ownDataChannel(datachannel, replay = []) {
|
|
2824
|
+
this.dcClient = datachannel;
|
|
2822
2825
|
try {
|
|
2823
2826
|
Logger.log(`[DATACHANNEL] Setting up datachannel "${datachannel.label}" callbacks...`);
|
|
2824
2827
|
datachannel.binaryType = "arraybuffer";
|
|
@@ -2833,14 +2836,14 @@ var WebRtcPlayerService = class WebRtcPlayerService extends SubService {
|
|
|
2833
2836
|
const message = `[DATACHANNEL] Data channel "${datachannel.label}" error. id:${datachannel.id}`;
|
|
2834
2837
|
Logger.error(message, e);
|
|
2835
2838
|
});
|
|
2836
|
-
fromEvent(datachannel, "open").pipe(tap(() => {
|
|
2837
|
-
Logger.info(`[DATACHANNEL] Data channel "${datachannel.label}" connected. id:${datachannel.id}`);
|
|
2838
|
-
}), takeUntil$1(merge(this.disconnect$, this.destroy$))).subscribe(() => this.onDataChannelConnected());
|
|
2839
2839
|
fromEvent(datachannel, "message").pipe(map$1((e) => e.data), takeUntil$1(merge(this.disconnect$, this.destroy$))).subscribe((data) => this.onDataChannelMessage$.next(data));
|
|
2840
|
-
|
|
2840
|
+
for (const buffered of replay) this.onDataChannelMessage$.next(buffered);
|
|
2841
|
+
(datachannel.readyState === "open" ? of(null) : fromEvent(datachannel, "open").pipe(take(1))).pipe(tap(() => {
|
|
2842
|
+
Logger.info(`[DATACHANNEL] Data channel "${datachannel.label}" connected. id:${datachannel.id}`);
|
|
2843
|
+
}), switchMap$1(() => this.videoService.video$.pipe(filter$1(Truthy), take(1))), takeUntil$1(merge(this.disconnect$, this.destroy$))).subscribe(() => this.onDataChannelConnected());
|
|
2841
2844
|
} catch (e) {
|
|
2842
2845
|
Logger.warn("[DATACHANNEL] Datachannel setup caused an exception: ", e);
|
|
2843
|
-
|
|
2846
|
+
this.dcClient = null;
|
|
2844
2847
|
}
|
|
2845
2848
|
}
|
|
2846
2849
|
onDataChannelConnected() {
|