mirror of
https://github.com/simplex-chat/simplex-chat.git
synced 2026-04-26 10:58:02 +00:00
android, desktop: call logs
This commit is contained in:
@@ -112,6 +112,7 @@ const processCommand = (function () {
|
||||
}
|
||||
async function initializeCall(config, mediaType, aesKey) {
|
||||
var _a;
|
||||
console.log("Initializing call");
|
||||
let pc;
|
||||
try {
|
||||
pc = new RTCPeerConnection(config.peerConnectionConfig);
|
||||
@@ -154,6 +155,7 @@ const processCommand = (function () {
|
||||
connectionHandler();
|
||||
}
|
||||
async function connectionHandler() {
|
||||
console.log(`Connection state change: ${pc.connectionState}, ${pc.iceConnectionState}, ${pc.iceGatheringState}, ${pc.signalingState}`);
|
||||
sendMessageToNative({
|
||||
resp: {
|
||||
type: "connection",
|
||||
@@ -209,6 +211,7 @@ const processCommand = (function () {
|
||||
}
|
||||
async function processCommand(body) {
|
||||
const { corrId, command } = body;
|
||||
console.log(`process command: ${command.type}`);
|
||||
const pc = activeCall === null || activeCall === void 0 ? void 0 : activeCall.connection;
|
||||
let resp;
|
||||
try {
|
||||
@@ -220,6 +223,7 @@ const processCommand = (function () {
|
||||
// This request for local media stream is made to prompt for camera/mic permissions on call start
|
||||
if (command.media)
|
||||
await getLocalMediaStream(command.media, VideoCamera.User);
|
||||
console.log("Asked video camera permission");
|
||||
const encryption = supportsInsertableStreams(useWorker);
|
||||
resp = { type: "capabilities", capabilities: { encryption } };
|
||||
break;
|
||||
@@ -370,11 +374,13 @@ const processCommand = (function () {
|
||||
}
|
||||
function addIceCandidates(conn, iceCandidates) {
|
||||
for (const c of iceCandidates) {
|
||||
console.log("Adding ice candidate");
|
||||
conn.addIceCandidate(new RTCIceCandidate(c));
|
||||
// console.log("addIceCandidates", JSON.stringify(c))
|
||||
}
|
||||
}
|
||||
async function setupMediaStreams(call) {
|
||||
console.log("Setup media streams start");
|
||||
const videos = getVideoElements();
|
||||
if (!videos)
|
||||
throw Error("no video elements");
|
||||
@@ -389,6 +395,7 @@ const processCommand = (function () {
|
||||
// Without doing it manually Firefox shows black screen but video can be played in Picture-in-Picture
|
||||
videos.local.play();
|
||||
videos.remote.play();
|
||||
console.log("Setup media streams end");
|
||||
}
|
||||
async function setupEncryptionWorker(call) {
|
||||
if (call.aesKey) {
|
||||
@@ -409,6 +416,7 @@ const processCommand = (function () {
|
||||
const pc = call.connection;
|
||||
let { localStream } = call;
|
||||
for (const track of localStream.getTracks()) {
|
||||
console.log(`Adding local track: ${track.kind}`);
|
||||
pc.addTrack(track, localStream);
|
||||
}
|
||||
if (call.aesKey && call.key) {
|
||||
@@ -429,6 +437,7 @@ const processCommand = (function () {
|
||||
}
|
||||
for (const stream of event.streams) {
|
||||
for (const track of stream.getTracks()) {
|
||||
console.log(`Adding remote track: ${track.kind}`);
|
||||
call.remoteStream.addTrack(track);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,6 +321,7 @@ const processCommand = (function () {
|
||||
}
|
||||
|
||||
async function initializeCall(config: CallConfig, mediaType: CallMediaType, aesKey?: string): Promise<Call> {
|
||||
console.log("Initializing call")
|
||||
let pc: RTCPeerConnection
|
||||
try {
|
||||
pc = new RTCPeerConnection(config.peerConnectionConfig)
|
||||
@@ -365,6 +366,7 @@ const processCommand = (function () {
|
||||
}
|
||||
|
||||
async function connectionHandler() {
|
||||
console.log(`Connection state change: ${pc.connectionState}, ${pc.iceConnectionState}, ${pc.iceGatheringState}, ${pc.signalingState}`)
|
||||
sendMessageToNative({
|
||||
resp: {
|
||||
type: "connection",
|
||||
@@ -423,6 +425,7 @@ const processCommand = (function () {
|
||||
|
||||
async function processCommand(body: WVAPICall): Promise<WVApiMessage> {
|
||||
const {corrId, command} = body
|
||||
console.log(`process command: ${command.type}`)
|
||||
const pc = activeCall?.connection
|
||||
let resp: WCallResponse
|
||||
try {
|
||||
@@ -432,6 +435,7 @@ const processCommand = (function () {
|
||||
if (activeCall) endCall()
|
||||
// This request for local media stream is made to prompt for camera/mic permissions on call start
|
||||
if (command.media) await getLocalMediaStream(command.media, VideoCamera.User)
|
||||
console.log("Asked video camera permission")
|
||||
const encryption = supportsInsertableStreams(useWorker)
|
||||
resp = {type: "capabilities", capabilities: {encryption}}
|
||||
break
|
||||
@@ -571,12 +575,14 @@ const processCommand = (function () {
|
||||
|
||||
function addIceCandidates(conn: RTCPeerConnection, iceCandidates: RTCIceCandidateInit[]) {
|
||||
for (const c of iceCandidates) {
|
||||
console.log("Adding ice candidate")
|
||||
conn.addIceCandidate(new RTCIceCandidate(c))
|
||||
// console.log("addIceCandidates", JSON.stringify(c))
|
||||
}
|
||||
}
|
||||
|
||||
async function setupMediaStreams(call: Call): Promise<void> {
|
||||
console.log("Setup media streams start")
|
||||
const videos = getVideoElements()
|
||||
if (!videos) throw Error("no video elements")
|
||||
await setupEncryptionWorker(call)
|
||||
@@ -590,6 +596,7 @@ const processCommand = (function () {
|
||||
// Without doing it manually Firefox shows black screen but video can be played in Picture-in-Picture
|
||||
videos.local.play()
|
||||
videos.remote.play()
|
||||
console.log("Setup media streams end")
|
||||
}
|
||||
|
||||
async function setupEncryptionWorker(call: Call) {
|
||||
@@ -611,6 +618,7 @@ const processCommand = (function () {
|
||||
let {localStream} = call
|
||||
|
||||
for (const track of localStream.getTracks()) {
|
||||
console.log(`Adding local track: ${track.kind}`)
|
||||
pc.addTrack(track, localStream)
|
||||
}
|
||||
|
||||
@@ -633,6 +641,7 @@ const processCommand = (function () {
|
||||
}
|
||||
for (const stream of event.streams) {
|
||||
for (const track of stream.getTracks()) {
|
||||
console.log(`Adding remote track: ${track.kind}`)
|
||||
call.remoteStream.addTrack(track)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user