refactor streamer to use stream providers (e.g. to plugin web torrent)

This commit is contained in:
Jurgis Sakalauskas
2023-01-04 14:26:05 +02:00
parent 8c900a774e
commit 3c9ea2fb39
13 changed files with 123 additions and 56 deletions
@@ -0,0 +1,21 @@
import { ReadStreamCreatable } from '../Interface/read-stream-creatable.interface';
import { FileEntity } from '../../VideoFiles/Entity/file.entity';
import { Inject, Injectable } from '@nestjs/common';
import { ReadStreamCreatableProviderInterface } from './read-stream-creatable-provider.interface';
export const ReadStreamCreatableProviders = 'ReadStreamCreatableProviders';
@Injectable()
export class ReadStreamCreatableProvider {
constructor(
@Inject(ReadStreamCreatableProviders)
private providers: Array<ReadStreamCreatableProviderInterface>,
) {}
getReadStreamCreatable(fileEntity: FileEntity): Promise<ReadStreamCreatable> {
for (const provider of this.providers) {
if (provider.supports(fileEntity)) {
return provider.getReadStreamCreatable(fileEntity);
}
}
}
}