Revert "feat(streams): add phase-2 SFU transport handshake and produce/consume APIs"

This reverts commit 498a7f838b7747470b220701505c4bfbd3ea8cff.
This commit is contained in:
2026-02-20 14:00:00 +00:00
parent ef652ea7e5
commit 37d7c27ba0
12 changed files with 65 additions and 1395 deletions

View File

@@ -1,24 +1,11 @@
import type {
SfuConsumerDescriptor,
SfuMediaKind,
SfuProducerDescriptor,
SfuSessionDescriptor,
SfuSessionState,
SfuTransportDescriptor,
SfuTransportDirection,
} from './types';
import type { SfuSessionDescriptor, SfuSessionState } from './types';
type StoredSfuSession = SfuSessionDescriptor & {
updatedAt: string;
};
const nowIso = (): string => new Date().toISOString();
export class SfuSessionRegistry {
private readonly sessions = new Map<string, StoredSfuSession>();
private readonly transports = new Map<string, SfuTransportDescriptor>();
private readonly producers = new Map<string, SfuProducerDescriptor>();
private readonly consumers = new Map<string, SfuConsumerDescriptor>();
get(streamSessionId: string): SfuSessionDescriptor | null {
const found = this.sessions.get(streamSessionId);
@@ -28,7 +15,8 @@ export class SfuSessionRegistry {
}
set(session: SfuSessionDescriptor): SfuSessionDescriptor {
this.sessions.set(session.streamSessionId, { ...session, updatedAt: nowIso() });
const now = new Date().toISOString();
this.sessions.set(session.streamSessionId, { ...session, updatedAt: now });
return session;
}
@@ -36,7 +24,11 @@ export class SfuSessionRegistry {
const existing = this.sessions.get(streamSessionId);
if (!existing) return null;
const next: StoredSfuSession = { ...existing, state, updatedAt: nowIso() };
const next: StoredSfuSession = {
...existing,
state,
updatedAt: new Date().toISOString(),
};
this.sessions.set(streamSessionId, next);
const { updatedAt: _updatedAt, ...descriptor } = next;
return descriptor;
@@ -45,97 +37,5 @@ export class SfuSessionRegistry {
list(): SfuSessionDescriptor[] {
return Array.from(this.sessions.values()).map(({ updatedAt: _updatedAt, ...descriptor }) => descriptor);
}
addTransport(input: {
transportId: string;
streamSessionId: string;
ownerDeviceId: string;
direction: SfuTransportDirection;
}): SfuTransportDescriptor {
const descriptor: SfuTransportDescriptor = {
transportId: input.transportId,
streamSessionId: input.streamSessionId,
ownerDeviceId: input.ownerDeviceId,
direction: input.direction,
state: 'new',
createdAt: nowIso(),
};
this.transports.set(descriptor.transportId, descriptor);
return descriptor;
}
getTransport(transportId: string): SfuTransportDescriptor | null {
return this.transports.get(transportId) ?? null;
}
listTransports(streamSessionId: string): SfuTransportDescriptor[] {
return Array.from(this.transports.values()).filter((transport) => transport.streamSessionId === streamSessionId);
}
connectTransport(transportId: string): SfuTransportDescriptor | null {
const existing = this.transports.get(transportId);
if (!existing) return null;
const next: SfuTransportDescriptor = { ...existing, state: 'connected' };
this.transports.set(transportId, next);
return next;
}
addProducer(input: {
producerId: string;
streamSessionId: string;
transportId: string;
cameraDeviceId: string;
kind: SfuMediaKind;
rtpParameters: Record<string, unknown>;
}): SfuProducerDescriptor {
const descriptor: SfuProducerDescriptor = {
producerId: input.producerId,
streamSessionId: input.streamSessionId,
transportId: input.transportId,
cameraDeviceId: input.cameraDeviceId,
kind: input.kind,
rtpParameters: input.rtpParameters,
createdAt: nowIso(),
};
this.producers.set(descriptor.producerId, descriptor);
return descriptor;
}
getProducer(producerId: string): SfuProducerDescriptor | null {
return this.producers.get(producerId) ?? null;
}
listProducers(streamSessionId: string): SfuProducerDescriptor[] {
return Array.from(this.producers.values())
.filter((producer) => producer.streamSessionId === streamSessionId)
.sort((left, right) => left.createdAt.localeCompare(right.createdAt));
}
addConsumer(input: {
consumerId: string;
streamSessionId: string;
transportId: string;
viewerDeviceId: string;
producerId: string;
kind: SfuMediaKind;
rtpParameters: Record<string, unknown>;
}): SfuConsumerDescriptor {
const descriptor: SfuConsumerDescriptor = {
consumerId: input.consumerId,
streamSessionId: input.streamSessionId,
transportId: input.transportId,
viewerDeviceId: input.viewerDeviceId,
producerId: input.producerId,
kind: input.kind,
rtpParameters: input.rtpParameters,
createdAt: nowIso(),
};
this.consumers.set(descriptor.consumerId, descriptor);
return descriptor;
}
listConsumers(streamSessionId: string): SfuConsumerDescriptor[] {
return Array.from(this.consumers.values()).filter((consumer) => consumer.streamSessionId === streamSessionId);
}
}