Files
discord-decomp/modules/go_live/StreamRTCConnection.tsx
T
2026-11-01 12:12:55 +02:00

676 lines
30 KiB
TypeScript

// Metro module 4278 (f4279).
import ClipsStore from "../clips/ClipsStore";
import { getSystemAnalyticsInfo } from "../system_analytics/SystemAnalyticsStore.native";
import ApplicationStreamingSettingsStore from "../../stores/ApplicationStreamingSettingsStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import ChannelStore from "../../stores/ChannelStore";
import HookErrorStore from "../../stores/HookErrorStore";
import MediaEngineStore from "../../stores/MediaEngineStore";
import NetworkStore from "../../stores/NetworkStore";
import RTCConnectionStore from "../../stores/RTCConnectionStore";
import RTCRegionStore from "../../stores/RTCRegionStore";
import { AnalyticEvents, MediaEngineHookTypes, RTCConnectionStates } from "../../Constants";
import { MediaEngineContextTypes } from "../../_bundle/Module4250";
import Durations from "../../utils/Durations";
import RTCConnection from "../../lib/RTCConnection";
import SoundshareStatsAggregator from "../../lib/SoundshareStatsAggregator";
import { Timeout } from "../../_bundle/Timeout";
import { decodeStreamKey } from "./utils/StreamKeyUtils";
import VideoStreamStats from "./VideoStreamStats";
import Module12 from "../../_bundle/Module12";
import Dispatcher from "../../Dispatcher";
import { RTCConnectionEvent } from "../../lib/RTCConnectionEvent";
import { BaseConnectionEvent } from "../../_bundle/Module4286";
import { getRunningGameAnalytics } from "../game_detection/GameAnalyticsUtils";
import AnalyticsUtils from "../../utils/AnalyticsUtils";
import CrossPlatformNativeUtils_native from "../../utils/CrossPlatformNativeUtils.native";
import getSoundshareAnalyticsContext from "./utils/getSoundshareAnalyticsContext";
import { now } from "../../_bundle/sleep";
import getStreamSourceMetadata_native from "./utils/getStreamSourceMetadata.native";
import * as _VoiceEngineStreamingManager from "./native/VoiceEngineStreamingManager";
import { isClipsEnabled } from "../clips/isClipsEnabled";
import getMediaPerformanceClass_android from "../device/getMediaPerformanceClass.android";
import { HermesBuiltin } from "../../_hermes/prelude";
let prototype, StreamRTCConnection;
let c2517_17 = 5 * Durations.Millis.SECOND;
let c2517_18 = {
DETACHED: 0,
0: "DETACHED",
WAITING: 1,
1: "WAITING",
ATTACHED: 2,
2: "ATTACHED",
STARTED: 3,
3: "STARTED",
PLAYING: 4,
4: "PLAYING",
SILENCE: 5,
5: "SILENCE"
};
const StreamRTCConnection2 = class StreamRTCConnection extends RTCConnection {
constructor({ sessionId, streamKey, serverId, initialLayout, analyticsContext, parentMediaSessionId, channelId }) {
const streamContext = decodeStreamKey(streamKey);
const { guildId, channelId: channelId2 } = streamContext;
const r31 = {
userId: AuthenticationStore.getId(),
sessionId,
guildId,
channelId: channelId2,
context: MediaEngineContextTypes.STREAM,
streamServerId: serverId,
streamChannelId: channelId,
parentMediaSessionId,
joinVoiceId: null
};
super(r31);
this.soundshareStats = new SoundshareStatsAggregator();
this._firstFrameDelivered = false;
this.screenshareFinishedCount = 0;
this.soundshareFailuresReported = {};
this.errorTimer = new Timeout();
this.streamContext = streamContext;
this.streamKey = streamKey;
this.videoStreamStats = new VideoStreamStats(initialLayout, this.isOwner);
this.analyticsContext = analyticsContext;
this.updateVideoStreamId = Module12.debounce((a0, a1) => {
const r13 = decodeStreamKey(this.streamKey);
Dispatcher.dispatch({
type: "RTC_CONNECTION_VIDEO",
guildId: r13.guildId,
channelId: r13.channelId,
userId: r13.ownerId,
streamId: a0,
rtcServerId: a1,
mediaEngineConnectionId: this.getMediaEngineConnectionId(),
context: MediaEngineContextTypes.STREAM
});
}, 200);
this.videoStreamStats.start();
this.initializeEvents();
}
get isOwner() {
const ownerId = this.streamContext.ownerId;
return AuthenticationStore.getId() === ownerId;
}
destroy(a0) {
this.videoStreamStats.stop();
this.trackVideoEndStats(a0);
this.updateVideoStreamId.cancel();
this.updateVideoStreamId(null, null);
this.updateVideoStreamId.flush();
this.errorTimer.stop();
Reflect.get(Object.getPrototypeOf(prototype), "destroy", this).call(this);
}
streamUpdate(a0) {
const _videoQuality2 = this._videoQuality;
if (_videoQuality2 != null) {
if (a0) {
_videoQuality2.pause();
} else {
_videoQuality2.resume();
}
}
}
layoutChange(a0) {
this.videoStreamStats.layoutChange(a0);
}
autoQualityChange() {
this.videoStreamStats.autoQualityChange();
}
getVideoStats() {
let r7;
const ownerId = this.streamContext.ownerId;
const _videoQuality2 = this._videoQuality;
if (_videoQuality2 != null) {
if (this.isOwner) {
let r10 = _videoQuality2.getOutboundStats()[0];
if (r10 == null) {
r10 = {};
}
r7 = r10;
} else {
r7 = _videoQuality2.getInboundStats(ownerId);
if (r7 == null) {
r7 = {};
}
}
return {
duration: r7.duration,
avg_bitrate: r7.avg_bitrate,
avg_fps: r7.avg_fps,
avg_resolution: r7.avg_resolution,
inbound_bitrate_estimate_percentile99: r7.inbound_bitrate_estimate_percentile99
};
}
return null;
}
getRegion() {
return this.analyticsContext.streamRegion;
}
getMaxViewers() {
return this.analyticsContext.maxViewers;
}
getVoiceParticipantType() {
return this.isOwner ? "streamer" : "receiver";
}
initializeEvents() {
let c14082_0 = false;
this.on(RTCConnectionEvent.State, (a0, a1, a2) => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_STATE",
state: a0,
...a1,
...a2,
streamKey: this.streamKey
});
if (a0 === RTCConnectionStates.RTC_CONNECTED) {
const _connection = this._connection;
if (_connection != null) {
_connection.on(BaseConnectionEvent.ScreenshareFinish, (screenshare_frames, videohook_frames, hybrid_dxgi_frames, hybrid_gdi_frames, hybrid_videohook_frames, hybrid_graphics_capture_frames, hybrid_capture_method_switches, hybrid_gdi_bitblt_frames, hybrid_gdi_printwindow_frames, hybrid_graphics_capture_frames_unique, hybrid_dxgi_frames_unique, hybrid_videohook_frames_unique, hybrid_gdi_bitblt_frames_unique, hybrid_gdi_printwindow_frames_unique, skip_history_json, quartz_frames, desktop_capturer_type, activity, go_live_camera_frames, screencapturekit_frames, hdr_frames_capable, hdr_frames, target_window_elevated, pipewire_frames, x11_frames, videohook_backend) => {
const streamApplicationFromHistory = this.analyticsContext.getStreamApplicationFromHistory(this.screenshareFinishedCount);
this.screenshareFinishedCount = this.screenshareFinishedCount + 1;
const runningGameAnalytics = getRunningGameAnalytics(streamApplicationFromHistory);
const { gameName, gameId, exe, distributor } = runningGameAnalytics;
const mediaSessionId = this.getMediaSessionId();
const rTCConnectionId = this.getRTCConnectionId();
getSystemAnalyticsInfo().then((result) => {
const r7 = result != null ? {
cpu_brand: result.cpu_brand,
cpu_vendor: result.cpu_vendor,
cpu_memory: result.cpu_memory,
gpu_brand: result.gpu_brand,
gpu_memory: result.gpu_memory
} : null;
const SCREENSHARE_FINISHED = AnalyticEvents.SCREENSHARE_FINISHED;
let r25 = screenshare_frames;
let r9 = videohook_frames;
let r24 = hybrid_dxgi_frames;
let r23 = hybrid_gdi_frames;
let r22 = hybrid_videohook_frames;
let r21 = hybrid_graphics_capture_frames;
let r18 = hybrid_graphics_capture_frames_unique;
let r14 = hybrid_dxgi_frames_unique;
let r17 = hybrid_videohook_frames_unique;
let r16 = hybrid_gdi_bitblt_frames_unique;
let r15 = hybrid_gdi_printwindow_frames_unique;
let r20 = quartz_frames;
let r19 = screencapturekit_frames;
let r40 = go_live_camera_frames;
if (screenshare_frames == null) {
r25 = 0;
}
if (videohook_frames == null) {
r9 = 0;
}
const r42 = r25 + r9;
if (hybrid_dxgi_frames == null) {
r24 = 0;
}
const r43 = r42 + r24;
if (hybrid_gdi_frames == null) {
r23 = 0;
}
const r44 = r43 + r23;
if (hybrid_videohook_frames == null) {
r22 = 0;
}
const r45 = r44 + r22;
if (hybrid_graphics_capture_frames == null) {
r21 = 0;
}
const r46 = r45 + r21;
if (quartz_frames == null) {
r20 = 0;
}
const r47 = r46 + r20;
if (screencapturekit_frames == null) {
r19 = 0;
}
const r48 = r47 + r19;
if (go_live_camera_frames == null) {
r40 = 0;
}
const r52 = r48 + r40 + (x11_frames == null ? 0 : x11_frames);
const r54 = pipewire_frames == null ? 0 : pipewire_frames;
if (hybrid_graphics_capture_frames_unique == null) {
r18 = 0;
}
if (hybrid_dxgi_frames_unique == null) {
r14 = 0;
}
const r56 = r18 + r14;
if (hybrid_videohook_frames_unique == null) {
r17 = 0;
}
const r57 = r56 + r17;
if (hybrid_gdi_bitblt_frames_unique == null) {
r16 = 0;
}
const r58 = r57 + r16;
if (hybrid_gdi_printwindow_frames_unique == null) {
r15 = 0;
}
AnalyticsUtils.track(SCREENSHARE_FINISHED, {
screenshare_frames,
videohook_frames,
hybrid_dxgi_frames,
hybrid_gdi_frames,
hybrid_videohook_frames,
hybrid_graphics_capture_frames,
hybrid_capture_method_switches,
hybrid_gdi_bitblt_frames,
hybrid_gdi_printwindow_frames,
hybrid_graphics_capture_frames_unique,
hybrid_dxgi_frames_unique,
hybrid_videohook_frames_unique,
hybrid_gdi_bitblt_frames_unique,
hybrid_gdi_printwindow_frames_unique,
skip_history_json,
quartz_frames,
screencapturekit_frames,
go_live_camera_frames,
total_frames: r52 + r54,
total_frames_unique: r58 + r15,
desktop_capturer_type,
media_session_id: mediaSessionId,
rtc_connection_id: rTCConnectionId,
context: MediaEngineContextTypes.STREAM,
activity,
soundshare_session: this.soundshareStats.getStats().soundshare_last_session,
picker_type_used: this.analyticsContext.nativePickerStyleUsed != null ? "native" : "internal",
duration: this.analyticsContext.getDuration(),
share_game_name: gameName,
share_game_id: gameId,
share_game_exe: exe,
share_game_distributor: distributor,
hdr_frames_capable,
hdr_frames,
discord_is_elevated: CrossPlatformNativeUtils_native.getDiscordIsElevated(),
target_window_elevated,
pipewire_frames,
x11_frames,
videohook_backend,
...r7
});
});
});
}
const _connection2 = this._connection;
if (_connection2 != null) {
_connection2.on(BaseConnectionEvent.SoundshareAttached, () => {
const goLiveSource = MediaEngineStore.getGoLiveSource();
if (goLiveSource?.desktopSource != null) {
AnalyticsUtils.track(AnalyticEvents.SOUNDSHARE_ATTACHED, {
...getSoundshareAnalyticsContext(goLiveSource?.desktopSource),
...this.getSoundshareAnalyticsProperties()
});
}
});
}
const _connection3 = this._connection;
if (_connection3 != null) {
_connection3.on(BaseConnectionEvent.SoundshareFailed, ({ failureCode, failureReason, willRetry }) => {
this.reportSoundshareFailure(MediaEngineStore.getGoLiveSource()?.desktopSource, failureCode, failureReason, willRetry);
});
}
const _connection4 = this._connection;
if (_connection4 != null) {
_connection4.on(BaseConnectionEvent.SoundshareSpeaking, () => {
const goLiveSource = MediaEngineStore.getGoLiveSource();
if (goLiveSource?.desktopSource != null) {
AnalyticsUtils.track(AnalyticEvents.SOUNDSHARE_TRANSMITTING, {
...getSoundshareAnalyticsContext(goLiveSource?.desktopSource),
...this.getSoundshareAnalyticsProperties()
});
if (HookErrorStore.getHookError(MediaEngineHookTypes.SOUND) != null) {
Dispatcher.dispatch({
type: "MEDIA_ENGINE_SOUNDSHARE_TRANSMITTING"
});
}
}
});
}
const _connection5 = this._connection;
if (_connection5 != null) {
_connection5.on(BaseConnectionEvent.SoundshareTrace, (a0) => {
const goLiveSource = MediaEngineStore.getGoLiveSource();
this.soundshareStats.traceEvent(goLiveSource == null ? void 0 : goLiveSource.desktopSource?.soundshareSession, a0);
const type2 = a0.type;
if (type2 === "soundshare_attach_requested") {
this.errorTimer.start(c2517_17, () => {
Dispatcher.dispatch({
type: "MEDIA_ENGINE_SOUNDSHARE_FAILED",
errorMessage: "Sound Hook Failed"
});
});
} else if (type2 === "soundshare_recv_failed") {
const { reason: reason2, code, retry } = a0;
if (goLiveSource?.desktopSource != null) {
this.reportSoundshareFailure(goLiveSource?.desktopSource, code, reason2, retry);
if (!retry) {
this.errorTimer.stop();
Dispatcher.dispatch({
type: "MEDIA_ENGINE_SOUNDSHARE_FAILED",
errorMessage: reason2,
errorCode: code
});
}
}
} else if (type2 === "soundshare_state_transition" && a0.newState === c2517_18.PLAYING) {
this.errorTimer.stop();
Dispatcher.dispatch({
type: "MEDIA_ENGINE_SOUNDSHARE_TRANSMITTING"
});
}
});
}
const _connection6 = this._connection;
if (_connection6 != null) {
_connection6.on(BaseConnectionEvent.FirstFrameStats, (a0) => {
if (!this._firstFrameDelivered) {
this._firstFrameDelivered = true;
const streamAnalyticsProperties = this.getStreamAnalyticsProperties();
AnalyticsUtils.track(AnalyticEvents.RECEIVER_FIRST_FRAME_DELIVERED, {
guild_id: streamAnalyticsProperties.guild_id,
channel_id: streamAnalyticsProperties.channel_id,
rtc_connection_id: streamAnalyticsProperties.rtc_connection_id,
media_session_id: streamAnalyticsProperties.media_session_id,
parent_media_session_id: streamAnalyticsProperties.parent_media_session_id,
num_viewers: this.analyticsContext.numViewers,
time_connected_to_first_frame_delivered: this.getDuration(),
time_total_to_first_frame: now() - this.getCreatedTime(),
time_remote_user_to_video_stream_created: a0.remoteVideoStreamCreatedTimestamp !== void 0 ? a0.remoteUserCreatedTimestamp !== void 0 ? Number(a0.remoteVideoStreamCreatedTimestamp - a0.remoteUserCreatedTimestamp) : null : null,
time_video_stream_created_to_video_data_received: a0.videoDataReceivedTimestamp !== void 0 ? a0.remoteVideoStreamCreatedTimestamp !== void 0 ? Number(a0.videoDataReceivedTimestamp - a0.remoteVideoStreamCreatedTimestamp) : null : null,
time_video_data_received_to_video_source_delivered_frame: a0.videoSourceDeliveredFrameTimestamp !== void 0 ? a0.videoDataReceivedTimestamp !== void 0 ? Number(a0.videoSourceDeliveredFrameTimestamp - a0.videoDataReceivedTimestamp) : null : null,
time_remote_user_to_mls_external_sender_updated: a0.updateMLSExternalSenderTimestamp !== void 0 ? a0.remoteUserCreatedTimestamp !== void 0 ? Number(a0.updateMLSExternalSenderTimestamp - a0.remoteUserCreatedTimestamp) : null : null,
time_remote_user_to_secure_frame_remote_key_ratchet_set: a0.setRemoteSecureFrameKeyRatchetTimestamp !== void 0 ? a0.remoteUserCreatedTimestamp !== void 0 ? Number(a0.setRemoteSecureFrameKeyRatchetTimestamp - a0.remoteUserCreatedTimestamp) : null : null,
time_remote_user_to_secure_frame_local_key_ratchet_set: a0.setLocalSecureFrameKeyRatchetTimestamp !== void 0 ? a0.remoteUserCreatedTimestamp !== void 0 ? Number(a0.setLocalSecureFrameKeyRatchetTimestamp - a0.remoteUserCreatedTimestamp) : null : null,
time_remote_user_to_first_frame_decrypted: a0.firstFrameDecryptedTimestamp !== void 0 ? a0.remoteUserCreatedTimestamp !== void 0 ? Number(a0.firstFrameDecryptedTimestamp - a0.remoteUserCreatedTimestamp) : null : null
});
}
});
}
const _connection7 = this._connection;
if (_connection7 != null) {
_connection7.on(BaseConnectionEvent.FirstFrameEncryptedStats, (a0) => {
const streamAnalyticsProperties = this.getStreamAnalyticsProperties();
AnalyticsUtils.track(AnalyticEvents.STREAMER_FIRST_FRAME_ENCRYPTED, {
guild_id: streamAnalyticsProperties.guild_id,
channel_id: streamAnalyticsProperties.channel_id,
rtc_connection_id: streamAnalyticsProperties.rtc_connection_id,
media_session_id: streamAnalyticsProperties.media_session_id,
parent_media_session_id: streamAnalyticsProperties.parent_media_session_id,
time_local_user_to_video_receivers_set: a0.videoReceiversSetTimestamp !== void 0 ? a0.localUserCreatedTimestamp !== void 0 ? Number(a0.videoReceiversSetTimestamp - a0.localUserCreatedTimestamp) : null : null,
time_local_user_to_mls_external_sender_updated: a0.updateMLSExternalSenderTimestamp !== void 0 ? a0.localUserCreatedTimestamp !== void 0 ? Number(a0.updateMLSExternalSenderTimestamp - a0.localUserCreatedTimestamp) : null : null,
time_local_user_to_secure_frame_remote_key_ratchet_set: a0.setRemoteSecureFrameKeyRatchetTimestamp !== void 0 ? a0.localUserCreatedTimestamp !== void 0 ? Number(a0.setRemoteSecureFrameKeyRatchetTimestamp - a0.localUserCreatedTimestamp) : null : null,
time_local_user_to_secure_frame_local_key_ratchet_set: a0.setLocalSecureFrameKeyRatchetTimestamp !== void 0 ? a0.localUserCreatedTimestamp !== void 0 ? Number(a0.setLocalSecureFrameKeyRatchetTimestamp - a0.localUserCreatedTimestamp) : null : null,
time_local_user_to_first_frame_encrypted: a0.firstFrameEncryptedTimestamp !== void 0 ? a0.localUserCreatedTimestamp !== void 0 ? Number(a0.firstFrameEncryptedTimestamp - a0.localUserCreatedTimestamp) : null : null
});
});
}
const _connection8 = this._connection;
if (_connection8 != null) {
_connection8.on(BaseConnectionEvent.Destroy, () => {
this.errorTimer.stop();
});
}
}
});
this.on(RTCConnectionEvent.Video, (a0, a1, a2, a3, a4) => {
const r12 = decodeStreamKey(this.streamKey);
if (r12.guildId === a0 && r12.channelId === a1 && r12.ownerId === a2) {
if (!(this.getMediaSessionId() == null || c14082_0)) {
this.trackVideoStartStats();
c14082_0 = true;
}
this.updateVideoStreamId(a3, a4);
}
});
this.on(RTCConnectionEvent.VideoSourceQualityChanged, (a0, a1, a2, a3, a4, a5) => {
Dispatcher.dispatch({
type: "MEDIA_ENGINE_VIDEO_SOURCE_QUALITY_CHANGED",
guildId: a0,
channelId: a1,
senderUserId: a2,
maxResolution: a3,
maxFrameRate: a4,
context: a5
});
});
this.on(RTCConnectionEvent.SecureFramesUpdate, () => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_SECURE_FRAMES_UPDATE"
});
});
this.on(RTCConnectionEvent.RosterMapUpdate, (a0) => {
Dispatcher.dispatch({
type: "RTC_CONNECTION_ROSTER_MAP_UPDATE",
userIds: a0
});
});
}
reportSoundshareFailure(a0, a1, a2, a3) {
let r5 = a0?.soundshareSession;
if (r5 == null) {
r5 = "";
}
if (this.soundshareFailuresReported[r5] == null) {
this.soundshareFailuresReported[r5] = new Set();
}
const r23 = a1 != null && !this.soundshareFailuresReported[r5].has(a1);
if (r23) {
this.soundshareFailuresReported[r5].add(a1);
}
if (a1 == null || r23) {
AnalyticsUtils.track(AnalyticEvents.SOUNDSHARE_FAILED, {
soundshare_failure_code: a1,
soundshare_failure_reason: a2,
soundshare_failure_will_retry: a3,
...getSoundshareAnalyticsContext(a0),
...this.getSoundshareAnalyticsProperties()
});
}
}
getStreamAnalyticsProperties() {
const analyticsContext = this.analyticsContext;
const { streamRegion, streamApplication, streamSourceType, actionContext } = analyticsContext;
const streamContext = this.streamContext;
const { ownerId, guildId } = streamContext;
const region = RTCRegionStore.getRegion(RTCConnectionStore.getHostname());
const runningGameAnalytics = getRunningGameAnalytics(streamApplication);
const { gameName: gameName2, gameId: gameId2, exe: exe2, distributor: distributor2, sku, gameMetadata } = runningGameAnalytics;
return {
channel_id: this.channelId,
rtc_connection_id: this.getRTCConnectionId(),
media_session_id: this.getMediaSessionId(),
parent_media_session_id: this.parentMediaSessionId,
sender_user_id: ownerId,
context: MediaEngineContextTypes.STREAM,
guild_id: guildId,
stream_region: streamRegion,
stream_source_type: streamSourceType,
guild_region: region,
participant_type: this.isOwner ? "streamer" : "receiver",
share_application_name: gameName2,
share_application_id: gameId2,
share_application_executable: exe2,
share_application_distributor: distributor2,
share_application_distributor_game_id: sku,
share_application_game_metadata: gameMetadata,
video_layout: this.videoStreamStats.getLayout(),
client_event_source: actionContext,
voice_backend_version: this.voiceVersion,
rtc_worker_backend_version: this.rtcWorkerVersion
};
}
getSoundshareAnalyticsProperties() {
return {
rtc_connection_id: this.getRTCConnectionId(),
soundshare_experimental: MediaEngineStore.getExperimentalSoundshare()
};
}
trackVideoStartStats() {
const r7 = this.isOwner ? getStreamSourceMetadata_native() : null;
AnalyticsUtils.track(AnalyticEvents.VIDEO_STREAM_STARTED, {
...this.getStreamAnalyticsProperties(),
...r7,
connection_type: NetworkStore.getType(),
effective_connection_speed: NetworkStore.getEffectiveConnectionSpeed(),
service_provider: NetworkStore.getServiceProvider(),
duration_go_live_modal: this.analyticsContext.goLiveModalDurationMs,
source_location_stack: this.analyticsContext.analyticsLocations
});
}
trackVideoEndStats(reason) {
let c14083_0, networkStats, codecUsageStats, c14083_6, c14083_7;
const channel = ChannelStore.getChannel(this.channelId);
const type = channel != null ? channel.type : null;
const ownerId = this.streamContext.ownerId;
const _videoQuality = this._videoQuality;
if (_videoQuality != null) {
networkStats = _videoQuality.getNetworkStats();
const isOwner2 = this.isOwner;
const getCodecUsageStats = _videoQuality.getCodecUsageStats;
codecUsageStats = isOwner2 ? getCodecUsageStats.call(_videoQuality, "streamer", this.userId) : getCodecUsageStats.call(_videoQuality, "receiver", ownerId);
c14083_6 = {
stream_application_name: _VoiceEngineStreamingManager.default.getApplicationNames()
};
const settings = ClipsStore.getSettings();
c14083_7 = this.isOwner ? {
clips_enabled: isClipsEnabled(),
clips_buffer_length: settings.clipsLength
} : {};
c14083_0 = this.isOwner ? {
bandwidth_estimation_experiment: this.getBandwidthEstimationExperiment()
} : {};
_videoQuality.getOutboundStats().forEach((item) => {
let num_frames = item.num_frames;
if (num_frames == null) {
num_frames = 0;
}
if (num_frames > 0) {
const VIDEO_STREAM_ENDED = AnalyticEvents.VIDEO_STREAM_ENDED;
const r19 = {
...codecUsageStats,
...networkStats,
...c14083_6
};
HermesBuiltin.copyDataProperties(r19, this.videoStreamStats.getStats());
HermesBuiltin.copyDataProperties(r19, item);
HermesBuiltin.copyDataProperties(r19, this.soundshareStats.getStats());
HermesBuiltin.copyDataProperties(r19, this.getStreamAnalyticsProperties());
HermesBuiltin.copyDataProperties(r19, c14083_7);
HermesBuiltin.copyDataProperties(r19, c14083_0);
r19.app_hardware_acceleration_enabled = CrossPlatformNativeUtils_native.getAppHardwareAccelerationEnabled();
r19.channel_type = type;
r19.reason = reason;
r19.max_viewers = this.analyticsContext.maxViewers;
r19.hostname = this.hostname;
r19.hardware_enabled = MediaEngineStore.getHardwareEncoding();
r19.device_performance_class = this.isOwner ? getMediaPerformanceClass_android() : null;
r19.soundshare_experimental = MediaEngineStore.getExperimentalSoundshare();
r19.quality_preset = ApplicationStreamingSettingsStore.getState().preset;
r19.discord_is_elevated = CrossPlatformNativeUtils_native.getDiscordIsElevated();
AnalyticsUtils.track(VIDEO_STREAM_ENDED, r19);
}
});
_videoQuality.getInboundParticipants().forEach((item) => {
const inboundStats = _videoQuality.getInboundStats(item);
let r18 = inboundStats?.num_frames;
if (r18 == null) {
r18 = 0;
}
if (r18 > 0) {
const VIDEO_STREAM_ENDED = AnalyticEvents.VIDEO_STREAM_ENDED;
const r23 = {
...codecUsageStats,
...networkStats,
...c14083_6
};
HermesBuiltin.copyDataProperties(r23, this.videoStreamStats.getStats());
HermesBuiltin.copyDataProperties(r23, inboundStats);
HermesBuiltin.copyDataProperties(r23, this.soundshareStats.getStats());
HermesBuiltin.copyDataProperties(r23, this.getStreamAnalyticsProperties());
HermesBuiltin.copyDataProperties(r23, c14083_7);
HermesBuiltin.copyDataProperties(r23, c14083_0);
r23.app_hardware_acceleration_enabled = CrossPlatformNativeUtils_native.getAppHardwareAccelerationEnabled();
r23.channel_type = type;
r23.reason = reason;
r23.max_viewers = this.analyticsContext.maxViewers;
r23.hostname = this.hostname;
r23.hardware_enabled = MediaEngineStore.getHardwareEncoding();
r23.device_performance_class = this.isOwner ? getMediaPerformanceClass_android() : null;
AnalyticsUtils.track(VIDEO_STREAM_ENDED, r23);
}
});
}
}
getExtraConnectionOptions() {
return {
streamUserId: decodeStreamKey(this.streamKey).ownerId
};
}
getMediaStreamKey() {
return this.streamKey;
}
};
const prototype2 = StreamRTCConnection2.prototype;
StreamRTCConnection = StreamRTCConnection2;
prototype = prototype2;
export default StreamRTCConnection;
export class StreamRTCAnalyticsContext {
constructor(a0) {
const { streamRegion, streamApplication, streamSourceType, actionContext, numViewers, goLiveModalDurationMs } = a0;
let analyticsLocations = a0.analyticsLocations;
this.streamRegion = streamRegion;
this.streamApplication = streamApplication;
this.streamApplicationHistory = [streamApplication];
this.streamSourceType = streamSourceType;
this.actionContext = actionContext;
this.maxViewers = numViewers;
this.goLiveModalDurationMs = goLiveModalDurationMs;
this.numViewers = numViewers;
if (analyticsLocations == null) {
analyticsLocations = [];
}
this.analyticsLocations = analyticsLocations;
}
setActionContext(a0) {
this.actionContext = a0;
}
updateStreamApplication(a0) {
this.streamApplication = a0;
this.streamApplicationHistory = [...this.streamApplicationHistory, a0];
}
setAnalyticsLocations(a0) {
this.analyticsLocations = a0;
}
trackViewerCount(a0) {
this.maxViewers = Math.max(a0, this.maxViewers);
this.numViewers = a0;
}
setNativePickerStyleUsed(a0) {
this.nativePickerStyleUsed = a0;
}
trackStart() {
this.startTime = performance.now();
}
trackEnd() {
this.endTime = performance.now();
}
getStreamApplicationFromHistory(a0) {
return this.streamApplicationHistory[a0];
}
getDuration() {
if (this.startTime == null) {
return null;
}
const r6 = performance.now();
let endTime = this.endTime;
if (endTime == null) {
endTime = r6;
}
return endTime - this.startTime;
}
}