mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-03 13:53:53 +02:00
Make some more fields readonly
This commit is contained in:
+4
-4
@@ -112,9 +112,9 @@ const FALLBACK_SAMPLE_RATE = 48000;
|
|||||||
*/
|
*/
|
||||||
export class Conversion {
|
export class Conversion {
|
||||||
/** The input file. */
|
/** The input file. */
|
||||||
input: Input;
|
readonly input: Input;
|
||||||
/** The output file. */
|
/** The output file. */
|
||||||
output: Output;
|
readonly output: Output;
|
||||||
|
|
||||||
/** @internal */
|
/** @internal */
|
||||||
_options: ConversionOptions;
|
_options: ConversionOptions;
|
||||||
@@ -168,9 +168,9 @@ export class Conversion {
|
|||||||
_lastProgress = 0;
|
_lastProgress = 0;
|
||||||
|
|
||||||
/** The list of tracks that are included in the output file. */
|
/** The list of tracks that are included in the output file. */
|
||||||
utilizedTracks: InputTrack[] = [];
|
readonly utilizedTracks: InputTrack[] = [];
|
||||||
/** The list of tracks from the input file that have been discarded, alongside the discard reason. */
|
/** The list of tracks from the input file that have been discarded, alongside the discard reason. */
|
||||||
discardedTracks: {
|
readonly discardedTracks: {
|
||||||
/** The track that was discarded. */
|
/** The track that was discarded. */
|
||||||
track: InputTrack;
|
track: InputTrack;
|
||||||
/** The reason for discarding the track. */
|
/** The reason for discarding the track. */
|
||||||
|
|||||||
+12
-12
@@ -9,11 +9,11 @@ import { AudioSample, VideoSample } from './sample';
|
|||||||
*/
|
*/
|
||||||
export abstract class CustomVideoDecoder {
|
export abstract class CustomVideoDecoder {
|
||||||
/** The input video's codec. */
|
/** The input video's codec. */
|
||||||
codec!: VideoCodec;
|
readonly codec!: VideoCodec;
|
||||||
/** The input video's decoder config. */
|
/** The input video's decoder config. */
|
||||||
config!: VideoDecoderConfig;
|
readonly config!: VideoDecoderConfig;
|
||||||
/** The callback to call when a decoded VideoSample is available. */
|
/** The callback to call when a decoded VideoSample is available. */
|
||||||
onSample!: (sample: VideoSample) => unknown;
|
readonly onSample!: (sample: VideoSample) => unknown;
|
||||||
|
|
||||||
/** Returns true iff the decoder can decode the given codec configuration. */
|
/** Returns true iff the decoder can decode the given codec configuration. */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
@@ -38,11 +38,11 @@ export abstract class CustomVideoDecoder {
|
|||||||
*/
|
*/
|
||||||
export abstract class CustomAudioDecoder {
|
export abstract class CustomAudioDecoder {
|
||||||
/** The input audio's codec. */
|
/** The input audio's codec. */
|
||||||
codec!: AudioCodec;
|
readonly codec!: AudioCodec;
|
||||||
/** The input audio's decoder config. */
|
/** The input audio's decoder config. */
|
||||||
config!: AudioDecoderConfig;
|
readonly config!: AudioDecoderConfig;
|
||||||
/** The callback to call when a decoded AudioSample is available. */
|
/** The callback to call when a decoded AudioSample is available. */
|
||||||
onSample!: (sample: AudioSample) => unknown;
|
readonly onSample!: (sample: AudioSample) => unknown;
|
||||||
|
|
||||||
/** Returns true iff the decoder can decode the given codec configuration. */
|
/** Returns true iff the decoder can decode the given codec configuration. */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
@@ -67,11 +67,11 @@ export abstract class CustomAudioDecoder {
|
|||||||
*/
|
*/
|
||||||
export abstract class CustomVideoEncoder {
|
export abstract class CustomVideoEncoder {
|
||||||
/** The codec with which to encode the video. */
|
/** The codec with which to encode the video. */
|
||||||
codec!: VideoCodec;
|
readonly codec!: VideoCodec;
|
||||||
/** Config for the encoder. */
|
/** Config for the encoder. */
|
||||||
config!: VideoEncoderConfig;
|
readonly config!: VideoEncoderConfig;
|
||||||
/** The callback to call when an EncodedPacket is available. */
|
/** The callback to call when an EncodedPacket is available. */
|
||||||
onPacket!: (packet: EncodedPacket, meta?: EncodedVideoChunkMetadata) => unknown;
|
readonly onPacket!: (packet: EncodedPacket, meta?: EncodedVideoChunkMetadata) => unknown;
|
||||||
|
|
||||||
/** Returns true iff the encoder can encode the given codec configuration. */
|
/** Returns true iff the encoder can encode the given codec configuration. */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
@@ -96,11 +96,11 @@ export abstract class CustomVideoEncoder {
|
|||||||
*/
|
*/
|
||||||
export abstract class CustomAudioEncoder {
|
export abstract class CustomAudioEncoder {
|
||||||
/** The codec with which to encode the audio. */
|
/** The codec with which to encode the audio. */
|
||||||
codec!: AudioCodec;
|
readonly codec!: AudioCodec;
|
||||||
/** Config for the encoder. */
|
/** Config for the encoder. */
|
||||||
config!: AudioEncoderConfig;
|
readonly config!: AudioEncoderConfig;
|
||||||
/** The callback to call when an EncodedPacket is available. */
|
/** The callback to call when an EncodedPacket is available. */
|
||||||
onPacket!: (packet: EncodedPacket, meta?: EncodedAudioChunkMetadata) => unknown;
|
readonly onPacket!: (packet: EncodedPacket, meta?: EncodedAudioChunkMetadata) => unknown;
|
||||||
|
|
||||||
/** Returns true iff the encoder can encode the given codec configuration. */
|
/** Returns true iff the encoder can encode the given codec configuration. */
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
|
|||||||
@@ -705,8 +705,11 @@ class VideoDecoderWrapper extends DecoderWrapper<VideoSample> {
|
|||||||
if (MatchingCustomDecoder) {
|
if (MatchingCustomDecoder) {
|
||||||
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
||||||
this.customDecoder = new MatchingCustomDecoder() as CustomVideoDecoder;
|
this.customDecoder = new MatchingCustomDecoder() as CustomVideoDecoder;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customDecoder.codec = codec;
|
this.customDecoder.codec = codec;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customDecoder.config = decoderConfig;
|
this.customDecoder.config = decoderConfig;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customDecoder.onSample = (sample) => {
|
this.customDecoder.onSample = (sample) => {
|
||||||
if (!(sample instanceof VideoSample)) {
|
if (!(sample instanceof VideoSample)) {
|
||||||
throw new TypeError('The argument passed to onSample must be a VideoSample.');
|
throw new TypeError('The argument passed to onSample must be a VideoSample.');
|
||||||
@@ -1151,8 +1154,11 @@ class AudioDecoderWrapper extends DecoderWrapper<AudioSample> {
|
|||||||
if (MatchingCustomDecoder) {
|
if (MatchingCustomDecoder) {
|
||||||
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
||||||
this.customDecoder = new MatchingCustomDecoder() as CustomAudioDecoder;
|
this.customDecoder = new MatchingCustomDecoder() as CustomAudioDecoder;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customDecoder.codec = codec;
|
this.customDecoder.codec = codec;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customDecoder.config = decoderConfig;
|
this.customDecoder.config = decoderConfig;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customDecoder.onSample = (sample) => {
|
this.customDecoder.onSample = (sample) => {
|
||||||
if (!(sample instanceof AudioSample)) {
|
if (!(sample instanceof AudioSample)) {
|
||||||
throw new TypeError('The argument passed to onSample must be an AudioSample.');
|
throw new TypeError('The argument passed to onSample must be an AudioSample.');
|
||||||
|
|||||||
@@ -382,8 +382,11 @@ class VideoEncoderWrapper {
|
|||||||
if (MatchingCustomEncoder) {
|
if (MatchingCustomEncoder) {
|
||||||
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
||||||
this.customEncoder = new MatchingCustomEncoder() as CustomVideoEncoder;
|
this.customEncoder = new MatchingCustomEncoder() as CustomVideoEncoder;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customEncoder.codec = this.encodingConfig.codec;
|
this.customEncoder.codec = this.encodingConfig.codec;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customEncoder.config = encoderConfig;
|
this.customEncoder.config = encoderConfig;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customEncoder.onPacket = (packet, meta) => {
|
this.customEncoder.onPacket = (packet, meta) => {
|
||||||
if (!(packet instanceof EncodedPacket)) {
|
if (!(packet instanceof EncodedPacket)) {
|
||||||
throw new TypeError('The first argument passed to onPacket must be an EncodedPacket.');
|
throw new TypeError('The first argument passed to onPacket must be an EncodedPacket.');
|
||||||
@@ -949,8 +952,11 @@ class AudioEncoderWrapper {
|
|||||||
if (MatchingCustomEncoder) {
|
if (MatchingCustomEncoder) {
|
||||||
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
// @ts-expect-error "Can't create instance of abstract class 🤓"
|
||||||
this.customEncoder = new MatchingCustomEncoder() as CustomAudioEncoder;
|
this.customEncoder = new MatchingCustomEncoder() as CustomAudioEncoder;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customEncoder.codec = this.encodingConfig.codec;
|
this.customEncoder.codec = this.encodingConfig.codec;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customEncoder.config = encoderConfig;
|
this.customEncoder.config = encoderConfig;
|
||||||
|
// @ts-expect-error It's technically readonly
|
||||||
this.customEncoder.onPacket = (packet, meta) => {
|
this.customEncoder.onPacket = (packet, meta) => {
|
||||||
if (!(packet instanceof EncodedPacket)) {
|
if (!(packet instanceof EncodedPacket)) {
|
||||||
throw new TypeError('The first argument passed to onPacket must be an EncodedPacket.');
|
throw new TypeError('The first argument passed to onPacket must be an EncodedPacket.');
|
||||||
|
|||||||
Reference in New Issue
Block a user