mirror of
https://github.com/imputnet/cobalt.git
synced 2025-06-28 17:38:31 +00:00
check transplant log
This commit is contained in:
parent
f572d99cc2
commit
931f8a26b0
@ -174,7 +174,10 @@ export function destroyInternalStream(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const transplantInternalTunnels = function(tunnelUrls, transplantUrls) {
|
const transplantInternalTunnels = function(tunnelUrls, transplantUrls) {
|
||||||
|
console.log(`[transplantInternalTunnels] Starting transplant - tunnels: ${tunnelUrls.length}, urls: ${transplantUrls.length}`);
|
||||||
|
|
||||||
if (tunnelUrls.length !== transplantUrls.length) {
|
if (tunnelUrls.length !== transplantUrls.length) {
|
||||||
|
console.log(`[transplantInternalTunnels] Length mismatch, aborting`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,13 +185,29 @@ const transplantInternalTunnels = function(tunnelUrls, transplantUrls) {
|
|||||||
const id = getInternalTunnelId(tun);
|
const id = getInternalTunnelId(tun);
|
||||||
const itunnel = getInternalTunnel(id);
|
const itunnel = getInternalTunnel(id);
|
||||||
|
|
||||||
if (!itunnel) continue;
|
console.log(`[transplantInternalTunnels] Processing tunnel ID: ${id}`);
|
||||||
|
console.log(`[transplantInternalTunnels] Old URL: ${itunnel?.url}`);
|
||||||
|
console.log(`[transplantInternalTunnels] New URL: ${url}`);
|
||||||
|
|
||||||
|
if (!itunnel) {
|
||||||
|
console.log(`[transplantInternalTunnels] No internal tunnel found for ID: ${id}`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
itunnel.url = url;
|
itunnel.url = url;
|
||||||
|
console.log(`[transplantInternalTunnels] Successfully updated tunnel ${id} URL`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[transplantInternalTunnels] Transplant completed`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const transplantTunnel = async function (dispatcher) {
|
const transplantTunnel = async function (dispatcher) {
|
||||||
|
console.log(`[transplant] Starting transplant for service: ${this.service}`);
|
||||||
|
console.log(`[transplant] Original request ID: ${this.originalRequest?.id}`);
|
||||||
|
console.log(`[transplant] Current URL: ${this.url}`);
|
||||||
|
|
||||||
if (this.pendingTransplant) {
|
if (this.pendingTransplant) {
|
||||||
|
console.log(`[transplant] Transplant already pending, waiting...`);
|
||||||
await this.pendingTransplant;
|
await this.pendingTransplant;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -197,31 +216,60 @@ const transplantTunnel = async function (dispatcher) {
|
|||||||
this.pendingTransplant = new Promise(r => finished = r);
|
this.pendingTransplant = new Promise(r => finished = r);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
console.log(`[transplant] Loading service handler: ${this.service}`);
|
||||||
const handler = await import(`../processing/services/${this.service}.js`);
|
const handler = await import(`../processing/services/${this.service}.js`);
|
||||||
|
|
||||||
|
console.log(`[transplant] Calling service with originalRequest:`, {
|
||||||
|
id: this.originalRequest?.id,
|
||||||
|
quality: this.originalRequest?.quality,
|
||||||
|
format: this.originalRequest?.format,
|
||||||
|
isAudioOnly: this.originalRequest?.isAudioOnly,
|
||||||
|
isAudioMuted: this.originalRequest?.isAudioMuted
|
||||||
|
});
|
||||||
|
|
||||||
const response = await handler.default({
|
const response = await handler.default({
|
||||||
...this.originalRequest,
|
...this.originalRequest,
|
||||||
dispatcher
|
dispatcher
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.log(`[transplant] Service response:`, {
|
||||||
|
hasUrls: !!response.urls,
|
||||||
|
urlsLength: response.urls ? [response.urls].flat().length : 0,
|
||||||
|
error: response.error,
|
||||||
|
type: response.type
|
||||||
|
});
|
||||||
|
|
||||||
if (!response.urls) {
|
if (!response.urls) {
|
||||||
|
console.log(`[transplant] No URLs in response, aborting transplant`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
response.urls = [response.urls].flat();
|
response.urls = [response.urls].flat();
|
||||||
|
console.log(`[transplant] Flattened URLs count: ${response.urls.length}`);
|
||||||
|
|
||||||
if (this.originalRequest.isAudioOnly && response.urls.length > 1) {
|
if (this.originalRequest.isAudioOnly && response.urls.length > 1) {
|
||||||
response.urls = [response.urls[1]];
|
response.urls = [response.urls[1]];
|
||||||
|
console.log(`[transplant] Using audio-only URL (index 1)`);
|
||||||
} else if (this.originalRequest.isAudioMuted) {
|
} else if (this.originalRequest.isAudioMuted) {
|
||||||
response.urls = [response.urls[0]];
|
response.urls = [response.urls[0]];
|
||||||
|
console.log(`[transplant] Using muted video URL (index 0)`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const tunnels = [this.urls].flat();
|
const tunnels = [this.urls].flat();
|
||||||
|
console.log(`[transplant] Tunnels count: ${tunnels.length}, response URLs count: ${response.urls.length}`);
|
||||||
|
|
||||||
if (tunnels.length !== response.urls.length) {
|
if (tunnels.length !== response.urls.length) {
|
||||||
|
console.log(`[transplant] Tunnel/URL count mismatch, aborting transplant`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`[transplant] Transplanting internal tunnels...`);
|
||||||
transplantInternalTunnels(tunnels, response.urls);
|
transplantInternalTunnels(tunnels, response.urls);
|
||||||
|
console.log(`[transplant] Transplant completed successfully`);
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.log(`[transplant] Error during transplant:`, error);
|
||||||
}
|
}
|
||||||
catch {}
|
|
||||||
finally {
|
finally {
|
||||||
finished();
|
finished();
|
||||||
delete this.pendingTransplant;
|
delete this.pendingTransplant;
|
||||||
|
Loading…
Reference in New Issue
Block a user