public bool DecoderMatches(string decoderId, ICodecSettings codecSettings) { if (Decoder == null) { return(false); } return(Decoder.CodecId == decoderId && Decoder.SettingsMatch(codecSettings)); }
public IEncoder CreateEncoder(string codecId, ICodecSettings codecSettings) { if (_encoderFactories.TryGetValue(codecId, out Func <ICodecSettings, IEncoder>?factory)) { return(factory(codecSettings ?? throw new InvalidOperationException($"CodecId '{codecId}' has null default settings."))); } throw new InvalidOperationException($"CodecId '{codecId}' is not registered."); }
public void RegisterCodec(string codecId, ICodecSettings defaultSettings, Func <ICodecSettings, IEncoder> encoderFactory, Func <ICodecSettings, IDecoder> decoderFactory) { if (string.IsNullOrEmpty(codecId)) { throw new ArgumentNullException(nameof(codecId)); } if (defaultSettings == null) { throw new ArgumentNullException(nameof(defaultSettings)); } if (encoderFactory == null) { throw new ArgumentNullException(nameof(encoderFactory)); } if (decoderFactory == null) { throw new ArgumentNullException(nameof(decoderFactory)); } _defaultSettings[codecId] = defaultSettings; _encoderFactories[codecId] = encoderFactory; _decoderFactories[codecId] = decoderFactory; }
public static OpusSettings CloneSettings(ICodecSettings codecSettings) { if (codecSettings == null) { throw new ArgumentNullException(nameof(codecSettings)); } if (codecSettings is OpusSettings opusSettings) { return(opusSettings.Clone()); } else { return(new OpusSettings() { SampleRate = codecSettings.SampleRate, Channels = codecSettings.Channels, DecoderGain = codecSettings.DecoderGain, FrameDuration = OpusDefaults.FrameDuration, Bitrate = OpusDefaults.Bitrate, }); } }